Allow user gesture to take priority over taskbar translation reset animnatiuon.
Bug: 273948325
Test: open overview
tap to open main app
quickly swipe up to show taskbar
Change-Id: I0bbb3a354baf9b56652f029a357d8a5803281da5
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java
index b98ea81..7e016a8 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java
@@ -564,7 +564,7 @@
long resetDuration = mControllers.taskbarStashController.isInApp()
? duration
: duration / 2;
- if (!mControllers.taskbarTranslationController.willAnimateToZeroBefore(resetDuration)
+ if (mControllers.taskbarTranslationController.shouldResetBackToZero(resetDuration)
&& (isAnimatingToLauncher() || mLauncherState == LauncherState.NORMAL)) {
animatorSet.play(mControllers.taskbarTranslationController
.createAnimToResetTranslation(resetDuration));
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarTranslationController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarTranslationController.java
index 065d111..4b18bb6 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarTranslationController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarTranslationController.java
@@ -54,6 +54,7 @@
private boolean mHasSprungOnceThisGesture;
private @Nullable ValueAnimator mSpringBounce;
private boolean mGestureEnded;
+ private boolean mGestureInProgress;
private boolean mAnimationToHomeRunning;
private final boolean mIsTransientTaskbar;
@@ -123,6 +124,7 @@
private void reset() {
mGestureEnded = false;
+ mGestureInProgress = false;
mHasSprungOnceThisGesture = false;
}
@@ -134,18 +136,24 @@
}
/**
- * Returns true if we will animate to zero before the input duration.
+ * Returns {@code true} if we should reset the animation back to zero.
+ *
+ * Returns {@code false} if there is a gesture in progress, or if we are already animating
+ * to 0 within the specified duration.
*/
- public boolean willAnimateToZeroBefore(long duration) {
+ public boolean shouldResetBackToZero(long duration) {
+ if (mGestureInProgress) {
+ return false;
+ }
if (mSpringBounce != null && mSpringBounce.isRunning()) {
long springDuration = mSpringBounce.getDuration();
long current = mSpringBounce.getCurrentPlayTime();
- return (springDuration - current < duration);
+ return (springDuration - current >= duration);
}
if (mTranslationYForSwipe.isAnimatingToValue(0)) {
- return mTranslationYForSwipe.getRemainingTime() < duration;
+ return mTranslationYForSwipe.getRemainingTime() >= duration;
}
- return false;
+ return true;
}
/**
@@ -188,6 +196,7 @@
mAnimationToHomeRunning = false;
cancelSpringIfExists();
reset();
+ mGestureInProgress = true;
}
/**
* Called when there is movement to move the taskbar.
@@ -211,6 +220,7 @@
mGestureEnded = true;
startSpring();
}
+ mGestureInProgress = false;
}
}
@@ -222,6 +232,7 @@
pw.println(prefix + "\tmHasSprungOnceThisGesture=" + mHasSprungOnceThisGesture);
pw.println(prefix + "\tmAnimationToHomeRunning=" + mAnimationToHomeRunning);
pw.println(prefix + "\tmGestureEnded=" + mGestureEnded);
+ pw.println(prefix + "\tmGestureInProgress=" + mGestureInProgress);
pw.println(prefix + "\tmSpringBounce is running=" + (mSpringBounce != null
&& mSpringBounce.isRunning()));
}