From 031373daa39c54582872da49a15b017ee8034099 Mon Sep 17 00:00:00 2001 From: Alex Chau Date: Tue, 15 Jun 2021 16:29:19 +0100 Subject: [PATCH] Reland "Snap to relative position to snappd task when dismissing" This reland commit ba61b98fca3a95f02b8802c4508fca5aa6903213 accidentally reverted by http://ag/15162411 Bug: 188793333 Test: manual Change-Id: Iae07a67d528aa80e8f87d37758244d0c46b61cf7 --- .../com/android/quickstep/views/RecentsView.java | 14 ++++++++------ src/com/android/launcher3/PagedView.java | 7 ++++++- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java index 6146b2d4cb..25b98d7b51 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -2504,12 +2504,15 @@ public abstract class RecentsView extends ViewGrou @ViewDebug.ExportedProperty(category = "launcher") protected int mCurrentPage; + // Difference between current scroll position and mCurrentPage's page scroll. Used to maintain + // relative scroll position unchanged in updateCurrentPageScroll. Cleared when snapping to a + // page. + protected int mCurrentPageScrollDiff; @ViewDebug.ExportedProperty(category = "launcher") protected int mNextPage = INVALID_PAGE; @@ -247,7 +251,7 @@ public abstract class PagedView extends ViewGrou // If the current page is invalid, just reset the scroll position to zero int newPosition = 0; if (0 <= mCurrentPage && mCurrentPage < getPageCount()) { - newPosition = getScrollForPage(mCurrentPage); + newPosition = getScrollForPage(mCurrentPage) + mCurrentPageScrollDiff; } mOrientationHandler.set(this, VIEW_SCROLL_TO, newPosition); mScroller.startScroll(mScroller.getCurrX(), 0, newPosition - mScroller.getCurrX(), 0); @@ -452,6 +456,7 @@ public abstract class PagedView extends ViewGrou * to provide custom behavior during animation. */ protected void onPageEndTransition() { + mCurrentPageScrollDiff = 0; AccessibilityManagerCompat.sendScrollFinishedEventToTest(getContext()); AccessibilityManagerCompat.sendCustomAccessibilityEvent(getPageAt(mCurrentPage), AccessibilityEvent.TYPE_VIEW_FOCUSED, null);