From 6b4b65f42b5a937330c825be27b32b751d88f1d8 Mon Sep 17 00:00:00 2001 From: Brian Isganitis Date: Thu, 10 Apr 2025 15:45:12 -0400 Subject: [PATCH] Defer updating alignment when LayoutTransition is running. This fixes a problem of 3-button variant of pinned taskbar. The code for updating the alignment (taskbar to hotseat) animation clashes with LayoutTransition, leading to weird icon states. This change coordinates these two animation systems. Fix: 409442851 Test: ABTD cherrypick to Q2 release candidate (manual) Flag: com.android.window.flags.enable_taskbar_recents_layout_transition Change-Id: Ifa80c384500a9cd3e65090ee39487977a2ac3b5d --- .../taskbar/TaskbarViewCallbacks.java | 2 +- .../taskbar/TaskbarViewController.java | 38 +++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewCallbacks.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewCallbacks.java index d0886e0ca1..ad5770d8c9 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewCallbacks.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewCallbacks.java @@ -132,7 +132,7 @@ public class TaskbarViewCallbacks { * Notifies launcher to update icon alignment. */ public void notifyIconLayoutBoundsChanged() { - mControllers.uiController.onIconLayoutBoundsChanged(); + mControllers.taskbarViewController.notifyIconLayoutBoundsChanged(); } /** diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java index 40718f16dd..c7d8a50383 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java @@ -162,6 +162,9 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar private final AnimatedFloat mTranslationXForBubbleBar = new AnimatedFloat( this::updateTranslationXForBubbleBar); + private final TransitionEndBoundsChangedNotifier mTransitionEndBoundsChangedNotifier = + new TransitionEndBoundsChangedNotifier(); + @Nullable private Animator mTaskbarShiftXAnim; @Nullable @@ -887,6 +890,16 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar as.play(reveal); } + void notifyIconLayoutBoundsChanged() { + final LayoutTransition layoutTransition = mTaskbarView.getLayoutTransition(); + if (layoutTransition != null && layoutTransition.isRunning()) { + // Defers notify until after transitions finish. + mTransitionEndBoundsChangedNotifier.mIsCanceled = false; + } else { + mControllers.uiController.onIconLayoutBoundsChanged(); + } + } + /** * Sets the Taskbar icon alignment relative to Launcher hotseat icons * @param alignmentRatio [0, 1] @@ -910,6 +923,12 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar mIsHotseatIconOnTopWhenAligned = isHotseatIconOnTopWhenAligned; mIsIconAlignedWithHotseat = isIconAlignedWithHotseat; mIsStashed = isStashed; + + final LayoutTransition layoutTransition = mTaskbarView.getLayoutTransition(); + if (layoutTransition != null && layoutTransition.isRunning()) { + mTransitionEndBoundsChangedNotifier.mIsCanceled = true; + layoutTransition.cancel(); + } mIconAlignControllerLazy = createIconAlignmentController(launcherDp); } mIconAlignControllerLazy.setPlayFraction(alignmentRatio); @@ -1261,6 +1280,7 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar // Do nothing. } }); + layoutTransition.addTransitionListener(mTransitionEndBoundsChangedNotifier); // Appearing. AnimatorSet appearingSet = new AnimatorSet(); @@ -1363,4 +1383,22 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar animator.setInterpolator(EMPHASIZED); return animator; } + + private class TransitionEndBoundsChangedNotifier implements TransitionListener { + private boolean mIsCanceled; + + @Override + public void startTransition( + LayoutTransition transition, ViewGroup container, View view, int type) { + // Do nothing. + } + + @Override + public void endTransition( + LayoutTransition transition, ViewGroup container, View view, int type) { + if (!transition.isRunning() && !mIsCanceled) { + mControllers.uiController.onIconLayoutBoundsChanged(); + } + } + } }