mirror of https://github.com/M66B/NetGuard.git
Orange system application names
This commit is contained in:
parent
a5a60e20b9
commit
3674f71cfc
|
@ -123,7 +123,7 @@ public class ActivityMain extends AppCompatActivity implements SharedPreferences
|
|||
@Override
|
||||
protected void onPostExecute(List<Rule> result) {
|
||||
if (running) {
|
||||
adapter = new RuleAdapter(result);
|
||||
adapter = new RuleAdapter(result, ActivityMain.this);
|
||||
rvApplication.setAdapter(adapter);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package eu.faircode.netguard;
|
|||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
||||
|
@ -12,12 +13,14 @@ import java.util.List;
|
|||
public class Rule implements Comparable<Rule> {
|
||||
public PackageInfo info;
|
||||
public String name;
|
||||
public boolean system;
|
||||
public boolean wifi_blocked;
|
||||
public boolean other_blocked;
|
||||
|
||||
private Rule(PackageInfo info, boolean wifi_blocked, boolean other_blocked, Context context) {
|
||||
this.info = info;
|
||||
this.name = info.applicationInfo.loadLabel(context.getPackageManager()).toString();
|
||||
this.system = ((info.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0);
|
||||
this.wifi_blocked = wifi_blocked;
|
||||
this.other_blocked = other_blocked;
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@ package eu.faircode.netguard;
|
|||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.TypedArray;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
|
@ -21,6 +23,9 @@ import java.util.List;
|
|||
public class RuleAdapter extends RecyclerView.Adapter<RuleAdapter.ViewHolder> implements Filterable {
|
||||
private static final String TAG = "NetGuard.RuleAdapter";
|
||||
|
||||
private Context context;
|
||||
private int colorText;
|
||||
private int colorAccent;
|
||||
private List<Rule> listAll;
|
||||
private List<Rule> listSelected;
|
||||
|
||||
|
@ -43,7 +48,15 @@ public class RuleAdapter extends RecyclerView.Adapter<RuleAdapter.ViewHolder> im
|
|||
}
|
||||
}
|
||||
|
||||
public RuleAdapter(List<Rule> listRule) {
|
||||
public RuleAdapter(List<Rule> listRule, Context context) {
|
||||
this.context = context;
|
||||
colorAccent = ContextCompat.getColor(context, R.color.colorAccent);
|
||||
TypedArray ta = context.getTheme().obtainStyledAttributes(new int[]{android.R.attr.textColorSecondary});
|
||||
try {
|
||||
colorText = ta.getColor(0, 0);
|
||||
} finally {
|
||||
ta.recycle();
|
||||
}
|
||||
listAll = listRule;
|
||||
listSelected = new ArrayList<>();
|
||||
listSelected.addAll(listRule);
|
||||
|
@ -68,8 +81,6 @@ public class RuleAdapter extends RecyclerView.Adapter<RuleAdapter.ViewHolder> im
|
|||
}
|
||||
Log.i(TAG, rule.info.packageName + ": " + name + "=" + isChecked);
|
||||
|
||||
Context context = buttonView.getContext();
|
||||
|
||||
SharedPreferences prefs = context.getSharedPreferences(name, Context.MODE_PRIVATE);
|
||||
prefs.edit().putBoolean(rule.info.packageName, isChecked).apply();
|
||||
|
||||
|
@ -81,9 +92,11 @@ public class RuleAdapter extends RecyclerView.Adapter<RuleAdapter.ViewHolder> im
|
|||
}
|
||||
};
|
||||
|
||||
holder.ivIcon.setImageDrawable(rule.getIcon(holder.view.getContext()));
|
||||
holder.ivIcon.setImageDrawable(rule.getIcon(context));
|
||||
holder.tvName.setText(rule.name);
|
||||
holder.tvName.setTextColor(rule.system ? colorAccent : colorText);
|
||||
holder.tvPackage.setText(rule.info.packageName);
|
||||
holder.tvPackage.setTextColor(rule.system ? colorAccent : colorText);
|
||||
|
||||
holder.cbWifi.setOnCheckedChangeListener(null);
|
||||
holder.cbWifi.setChecked(rule.wifi_blocked);
|
||||
|
@ -155,7 +168,7 @@ public class RuleAdapter extends RecyclerView.Adapter<RuleAdapter.ViewHolder> im
|
|||
|
||||
@Override
|
||||
public RuleAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
return new ViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.rule, parent, false));
|
||||
return new ViewHolder(LayoutInflater.from(context).inflate(R.layout.rule, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
BIN
screenshot.png
BIN
screenshot.png
Binary file not shown.
Before Width: | Height: | Size: 249 KiB After Width: | Height: | Size: 256 KiB |
Loading…
Reference in New Issue