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

Commit 21582217 authored by Jean Chen's avatar Jean Chen
Browse files

refactor(MultiFingerMultiTap): Rename mDetectTriple to...

refactor(MultiFingerMultiTap): Rename mDetectTriple to mDetectSingleFingerTripleTap before implement TwoFingerTripleTap

1. Enhance naming accuracy to enable clear differentiation between new and existing features. Then add new boolean parameter, mDetectTwoFingerTripleTap, for feature.
2. Remove unnecessary local variables, mDetectTripleTap,  in Detecting State and use global variables directly.

Bug: 297805269
Test: manual
Test: atest MagnificationGestureHandlerTest
Test: atest WindowMagnificationGestureHandlerTest
Test: atest FullScreenMagnificationGestureHandlerTest
Change-Id: I94eb9bc6114a7d562e9f8f8f90970fa96e24c473
parent 3f40875d
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -873,7 +873,7 @@ public class FullScreenMagnificationGestureHandler extends MagnificationGestureH

                        transitionToDelegatingStateAndClear();

                    } else if (mDetectTripleTap
                    } else if (mDetectSingleFingerTripleTap
                            // If activated, delay an ACTION_DOWN for mMultiTapMaxDelay
                            // to ensure reachability of
                            // STATE_PANNING_SCALING(triggerable with ACTION_POINTER_DOWN)
@@ -989,7 +989,7 @@ public class FullScreenMagnificationGestureHandler extends MagnificationGestureH
            // Shortcut acts as the 2 initial taps
            if (mShortcutTriggered) return tapCount() + 2 >= numTaps;

            final boolean multitapTriggered = mDetectTripleTap
            final boolean multitapTriggered = mDetectSingleFingerTripleTap
                    && tapCount() >= numTaps
                    && isMultiTap(mPreLastDown, mLastDown)
                    && isMultiTap(mPreLastUp, mLastUp);
@@ -1205,7 +1205,7 @@ public class FullScreenMagnificationGestureHandler extends MagnificationGestureH
         * @return true if tap is out of distance slop
         */
        boolean isTapOutOfDistanceSlop() {
            if (!mDetectTripleTap) return false;
            if (!mDetectSingleFingerTripleTap) return false;
            if (mPreLastDown == null || mLastDown == null) {
                return false;
            }
@@ -1282,7 +1282,7 @@ public class FullScreenMagnificationGestureHandler extends MagnificationGestureH
                + ", mMagnifiedInteractionState=" + mPanningScalingState
                + ", mViewportDraggingState=" + mViewportDraggingState
                + ", mSinglePanningState=" + mSinglePanningState
                + ", mDetectTripleTap=" + mDetectTripleTap
                + ", mDetectSingleFingerTripleTap=" + mDetectSingleFingerTripleTap
                + ", mDetectShortcutTrigger=" + mDetectShortcutTrigger
                + ", mCurrentState=" + State.nameOf(mCurrentState)
                + ", mPreviousState=" + State.nameOf(mPreviousState)
+5 −5
Original line number Diff line number Diff line
@@ -57,11 +57,11 @@ public abstract class MagnificationGestureHandler extends BaseEventStreamTransfo
    protected final boolean mDetectShortcutTrigger;

    /**
     * {@code true} if this detector should detect and respond to triple-tap
     * {@code true} if this detector should detect and respond to single-finger triple-tap
     * gestures for engaging and disengaging magnification,
     * {@code false} if it should ignore such gestures
     */
    protected final boolean mDetectTripleTap;
    protected final boolean mDetectSingleFingerTripleTap;

    /** Callback interface to report that magnification is interactive with a user. */
    public interface Callback {
@@ -85,12 +85,12 @@ public abstract class MagnificationGestureHandler extends BaseEventStreamTransfo
    private final AccessibilityTraceManager mTrace;
    protected final Callback mCallback;

    protected MagnificationGestureHandler(int displayId, boolean detectTripleTap,
    protected MagnificationGestureHandler(int displayId, boolean detectSingleFingerTripleTap,
            boolean detectShortcutTrigger,
            AccessibilityTraceManager trace,
            @NonNull Callback callback) {
        mDisplayId = displayId;
        mDetectTripleTap = detectTripleTap;
        mDetectSingleFingerTripleTap = detectSingleFingerTripleTap;
        mDetectShortcutTrigger = detectShortcutTrigger;
        mTrace = trace;
        mCallback = callback;
@@ -128,7 +128,7 @@ public abstract class MagnificationGestureHandler extends BaseEventStreamTransfo
    }

    private boolean shouldDispatchTransformedEvent(MotionEvent event) {
        if ((!mDetectTripleTap && !mDetectShortcutTrigger) || !event.isFromSource(
        if ((!mDetectSingleFingerTripleTap && !mDetectShortcutTrigger) || !event.isFromSource(
                SOURCE_TOUCHSCREEN)) {
            return true;
        }
+7 −15
Original line number Diff line number Diff line
@@ -111,7 +111,7 @@ public class WindowMagnificationGestureHandler extends MagnificationGestureHandl
                (event, rawEvent, policyFlags) -> dispatchTransformedEvent(event, rawEvent,
                        policyFlags));
        mDelegatingState = new DelegatingState(mMotionEventDispatcherDelegate);
        mDetectingState = new DetectingState(context, mDetectTripleTap);
        mDetectingState = new DetectingState(context);
        mViewportDraggingState = new ViewportDraggingState();
        mObservePanningScalingState = new PanningScalingGestureState(
                new PanningScalingHandler(context, MAX_SCALE, MIN_SCALE, true,
@@ -448,22 +448,14 @@ public class WindowMagnificationGestureHandler extends MagnificationGestureHandl

        private final MagnificationGesturesObserver mGesturesObserver;

        /**
         * {@code true} if this detector should detect and respond to triple-tap
         * gestures for engaging and disengaging magnification,
         * {@code false} if it should ignore such gestures
         */
        private final boolean mDetectTripleTap;

        DetectingState(@UiContext Context context, boolean detectTripleTap) {
            mDetectTripleTap = detectTripleTap;
            final MultiTap multiTap = new MultiTap(context, mDetectTripleTap ? 3 : 1,
                    mDetectTripleTap
        DetectingState(@UiContext Context context) {
            final MultiTap multiTap = new MultiTap(context, mDetectSingleFingerTripleTap ? 3 : 1,
                    mDetectSingleFingerTripleTap
                            ? MagnificationGestureMatcher.GESTURE_TRIPLE_TAP
                            : MagnificationGestureMatcher.GESTURE_SINGLE_TAP, null);
            final MultiTapAndHold multiTapAndHold = new MultiTapAndHold(context,
                    mDetectTripleTap ? 3 : 1,
                    mDetectTripleTap
                    mDetectSingleFingerTripleTap ? 3 : 1,
                    mDetectSingleFingerTripleTap
                            ? MagnificationGestureMatcher.GESTURE_TRIPLE_TAP_AND_HOLD
                            : MagnificationGestureMatcher.GESTURE_SINGLE_TAP_AND_HOLD, null);
            mGesturesObserver = new MagnificationGesturesObserver(this,
@@ -488,7 +480,7 @@ public class WindowMagnificationGestureHandler extends MagnificationGestureHandl
        @Override
        public boolean shouldStopDetection(MotionEvent motionEvent) {
            return !mWindowMagnificationMgr.isWindowMagnifierEnabled(mDisplayId)
                    && !mDetectTripleTap;
                    && !mDetectSingleFingerTripleTap;
        }

        @Override
+2 −2
Original line number Diff line number Diff line
@@ -1065,7 +1065,7 @@ public class FullScreenMagnificationGestureHandlerTest {
                    mMgh.clearAndTransitionToStateDetecting();
                    break;
                case STATE_ACTIVATED:
                    if (mMgh.mDetectTripleTap) {
                    if (mMgh.mDetectSingleFingerTripleTap) {
                        goFromStateIdleTo(STATE_2TAPS);
                        tap();
                    } else {
@@ -1147,7 +1147,7 @@ public class FullScreenMagnificationGestureHandlerTest {
                break;
            case STATE_ACTIVATED:
            case STATE_ZOOMED_OUT_FROM_SERVICE:
                if (mMgh.mDetectTripleTap) {
                if (mMgh.mDetectSingleFingerTripleTap) {
                    tap();
                    tap();
                    returnToNormalFrom(STATE_ACTIVATED_2TAPS);