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

Commit 2110da5e authored by nebkat's avatar nebkat
Browse files

Status Bar Brightness Control Padding

Add a padding to the brightness control on both sides to make it easier
to reach the min/max brightness.

Change-Id: Ia42444321f82aaac97c0c442796dec551b1bcd65
parent f9fd78a0
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 {