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

Commit f6e45211 authored by Tracy Zhou's avatar Tracy Zhou Committed by Android (Google) Code Review
Browse files

Merge "Simplify trackpad multi-finger gesture recognition logic for back...

Merge "Simplify trackpad multi-finger gesture recognition logic for back notification shade" into udc-qpr-dev
parents 124be9fe 2ecd01d3
Loading
Loading
Loading
Loading
+10 −16
Original line number Diff line number Diff line
@@ -20,9 +20,8 @@ import static android.view.InputDevice.SOURCE_TOUCHPAD;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_EXCLUDE_FROM_SCREEN_MAGNIFICATION;

import static com.android.systemui.classifier.Classifier.BACK_GESTURE;
import static com.android.systemui.navigationbar.gestural.Utilities.isTrackpadFourFingerSwipe;
import static com.android.systemui.navigationbar.gestural.Utilities.isTrackpadMultiFingerSwipe;
import static com.android.systemui.navigationbar.gestural.Utilities.isTrackpadScroll;
import static com.android.systemui.navigationbar.gestural.Utilities.isTrackpadThreeFingerSwipe;

import android.annotation.NonNull;
import android.app.ActivityManager;
@@ -989,7 +988,7 @@ public class EdgeBackGestureHandler implements PluginListener<NavigationEdgeBack

    private void onMotionEvent(MotionEvent ev) {
        int action = ev.getActionMasked();
        boolean isTrackpadMultiFingerSwipe = isTrackpadMultiFingerSwipe(
        boolean isTrackpadThreeFingerSwipe = isTrackpadThreeFingerSwipe(
                mIsTrackpadGestureFeaturesEnabled, ev);
        if (action == MotionEvent.ACTION_DOWN) {
            if (DEBUG_MISSING_GESTURE) {
@@ -1003,7 +1002,7 @@ public class EdgeBackGestureHandler implements PluginListener<NavigationEdgeBack
            // Verify if this is in within the touch region and we aren't in immersive mode, and
            // either the bouncer is showing or the notification panel is hidden
            mInputEventReceiver.setBatchingEnabled(false);
            if (isTrackpadMultiFingerSwipe) {
            if (isTrackpadThreeFingerSwipe) {
                // Since trackpad gestures don't have zones, this will be determined later by the
                // direction of the gesture. {@code mIsOnLeftEdge} is set to false to begin with.
                mDeferSetIsOnLeftEdge = true;
@@ -1019,11 +1018,11 @@ public class EdgeBackGestureHandler implements PluginListener<NavigationEdgeBack
                    && !mGestureBlockingActivityRunning
                    && !QuickStepContract.isBackGestureDisabled(mSysUiFlags)
                    && !isTrackpadScroll(mIsTrackpadGestureFeaturesEnabled, ev);
            if (isTrackpadMultiFingerSwipe) {
            if (isTrackpadThreeFingerSwipe) {
                // Trackpad back gestures don't have zones, so we don't need to check if the down
                // event is within insets.
                mAllowGesture = isBackAllowedCommon && isValidTrackpadBackGesture(
                        isTrackpadMultiFingerSwipe);
                        isTrackpadThreeFingerSwipe);
            } else {
                mAllowGesture = isBackAllowedCommon && !mUsingThreeButtonNav && isWithinInsets
                    && isWithinTouchRegion((int) ev.getX(), (int) ev.getY())
@@ -1034,7 +1033,7 @@ public class EdgeBackGestureHandler implements PluginListener<NavigationEdgeBack
                mEdgeBackPlugin.onMotionEvent(ev);
                dispatchToBackAnimation(ev);
            }
            if (mLogGesture || isTrackpadMultiFingerSwipe) {
            if (mLogGesture || isTrackpadThreeFingerSwipe) {
                mDownPoint.set(ev.getX(), ev.getY());
                mEndPoint.set(-1, -1);
                mThresholdCrossed = false;
@@ -1045,10 +1044,10 @@ public class EdgeBackGestureHandler implements PluginListener<NavigationEdgeBack
            mTmpLogDate.setTime(curTime);
            String curTimeStr = mLogDateFormat.format(mTmpLogDate);
            (isWithinInsets ? mGestureLogInsideInsets : mGestureLogOutsideInsets).log(String.format(
                    "Gesture [%d [%s],alw=%B, mltf=%B, left=%B, defLeft=%B, backAlw=%B, disbld=%B,"
                    "Gesture [%d [%s],alw=%B, t3fs=%B, left=%B, defLeft=%B, backAlw=%B, disbld=%B,"
                            + " qsDisbld=%b, blkdAct=%B, pip=%B,"
                            + " disp=%s, wl=%d, il=%d, wr=%d, ir=%d, excl=%s]",
                    curTime, curTimeStr, mAllowGesture, isTrackpadMultiFingerSwipe,
                    curTime, curTimeStr, mAllowGesture, isTrackpadThreeFingerSwipe,
                    mIsOnLeftEdge, mDeferSetIsOnLeftEdge, mIsBackGestureAllowed,
                    QuickStepContract.isBackGestureDisabled(mSysUiFlags), mDisabledForQuickstep,
                    mGestureBlockingActivityRunning, mIsInPip, mDisplaySize,
@@ -1057,8 +1056,7 @@ public class EdgeBackGestureHandler implements PluginListener<NavigationEdgeBack
            if (!mThresholdCrossed) {
                mEndPoint.x = (int) ev.getX();
                mEndPoint.y = (int) ev.getY();
                if (action == MotionEvent.ACTION_POINTER_DOWN && (!isTrackpadMultiFingerSwipe
                        || isTrackpadFourFingerSwipe(mIsTrackpadGestureFeaturesEnabled, ev))) {
                if (action == MotionEvent.ACTION_POINTER_DOWN && !isTrackpadThreeFingerSwipe) {
                    if (mAllowGesture) {
                        logGesture(SysUiStatsLog.BACK_GESTURE__TYPE__INCOMPLETE_MULTI_TOUCH);
                        if (DEBUG_MISSING_GESTURE) {
@@ -1070,11 +1068,7 @@ public class EdgeBackGestureHandler implements PluginListener<NavigationEdgeBack
                    mLogGesture = false;
                    return;
                } else if (action == MotionEvent.ACTION_MOVE) {
                    if (isTrackpadFourFingerSwipe(isTrackpadMultiFingerSwipe, ev)) {
                        cancelGesture(ev);
                        return;
                    }
                    if (isTrackpadMultiFingerSwipe && mDeferSetIsOnLeftEdge) {
                    if (isTrackpadThreeFingerSwipe && mDeferSetIsOnLeftEdge) {
                        // mIsOnLeftEdge is determined by the relative position between the down
                        // and the current motion event for trackpad gestures instead of zoning.
                        mIsOnLeftEdge = mEndPoint.x > mDownPoint.x;
+4 −14
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.systemui.navigationbar.gestural;

import static android.view.MotionEvent.AXIS_GESTURE_SWIPE_FINGER_COUNT;
import static android.view.MotionEvent.CLASSIFICATION_MULTI_FINGER_SWIPE;
import static android.view.MotionEvent.CLASSIFICATION_TWO_FINGER_SWIPE;

@@ -29,21 +30,10 @@ public final class Utilities {
                && event.getClassification() == CLASSIFICATION_TWO_FINGER_SWIPE;
    }

    public static boolean isTrackpadMultiFingerSwipe(boolean isTrackpadGestureFeaturesEnabled,
            MotionEvent event) {
        return isTrackpadGestureFeaturesEnabled
                && event.getClassification() == CLASSIFICATION_MULTI_FINGER_SWIPE;
    }

    public static boolean isTrackpadThreeFingerSwipe(boolean isTrackpadGestureFeaturesEnabled,
            MotionEvent event) {
        return isTrackpadMultiFingerSwipe(isTrackpadGestureFeaturesEnabled, event)
                && event.getPointerCount() == 3;
    }

    public static boolean isTrackpadFourFingerSwipe(boolean isTrackpadGestureFeaturesEnabled,
            MotionEvent event) {
        return isTrackpadMultiFingerSwipe(isTrackpadGestureFeaturesEnabled, event)
                && event.getPointerCount() == 4;
        return isTrackpadGestureFeaturesEnabled
                && event.getClassification() == CLASSIFICATION_MULTI_FINGER_SWIPE
                && event.getAxisValue(AXIS_GESTURE_SWIPE_FINGER_COUNT) == 3;
    }
}
+14 −13
Original line number Diff line number Diff line
@@ -17,8 +17,6 @@
package com.android.systemui.shade;

import static android.app.StatusBarManager.WINDOW_STATE_SHOWING;
import static android.view.MotionEvent.CLASSIFICATION_MULTI_FINGER_SWIPE;
import static android.view.MotionEvent.CLASSIFICATION_TWO_FINGER_SWIPE;
import static android.view.View.INVISIBLE;
import static android.view.View.VISIBLE;

@@ -30,6 +28,8 @@ import static com.android.systemui.classifier.Classifier.BOUNCER_UNLOCK;
import static com.android.systemui.classifier.Classifier.GENERIC;
import static com.android.systemui.classifier.Classifier.QUICK_SETTINGS;
import static com.android.systemui.classifier.Classifier.UNLOCK;
import static com.android.systemui.navigationbar.gestural.Utilities.isTrackpadScroll;
import static com.android.systemui.navigationbar.gestural.Utilities.isTrackpadThreeFingerSwipe;
import static com.android.systemui.shade.ShadeExpansionStateManagerKt.STATE_CLOSED;
import static com.android.systemui.shade.ShadeExpansionStateManagerKt.STATE_OPEN;
import static com.android.systemui.shade.ShadeExpansionStateManagerKt.STATE_OPENING;
@@ -4655,6 +4655,9 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump
            final float x = event.getX(pointerIndex);
            final float y = event.getY(pointerIndex);
            boolean canCollapsePanel = canCollapsePanelOnTouch();
            final boolean isTrackpadTwoOrThreeFingerSwipe = isTrackpadScroll(
                    mTrackpadGestureFeaturesEnabled, event) || isTrackpadThreeFingerSwipe(
                    mTrackpadGestureFeaturesEnabled, event);

            switch (event.getActionMasked()) {
                case MotionEvent.ACTION_DOWN:
@@ -4687,7 +4690,7 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump
                    addMovement(event);
                    break;
                case MotionEvent.ACTION_POINTER_UP:
                    if (isTrackpadMotionEvent(event)) {
                    if (isTrackpadTwoOrThreeFingerSwipe) {
                        break;
                    }
                    final int upPointer = event.getPointerId(event.getActionIndex());
@@ -4703,7 +4706,7 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump
                    mShadeLog.logMotionEventStatusBarState(event,
                            mStatusBarStateController.getState(),
                            "onInterceptTouchEvent: pointer down action");
                    if (!isTrackpadMotionEvent(event)
                    if (!isTrackpadTwoOrThreeFingerSwipe
                            && mStatusBarStateController.getState() == StatusBarState.KEYGUARD) {
                        mMotionAborted = true;
                        mVelocityTracker.clear();
@@ -4852,9 +4855,13 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump
                return false;
            }

            final boolean isTrackpadTwoOrThreeFingerSwipe = isTrackpadScroll(
                    mTrackpadGestureFeaturesEnabled, event) || isTrackpadThreeFingerSwipe(
                    mTrackpadGestureFeaturesEnabled, event);

            // On expanding, single mouse click expands the panel instead of dragging.
            if (isFullyCollapsed() && (event.isFromSource(InputDevice.SOURCE_MOUSE)
                    && !isTrackpadMotionEvent(event))) {
                    && !isTrackpadTwoOrThreeFingerSwipe)) {
                if (event.getAction() == MotionEvent.ACTION_UP) {
                    expand(true /* animate */);
                }
@@ -4914,7 +4921,7 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump
                    break;

                case MotionEvent.ACTION_POINTER_UP:
                    if (isTrackpadMotionEvent(event)) {
                    if (isTrackpadTwoOrThreeFingerSwipe) {
                        break;
                    }
                    final int upPointer = event.getPointerId(event.getActionIndex());
@@ -4933,7 +4940,7 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump
                    mShadeLog.logMotionEventStatusBarState(event,
                            mStatusBarStateController.getState(),
                            "handleTouch: pointer down action");
                    if (!isTrackpadMotionEvent(event)
                    if (!isTrackpadTwoOrThreeFingerSwipe
                            && mStatusBarStateController.getState() == StatusBarState.KEYGUARD) {
                        mMotionAborted = true;
                        endMotionEvent(event, x, y, true /* forceCancel */);
@@ -5008,12 +5015,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump
            mShadeLog.logHandleTouchLastReturn(event, !mGestureWaitForTouchSlop, mTracking);
            return !mGestureWaitForTouchSlop || mTracking;
        }

        private boolean isTrackpadMotionEvent(MotionEvent ev) {
            return mTrackpadGestureFeaturesEnabled && (
                    ev.getClassification() == CLASSIFICATION_MULTI_FINGER_SWIPE
                            || ev.getClassification() == CLASSIFICATION_TWO_FINGER_SWIPE);
        }
    }

    private final class HeadsUpNotificationViewControllerImpl implements