mirror of https://github.com/M66B/NetGuard.git
Dim disabled applications
This commit is contained in:
parent
9877db4cfd
commit
0678d84dd9
|
@ -4,6 +4,7 @@ import android.content.Context;
|
|||
import android.content.SharedPreferences;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -14,13 +15,22 @@ public class Rule implements Comparable<Rule> {
|
|||
public PackageInfo info;
|
||||
public String name;
|
||||
public boolean system;
|
||||
public boolean disabled;
|
||||
public boolean wifi_blocked;
|
||||
public boolean other_blocked;
|
||||
|
||||
private Rule(PackageInfo info, boolean wifi_blocked, boolean other_blocked, Context context) {
|
||||
PackageManager pm = context.getPackageManager();
|
||||
this.info = info;
|
||||
this.name = info.applicationInfo.loadLabel(context.getPackageManager()).toString();
|
||||
this.name = info.applicationInfo.loadLabel(pm).toString();
|
||||
this.system = ((info.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0);
|
||||
|
||||
int setting = pm.getApplicationEnabledSetting(info.packageName);
|
||||
if (setting == PackageManager.COMPONENT_ENABLED_STATE_DEFAULT)
|
||||
this.disabled = !info.applicationInfo.enabled;
|
||||
else
|
||||
this.disabled = (setting != PackageManager.COMPONENT_ENABLED_STATE_ENABLED);
|
||||
|
||||
this.wifi_blocked = wifi_blocked;
|
||||
this.other_blocked = other_blocked;
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import android.content.Context;
|
|||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Color;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.util.Log;
|
||||
|
@ -92,11 +93,15 @@ public class RuleAdapter extends RecyclerView.Adapter<RuleAdapter.ViewHolder> im
|
|||
}
|
||||
};
|
||||
|
||||
int color = rule.system ? colorAccent : colorText;
|
||||
if (rule.disabled)
|
||||
color = Color.argb(100, Color.red(color), Color.green(color), Color.blue(color));
|
||||
|
||||
holder.ivIcon.setImageDrawable(rule.getIcon(context));
|
||||
holder.tvName.setText(rule.name);
|
||||
holder.tvName.setTextColor(rule.system ? colorAccent : colorText);
|
||||
holder.tvName.setTextColor(color);
|
||||
holder.tvPackage.setText(rule.info.packageName);
|
||||
holder.tvPackage.setTextColor(rule.system ? colorAccent : colorText);
|
||||
holder.tvPackage.setTextColor(color);
|
||||
|
||||
holder.cbWifi.setOnCheckedChangeListener(null);
|
||||
holder.cbWifi.setChecked(rule.wifi_blocked);
|
||||
|
|
Loading…
Reference in New Issue