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

Commit a6684ba4 authored by Andy Wickham's avatar Andy Wickham Committed by Automerger Merge Worker
Browse files

Merge "Adds haptics to Overview gesture in Sandbox." into...

Merge "Adds haptics to Overview gesture in Sandbox." into ub-launcher3-rvc-qpr-dev am: 91fbf661 am: 4341d784

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/12230464

Change-Id: Ide2387406eaaad3c281749b9d7bc90f3e403883e
parents 8d957872 4341d784
Loading
Loading
Loading
Loading
+17 −1
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@
package com.android.quickstep.interaction;

import static com.android.launcher3.Utilities.squaredHypot;
import static com.android.launcher3.util.VibratorWrapper.OVERVIEW_HAPTIC;
import static com.android.quickstep.interaction.NavBarGestureHandler.NavBarGestureResult.ASSISTANT_COMPLETED;
import static com.android.quickstep.interaction.NavBarGestureHandler.NavBarGestureResult.ASSISTANT_NOT_STARTED_BAD_ANGLE;
import static com.android.quickstep.interaction.NavBarGestureHandler.NavBarGestureResult.ASSISTANT_NOT_STARTED_SWIPE_TOO_SHORT;
@@ -48,6 +49,7 @@ import com.android.launcher3.ResourceUtils;
import com.android.launcher3.anim.Interpolators;
import com.android.launcher3.util.VibratorWrapper;
import com.android.quickstep.SysUINavigationMode.Mode;
import com.android.quickstep.util.MotionPauseDetector;
import com.android.quickstep.util.NavBarPosition;
import com.android.quickstep.util.TriggerSwipeUpTouchTracker;
import com.android.systemui.shared.system.QuickStepContract;
@@ -74,6 +76,7 @@ public class NavBarGestureHandler implements OnTouchListener,
    private final PointF mAssistantStartDragPos = new PointF();
    private final PointF mDownPos = new PointF();
    private final PointF mLastPos = new PointF();
    private final MotionPauseDetector mMotionPauseDetector;
    private boolean mTouchCameFromAssistantCorner;
    private boolean mTouchCameFromNavBar;
    private boolean mPassedAssistantSlop;
@@ -100,6 +103,7 @@ public class NavBarGestureHandler implements OnTouchListener,
                new TriggerSwipeUpTouchTracker(context, true /*disableHorizontalSwipe*/,
                        new NavBarPosition(Mode.NO_BUTTON, displayRotation),
                        null /*onInterceptTouch*/, this);
        mMotionPauseDetector = new MotionPauseDetector(context);

        final Resources resources = context.getResources();
        mBottomGestureHeight =
@@ -177,12 +181,14 @@ public class NavBarGestureHandler implements OnTouchListener,
                }
                mLaunchedAssistant = false;
                mSwipeUpTouchTracker.init();
                mMotionPauseDetector.clear();
                mMotionPauseDetector.setOnMotionPauseListener(this::onMotionPauseChanged);
                break;
            case MotionEvent.ACTION_MOVE:
                mLastPos.set(event.getX(), event.getY());
                if (!mAssistantGestureActive) {
                    break;
                }
                mLastPos.set(event.getX(), event.getY());

                if (!mPassedAssistantSlop) {
                    // Normal gesture, ensure we pass the slop before we start tracking the gesture
@@ -213,6 +219,8 @@ public class NavBarGestureHandler implements OnTouchListener,
                break;
            case MotionEvent.ACTION_UP:
            case MotionEvent.ACTION_CANCEL:
                mMotionPauseDetector.clear();
                mMotionPauseDetector.setOnMotionPauseListener(null);
                if (mGestureCallback != null && !intercepted && mTouchCameFromNavBar) {
                    mGestureCallback.onNavBarGestureAttempted(
                            HOME_OR_OVERVIEW_NOT_STARTED_WRONG_SWIPE_DIRECTION, new PointF());
@@ -239,9 +247,17 @@ public class NavBarGestureHandler implements OnTouchListener,
        }
        mSwipeUpTouchTracker.onMotionEvent(event);
        mAssistantGestureDetector.onTouchEvent(event);
        mMotionPauseDetector.addPosition(event);
        mMotionPauseDetector.setDisallowPause(mLastPos.y >= mDisplaySize.y - mBottomGestureHeight);
        return intercepted;
    }

    protected void onMotionPauseChanged(boolean isPaused) {
        if (isPaused) {
            VibratorWrapper.INSTANCE.get(mContext).vibrate(OVERVIEW_HAPTIC);
        }
    }

    /**
     * Determine if angle is larger than threshold for assistant detection
     */