diff options
| author | 2023-10-11 16:06:54 +0800 | |
|---|---|---|
| committer | 2023-10-12 00:52:41 +0000 | |
| commit | 21582217e4c5b8c461cf7efd2b9057e37e6b423f (patch) | |
| tree | ebdb5b5240a76b8d3830156973330384f364838a | |
| parent | 3f40875da870a22d4cd2c9c8495c847817ee4f72 (diff) | |
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
4 files changed, 18 insertions, 26 deletions
diff --git a/services/accessibility/java/com/android/server/accessibility/magnification/FullScreenMagnificationGestureHandler.java b/services/accessibility/java/com/android/server/accessibility/magnification/FullScreenMagnificationGestureHandler.java index 30b9d0b59467..01064ac83fb2 100644 --- a/services/accessibility/java/com/android/server/accessibility/magnification/FullScreenMagnificationGestureHandler.java +++ b/services/accessibility/java/com/android/server/accessibility/magnification/FullScreenMagnificationGestureHandler.java @@ -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) diff --git a/services/accessibility/java/com/android/server/accessibility/magnification/MagnificationGestureHandler.java b/services/accessibility/java/com/android/server/accessibility/magnification/MagnificationGestureHandler.java index 28946939e6fd..8476a5e30e27 100644 --- a/services/accessibility/java/com/android/server/accessibility/magnification/MagnificationGestureHandler.java +++ b/services/accessibility/java/com/android/server/accessibility/magnification/MagnificationGestureHandler.java @@ -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; } diff --git a/services/accessibility/java/com/android/server/accessibility/magnification/WindowMagnificationGestureHandler.java b/services/accessibility/java/com/android/server/accessibility/magnification/WindowMagnificationGestureHandler.java index c58e9a6d0a2f..2d9dcb96d53d 100644 --- a/services/accessibility/java/com/android/server/accessibility/magnification/WindowMagnificationGestureHandler.java +++ b/services/accessibility/java/com/android/server/accessibility/magnification/WindowMagnificationGestureHandler.java @@ -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 diff --git a/services/tests/servicestests/src/com/android/server/accessibility/magnification/FullScreenMagnificationGestureHandlerTest.java b/services/tests/servicestests/src/com/android/server/accessibility/magnification/FullScreenMagnificationGestureHandlerTest.java index 430f600a6288..caa9e7c3aecb 100644 --- a/services/tests/servicestests/src/com/android/server/accessibility/magnification/FullScreenMagnificationGestureHandlerTest.java +++ b/services/tests/servicestests/src/com/android/server/accessibility/magnification/FullScreenMagnificationGestureHandlerTest.java @@ -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); |