From 3af714f052d183aa31f22eee3afeecb94ec552db Mon Sep 17 00:00:00 2001 From: Tony Wickham Date: Wed, 5 Aug 2020 13:32:37 -0700 Subject: [PATCH] Remove overscroll on running task when it's not attached to RecentsView This allows the running task to follow the finger freely until motion pause is detected (or when trying to quick switch in a direciton that has no tasks, as RecentsView is still attached until you swipe up). Bug: 149934536 Change-Id: If68166e962af9f28c56017838f720e15ddb96560 --- .../com/android/quickstep/BaseSwipeUpHandlerV2.java | 10 ++++++++++ .../src/com/android/quickstep/views/RecentsView.java | 9 ++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandlerV2.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandlerV2.java index 929b11ad66..ed33532e6d 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandlerV2.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandlerV2.java @@ -488,6 +488,16 @@ public abstract class BaseSwipeUpHandlerV2, Q exte recentsAttachedToAppWindow = mIsShelfPeeking || mIsLikelyToStartNewTask; } mAnimationFactory.setRecentsAttachedToAppWindow(recentsAttachedToAppWindow, animate); + + // Reapply window transform throughout the attach animation, as the animation affects how + // much the window is bound by overscroll (vs moving freely). + if (animate) { + ValueAnimator reapplyWindowTransformAnim = ValueAnimator.ofFloat(0, 1); + reapplyWindowTransformAnim.addUpdateListener(anim -> applyWindowTransform()); + reapplyWindowTransformAnim.setDuration(RECENTS_ATTACH_DURATION).start(); + } else { + applyWindowTransform(); + } } @Override diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java index 857a020698..26e6055174 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java @@ -2290,7 +2290,14 @@ public abstract class RecentsView extends PagedView if (pageIndex == -1) { return 0; } - return getScrollForPage(pageIndex) - mOrientationHandler.getPrimaryScroll(this); + // Unbound the scroll (due to overscroll) if the adjacent tasks are offset away from it. + // This allows the page to move freely, given there's no visual indication why it shouldn't. + int boundedScroll = mOrientationHandler.getPrimaryScroll(this); + int unboundedScroll = getUnboundedScroll(); + float unboundedProgress = mAdjacentPageOffset; + int scroll = Math.round(unboundedScroll * unboundedProgress + + boundedScroll * (1 - unboundedProgress)); + return getScrollForPage(pageIndex) - scroll; } public Consumer getEventDispatcher(float navbarRotation) {