From fdf9315b8ea30a8dc7c1c75b41e531f3e30ded8b Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Fri, 18 May 2018 09:11:49 -0700 Subject: [PATCH] Fix thresholds with deferred-start swipe up gestures - We were previously using the drag threshold (10dp) for both gesture start and drag start, when we should be using the touch threshold (24dp) for the deferred gesture start to ensure it coincides with the touch threshold for the buttons in the nav bar. Bug: 79970627 Test: Swipe up over the back button, ensure that we don't both start the animation and also trigger back press Change-Id: Ib4b2a3e2492da144485f87be5477eabf3e96e843 --- .../quickstep/OtherActivityTouchConsumer.java | 27 +++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/quickstep/src/com/android/quickstep/OtherActivityTouchConsumer.java b/quickstep/src/com/android/quickstep/OtherActivityTouchConsumer.java index 2d41a5bf6c..d1003a51c3 100644 --- a/quickstep/src/com/android/quickstep/OtherActivityTouchConsumer.java +++ b/quickstep/src/com/android/quickstep/OtherActivityTouchConsumer.java @@ -82,7 +82,10 @@ public class OtherActivityTouchConsumer extends ContextWrapper implements TouchC private final PointF mLastPos = new PointF(); private int mActivePointerId = INVALID_POINTER_ID; private boolean mPassedInitialSlop; + // Used for non-deferred gestures to determine when to start dragging private int mQuickStepDragSlop; + // Used for deferred gestures to determine both start of animation and dragging + private int mQuickStepTouchSlop; private float mStartDisplacement; private WindowTransformSwipeHandler mInteractionHandler; private int mDisplayRotation; @@ -128,6 +131,7 @@ public class OtherActivityTouchConsumer extends ContextWrapper implements TouchC mLastPos.set(mDownPos); mPassedInitialSlop = false; mQuickStepDragSlop = NavigationBarCompat.getQuickStepDragSlopPx(); + mQuickStepTouchSlop = NavigationBarCompat.getQuickStepTouchSlopPx(); // Start the window animation on down to give more time for launcher to draw if the // user didn't start the gesture over the back button @@ -160,15 +164,22 @@ public class OtherActivityTouchConsumer extends ContextWrapper implements TouchC } mLastPos.set(ev.getX(pointerIndex), ev.getY(pointerIndex)); float displacement = getDisplacement(ev); - if (!mPassedInitialSlop - && Math.abs(displacement) > mQuickStepDragSlop) { - mPassedInitialSlop = true; - mStartDisplacement = displacement; - - // If we deferred starting the window animation on touch down, then - // start tracking now + if (!mPassedInitialSlop) { if (mIsDeferredDownTarget) { - startTouchTrackingForWindowAnimation(ev.getEventTime()); + // Deferred gesture, start the animation and gesture tracking once we pass + // the touch slop + if (Math.abs(displacement) > mQuickStepTouchSlop) { + startTouchTrackingForWindowAnimation(ev.getEventTime()); + mPassedInitialSlop = true; + mStartDisplacement = displacement; + } + } else { + // Normal gesture, ensure we pass the drag slop before we start tracking + // the gesture + if (Math.abs(displacement) > mQuickStepDragSlop) { + mPassedInitialSlop = true; + mStartDisplacement = displacement; + } } }