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

Commit b8379d2d authored by Tyler Freeman's avatar Tyler Freeman Committed by Android (Google) Code Review
Browse files

Merge "fix(MultiFingerMultiTap): The two finger triple tap is hard work when...

Merge "fix(MultiFingerMultiTap): The two finger triple tap is hard work when Magnification is activated" into main
parents c0c00128 120e7c46
Loading
Loading
Loading
Loading
+26 −15
Original line number Diff line number Diff line
@@ -916,19 +916,28 @@ public class FullScreenMagnificationGestureHandler extends MagnificationGestureH
                            && event.getPointerCount() == 2;
                    mHandler.removeMessages(MESSAGE_TRANSITION_TO_DELEGATING_STATE);

                    if (isActivated() && event.getPointerCount() == 2) {
                        storePointerDownLocation(mSecondPointerDownLocation, event);
                        mHandler.sendEmptyMessageDelayed(MESSAGE_TRANSITION_TO_PANNINGSCALING_STATE,
                                ViewConfiguration.getTapTimeout());
                    } else if (mIsTwoFingerCountReached) {
                        // Placing two-finger triple-taps behind isActivated to avoid
                        // blocking panning scaling state
                    if (event.getPointerCount() == 2) {
                        if (isMultiFingerMultiTapTriggered(/* targetTapCount= */ 2, event)) {
                            // 3tap and hold
                            afterLongTapTimeoutTransitionToDraggingState(event);
                        } else {
                            if (mDetectTwoFingerTripleTap) {
                                // If mDetectTwoFingerTripleTap, delay transition to the delegating
                                // state for mMultiTapMaxDelay to ensure reachability of
                                // multi finger multi tap
                                afterMultiTapTimeoutTransitionToDelegatingState();
                            }

                            if (isActivated()) {
                                // If activated, delay transition to the panning scaling
                                // state for tap timeout to ensure reachability of
                                // multi finger multi tap
                                storePointerDownLocation(mSecondPointerDownLocation, event);
                                mHandler.sendEmptyMessageDelayed(
                                        MESSAGE_TRANSITION_TO_PANNINGSCALING_STATE,
                                        ViewConfiguration.getTapTimeout());
                            }
                        }
                    } else {
                        transitionToDelegatingStateAndClear();
                    }
@@ -953,6 +962,9 @@ public class FullScreenMagnificationGestureHandler extends MagnificationGestureH
                        // (which is a rare combo to be used aside from magnification)
                        if (isMultiTapTriggered(2 /* taps */) && event.getPointerCount() == 1) {
                            transitionToViewportDraggingStateAndClear(event);
                        } else if (isMultiFingerMultiTapTriggered(/* targetTapCount= */ 2, event)
                                && event.getPointerCount() == 2) {
                            transitionToViewportDraggingStateAndClear(event);
                        } else if (isActivated() && event.getPointerCount() == 2) {
                            if (mIsSinglePanningEnabled
                                    && overscrollState(event, mFirstPointerDownLocation)
@@ -961,11 +973,6 @@ public class FullScreenMagnificationGestureHandler extends MagnificationGestureH
                            }
                            //Primary pointer is swiping, so transit to PanningScalingState
                            transitToPanningScalingStateAndClear();
                        } else if (isMultiFingerMultiTapTriggered(/* targetTapCount= */ 2, event)
                                && event.getPointerCount() == 2) {
                            // Placing two-finger triple-taps behind isActivated to avoid
                            // blocking panning scaling state
                            transitionToViewportDraggingStateAndClear(event);
                        } else if (mIsSinglePanningEnabled
                                && isActivated()
                                && event.getPointerCount() == 1) {
@@ -979,7 +986,10 @@ public class FullScreenMagnificationGestureHandler extends MagnificationGestureH
                        }
                    } else if (isActivated() && pointerDownValid(mSecondPointerDownLocation)
                            && distanceClosestPointerToPoint(
                            mSecondPointerDownLocation, /* move */ event) > mSwipeMinDistance) {
                            mSecondPointerDownLocation, /* move */ event) > mSwipeMinDistance
                            // If mCompleteTapCount is not zero, it means that it is a multi tap
                            // gesture. So, we should not transit to the PanningScalingState.
                            && mCompletedTapCount == 0) {
                        // Second pointer is swiping, so transit to PanningScalingState
                        transitToPanningScalingStateAndClear();
                    }
@@ -988,6 +998,7 @@ public class FullScreenMagnificationGestureHandler extends MagnificationGestureH
                case ACTION_UP: {

                    mHandler.removeMessages(MESSAGE_ON_TRIPLE_TAP_AND_HOLD);
                    mHandler.removeMessages(MESSAGE_TRANSITION_TO_PANNINGSCALING_STATE);

                    if (!mFullScreenMagnificationController.magnificationRegionContains(
                            mDisplayId, event.getX(), event.getY())) {
+46 −0
Original line number Diff line number Diff line
@@ -587,6 +587,38 @@ public class FullScreenMagnificationGestureHandlerTest {
        verify(mMockMagnificationLogger).logMagnificationTwoFingerTripleTap(true);
    }

    @Test
    @RequiresFlagsEnabled(Flags.FLAG_ENABLE_MAGNIFICATION_MULTIPLE_FINGER_MULTIPLE_TAP_GESTURE)
    public void testTwoFingerTap_StateIsActivated_shouldInDelegating() {
        assumeTrue(mMgh.mIsSinglePanningEnabled);
        mMgh.setSinglePanningEnabled(false);
        goFromStateIdleTo(STATE_ACTIVATED);
        allowEventDelegation();

        send(downEvent());
        send(pointerEvent(ACTION_POINTER_DOWN, DEFAULT_X * 2, DEFAULT_Y));
        send(upEvent());
        fastForward(ViewConfiguration.getDoubleTapTimeout());

        assertTrue(mMgh.mCurrentState == mMgh.mDelegatingState);
    }

    @Test
    @RequiresFlagsEnabled(Flags.FLAG_ENABLE_MAGNIFICATION_MULTIPLE_FINGER_MULTIPLE_TAP_GESTURE)
    public void testTwoFingerTap_StateIsIdle_shouldInDelegating() {
        assumeTrue(mMgh.mIsSinglePanningEnabled);
        mMgh.setSinglePanningEnabled(false);
        goFromStateIdleTo(STATE_IDLE);
        allowEventDelegation();

        send(downEvent());
        send(pointerEvent(ACTION_POINTER_DOWN, DEFAULT_X * 2, DEFAULT_Y));
        send(upEvent());
        fastForward(ViewConfiguration.getDoubleTapTimeout());

        assertTrue(mMgh.mCurrentState == mMgh.mDelegatingState);
    }

    @Test
    public void testMultiTap_outOfDistanceSlop_shouldInIdle() {
        // All delay motion events should be sent, if multi-tap with out of distance slop.
@@ -718,6 +750,20 @@ public class FullScreenMagnificationGestureHandlerTest {
        returnToNormalFrom(STATE_PANNING);
    }

    @Test
    public void testTwoFingerDown_twoPointerDownAndActivatedState_panningState() {
        goFromStateIdleTo(STATE_ACTIVATED);
        PointF pointer1 = DEFAULT_POINT;
        PointF pointer2 = new PointF(DEFAULT_X * 1.5f, DEFAULT_Y);

        send(downEvent());
        send(pointerEvent(ACTION_POINTER_DOWN, new PointF[] {pointer1, pointer2}, 1));
        fastForward(ViewConfiguration.getTapTimeout());
        assertIn(STATE_PANNING);

        returnToNormalFrom(STATE_PANNING);
    }

    @Test
    public void testActivatedWithTripleTap_invokeShowWindowPromptAction() {
        goFromStateIdleTo(STATE_ACTIVATED);