From b9402efa2008e8cdb407c59f5604d5a307451d71 Mon Sep 17 00:00:00 2001 From: M66B Date: Sun, 11 Sep 2016 14:13:45 +0200 Subject: [PATCH] Fixed settings dependency on Android 4 --- .../eu/faircode/netguard/ActivitySettings.java | 14 +++++++------- app/src/main/res/values/strings.xml | 1 + 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/eu/faircode/netguard/ActivitySettings.java b/app/src/main/java/eu/faircode/netguard/ActivitySettings.java index d6088bfc..b28847bc 100644 --- a/app/src/main/java/eu/faircode/netguard/ActivitySettings.java +++ b/app/src/main/java/eu/faircode/netguard/ActivitySettings.java @@ -175,10 +175,6 @@ public class ActivitySettings extends AppCompatActivity implements SharedPrefere pref_wifi_homes.setEntries(listSSID.toArray(new CharSequence[0])); pref_wifi_homes.setEntryValues(listSSID.toArray(new CharSequence[0])); - // Filtering always enabled - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) - screen.findPreference("filter").setEnabled(false); - Preference pref_reset_usage = screen.findPreference("reset_usage"); pref_reset_usage.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override @@ -585,10 +581,8 @@ public class ActivitySettings extends AppCompatActivity implements SharedPrefere LocalBroadcastManager.getInstance(this).sendBroadcast(ruleset); } else if ("filter".equals(name)) { - ServiceSinkhole.reload("changed " + name, this); - // Show dialog - if (prefs.getBoolean(name, false)) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && prefs.getBoolean(name, false)) { LayoutInflater inflater = LayoutInflater.from(ActivitySettings.this); View view = inflater.inflate(R.layout.filter, null, false); dialogFilter = new AlertDialog.Builder(ActivitySettings.this) @@ -608,8 +602,14 @@ public class ActivitySettings extends AppCompatActivity implements SharedPrefere }) .create(); dialogFilter.show(); + } else if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP && !prefs.getBoolean(name, false)) { + prefs.edit().putBoolean(name, true).apply(); + ((TwoStatePreference) getPreferenceScreen().findPreference(name)).setChecked(true); + Toast.makeText(ActivitySettings.this, R.string.msg_filter4, Toast.LENGTH_SHORT).show(); } + ServiceSinkhole.reload("changed " + name, this); + } else if ("use_hosts".equals(name)) ServiceSinkhole.reload("changed " + name, this); diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index a98a1622..599a3074 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -180,6 +180,7 @@ Your internet traffic is not being sent to a remote VPN server. For consistent results, the Android data saving options should be disabled for NetGuard \n\nIn the next dialog, enable the options \"Background data\" and \"Unrestricted data usage\" Using filtering will cause Android to attribute data and power usage to NetGuard - Android assumes the data and power are being used by NetGuard, rather than the original applications + Android 4 requires filtering to be enabled Traffic logging is disabled, use the switch above to enable logging. Traffic logging might result in extra battery usage. This will reset the rules and conditions to their default values This will delete access attempt log lines without allow/block rules