diff options
author | Jim Miller <jaggies@google.com> | 2011-01-07 16:55:33 -0800 |
---|---|---|
committer | Jim Miller <jaggies@google.com> | 2011-01-09 14:26:54 -0800 |
commit | 9391b9545f9845eae15713357bc4081853451f4a (patch) | |
tree | 13cedced507414018986c38ee58cf731920bdc79 | |
parent | 7da8cae44b622518fbffd6d265f291c39e9fc722 (diff) | |
download | packages_apps_settings-9391b9545f9845eae15713357bc4081853451f4a.zip packages_apps_settings-9391b9545f9845eae15713357bc4081853451f4a.tar.gz packages_apps_settings-9391b9545f9845eae15713357bc4081853451f4a.tar.bz2 |
Fix 3333434: Rename "Display" to "Screen" and make dynamic
This changes the setting "Display" to "Screen" and updates
the timeout summary to reflect the current setting.
Change-Id: Id8209d445f65a0908ae8093a8f5f7f951f333053
-rw-r--r-- | res/values/strings.xml | 6 | ||||
-rw-r--r-- | src/com/android/settings/DisplaySettings.java | 31 |
2 files changed, 28 insertions, 9 deletions
diff --git a/res/values/strings.xml b/res/values/strings.xml index 8e56db3..64f8d9e 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -1150,7 +1150,7 @@ <!-- Main Settings screen setting option name to go into the sound settings screen --> <string name="sound_settings_title">Sound</string> <!-- Main Settings screen setting option name to go into the display settings screen --> - <string name="display_settings_title">Display</string> + <string name="display_settings_title">Screen</string> <!-- Sound settings screen heading --> <string name="sound_settings">Sound settings</string> <!-- Sound settings screen, setting option name checkbox --> @@ -1298,9 +1298,9 @@ <!-- Sound & display settings screen, setting option summary to change brightness --> <string name="brightness_summary">Adjust the brightness of the screen</string> <!-- Sound & display settings screen, setting option name to change screen timeout --> - <string name="screen_timeout">Screen timeout</string> + <string name="screen_timeout">Timeout</string> <!-- Sound & display settings screen, setting option summary to change screen timeout --> - <string name="screen_timeout_summary">Adjust the delay before the screen automatically turns off</string> + <string name="screen_timeout_summary">Screen turns off automatically after <xliff:g id="timeout_description">%1$s</xliff:g></string> <!-- Sound & display settings screen, setting option name to change whether the screen adjusts automatically based on lighting conditions --> <string name="automatic_brightness">Automatic brightness</string> diff --git a/src/com/android/settings/DisplaySettings.java b/src/com/android/settings/DisplaySettings.java index 5945884..0e17810 100644 --- a/src/com/android/settings/DisplaySettings.java +++ b/src/com/android/settings/DisplaySettings.java @@ -51,6 +51,8 @@ public class DisplaySettings extends SettingsPreferenceFragment implements private IWindowManager mWindowManager; + private ListPreference mScreenTimeoutPreference; + @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -64,12 +66,28 @@ public class DisplaySettings extends SettingsPreferenceFragment implements mAccelerometer = (CheckBoxPreference) findPreference(KEY_ACCELEROMETER); mAccelerometer.setPersistent(false); - ListPreference screenTimeoutPreference = - (ListPreference) findPreference(KEY_SCREEN_TIMEOUT); - screenTimeoutPreference.setValue(String.valueOf(Settings.System.getInt( - resolver, SCREEN_OFF_TIMEOUT, FALLBACK_SCREEN_TIMEOUT_VALUE))); - screenTimeoutPreference.setOnPreferenceChangeListener(this); - disableUnusableTimeouts(screenTimeoutPreference); + mScreenTimeoutPreference = (ListPreference) findPreference(KEY_SCREEN_TIMEOUT); + final long currentTimeout = Settings.System.getLong(resolver, SCREEN_OFF_TIMEOUT, + FALLBACK_SCREEN_TIMEOUT_VALUE); + mScreenTimeoutPreference.setValue(String.valueOf(currentTimeout)); + mScreenTimeoutPreference.setOnPreferenceChangeListener(this); + disableUnusableTimeouts(mScreenTimeoutPreference); + updateTimeoutPreferenceDescription(resolver, currentTimeout); + } + + private void updateTimeoutPreferenceDescription(ContentResolver resolver, long currentTimeout) { + final CharSequence[] entries = mScreenTimeoutPreference.getEntries(); + final CharSequence[] values = mScreenTimeoutPreference.getEntryValues(); + int best = 0; + for (int i = 0; i < values.length; i++) { + long timeout = Long.valueOf(values[i].toString()); + if (currentTimeout >= timeout) { + best = i; + } + } + String summary = mScreenTimeoutPreference.getContext() + .getString(R.string.screen_timeout_summary, entries[best]); + mScreenTimeoutPreference.setSummary(summary); } private void disableUnusableTimeouts(ListPreference screenTimeoutPreference) { @@ -195,6 +213,7 @@ public class DisplaySettings extends SettingsPreferenceFragment implements try { Settings.System.putInt(getContentResolver(), SCREEN_OFF_TIMEOUT, value); + updateTimeoutPreferenceDescription(getContentResolver(), value); } catch (NumberFormatException e) { Log.e(TAG, "could not persist screen timeout setting", e); } |