Add haptic feedback to Launcher recent apps scrolling

Add light LOW_TICK effects when the scrolling on RecentsView
snaps to a page, and a stronger TICK effect when the edges
absorb the scroll (by scrolling fast towards one of the edges).

Fix: 182382085
Test: manual
Change-Id: Ifb917ae499f73607707773f9870eb39cd6fe16ef
This commit is contained in:
Lais Andrade
2021-05-21 13:50:46 +01:00
parent 9f194ee290
commit b1ef5e5c55
3 changed files with 60 additions and 0 deletions

View File

@@ -479,9 +479,11 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou
if (newPos < mMinScroll && oldPos >= mMinScroll) {
mEdgeGlowLeft.onAbsorb((int) mScroller.getCurrVelocity());
mScroller.abortAnimation();
onEdgeAbsorbingScroll();
} else if (newPos > mMaxScroll && oldPos <= mMaxScroll) {
mEdgeGlowRight.onAbsorb((int) mScroller.getCurrVelocity());
mScroller.abortAnimation();
onEdgeAbsorbingScroll();
}
}
@@ -1332,6 +1334,13 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou
protected void onNotSnappingToPageInFreeScroll() { }
/**
* Called when the view edges absorb part of the scroll. Subclasses can override this
* to provide custom behavior during animation.
*/
protected void onEdgeAbsorbingScroll() {
}
protected boolean shouldFlingForVelocity(int velocity) {
float threshold = mAllowEasyFling ? mEasyFlingThresholdVelocity : mFlingThresholdVelocity;
return Math.abs(velocity) > threshold;