Added settings to reload on every connectivity change

This commit is contained in:
M66B 2017-08-20 09:11:34 +02:00
parent 16a34aafdf
commit 7b96f5a950
5 changed files with 19 additions and 1 deletions

View File

@ -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() {

View File

@ -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);
}

View File

@ -90,6 +90,7 @@ however it is impossible to guarantee NetGuard will work correctly on every devi
<string name="setting_call">Disable on call</string>
<string name="setting_lockdown_wifi">Lockdown Wi-Fi</string>
<string name="setting_lockdown_other">Lockdown mobile</string>
<string name="setting_reload_onconnectivity">Reload on every connectivity change</string>
<string name="setting_advanced_options">Advanced options</string>
<string name="setting_system">Manage system apps</string>

View File

@ -143,6 +143,10 @@
android:defaultValue="true"
android:key="lockdown_other"
android:title="@string/setting_lockdown_other" />
<CheckBoxPreference
android:defaultValue="false"
android:key="reload_onconnectivity"
android:title="@string/setting_reload_onconnectivity" />
</PreferenceCategory>
</PreferenceScreen>

View File

@ -143,6 +143,10 @@
android:defaultValue="true"
android:key="lockdown_other"
android:title="@string/setting_lockdown_other" />
<eu.faircode.netguard.SwitchPreference
android:defaultValue="false"
android:key="reload_onconnectivity"
android:title="@string/setting_reload_onconnectivity" />
</PreferenceCategory>
</PreferenceScreen>