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
This commit is contained in:
Winson Chung 2018-05-18 09:11:49 -07:00
parent f3cc505e86
commit fdf9315b8e
1 changed files with 19 additions and 8 deletions

View File

@ -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;
}
}
}