Add a "Don't ask again" checkbox to the avoid bad wifi dialog.

Also update the settings code to reflect the new tristate
semantics of the NETWORK_AVOID_BAD_WIFI setting.

Bug: 31075769
Change-Id: Icd21d8272abe6afd42ee8a41e2c7e1a6af77f0b3
This commit is contained in:
Lorenzo Colitti
2016-09-19 01:08:07 +09:00
parent 0d00554d62
commit c179f33c87
2 changed files with 20 additions and 25 deletions

View File

@@ -170,8 +170,8 @@ public class ConfigureWifiSettings extends SettingsPreferenceFragment
}
private boolean avoidBadWifiCurrentSettings() {
return Settings.Global.getInt(getContentResolver(),
Settings.Global.NETWORK_AVOID_BAD_WIFI, 0) == 1;
return "1".equals(Settings.Global.getString(getContentResolver(),
Settings.Global.NETWORK_AVOID_BAD_WIFI));
}
@Override
@@ -183,17 +183,10 @@ public class ConfigureWifiSettings extends SettingsPreferenceFragment
Settings.Global.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON,
((SwitchPreference) preference).isChecked() ? 1 : 0);
} else if (KEY_CELLULAR_FALLBACK.equals(key)) {
// On: avoid bad wifi. Off: prompt.
String settingName = Settings.Global.NETWORK_AVOID_BAD_WIFI;
if (((SwitchPreference) preference).isChecked()) {
// The user wants to avoid bad wifi networks. Remember the choice.
Settings.Global.putInt(getContentResolver(), settingName, 1);
} else {
// Unset the setting. ConnectivityService interprets null to mean "use the carrier
// default". We don't set the setting to 0 because if we do, and the user switches
// to a carrier that does not restrict cellular fallback, then there is no way to
// set it to 1 again because on such a carrier the toggle is never shown.
Settings.Global.putString(getContentResolver(), settingName, null);
}
Settings.Global.putString(getContentResolver(), settingName,
((SwitchPreference) preference).isChecked() ? "1" : null);
} else {
return super.onPreferenceTreeClick(preference);
}