From 7b96f5a950deb6126c9249e01a17854d61024b9e Mon Sep 17 00:00:00 2001 From: M66B Date: Sun, 20 Aug 2017 09:11:34 +0200 Subject: [PATCH] Added settings to reload on every connectivity change --- .../main/java/eu/faircode/netguard/ActivitySettings.java | 7 +++++++ .../main/java/eu/faircode/netguard/ServiceSinkhole.java | 4 +++- app/src/main/res/values/strings.xml | 1 + app/src/main/res/xml-v14/preferences.xml | 4 ++++ app/src/main/res/xml-v21/preferences.xml | 4 ++++ 5 files changed, 19 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/eu/faircode/netguard/ActivitySettings.java b/app/src/main/java/eu/faircode/netguard/ActivitySettings.java index 40e5809c..d344b1f5 100644 --- a/app/src/main/java/eu/faircode/netguard/ActivitySettings.java +++ b/app/src/main/java/eu/faircode/netguard/ActivitySettings.java @@ -199,6 +199,13 @@ public class ActivitySettings extends AppCompatActivity implements SharedPrefere } }); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + TwoStatePreference pref_reload_onconnectivity = + (TwoStatePreference) screen.findPreference("reload_onconnectivity"); + pref_reload_onconnectivity.setChecked(true); + pref_reload_onconnectivity.setEnabled(false); + } + // Handle port forwarding Preference pref_forwarding = screen.findPreference("forwarding"); pref_forwarding.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { diff --git a/app/src/main/java/eu/faircode/netguard/ServiceSinkhole.java b/app/src/main/java/eu/faircode/netguard/ServiceSinkhole.java index b68789a4..1e7896de 100644 --- a/app/src/main/java/eu/faircode/netguard/ServiceSinkhole.java +++ b/app/src/main/java/eu/faircode/netguard/ServiceSinkhole.java @@ -2257,7 +2257,9 @@ public class ServiceSinkhole extends VpnService implements SharedPreferences.OnS @Override public void onLinkPropertiesChanged(Network network, LinkProperties linkProperties) { // Make sure the right DNS servers are being used - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ServiceSinkhole.this); + if (prefs.getBoolean("reload_onconnectivity", false) || + Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) reload("link properties changed", ServiceSinkhole.this, false); } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 6877386c..df03c050 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -90,6 +90,7 @@ however it is impossible to guarantee NetGuard will work correctly on every devi Disable on call Lockdown Wi-Fi Lockdown mobile + Reload on every connectivity change Advanced options Manage system apps diff --git a/app/src/main/res/xml-v14/preferences.xml b/app/src/main/res/xml-v14/preferences.xml index f3748873..fdd02c77 100644 --- a/app/src/main/res/xml-v14/preferences.xml +++ b/app/src/main/res/xml-v14/preferences.xml @@ -143,6 +143,10 @@ android:defaultValue="true" android:key="lockdown_other" android:title="@string/setting_lockdown_other" /> + diff --git a/app/src/main/res/xml-v21/preferences.xml b/app/src/main/res/xml-v21/preferences.xml index dce42667..73b57006 100644 --- a/app/src/main/res/xml-v21/preferences.xml +++ b/app/src/main/res/xml-v21/preferences.xml @@ -143,6 +143,10 @@ android:defaultValue="true" android:key="lockdown_other" android:title="@string/setting_lockdown_other" /> +