Override displacement for transient taskbar instead of mCurrentShift
mCurrentShift is based on displacement, but is used and set in different
places. To keep consistency throughout, we should override the
displacement at the source instead.
Test: manually swiped up between home/overview threshold and catch up
threshold; let go to go to overview and ensure no jump occurs.
Flag: teamfood (ENABLE_TRANSIENT_TASKBAR)
Fixes: 259981285
Change-Id: Id9f5b2bcdc2e56e15ddb6d93c4ee5d5ececc094d
diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
index 4b35859..1bc00be 100644
--- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
+++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
@@ -831,7 +831,7 @@
return;
}
mLauncherTransitionController.setProgress(
- Math.max(getTaskbarProgress(), getScaleProgressDueToScroll()), mDragLengthFactor);
+ Math.max(mCurrentShift.value, getScaleProgressDueToScroll()), mDragLengthFactor);
}
/**
@@ -2212,7 +2212,7 @@
AnimatorControllerWithResistance playbackController =
remoteHandle.getPlaybackController();
if (playbackController != null) {
- playbackController.setProgress(Math.max(getTaskbarProgress(),
+ playbackController.setProgress(Math.max(mCurrentShift.value,
getScaleProgressDueToScroll()), mDragLengthFactor);
}
@@ -2264,31 +2264,32 @@
}
/**
- * Overrides the current shift progress to keep the app window at the bottom of the screen
- * while the transient taskbar is being swiped in.
+ * Overrides the gesture displacement to keep the app window at the bottom of the screen while
+ * the transient taskbar is being swiped in.
*
* There is also a catch up period so that the window can start moving 1:1 with the swipe.
*/
- private float getTaskbarProgress() {
+ @Override
+ protected float overrideDisplacementForTransientTaskbar(float displacement) {
if (!mIsTransientTaskbar) {
- return mCurrentShift.value;
+ return displacement;
}
if (mTaskbarAlreadyOpen) {
- return mCurrentShift.value;
+ return displacement;
}
- if (mCurrentDisplacement < mTaskbarAppWindowThreshold) {
+ if (displacement < mTaskbarAppWindowThreshold) {
return 0;
}
- // "Catch up" with `mCurrentShift.value`.
- if (mCurrentDisplacement < mTaskbarCatchUpThreshold) {
- return Utilities.mapToRange(mCurrentDisplacement, mTaskbarAppWindowThreshold,
- mTaskbarCatchUpThreshold, 0, mCurrentShift.value, ACCEL_DEACCEL);
+ // "Catch up" with the displacement at mTaskbarCatchUpThreshold.
+ if (displacement < mTaskbarCatchUpThreshold) {
+ return Utilities.mapToRange(displacement, mTaskbarAppWindowThreshold,
+ mTaskbarCatchUpThreshold, 0, mTaskbarCatchUpThreshold, ACCEL_DEACCEL);
}
- return mCurrentShift.value;
+ return displacement;
}
private void setDividerShown(boolean shown, boolean immediate) {
diff --git a/quickstep/src/com/android/quickstep/SwipeUpAnimationLogic.java b/quickstep/src/com/android/quickstep/SwipeUpAnimationLogic.java
index ddb06ce..fdde45a 100644
--- a/quickstep/src/com/android/quickstep/SwipeUpAnimationLogic.java
+++ b/quickstep/src/com/android/quickstep/SwipeUpAnimationLogic.java
@@ -116,7 +116,7 @@
@UiThread
public void updateDisplacement(float displacement) {
// We are moving in the negative x/y direction
- displacement = -displacement;
+ displacement = overrideDisplacementForTransientTaskbar(-displacement);
mCurrentDisplacement = displacement;
float shift;
@@ -131,6 +131,17 @@
}
/**
+ * When Transient Taskbar is enabled, subclasses can override the displacement to keep the app
+ * window at the bottom of the screen while taskbar is being swiped in.
+ * @param displacement The distance the user has swiped up from the bottom of the screen. This
+ * value will be positive unless the user swipe downwards.
+ * @return the overridden displacement.
+ */
+ protected float overrideDisplacementForTransientTaskbar(float displacement) {
+ return displacement;
+ }
+
+ /**
* Called when the value of {@link #mCurrentShift} changes
*/
@UiThread