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
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user