Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8e5a6d0b authored by Steve Kondik's avatar Steve Kondik Committed by Gerrit Code Review
Browse files

Merge "Status Bar Brightness Control Padding" into ics

parents 4ccca1f8 2110da5e
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -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 {