From 822acf4d25090d9c8ee19a03724c08aacffe122e Mon Sep 17 00:00:00 2001 From: Alex Chau Date: Thu, 3 Jun 2021 11:35:05 +0100 Subject: [PATCH] Make quick switch track finger 1:1 - When calculating motion delta, it should consider the scale of pagedView - Adjust significant threshold of tablet quick switch to 15% of page width (roughly 100dp) Fixes: 188786242 Test: manual on quick switch Change-Id: Idaa6c5b721decb573e97158c5fbcd67fa224f9d1 --- .../src/com/android/quickstep/views/RecentsView.java | 8 ++++++++ src/com/android/launcher3/PagedView.java | 12 +++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java index 7cd8d603ea..9c06a961f5 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -342,6 +342,8 @@ public abstract class RecentsView mSizeStrategy; protected RecentsAnimationController mRecentsAnimationController; @@ -974,6 +976,12 @@ public abstract class RecentsView extends ViewGrou mAllowOverScroll = enable; } + protected float getSignificantMoveThreshold() { + return SIGNIFICANT_MOVE_THRESHOLD; + } + @Override public boolean onTouchEvent(MotionEvent ev) { // Skip touch handling if there are no pages to swipe @@ -1218,6 +1222,7 @@ public abstract class PagedView extends ViewGrou } delta -= consumed; } + delta /= mOrientationHandler.getPrimaryScale(this); // Only scroll and update mLastMotionX if we have moved some discrete amount. We // keep the remainder because we are actually testing if we've moved from the last @@ -1270,11 +1275,12 @@ public abstract class PagedView extends ViewGrou int velocity = (int) mOrientationHandler.getPrimaryVelocity(velocityTracker, mActivePointerId); - int delta = (int) (primaryDirection - mDownMotionPrimary); + float delta = primaryDirection - mDownMotionPrimary; + delta /= mOrientationHandler.getPrimaryScale(this); int pageOrientedSize = mOrientationHandler.getMeasuredSize(getPageAt(mCurrentPage)); - boolean isSignificantMove = Math.abs(delta) > pageOrientedSize * - SIGNIFICANT_MOVE_THRESHOLD; + boolean isSignificantMove = Math.abs(delta) + > pageOrientedSize * getSignificantMoveThreshold(); mTotalMotion += Math.abs(mLastMotion + mLastMotionRemainder - primaryDirection); boolean passedSlop = mAllowEasyFling || mTotalMotion > mPageSlop;