diff options
| author | 2017-08-15 11:07:21 -0700 | |
|---|---|---|
| committer | 2017-08-15 11:30:19 -0700 | |
| commit | 7d071ae0dc29ad4ccd8a9df751a4c2aed627ede6 (patch) | |
| tree | de26ec270517199df6064cb1fdceccb8e1c1764b | |
| parent | ed0c5cf48f65712712e677a2918966384fb050d0 (diff) | |
Low ram devices recents list is throwable
On a low ram device, the recents list can be thrown when flinging. It
can skip more tasks in the list when flinged harder.
Change-Id: Ie21309f97178b79121d4edc42541f45b13cf5931
Fixes: 64584893
Bug: 62251652
Test: manual - use low end device to go recents with items and fling
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewScroller.java | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewScroller.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewScroller.java index 27cfdc133bc8..0b20b105617d 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewScroller.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewScroller.java @@ -89,6 +89,9 @@ public class TaskStackViewScroller { mContext = context; mCb = cb; mScroller = new OverScroller(context); + if (Recents.getConfiguration().isLowRamDevice) { + mScroller.setFriction(0.06f); + } mLayoutAlgorithm = layoutAlgorithm; mFlingAnimationUtils = new FlingAnimationUtils(context, 0.3f); } @@ -195,7 +198,6 @@ public class TaskStackViewScroller { return Float.compare(getScrollAmountOutOfBounds(mStackScrollP), 0f) != 0; } - /** * Scrolls the closest task and snaps into place. Only used in recents for low ram devices. * @param velocity of scroll @@ -208,19 +210,30 @@ public class TaskStackViewScroller { || stackScroll > mLayoutAlgorithm.mMaxScrollP) { return; } - TaskStackLowRamLayoutAlgorithm algorithm = mLayoutAlgorithm.mTaskStackLowRamLayoutAlgorithm; - float newScrollP = algorithm.getClosestTaskP(stackScroll, - mLayoutAlgorithm.mNumStackTasks, velocity); - float flingThreshold = ViewConfiguration.get(mContext).getScaledMinimumFlingVelocity(); + float flingThreshold = ViewConfiguration.get(mContext).getScaledMinimumFlingVelocity(); if (Math.abs(velocity) > flingThreshold) { + int minY = algorithm.percentageToScroll(mLayoutAlgorithm.mMinScrollP); + int maxY = algorithm.percentageToScroll(mLayoutAlgorithm.mMaxScrollP); + + // Calculate the fling and snap to closest task from final y position, computeScroll() + // never runs when cancelled with animateScroll() and the overscroll is not calculated + // here + fling(0 /* downScrollP */, 0 /* downY */, algorithm.percentageToScroll(stackScroll), + -velocity, minY, maxY, 0 /* overscroll */); + float pos = algorithm.scrollToPercentage(mScroller.getFinalY()); + + float newScrollP = algorithm.getClosestTaskP(pos, mLayoutAlgorithm.mNumStackTasks, + velocity); ValueAnimator animator = ObjectAnimator.ofFloat(stackScroll, newScrollP); mFlingAnimationUtils.apply(animator, algorithm.percentageToScroll(stackScroll), algorithm.percentageToScroll(newScrollP), velocity); animateScroll(newScrollP, (int) animator.getDuration(), animator.getInterpolator(), null /* postRunnable */); } else { + float newScrollP = algorithm.getClosestTaskP(stackScroll, + mLayoutAlgorithm.mNumStackTasks, velocity); animateScroll(newScrollP, 300, Interpolators.ACCELERATE_DECELERATE, null /* postRunnable */); } |