summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoman Birg <roman@cyngn.com>2015-04-27 17:00:43 -0700
committerAdnan Begovic <adnan@cyngn.com>2015-10-29 17:36:31 -0700
commit86ec224cb4e5aef5a5b230bd4948ca8fb1d16b0d (patch)
treed60f1964d39a76a7c7e2c9f4c4468b475efd4e68
parentc0cb5a34fb71933b6d7ecb803779874234a24071 (diff)
downloadpackages_apps_Settings-86ec224cb4e5aef5a5b230bd4948ca8fb1d16b0d.zip
packages_apps_Settings-86ec224cb4e5aef5a5b230bd4948ca8fb1d16b0d.tar.gz
packages_apps_Settings-86ec224cb4e5aef5a5b230bd4948ca8fb1d16b0d.tar.bz2
Settings: persist backlight brightness setting
Save the user value locally every time it is modified so we can retreive it reliably. Change-Id: I0d4489c17809a7a53864ab553d97aed60a8f8e88 Signed-off-by: Roman Birg <roman@cyngn.com>
-rw-r--r--src/com/android/settings/ButtonSettings.java13
-rw-r--r--src/com/android/settings/cyanogenmod/ButtonBacklightBrightness.java11
2 files changed, 13 insertions, 11 deletions
diff --git a/src/com/android/settings/ButtonSettings.java b/src/com/android/settings/ButtonSettings.java
index 843d668..73296d5 100644
--- a/src/com/android/settings/ButtonSettings.java
+++ b/src/com/android/settings/ButtonSettings.java
@@ -591,7 +591,8 @@ public class ButtonSettings extends SettingsPreferenceFragment implements
Settings.Secure.putInt(context.getContentResolver(),
Settings.Secure.BUTTON_BRIGHTNESS, 0);
} else {
- int oldBright = prefs.getInt("pre_navbar_button_backlight", defaultBrightness);
+ int oldBright = prefs.getInt(ButtonBacklightBrightness.KEY_BUTTON_BACKLIGHT,
+ defaultBrightness);
Settings.Secure.putInt(context.getContentResolver(),
Settings.Secure.BUTTON_BRIGHTNESS, oldBright);
}
@@ -672,16 +673,6 @@ 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);
diff --git a/src/com/android/settings/cyanogenmod/ButtonBacklightBrightness.java b/src/com/android/settings/cyanogenmod/ButtonBacklightBrightness.java
index 55ca14e..1a941d7 100644
--- a/src/com/android/settings/cyanogenmod/ButtonBacklightBrightness.java
+++ b/src/com/android/settings/cyanogenmod/ButtonBacklightBrightness.java
@@ -20,11 +20,13 @@ import android.app.AlertDialog;
import android.content.ContentResolver;
import android.content.Context;
import android.content.DialogInterface;
+import android.content.SharedPreferences;
import android.content.res.Resources;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
import android.preference.DialogPreference;
+import android.preference.PreferenceManager;
import android.provider.Settings;
import android.util.AttributeSet;
import android.view.View;
@@ -43,6 +45,8 @@ public class ButtonBacklightBrightness extends DialogPreference implements
SeekBar.OnSeekBarChangeListener {
private static final int DEFAULT_BUTTON_TIMEOUT = 5;
+ public static final String KEY_BUTTON_BACKLIGHT = "pre_navbar_button_backlight";
+
private Window mWindow;
private BrightnessControl mButtonBrightness;
@@ -159,6 +163,13 @@ public class ButtonBacklightBrightness extends DialogPreference implements
return;
}
+ if (mButtonBrightness != null) {
+ PreferenceManager.getDefaultSharedPreferences(getContext())
+ .edit()
+ .putInt(KEY_BUTTON_BACKLIGHT, mButtonBrightness.getBrightness(false))
+ .apply();
+ }
+
applyTimeout(mTimeoutBar.getProgress());
if (mButtonBrightness != null) {
mButtonBrightness.applyBrightness();