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

Commit e2ca84c8 authored by Phil Tunstall's avatar Phil Tunstall Committed by Michael Bestas
Browse files

Fix status bar brightness control when on secure lock screen

When the notifications panel is disabled no views are handling touch events
on the status bar, so we see nothing beyond each ACTION_DOWN. Intercept touch
events when needed specifically for brightness control.

Also recycle VelocityTracker when we're not using it, as per its documentation.

Change-Id: I84d4c788bcdb1e05244710aca933d97e3e60d1b5
parent 1311a90e
Loading
Loading
Loading
Loading
+43 −41
Original line number Diff line number Diff line
@@ -298,7 +298,7 @@ public class PhoneStatusBar extends BaseStatusBar {
    CustomTheme mCurrentTheme;
    private boolean mRecreating = false;

    private boolean mBrightnessControl = true;
    private boolean mBrightnessControl;
    private float mScreenWidth;
    private int mMinBrightness;
    int mLinger;
@@ -780,8 +780,6 @@ public class PhoneStatusBar extends BaseStatusBar {
        mPowerWidget.setupWidget();
        mPowerWidget.updateVisibility();

        mVelocityTracker = VelocityTracker.obtain();

        return mStatusBarView;
    }

@@ -2024,10 +2022,7 @@ public class PhoneStatusBar extends BaseStatusBar {
        }
    }

    private void brightnessControl(MotionEvent event)
    {
        if (mBrightnessControl)
        {
    private void brightnessControl(MotionEvent event) {
        final int action = event.getAction();
        final int x = (int) event.getRawX();
        final int y = (int) event.getRawY();
@@ -2035,6 +2030,7 @@ public class PhoneStatusBar extends BaseStatusBar {
            mLinger = 0;
            mInitialTouchX = x;
            mInitialTouchY = y;
            mVelocityTracker = VelocityTracker.obtain();
            mHandler.removeCallbacks(mLongPressBrightnessChange);
            if ((y + mViewDelta) < mNotificationHeaderHeight) {
                mHandler.postDelayed(mLongPressBrightnessChange,
@@ -2062,11 +2058,12 @@ public class PhoneStatusBar extends BaseStatusBar {
            }
        } else if (action == MotionEvent.ACTION_UP
                || action == MotionEvent.ACTION_CANCEL) {
            mVelocityTracker.recycle();
            mVelocityTracker = null;
            mHandler.removeCallbacks(mLongPressBrightnessChange);
            mLinger = 0;
        }
    }
    }

    public boolean interceptTouchEvent(MotionEvent event) {
        if (SPEW) {
@@ -2085,8 +2082,6 @@ public class PhoneStatusBar extends BaseStatusBar {
            mGestureRec.add(event);
        }

        brightnessControl(event);

        // Cling (first-run help) handling.
        // The cling is supposed to show the first time you drag, or even tap, the status bar.
        // It should show the notification panel, then fade in after half a second, giving you
@@ -2102,6 +2097,13 @@ public class PhoneStatusBar extends BaseStatusBar {
            hideCling();
        }

        if (mBrightnessControl) {
            brightnessControl(event);
            if ((mDisabled & StatusBarManager.DISABLE_EXPAND) != 0) {
                return true;
            }
        }

        return false;
    }