From 1e19d7fe74d18fae4b9c5c268f40dd11282cea7e Mon Sep 17 00:00:00 2001 From: Lyn Han Date: Wed, 5 Feb 2020 19:10:58 -0800 Subject: [PATCH] Inflate bubble promoted from overflow BubbleData#promoteBubbleFromOverflow - inflate bubble; when done, go through notificationEntryUpdated (doAdd) Fixes: 148247568 Fixes: 148878180 Bug: 148878788 Test: atest SystemUITests Test: manual - tap bubble to promote it from overflow -> bubble shows up left of row, gone from overflow; oldest bubble in row overflows when count > 5, shows up left of first row in overflow Change-Id: If33a0e0f5d9a5e4e042ad965f2b55a44e8b508dd --- .../com/android/systemui/bubbles/Bubble.java | 4 ++++ .../systemui/bubbles/BubbleController.java | 3 ++- .../android/systemui/bubbles/BubbleData.java | 21 +++++++++++++------ .../systemui/bubbles/BubbleStackView.java | 1 + 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/Bubble.java b/packages/SystemUI/src/com/android/systemui/bubbles/Bubble.java index 45705b76f09c1..1e39954ed414a 100644 --- a/packages/SystemUI/src/com/android/systemui/bubbles/Bubble.java +++ b/packages/SystemUI/src/com/android/systemui/bubbles/Bubble.java @@ -226,6 +226,10 @@ class Bubble { mIconView.update(this); } + void setInflated(boolean inflated) { + mInflated = inflated; + } + /** * Set visibility of bubble in the expanded state. * diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java index 05838abe184a7..762e5f21cd63c 100644 --- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java +++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java @@ -749,7 +749,8 @@ public class BubbleController implements ConfigurationController.ConfigurationLi } void promoteBubbleFromOverflow(Bubble bubble) { - mBubbleData.promoteBubbleFromOverflow(bubble); + bubble.setInflateSynchronously(mInflateSynchronously); + mBubbleData.promoteBubbleFromOverflow(bubble, mStackView, mBubbleIconFactory); } /** diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleData.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleData.java index 673121f927162..8a5aad8759798 100644 --- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleData.java +++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleData.java @@ -199,16 +199,21 @@ public class BubbleData { dispatchPendingChanges(); } - public void promoteBubbleFromOverflow(Bubble bubble) { + public void promoteBubbleFromOverflow(Bubble bubble, BubbleStackView stack, + BubbleIconFactory factory) { if (DEBUG_BUBBLE_DATA) { Log.d(TAG, "promoteBubbleFromOverflow: " + bubble); } - mOverflowBubbles.remove(bubble); - doAdd(bubble); - setSelectedBubbleInternal(bubble); + // Preserve new order for next repack, which sorts by last updated time. bubble.markUpdatedAt(mTimeSource.currentTimeMillis()); - trim(); + setSelectedBubbleInternal(bubble); + mOverflowBubbles.remove(bubble); + + bubble.inflate( + b -> notificationEntryUpdated(bubble, /* suppressFlyout */ + false, /* showInShade */ true), + mContext, stack, factory); dispatchPendingChanges(); } @@ -445,6 +450,10 @@ public class BubbleData { mOverflowBubbles.add(0, bubbleToRemove); if (mOverflowBubbles.size() == mMaxOverflowBubbles + 1) { // Remove oldest bubble. + if (DEBUG_BUBBLE_DATA) { + Log.d(TAG, "Overflow full. Remove bubble: " + mOverflowBubbles.get( + mOverflowBubbles.size() - 1)); + } mOverflowBubbles.remove(mOverflowBubbles.size() - 1); } } @@ -511,7 +520,7 @@ public class BubbleData { if (Objects.equals(bubble, mSelectedBubble)) { return; } - if (bubble != null && !mBubbles.contains(bubble)) { + if (bubble != null && !mBubbles.contains(bubble) && !mOverflowBubbles.contains(bubble)) { Log.e(TAG, "Cannot select bubble which doesn't exist!" + " (" + bubble + ") bubbles=" + mBubbles); return; diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java index bce172b891872..acaf271097efd 100644 --- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java +++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java @@ -795,6 +795,7 @@ public class BubbleStackView extends FrameLayout { if (removedIndex >= 0) { mBubbleContainer.removeViewAt(removedIndex); bubble.cleanupExpandedState(); + bubble.setInflated(false); logBubbleEvent(bubble, SysUiStatsLog.BUBBLE_UICHANGED__ACTION__DISMISSED); } else { Log.d(TAG, "was asked to remove Bubble, but didn't find the view! " + bubble);