Fix running task damped by overscroll when other tasks are offscreen
Test: Swipe up and to the left from an app, ensure the running task
scrolls freely until the adjacent task comes in from offscreen
Bug: 185411781
Change-Id: I9749124a6b6f014b55e3430d1764766a232eb9dd
diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java
index d2d3bc3..23f7200 100644
--- a/quickstep/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/RecentsView.java
@@ -644,28 +644,9 @@
// Draw overscroll
if (mAllowOverScroll && (!mEdgeGlowRight.isFinished() || !mEdgeGlowLeft.isFinished())) {
final int restoreCount = canvas.save();
- final int width = getWidth();
- final int height = getHeight();
- int primarySize = mOrientationHandler.getPrimaryValue(width, height);
- int secondarySize = mOrientationHandler.getSecondaryValue(width, height);
- float effectiveShift = 0;
- if (!mEdgeGlowLeft.isFinished()) {
- mEdgeGlowLeft.setSize(secondarySize, primarySize);
- if (((TranslateEdgeEffect) mEdgeGlowLeft).getTranslationShift(mTempFloat)) {
- effectiveShift = mTempFloat[0];
- postInvalidateOnAnimation();
- }
- }
- if (!mEdgeGlowRight.isFinished()) {
- mEdgeGlowRight.setSize(secondarySize, primarySize);
- if (((TranslateEdgeEffect) mEdgeGlowRight).getTranslationShift(mTempFloat)) {
- effectiveShift -= mTempFloat[0];
- postInvalidateOnAnimation();
- }
- }
-
- int scroll = OverScroll.dampedScroll(effectiveShift * primarySize, primarySize);
+ int primarySize = mOrientationHandler.getPrimaryValue(getWidth(), getHeight());
+ int scroll = OverScroll.dampedScroll(getUndampedOverScrollShift(), primarySize);
mOrientationHandler.set(canvas, CANVAS_TRANSLATE, scroll);
if (mOverScrollShift != scroll) {
@@ -687,6 +668,31 @@
}
}
+ private float getUndampedOverScrollShift() {
+ final int width = getWidth();
+ final int height = getHeight();
+ int primarySize = mOrientationHandler.getPrimaryValue(width, height);
+ int secondarySize = mOrientationHandler.getSecondaryValue(width, height);
+
+ float effectiveShift = 0;
+ if (!mEdgeGlowLeft.isFinished()) {
+ mEdgeGlowLeft.setSize(secondarySize, primarySize);
+ if (((TranslateEdgeEffect) mEdgeGlowLeft).getTranslationShift(mTempFloat)) {
+ effectiveShift = mTempFloat[0];
+ postInvalidateOnAnimation();
+ }
+ }
+ if (!mEdgeGlowRight.isFinished()) {
+ mEdgeGlowRight.setSize(secondarySize, primarySize);
+ if (((TranslateEdgeEffect) mEdgeGlowRight).getTranslationShift(mTempFloat)) {
+ effectiveShift -= mTempFloat[0];
+ postInvalidateOnAnimation();
+ }
+ }
+
+ return effectiveShift * primarySize;
+ }
+
/**
* Returns the view shift due to overscroll
*/
@@ -3512,8 +3518,16 @@
if (pageIndex == -1) {
return 0;
}
+
+ int overScrollShift = getOverScrollShift();
+ if (mAdjacentPageVerticalOffset > 0) {
+ // Don't dampen the scroll (due to overscroll) if the adjacent tasks are offscreen, so
+ // that the page can move freely given there's no visual indication why it shouldn't.
+ overScrollShift = (int) Utilities.mapRange(mAdjacentPageVerticalOffset, overScrollShift,
+ getUndampedOverScrollShift());
+ }
return getScrollForPage(pageIndex) - mOrientationHandler.getPrimaryScroll(this)
- + getOverScrollShift();
+ + overScrollShift;
}
/**