Merge "Fix manual brightness adjustment." into jb-dev
diff --git a/src/com/android/settings/BrightnessPreference.java b/src/com/android/settings/BrightnessPreference.java
index e015914..9023ea3 100644
--- a/src/com/android/settings/BrightnessPreference.java
+++ b/src/com/android/settings/BrightnessPreference.java
@@ -55,6 +55,8 @@
getContext().getResources().getInteger(com.android.internal.R.integer.config_screenBrightnessDim);
private static final int MAXIMUM_BACKLIGHT = android.os.Power.BRIGHTNESS_ON;
+ private static final int SEEK_BAR_RANGE = 10000;
+
private ContentObserver mBrightnessObserver = new ContentObserver(new Handler()) {
@Override
public void onChange(boolean selfChange) {
@@ -98,7 +100,7 @@
super.onBindDialogView(view);
mSeekBar = getSeekBar(view);
- mSeekBar.setMax(10000);
+ mSeekBar.setMax(SEEK_BAR_RANGE);
mOldBrightness = getBrightness();
mSeekBar.setProgress(mOldBrightness);
@@ -141,11 +143,10 @@
} else {
brightness = Settings.System.getInt(getContext().getContentResolver(),
Settings.System.SCREEN_BRIGHTNESS, 100);
- brightness = (MAXIMUM_BACKLIGHT - mScreenBrightnessDim)
- / (brightness - mScreenBrightnessDim);
-
+ brightness = (brightness - mScreenBrightnessDim)
+ / (MAXIMUM_BACKLIGHT - mScreenBrightnessDim);
}
- return (int)(brightness*10000);
+ return (int)(brightness*SEEK_BAR_RANGE);
}
private int getBrightnessMode(int defaultValue) {
@@ -197,7 +198,7 @@
private void setBrightness(int brightness, boolean write) {
if (mAutomaticMode) {
- float valf = (((float)brightness*2)/10000) - 1.0f;
+ float valf = (((float)brightness*2)/SEEK_BAR_RANGE) - 1.0f;
try {
IPowerManager power = IPowerManager.Stub.asInterface(
ServiceManager.getService("power"));
@@ -213,7 +214,7 @@
}
} else {
int range = (MAXIMUM_BACKLIGHT - mScreenBrightnessDim);
- brightness = (brightness*range)/10000 + mScreenBrightnessDim;
+ brightness = (brightness*range)/SEEK_BAR_RANGE + mScreenBrightnessDim;
try {
IPowerManager power = IPowerManager.Stub.asInterface(
ServiceManager.getService("power"));