summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRoman Birg <roman@cyngn.com>2015-04-27 10:56:19 -0700
committerAdnan Begovic <adnan@cyngn.com>2015-10-29 17:36:31 -0700
commitc0cb5a34fb71933b6d7ecb803779874234a24071 (patch)
tree8d8338345890c2b3219c5c4bdc0e52fe938deadf /src
parentc73ae5388019fd92d0e6bb4c2473772ca8d930b8 (diff)
downloadpackages_apps_Settings-c0cb5a34fb71933b6d7ecb803779874234a24071.zip
packages_apps_Settings-c0cb5a34fb71933b6d7ecb803779874234a24071.tar.gz
packages_apps_Settings-c0cb5a34fb71933b6d7ecb803779874234a24071.tar.bz2
Settings: fix button back light restore logic
Only persist backlight data if it's modified by the user, otherwise we can just restore the default framework value when enabling. Always restore a backlight value setting, either the framework default, or user saved value. Change-Id: I2d6e95a48bc4ac4dbe6d639d87dc93ec1799c290 Signed-off-by: Roman Birg <roman@cyngn.com>
Diffstat (limited to 'src')
-rw-r--r--src/com/android/settings/ButtonSettings.java27
1 files changed, 13 insertions, 14 deletions
diff --git a/src/com/android/settings/ButtonSettings.java b/src/com/android/settings/ButtonSettings.java
index d200679..843d668 100644
--- a/src/com/android/settings/ButtonSettings.java
+++ b/src/com/android/settings/ButtonSettings.java
@@ -587,25 +587,14 @@ public class ButtonSettings extends SettingsPreferenceFragment implements
cmHardwareManager.set(CmHardwareManager.FEATURE_KEY_DISABLE, enabled);
/* Save/restore button timeouts to disable them in softkey mode */
- Editor editor = prefs.edit();
-
if (enabled) {
- int currentBrightness = Settings.Secure.getInt(context.getContentResolver(),
- Settings.Secure.BUTTON_BRIGHTNESS, defaultBrightness);
- if (!prefs.contains("pre_navbar_button_backlight")) {
- editor.putInt("pre_navbar_button_backlight", currentBrightness);
- }
Settings.Secure.putInt(context.getContentResolver(),
Settings.Secure.BUTTON_BRIGHTNESS, 0);
} else {
- int oldBright = prefs.getInt("pre_navbar_button_backlight", -1);
- if (oldBright != -1) {
- Settings.Secure.putInt(context.getContentResolver(),
- Settings.Secure.BUTTON_BRIGHTNESS, oldBright);
- editor.remove("pre_navbar_button_backlight");
- }
+ int oldBright = prefs.getInt("pre_navbar_button_backlight", defaultBrightness);
+ Settings.Secure.putInt(context.getContentResolver(),
+ Settings.Secure.BUTTON_BRIGHTNESS, oldBright);
}
- editor.commit();
}
private void updateDisableNavkeysOption() {
@@ -683,6 +672,16 @@ public class ButtonSettings extends SettingsPreferenceFragment implements
} else if (preference == mDisableNavigationKeys) {
mDisableNavigationKeys.setEnabled(false);
mNavigationPreferencesCat.setEnabled(false);
+
+ if (mDisableNavigationKeys.isChecked()) {
+ // enabling virtual nav keys, back it up lights setting
+ final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(
+ getActivity());
+ int currentBrightness = Settings.Secure.getInt(getActivity().getContentResolver(),
+ Settings.Secure.BUTTON_BRIGHTNESS, -1);
+ prefs.edit().putInt("pre_navbar_button_backlight", currentBrightness).apply();
+ }
+
writeDisableNavkeysOption(getActivity(), mDisableNavigationKeys.isChecked());
updateDisableNavkeysOption();
updateDisableNavkeysCategories(true);