mirror of https://github.com/M66B/NetGuard.git
Removed displaying default state
This commit is contained in:
parent
5197832ff0
commit
993f51b985
|
@ -19,10 +19,8 @@ public class Rule implements Comparable<Rule> {
|
|||
public boolean disabled;
|
||||
public boolean wifi_blocked;
|
||||
public boolean other_blocked;
|
||||
public boolean wifi_default;
|
||||
public boolean other_default;
|
||||
|
||||
private Rule(PackageInfo info, boolean wifi_blocked, boolean other_blocked, boolean wifi_default, boolean other_default, Context context) {
|
||||
private Rule(PackageInfo info, boolean wifi_blocked, boolean other_blocked, Context context) {
|
||||
PackageManager pm = context.getPackageManager();
|
||||
this.info = info;
|
||||
this.name = info.applicationInfo.loadLabel(pm).toString();
|
||||
|
@ -36,8 +34,6 @@ public class Rule implements Comparable<Rule> {
|
|||
|
||||
this.wifi_blocked = wifi_blocked;
|
||||
this.other_blocked = other_blocked;
|
||||
this.wifi_default = wifi_default;
|
||||
this.other_default = other_default;
|
||||
}
|
||||
|
||||
public static List<Rule> getRules(Context context) {
|
||||
|
@ -51,8 +47,6 @@ public class Rule implements Comparable<Rule> {
|
|||
info,
|
||||
wifi.getBoolean(info.packageName, prefs.getBoolean("whitelist_wifi", true)),
|
||||
other.getBoolean(info.packageName, prefs.getBoolean("whitelist_other", true)),
|
||||
!wifi.contains(info.packageName),
|
||||
!other.contains(info.packageName),
|
||||
context
|
||||
));
|
||||
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
package eu.faircode.netguard;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Color;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.util.Log;
|
||||
|
@ -77,11 +75,9 @@ public class RuleAdapter extends RecyclerView.Adapter<RuleAdapter.ViewHolder> im
|
|||
if (buttonView == holder.cbWifi) {
|
||||
name = "wifi";
|
||||
rule.wifi_blocked = isChecked;
|
||||
rule.wifi_default = false;
|
||||
} else {
|
||||
name = "other";
|
||||
rule.other_blocked = isChecked;
|
||||
rule.other_default = false;
|
||||
}
|
||||
Log.i(TAG, rule.info.packageName + ": " + name + "=" + isChecked);
|
||||
|
||||
|
@ -107,33 +103,10 @@ public class RuleAdapter extends RecyclerView.Adapter<RuleAdapter.ViewHolder> im
|
|||
holder.cbWifi.setOnCheckedChangeListener(null);
|
||||
holder.cbWifi.setChecked(rule.wifi_blocked);
|
||||
holder.cbWifi.setOnCheckedChangeListener(cbListener);
|
||||
holder.cbWifi.setAlpha(rule.wifi_default ? 0.4f : 1);
|
||||
|
||||
holder.cbOther.setOnCheckedChangeListener(null);
|
||||
holder.cbOther.setChecked(rule.other_blocked);
|
||||
holder.cbOther.setOnCheckedChangeListener(cbListener);
|
||||
holder.cbOther.setAlpha(rule.other_default ? 0.4f : 1);
|
||||
|
||||
holder.view.setOnLongClickListener(new View.OnLongClickListener() {
|
||||
@Override
|
||||
public boolean onLongClick(View view) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
SharedPreferences wifi = context.getSharedPreferences("wifi", Context.MODE_PRIVATE);
|
||||
SharedPreferences other = context.getSharedPreferences("other", Context.MODE_PRIVATE);
|
||||
|
||||
wifi.edit().remove(rule.info.packageName).apply();
|
||||
other.edit().remove(rule.info.packageName).apply();
|
||||
|
||||
rule.wifi_blocked = prefs.getBoolean("whitelist_wifi", true);
|
||||
rule.wifi_default = true;
|
||||
rule.other_blocked = prefs.getBoolean("whitelist_other", true);
|
||||
rule.other_default = true;
|
||||
|
||||
notifyDataSetChanged();
|
||||
BlackHoleService.reload(null, context);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue