diff options
author | Dianne Hackborn <hackbod@google.com> | 2012-06-04 15:32:54 -0700 |
---|---|---|
committer | Dianne Hackborn <hackbod@google.com> | 2012-06-04 15:32:54 -0700 |
commit | 883329ca1376054228ff67a923252121b5531265 (patch) | |
tree | 8f5ee490e9d904552cc3efdacd6ead29a87fd84f /src | |
parent | 98894ed4106222b79c7ca67d5b3995878e8ae98d (diff) | |
download | packages_apps_settings-883329ca1376054228ff67a923252121b5531265.zip packages_apps_settings-883329ca1376054228ff67a923252121b5531265.tar.gz packages_apps_settings-883329ca1376054228ff67a923252121b5531265.tar.bz2 |
Fix issue #6603152: User-adjustable autobrightness broken?
Two issues:
- The new brightness was not being applied when switching out
of auto-brightness mode.
- We were resetting to the last brightness level when switching
modes. This is because at that point we read the current
brightness setting, but that isn't changed as the user adjusts
only when the final value is committed. To fix this, we have
a new local variable keeping track of the last brightness value
we have shown and use that when we haven't committed the
brightness to settings.
Change-Id: I7cc02c9f90128eacec427587a3f6b8f25ede4bd3
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/settings/BrightnessPreference.java | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/com/android/settings/BrightnessPreference.java b/src/com/android/settings/BrightnessPreference.java index c80f66d..eff5c50 100644 --- a/src/com/android/settings/BrightnessPreference.java +++ b/src/com/android/settings/BrightnessPreference.java @@ -47,6 +47,8 @@ public class BrightnessPreference extends SeekBarDialogPreference implements private boolean mAutomaticAvailable; private boolean mAutomaticMode; + private int mCurBrightness = -1; + private boolean mRestoredOldState; // Backlight range is from 0 - 255. Need to make sure that user @@ -60,6 +62,7 @@ public class BrightnessPreference extends SeekBarDialogPreference implements private ContentObserver mBrightnessObserver = new ContentObserver(new Handler()) { @Override public void onChange(boolean selfChange) { + mCurBrightness = -1; onBrightnessChanged(); } }; @@ -135,6 +138,7 @@ public class BrightnessPreference extends SeekBarDialogPreference implements : Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL); mSeekBar.setProgress(getBrightness()); mSeekBar.setEnabled(!mAutomaticMode); + setBrightness(mSeekBar.getProgress(), false); } private int getBrightness() { @@ -145,8 +149,12 @@ public class BrightnessPreference extends SeekBarDialogPreference implements Settings.System.SCREEN_AUTO_BRIGHTNESS_ADJ, 0); brightness = (brightness+1)/2; } else { - brightness = Settings.System.getInt(getContext().getContentResolver(), - Settings.System.SCREEN_BRIGHTNESS, 100); + if (mCurBrightness < 0) { + brightness = Settings.System.getInt(getContext().getContentResolver(), + Settings.System.SCREEN_BRIGHTNESS, 100); + } else { + brightness = mCurBrightness; + } brightness = (brightness - mScreenBrightnessDim) / (MAXIMUM_BACKLIGHT - mScreenBrightnessDim); } @@ -199,6 +207,7 @@ public class BrightnessPreference extends SeekBarDialogPreference implements } setBrightness(mOldBrightness, false); mRestoredOldState = true; + mCurBrightness = -1; } private void setBrightness(int brightness, boolean write) { @@ -229,9 +238,12 @@ public class BrightnessPreference extends SeekBarDialogPreference implements power.setBacklightBrightness(brightness); } if (write) { + mCurBrightness = -1; final ContentResolver resolver = getContext().getContentResolver(); Settings.System.putInt(resolver, Settings.System.SCREEN_BRIGHTNESS, brightness); + } else { + mCurBrightness = brightness; } } catch (RemoteException doe) { } @@ -255,6 +267,7 @@ public class BrightnessPreference extends SeekBarDialogPreference implements myState.progress = mSeekBar.getProgress(); myState.oldAutomatic = mOldAutomatic == 1; myState.oldProgress = mOldBrightness; + myState.curBrightness = mCurBrightness; // Restore the old state when the activity or dialog is being paused restoreOldState(); @@ -275,6 +288,7 @@ public class BrightnessPreference extends SeekBarDialogPreference implements mOldAutomatic = myState.oldAutomatic ? 1 : 0; setMode(myState.automatic ? 1 : 0); setBrightness(myState.progress, false); + mCurBrightness = myState.curBrightness; } private static class SavedState extends BaseSavedState { @@ -283,6 +297,7 @@ public class BrightnessPreference extends SeekBarDialogPreference implements boolean oldAutomatic; int progress; int oldProgress; + int curBrightness; public SavedState(Parcel source) { super(source); @@ -290,6 +305,7 @@ public class BrightnessPreference extends SeekBarDialogPreference implements progress = source.readInt(); oldAutomatic = source.readInt() == 1; oldProgress = source.readInt(); + curBrightness = source.readInt(); } @Override @@ -299,6 +315,7 @@ public class BrightnessPreference extends SeekBarDialogPreference implements dest.writeInt(progress); dest.writeInt(oldAutomatic ? 1 : 0); dest.writeInt(oldProgress); + dest.writeInt(curBrightness); } public SavedState(Parcelable superState) { |