summaryrefslogtreecommitdiffstats
path: root/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
diff options
context:
space:
mode:
Diffstat (limited to 'packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java')
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java13
1 files changed, 12 insertions, 1 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
index 8708104..e2ae054 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -125,6 +125,8 @@ public class PhoneStatusBar extends StatusBar {
private static final boolean CLOSE_PANEL_WHEN_EMPTIED = true;
+ private static final float BRIGHTNESS_CONTROL_PADDING = 0.15f;
+
private boolean mShowClock;
private boolean mBrightnessControl;
private boolean mAutoBrightness;
@@ -1594,7 +1596,16 @@ public class PhoneStatusBar extends StatusBar {
if (yVel < 50.0f) {
if (mLinger > 20) {
float x = (float) event.getRawX();
- int newBrightness = (int) Math.round(((x / mScreenWidth) * android.os.Power.BRIGHTNESS_ON));
+ float raw = (x / mScreenWidth);
+
+ // Add a padding to the brightness control on both sides to make it easier
+ // to reach min/max brightness
+ float padded = Math.min(1.0f - BRIGHTNESS_CONTROL_PADDING, Math.max(BRIGHTNESS_CONTROL_PADDING, raw));
+ float value = (padded - BRIGHTNESS_CONTROL_PADDING) / (1 - (2.0f * BRIGHTNESS_CONTROL_PADDING));
+
+ int newBrightness = mMinBrightness + (int) Math.round(value *
+ (android.os.Power.BRIGHTNESS_ON - mMinBrightness));
+
newBrightness = Math.min(newBrightness, android.os.Power.BRIGHTNESS_ON);
newBrightness = Math.max(newBrightness, mMinBrightness);
try {