Fixed settings dependency on Android 4

This commit is contained in:
M66B 2016-09-11 14:13:45 +02:00
parent 186e854601
commit b9402efa20
2 changed files with 8 additions and 7 deletions

View File

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

View File

@ -180,6 +180,7 @@ Your internet traffic is not being sent to a remote VPN server.</string>
<string name="msg_datasaving">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\"</string>
<string name="msg_filter">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</string>
<string name="msg_filter4">Android 4 requires filtering to be enabled</string>
<string name="msg_log_disabled">Traffic logging is disabled, use the switch above to enable logging. Traffic logging might result in extra battery usage.</string>
<string name="msg_clear_rules">This will reset the rules and conditions to their default values</string>
<string name="msg_reset_access">This will delete access attempt log lines without allow/block rules</string>