From 774dcd06aea583f6f461ee3a68e65c90dc1087ee Mon Sep 17 00:00:00 2001 From: Sunny Goyal Date: Wed, 26 Oct 2022 10:29:46 -0700 Subject: [PATCH] Relying on the controller state instead of animator state for icon alignment Bug: 246644619 Test: Presubmit Change-Id: Iaa4ddd94a6d85acb9f8501263665ea78394815de --- .../taskbar/LauncherTaskbarUIController.java | 5 +++ .../TaskbarLauncherStateController.java | 33 +++++++++++-------- .../taskbar/TaskbarUIController.java | 7 ++++ .../taskbar/TaskbarViewController.java | 10 +++--- .../com/android/quickstep/AnimatedFloat.java | 20 ----------- 5 files changed, 35 insertions(+), 40 deletions(-) diff --git a/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java b/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java index c9e42b7bac..317f6a4884 100644 --- a/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java +++ b/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java @@ -355,6 +355,11 @@ public class LauncherTaskbarUIController extends TaskbarUIController { mTaskbarLauncherStateController.applyState(); } + @Override + public boolean isIconAlignedWithHotseat() { + return mTaskbarLauncherStateController.isIconAlignedWithHotseat(); + } + @Override public void dumpLogs(String prefix, PrintWriter pw) { super.dumpLogs(prefix, pw); diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java index bc5bcf5b28..723e21400e 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java @@ -38,9 +38,8 @@ import com.android.launcher3.Utilities; import com.android.launcher3.anim.AnimatorListeners; import com.android.launcher3.statemanager.StateManager; import com.android.launcher3.uioverrides.QuickstepLauncher; -import com.android.launcher3.util.MultiPropertyFactory.MultiProperty; import com.android.launcher3.uioverrides.states.OverviewState; -import com.android.launcher3.util.MultiValueAlpha; +import com.android.launcher3.util.MultiPropertyFactory.MultiProperty; import com.android.quickstep.AnimatedFloat; import com.android.quickstep.RecentsAnimationCallbacks; import com.android.quickstep.RecentsAnimationController; @@ -251,17 +250,7 @@ import java.util.StringJoiner; private Animator onStateChangeApplied(int changedFlags, long duration, boolean start) { boolean goingToLauncher = isInLauncher(); - final float toAlignment; - if (goingToLauncher) { - boolean isInStashedState = mLauncherState.isTaskbarStashed(mLauncher); - boolean willStashVisually = isInStashedState - && mControllers.taskbarStashController.supportsVisualStashing(); - boolean isTaskbarAlignedWithHotseat = - mLauncherState.isTaskbarAlignedWithHotseat(mLauncher); - toAlignment = isTaskbarAlignedWithHotseat && !willStashVisually ? 1 : 0; - } else { - toAlignment = 0; - } + final float toAlignment = isIconAlignedWithHotseat() ? 1 : 0; if (DEBUG) { Log.d(TAG, "onStateChangeApplied - mState: " + getStateString(mState) + ", changedFlags: " + getStateString(changedFlags) @@ -357,6 +346,22 @@ import java.util.StringJoiner; return mLauncherState.isTaskbarAlignedWithHotseat(mLauncher); } + /** + * Returns if icons should be aligned to hotseat in the current transition + */ + public boolean isIconAlignedWithHotseat() { + if (isInLauncher()) { + boolean isInStashedState = mLauncherState.isTaskbarStashed(mLauncher); + boolean willStashVisually = isInStashedState + && mControllers.taskbarStashController.supportsVisualStashing(); + boolean isTaskbarAlignedWithHotseat = + mLauncherState.isTaskbarAlignedWithHotseat(mLauncher); + return isTaskbarAlignedWithHotseat && !willStashVisually; + } else { + return false; + } + } + private void playStateTransitionAnim(AnimatorSet animatorSet, long duration, boolean committed) { boolean isInStashedState = mLauncherState.isTaskbarStashed(mLauncher); @@ -395,7 +400,7 @@ import java.util.StringJoiner; || (!taskbarWillBeVisible && Float.compare(currentValue, 0) != 0); mControllers.taskbarViewController.setLauncherIconAlignment( - mIconAlignment.value, mIconAlignment.getEndValue(), mLauncher.getDeviceProfile()); + mIconAlignment.value, mLauncher.getDeviceProfile()); mControllers.navbarButtonsViewController.updateTaskbarAlignment(mIconAlignment.value); // Switch taskbar and hotseat in last frame updateIconAlphaForHome(taskbarWillBeVisible ? 1 : 0); diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java index 2294306ac3..11521260e9 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java @@ -114,6 +114,13 @@ public class TaskbarUIController { || mControllers.navbarButtonsViewController.isEventOverAnyItem(ev); } + /** + * Returns true if icons should be aligned to hotseat in the current transition. + */ + public boolean isIconAlignedWithHotseat() { + return false; + } + @CallSuper protected void dumpLogs(String prefix, PrintWriter pw) { pw.println(String.format( diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java index ee87185f95..a73528b5ef 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java @@ -280,10 +280,9 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar * 0 => not aligned * 1 => fully aligned */ - public void setLauncherIconAlignment(float alignmentRatio, Float endAlignment, - DeviceProfile launcherDp) { + public void setLauncherIconAlignment(float alignmentRatio, DeviceProfile launcherDp) { if (mIconAlignControllerLazy == null) { - mIconAlignControllerLazy = createIconAlignmentController(launcherDp, endAlignment); + mIconAlignControllerLazy = createIconAlignmentController(launcherDp); } mIconAlignControllerLazy.setPlayFraction(alignmentRatio); if (alignmentRatio <= 0 || alignmentRatio >= 1) { @@ -295,8 +294,7 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar /** * Creates an animation for aligning the taskbar icons with the provided Launcher device profile */ - private AnimatorPlaybackController createIconAlignmentController(DeviceProfile launcherDp, - Float endAlignment) { + private AnimatorPlaybackController createIconAlignmentController(DeviceProfile launcherDp) { mOnControllerPreCreateCallback.run(); PendingAnimation setter = new PendingAnimation(100); DeviceProfile taskbarDp = mActivity.getDeviceProfile(); @@ -322,7 +320,7 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar setter.addOnFrameListener(anim -> mActivity.setTaskbarWindowHeight( anim.getAnimatedFraction() > 0 ? expandedHeight : collapsedHeight)); - boolean isToHome = endAlignment != null && endAlignment == 1; + boolean isToHome = mControllers.uiController.isIconAlignedWithHotseat(); for (int i = 0; i < mTaskbarView.getChildCount(); i++) { View child = mTaskbarView.getChildAt(i); int positionInHotseat; diff --git a/quickstep/src/com/android/quickstep/AnimatedFloat.java b/quickstep/src/com/android/quickstep/AnimatedFloat.java index b06b894c6e..5ab3c58e4d 100644 --- a/quickstep/src/com/android/quickstep/AnimatedFloat.java +++ b/quickstep/src/com/android/quickstep/AnimatedFloat.java @@ -98,15 +98,6 @@ public class AnimatedFloat { } } - /** - * Starts the animation. - */ - public void startAnimation() { - if (mValueAnimator != null) { - mValueAnimator.start(); - } - } - public void cancelAnimation() { if (mValueAnimator != null) { mValueAnimator.cancel(); @@ -119,10 +110,6 @@ public class AnimatedFloat { } } - public ObjectAnimator getCurrentAnimation() { - return mValueAnimator; - } - public boolean isAnimating() { return mValueAnimator != null; } @@ -140,11 +127,4 @@ public class AnimatedFloat { public boolean isSettledOnValue(float endValue) { return !isAnimating() && value == endValue; } - - /** - * Returns the value we are animating to, or {@code null} if we are not currently animating. - */ - public Float getEndValue() { - return mEndValue; - } }