From 6827e13a2d71b3c6c14bbf3a70f0ceccd0c5129f Mon Sep 17 00:00:00 2001 From: Mady Mellor Date: Thu, 14 Apr 2022 23:49:07 +0000 Subject: [PATCH] Skip onTaskMovedToFront if the bubble selection is animating When a bubble gets dismissed while the stack is expanded, we should select the next available bubble. Instead, we are collapsing. This is because we get an onTaskMovedToFront event for the app behind bubbles moving to the front, which causes the stack to collapse. To fix this I add a check to see if the switch animation is running, and if so we skip the collapse in onTaskMovedToFront. Bug: 208648025 Test: manual - have multiple bubbles, expand the stack, visit each bubble - dismiss each bubble by dragging to dismiss target => observe that after dismissing each bubble, the next bubble is selected (if available) Change-Id: If82c004ecd1ec8920e934dbae2107b4c37853cb5 --- .../android/wm/shell/bubbles/BubbleController.java | 4 +++- .../com/android/wm/shell/bubbles/BubbleStackView.java | 11 +++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java index b6fb82852c2f8..5ef24133ca113 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java @@ -385,7 +385,9 @@ public class BubbleController { mMainExecutor.execute(() -> { int expandedId = INVALID_TASK_ID; if (mStackView != null && mStackView.getExpandedBubble() != null - && isStackExpanded() && !mStackView.isExpansionAnimating()) { + && isStackExpanded() + && !mStackView.isExpansionAnimating() + && !mStackView.isSwitchAnimating()) { expandedId = mStackView.getExpandedBubble().getTaskId(); } if (expandedId != INVALID_TASK_ID && expandedId != taskId) { diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java index 322c0bf808162..fdf3d684951b1 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java @@ -1607,6 +1607,13 @@ public class BubbleStackView extends FrameLayout return mIsExpansionAnimating; } + /** + * Whether the stack of bubbles is animating a switch between bubbles. + */ + public boolean isSwitchAnimating() { + return mIsBubbleSwitchAnimating; + } + /** * The {@link Bubble} that is expanded, null if one does not exist. */ @@ -2467,6 +2474,10 @@ public class BubbleStackView extends FrameLayout private void dismissBubbleIfExists(@Nullable BubbleViewProvider bubble) { if (bubble != null && mBubbleData.hasBubbleInStackWithKey(bubble.getKey())) { + if (mIsExpanded && mBubbleData.getBubbles().size() > 1) { + // If we have more than 1 bubble we will perform the switch animation + mIsBubbleSwitchAnimating = true; + } mBubbleData.dismissBubbleWithKey(bubble.getKey(), Bubbles.DISMISS_USER_GESTURE); } }