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

Commit 011f2a8b authored by Jean Chen's avatar Jean Chen Committed by Android (Google) Code Review
Browse files

Merge "refactor(MultiFingerMultiTap): Create a list to collect all gestures...

Merge "refactor(MultiFingerMultiTap): Create a list to collect all gestures and finally send them to the GesturesObserver" into main
parents 0ca24e3d a046d18e
Loading
Loading
Loading
Loading
+42 −14
Original line number Diff line number Diff line
@@ -39,9 +39,12 @@ import com.android.internal.accessibility.util.AccessibilityStatsLogUtils;
import com.android.internal.annotations.VisibleForTesting;
import com.android.server.accessibility.AccessibilityTraceManager;
import com.android.server.accessibility.EventStreamTransformation;
import com.android.server.accessibility.Flags;
import com.android.server.accessibility.gestures.GestureMatcher;
import com.android.server.accessibility.gestures.MultiTap;
import com.android.server.accessibility.gestures.MultiTapAndHold;

import java.util.ArrayList;
import java.util.List;

/**
@@ -453,7 +456,31 @@ public class WindowMagnificationGestureHandler extends MagnificationGestureHandl
        private final MagnificationGesturesObserver mGesturesObserver;

        DetectingState(@UiContext Context context) {
            final MultiTap multiTap = new MultiTap(context, mDetectSingleFingerTripleTap ? 3 : 1,
            if (Flags.enableMagnificationMultipleFingerMultipleTapGesture()) {
                final List<GestureMatcher> mGestureMatchers = new ArrayList<>();

                mGestureMatchers.add(new SimpleSwipe(context));
                // Observe single tap and single tap and hold to reduce response time when the
                // user performs these two gestures inside the window magnifier.
                mGestureMatchers.add(new MultiTap(context,
                        mDetectSingleFingerTripleTap ? 3 : 1,
                        mDetectSingleFingerTripleTap
                                ? MagnificationGestureMatcher.GESTURE_TRIPLE_TAP
                                : MagnificationGestureMatcher.GESTURE_SINGLE_TAP,
                        null));
                mGestureMatchers.add(new MultiTapAndHold(context,
                        mDetectSingleFingerTripleTap ? 3 : 1,
                        mDetectSingleFingerTripleTap
                                ? MagnificationGestureMatcher.GESTURE_TRIPLE_TAP_AND_HOLD
                                : MagnificationGestureMatcher.GESTURE_SINGLE_TAP_AND_HOLD,
                        null));
                mGestureMatchers.add(new TwoFingersDownOrSwipe(context));

                mGesturesObserver = new MagnificationGesturesObserver(this,
                        mGestureMatchers.toArray(new GestureMatcher[mGestureMatchers.size()]));
            } else {
                final MultiTap multiTap = new MultiTap(context,
                        mDetectSingleFingerTripleTap ? 3 : 1,
                        mDetectSingleFingerTripleTap
                                ? MagnificationGestureMatcher.GESTURE_TRIPLE_TAP
                                : MagnificationGestureMatcher.GESTURE_SINGLE_TAP, null);
@@ -468,6 +495,7 @@ public class WindowMagnificationGestureHandler extends MagnificationGestureHandl
                        multiTapAndHold,
                        new TwoFingersDownOrSwipe(context));
            }
        }

        @Override
        public void onMotionEvent(MotionEvent event, MotionEvent rawEvent, int policyFlags) {