Merge "Bug 5042999: Wi-Fi disconnect policy strings"
This commit is contained in:
committed by
Android (Google) Code Review
commit
e5d6179291
@@ -358,34 +358,34 @@
|
||||
|
||||
<!-- Wi-Fi settings. Presented as a list dialog to the user to choose the Wi-Fi sleep policy. -->
|
||||
<string-array name="wifi_sleep_policy_entries">
|
||||
<!-- Wi-Fi should go to sleep when the screen turns off. -->
|
||||
<item>When screen turns off (uses more mobile data)</item>
|
||||
<!-- When plugged in, never go to sleep. When on battery, go to sleep when screen turns off. -->
|
||||
<item>Never when plugged in</item>
|
||||
<!-- Never go to sleep. -->
|
||||
<item>Never (uses more battery power)</item>
|
||||
<!-- Always keep Wi-Fi on when screen turns off. -->
|
||||
<item>Always</item>
|
||||
<!-- Keep Wi-Fi on when screen turns off and plugged in. When on battery, go to sleep when screen turns off. -->
|
||||
<item>Only when plugged in</item>
|
||||
<!-- Do not keep Wi-Fi on when screen turns off. -->
|
||||
<item>Never (increases data usage)</item>
|
||||
</string-array>
|
||||
|
||||
<!-- Wi-Fi settings. Presented as a list dialog to the user to choose the Wi-Fi sleep policy. Used when
|
||||
the device is Wi-Fi-only. [CHAR LIMIT=30] -->
|
||||
<string-array name="wifi_sleep_policy_entries_wifi_only">
|
||||
<!-- Wi-Fi should go to sleep when the screen turns off, for Wi-Fi-only devices. -->
|
||||
<item>When screen turns off</item>
|
||||
<!-- When plugged in, never go to sleep. When on battery, go to sleep when screen turns off. -->
|
||||
<item>Never when plugged in</item>
|
||||
<!-- Never go to sleep. -->
|
||||
<item>Never (uses more battery power)</item>
|
||||
<!-- Always keep Wi-Fi on when screen turns off. -->
|
||||
<item>Always</item>
|
||||
<!-- Keep Wi-Fi on when screen turns off and plugged in. When on battery, go to sleep when screen turns off. -->
|
||||
<item>Only when plugged in</item>
|
||||
<!-- Do not keep Wi-Fi on when screen turns off, for Wi-Fi-only devices, no other data connection -->
|
||||
<item>Never</item>
|
||||
</string-array>
|
||||
|
||||
<!-- Match with wifi_sleep_policy_entries and the values of the settings in Settings class. --> <skip />
|
||||
<!-- Do not translate. -->
|
||||
<string-array name="wifi_sleep_policy_values">
|
||||
<!-- Do not translate. -->
|
||||
<item>0</item>
|
||||
<item>2</item>
|
||||
<!-- Do not translate. -->
|
||||
<item>1</item>
|
||||
<!-- Do not translate. -->
|
||||
<item>2</item>
|
||||
<item>0</item>
|
||||
</string-array>
|
||||
|
||||
<!-- Wi-Fi settings. Presented as a list dialog to the user to choose the Wi-Fi frequency band. -->
|
||||
|
@@ -1150,12 +1150,8 @@
|
||||
<string name="wifi_enable_watchdog_service">Avoid poor connections</string>
|
||||
<!-- Checkbox summary for option to toggle wifi watchdog service -->
|
||||
<string name="wifi_enable_watchdog_service_summary">Don\'t use a Wi-Fi network unless it has a decent internet connection</string>
|
||||
<!-- Setting title for setting the wifi sleep policy -->
|
||||
<string name="wifi_setting_sleep_policy_title">Wi-Fi disconnect policy</string>
|
||||
<!-- Setting summary for setting the wifi sleep policy -->
|
||||
<string name="wifi_setting_sleep_policy_summary">Specify when to switch from Wi-Fi to mobile data</string>
|
||||
<!-- Setting summary for setting the wifi sleep policy for wifi-only devices [CHAR LIMIT=100] -->
|
||||
<string name="wifi_setting_sleep_policy_summary_wifi_only">Specify when to disconnect from Wi-Fi</string>
|
||||
<!-- Setting title for setting the wifi sleep policy. Do we keep Wi-Fi active when the screen turns off? -->
|
||||
<string name="wifi_setting_sleep_policy_title">Keep Wi-Fi during sleep</string>
|
||||
<!-- Generic error message when the sleep policy could not be set. -->
|
||||
<string name="wifi_setting_sleep_policy_error">There was a problem changing the setting</string>
|
||||
<!-- Action bar text message to manually add a wifi network [CHAR LIMIT=20]-->
|
||||
|
@@ -27,7 +27,6 @@
|
||||
<ListPreference
|
||||
android:key="sleep_policy"
|
||||
android:title="@string/wifi_setting_sleep_policy_title"
|
||||
android:summary="@string/wifi_setting_sleep_policy_summary"
|
||||
android:persistent="false"
|
||||
android:entries="@array/wifi_sleep_policy_entries"
|
||||
android:entryValues="@array/wifi_sleep_policy_values"
|
||||
|
@@ -99,16 +99,37 @@ public class AdvancedWifiSettings extends SettingsPreferenceFragment
|
||||
if (sleepPolicyPref != null) {
|
||||
if (Utils.isWifiOnly(getActivity())) {
|
||||
sleepPolicyPref.setEntries(R.array.wifi_sleep_policy_entries_wifi_only);
|
||||
sleepPolicyPref.setSummary(R.string.wifi_setting_sleep_policy_summary_wifi_only);
|
||||
}
|
||||
sleepPolicyPref.setOnPreferenceChangeListener(this);
|
||||
int value = Settings.System.getInt(getContentResolver(),
|
||||
Settings.System.WIFI_SLEEP_POLICY,
|
||||
Settings.System.WIFI_SLEEP_POLICY_NEVER);
|
||||
sleepPolicyPref.setValue(String.valueOf(value));
|
||||
String stringValue = String.valueOf(value);
|
||||
sleepPolicyPref.setValue(stringValue);
|
||||
updateSleepPolicySummary(sleepPolicyPref, stringValue);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateSleepPolicySummary(Preference sleepPolicyPref, String value) {
|
||||
if (value != null) {
|
||||
String[] values = getResources().getStringArray(R.array.wifi_sleep_policy_values);
|
||||
final int summaryArrayResId = Utils.isWifiOnly(getActivity()) ?
|
||||
R.array.wifi_sleep_policy_entries_wifi_only : R.array.wifi_sleep_policy_entries;
|
||||
String[] summaries = getResources().getStringArray(summaryArrayResId);
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
if (value.equals(values[i])) {
|
||||
if (i < summaries.length) {
|
||||
sleepPolicyPref.setSummary(summaries[i]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sleepPolicyPref.setSummary("");
|
||||
Log.e(TAG, "Invalid sleep policy value: " + value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceTreeClick(PreferenceScreen screen, Preference preference) {
|
||||
String key = preference.getKey();
|
||||
@@ -133,7 +154,7 @@ public class AdvancedWifiSettings extends SettingsPreferenceFragment
|
||||
|
||||
if (KEY_FREQUENCY_BAND.equals(key)) {
|
||||
try {
|
||||
mWifiManager.setFrequencyBand(Integer.parseInt(((String) newValue)), true);
|
||||
mWifiManager.setFrequencyBand(Integer.parseInt((String) newValue), true);
|
||||
} catch (NumberFormatException e) {
|
||||
Toast.makeText(getActivity(), R.string.wifi_setting_frequency_band_error,
|
||||
Toast.LENGTH_SHORT).show();
|
||||
@@ -143,8 +164,10 @@ public class AdvancedWifiSettings extends SettingsPreferenceFragment
|
||||
|
||||
if (KEY_SLEEP_POLICY.equals(key)) {
|
||||
try {
|
||||
Settings.System.putInt(getContentResolver(),
|
||||
Settings.System.WIFI_SLEEP_POLICY, Integer.parseInt(((String) newValue)));
|
||||
String stringValue = (String) newValue;
|
||||
Settings.System.putInt(getContentResolver(), Settings.System.WIFI_SLEEP_POLICY,
|
||||
Integer.parseInt(stringValue));
|
||||
updateSleepPolicySummary(preference, stringValue);
|
||||
} catch (NumberFormatException e) {
|
||||
Toast.makeText(getActivity(), R.string.wifi_setting_sleep_policy_error,
|
||||
Toast.LENGTH_SHORT).show();
|
||||
|
Reference in New Issue
Block a user