From c3bb65a045dd30f906ff4f140e692e4e742daa3d Mon Sep 17 00:00:00 2001 From: Jon Miranda Date: Tue, 21 Mar 2023 12:05:47 -0700 Subject: [PATCH] Fix bug where taskbar jumps when double swiping up. Bug: 273948325 Change-Id: Ib3f19f4bf7348cd3545864351d48780dbc9acd65 Flag: ENABLE_TRANSIENT_TASKBAR Test: swipe up to unstash taskbar, quickly swipe up again --- .../taskbar/TaskbarTranslationController.java | 20 +++++++++++++++---- .../TaskbarStashInputConsumer.java | 4 ++++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarTranslationController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarTranslationController.java index 062b4ce52a..b9b63dbac6 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarTranslationController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarTranslationController.java @@ -76,12 +76,11 @@ public class TaskbarTranslationController implements TaskbarControllers.Loggable /** * Called to cancel any existing animations. */ - public void cancelAnimationIfExists() { + public void cancelSpringIfExists() { if (mSpringBounce != null) { mSpringBounce.cancel(); mSpringBounce = null; } - reset(); } private void updateTranslationYForSwipe() { @@ -138,13 +137,14 @@ public class TaskbarTranslationController implements TaskbarControllers.Loggable * Returns an animation to reset the taskbar translation to {@code 0}. */ public ObjectAnimator createAnimToResetTranslation(long duration) { - ObjectAnimator animator = ObjectAnimator.ofFloat(mTranslationYForSwipe, VALUE, 0); + ObjectAnimator animator = mTranslationYForSwipe.animateToValue(0); animator.setInterpolator(Interpolators.LINEAR); animator.setDuration(duration); animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { - cancelAnimationIfExists(); + cancelSpringIfExists(); + reset(); mAnimationToHomeRunning = true; } @@ -162,6 +162,18 @@ public class TaskbarTranslationController implements TaskbarControllers.Loggable */ public class TransitionCallback { + /** + * Clears any existing animations so that user + * can take control over the movement of the taskbaer. + */ + public void onActionDown() { + if (mAnimationToHomeRunning) { + mTranslationYForSwipe.cancelAnimation(); + } + mAnimationToHomeRunning = false; + cancelSpringIfExists(); + reset(); + } /** * Called when there is movement to move the taskbar. */ diff --git a/quickstep/src/com/android/quickstep/inputconsumers/TaskbarStashInputConsumer.java b/quickstep/src/com/android/quickstep/inputconsumers/TaskbarStashInputConsumer.java index 1ddb855ef2..a01d634b7c 100644 --- a/quickstep/src/com/android/quickstep/inputconsumers/TaskbarStashInputConsumer.java +++ b/quickstep/src/com/android/quickstep/inputconsumers/TaskbarStashInputConsumer.java @@ -126,6 +126,10 @@ public class TaskbarStashInputConsumer extends DelegateInputConsumer { mCanceledUnstashHint = false; } } + + if (mTransitionCallback != null && !mIsTaskbarAllAppsOpen) { + mTransitionCallback.onActionDown(); + } break; case MotionEvent.ACTION_POINTER_UP: int ptrIdx = ev.getActionIndex();