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
This commit is contained in:
Alex Chau committed 2021-06-03 18:07:52 +01:00
1 parent 3256647b03
commit 822acf4d25
2 files changed
+17 -3

No files matched your search

+9 -3
View File
@@ -1147,6 +1147,10 @@ public abstract class PagedView<T extends View & PageIndicator> 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<T extends View & PageIndicator> 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<T extends View & PageIndicator> 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;