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

Commit 3a4bc79d authored by Mady Mellor's avatar Mady Mellor
Browse files

Update stylus gesture to access quick settings to use the new buttons

In M+ BUTTON_STYLUS_PRIMARY/SECONDARY should be used to recognize stylus
button events, this CL updates the usage to open quick settings.

It also enables similar mouse button + drag events to open QS.

Bug: 21148238
Change-Id: I8a47eb9c3d5e2016e039ec52d881b36f3a4480fa
parent 5fa7b8bd
Loading
Loading
Loading
Loading
+19 −8
Original line number Diff line number Diff line
@@ -767,14 +767,7 @@ public class NotificationPanelView extends PanelView implements
                && mQsExpansionEnabled) {
            mTwoFingerQsExpandPossible = true;
        }
        final int pointerCount = event.getPointerCount();
        final boolean twoFingerDrag = action == MotionEvent.ACTION_POINTER_DOWN
                && pointerCount == 2;
        final boolean stylusClickDrag = action == MotionEvent.ACTION_DOWN
                && pointerCount == 1 && event.getToolType(0) == MotionEvent.TOOL_TYPE_STYLUS
                && (event.isButtonPressed(MotionEvent.BUTTON_SECONDARY)
                        || event.isButtonPressed(MotionEvent.BUTTON_TERTIARY));
        if (mTwoFingerQsExpandPossible && (twoFingerDrag || stylusClickDrag)
        if (mTwoFingerQsExpandPossible && isOpenQsEvent(event)
                && event.getY(event.getActionIndex()) < mStatusBarMinHeight) {
            MetricsLogger.count(mContext, COUNTER_PANEL_OPEN_QS, 1);
            mQsExpandImmediate = true;
@@ -793,6 +786,24 @@ public class NotificationPanelView extends PanelView implements
                || y <= mQsContainer.getY() + mQsContainer.getHeight());
    }

    private boolean isOpenQsEvent(MotionEvent event) {
        final int pointerCount = event.getPointerCount();
        final int action = event.getActionMasked();

        final boolean twoFingerDrag = action == MotionEvent.ACTION_POINTER_DOWN
                && pointerCount == 2;

        final boolean stylusButtonClickDrag = action == MotionEvent.ACTION_DOWN
                && (event.isButtonPressed(MotionEvent.BUTTON_STYLUS_PRIMARY)
                        || event.isButtonPressed(MotionEvent.BUTTON_STYLUS_SECONDARY));

        final boolean mouseButtonClickDrag = action == MotionEvent.ACTION_DOWN
                && (event.isButtonPressed(MotionEvent.BUTTON_SECONDARY)
                        || event.isButtonPressed(MotionEvent.BUTTON_TERTIARY));

        return twoFingerDrag || stylusButtonClickDrag || mouseButtonClickDrag;
    }

    private void handleQsDown(MotionEvent event) {
        if (event.getActionMasked() == MotionEvent.ACTION_DOWN
                && shouldQuickSettingsIntercept(event.getX(), event.getY(), -1)) {