From dd6674033da00888b21b8239a739aeb36e0e04d6 Mon Sep 17 00:00:00 2001 From: Mady Mellor Date: Wed, 2 Jun 2021 17:30:16 -0700 Subject: [PATCH 1/2] Fix the dot not showing when it should * Sometimes the dot doesn't show when it should, this was happening because the mAfterFlyoutHidden might not be set for updates to the flyout Test: manual 1) add a new bubble, before the flyout for it has animated away, add a second bubble, before 2nd bubble's flyout as animated away, add another update to it 2) wait for the flyout to animate away, ensure the update dot is visible Bug: 185438888 Change-Id: I7e21ee87cb2ad02871330178668bc07962485e2d --- .../src/com/android/wm/shell/bubbles/BubbleFlyoutView.java | 3 ++- .../src/com/android/wm/shell/bubbles/BubbleStackView.java | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleFlyoutView.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleFlyoutView.java index 2fc696cda7580..35a4f33ecf723 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleFlyoutView.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleFlyoutView.java @@ -231,7 +231,8 @@ public class BubbleFlyoutView extends FrameLayout { * Fade animation for consecutive flyouts. */ void animateUpdate(Bubble.FlyoutMessage flyoutMessage, float parentWidth, PointF stackPos, - boolean hideDot) { + boolean hideDot, Runnable onHide) { + mOnHide = onHide; final Runnable afterFadeOut = () -> { updateFlyoutMessage(flyoutMessage, parentWidth); // Wait for TextViews to layout with updated height. 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 7e48a7e139200..7b92713268e7d 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 @@ -2401,7 +2401,8 @@ public class BubbleStackView extends FrameLayout if (mFlyout.getVisibility() == View.VISIBLE) { mFlyout.animateUpdate(bubble.getFlyoutMessage(), getWidth(), - mStackAnimationController.getStackPosition(), !bubble.showDot()); + mStackAnimationController.getStackPosition(), !bubble.showDot(), + mAfterFlyoutHidden /* onHide */); } else { mFlyout.setVisibility(INVISIBLE); mFlyout.setupFlyoutStartingAsDot(bubble.getFlyoutMessage(), @@ -2409,7 +2410,7 @@ public class BubbleStackView extends FrameLayout mStackAnimationController.isStackOnLeftSide(), bubble.getIconView().getDotColor() /* dotColor */, expandFlyoutAfterDelay /* onLayoutComplete */, - mAfterFlyoutHidden, + mAfterFlyoutHidden /* onHide */, bubble.getIconView().getDotCenter(), !bubble.showDot(), mPositioner); From 305cfd268357ca4eb1b1c36e9f6f71aed9fca61a Mon Sep 17 00:00:00 2001 From: Mady Mellor Date: Thu, 3 Jun 2021 12:26:08 -0700 Subject: [PATCH 2/2] Fix dot & badge being on correct side for the first bubble added * stackAnimationController#isStackOnLeftSide depends on the position being set which happens when a view gets added so we should add the view & then set mStackOnLeftOrWillBe * removed unused code Test: manual 1) have no bubbles 2) add a bubble (needs to be on left side -- this is the default unless you've placed the stack on right side beforehand) => observe that the update dot & badge are on the right hand side of the bubble Bug: 185438888 Change-Id: I6129aff7c352fad8d29a6c243549f0d3580d62c8 --- .../android/wm/shell/bubbles/BubbleStackView.java | 14 +++++++------- .../animation/StackAnimationController.java | 3 --- 2 files changed, 7 insertions(+), 10 deletions(-) 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 7b92713268e7d..e5ffe91aebbe5 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 @@ -1497,22 +1497,22 @@ public class BubbleStackView extends FrameLayout mStackAnimationController.setStackPosition(mPositioner.getDefaultStartPosition()); } - if (getBubbleCount() == 0) { - mStackOnLeftOrWillBe = mStackAnimationController.isStackOnLeftSide(); - } - if (bubble.getIconView() == null) { return; } + mBubbleContainer.addView(bubble.getIconView(), 0, + new FrameLayout.LayoutParams(mPositioner.getBubbleSize(), + mPositioner.getBubbleSize())); + + if (getBubbleCount() == 0) { + mStackOnLeftOrWillBe = mStackAnimationController.isStackOnLeftSide(); + } // Set the dot position to the opposite of the side the stack is resting on, since the stack // resting slightly off-screen would result in the dot also being off-screen. bubble.getIconView().setDotBadgeOnLeft(!mStackOnLeftOrWillBe /* onLeft */); bubble.getIconView().setOnClickListener(mBubbleClickListener); bubble.getIconView().setOnTouchListener(mBubbleTouchListener); - mBubbleContainer.addView(bubble.getIconView(), 0, - new FrameLayout.LayoutParams(mPositioner.getBubbleSize(), - mPositioner.getBubbleSize())); updateBubbleShadows(false /* showForAllBubbles */); animateInFlyoutForBubble(bubble); requestUpdate(); diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/animation/StackAnimationController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/animation/StackAnimationController.java index 8043d2b8b2f92..12d55b85fac6a 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/animation/StackAnimationController.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/animation/StackAnimationController.java @@ -124,9 +124,6 @@ public class StackAnimationController extends */ private Rect mAnimatingToBounds = new Rect(); - /** Initial starting location for the stack. */ - @Nullable private BubbleStackView.RelativeStackPosition mStackStartPosition; - /** Whether or not the stack's start position has been set. */ private boolean mStackMovedToStartPosition = false;