From e13955780536452c35ea8799b2fb4cd3cf7961df Mon Sep 17 00:00:00 2001 From: Lyn Han Date: Mon, 23 Mar 2020 15:48:54 -0700 Subject: [PATCH] Remove bubble from stack by key instead of icon Fixes: 152251180 Test: manual - bubbles trimmed on overflow Test: manual - normal bubble removal still works fine Change-Id: I19b8fa54f28ae6c959354f4a3a7f4d0e8ed70d44 --- .../android/systemui/bubbles/BubbleData.java | 8 ++++--- .../systemui/bubbles/BubbleStackView.java | 21 ++++++++++--------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleData.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleData.java index fcbd9121fcda0..077ffd3729e5b 100644 --- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleData.java +++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleData.java @@ -403,6 +403,9 @@ public class BubbleData { } private void doRemove(String key, @DismissReason int reason) { + if (DEBUG_BUBBLE_DATA) { + Log.d(TAG, "doRemove: " + key); + } // If it was pending remove it for (int i = 0; i < mPendingBubbles.size(); i++) { if (mPendingBubbles.get(i).getKey().equals(key)) { @@ -445,15 +448,14 @@ public class BubbleData { if (reason == BubbleController.DISMISS_AGED || reason == BubbleController.DISMISS_USER_GESTURE) { if (DEBUG_BUBBLE_DATA) { - Log.d(TAG, "overflowing bubble: " + bubble); + Log.d(TAG, "Overflowing: " + bubble); } mOverflowBubbles.add(0, bubble); bubble.stopInflation(); - if (mOverflowBubbles.size() == mMaxOverflowBubbles + 1) { // Remove oldest bubble. if (DEBUG_BUBBLE_DATA) { - Log.d(TAG, "Overflow full. Remove bubble: " + mOverflowBubbles.get( + Log.d(TAG, "Overflow full. Remove: " + mOverflowBubbles.get( mOverflowBubbles.size() - 1)); } mOverflowBubbles.remove(mOverflowBubbles.size() - 1); diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java index cff371f93f3d8..541c8cf19943b 100644 --- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java +++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java @@ -940,7 +940,6 @@ public class BubbleStackView extends FrameLayout { ViewClippingUtil.setClippingDeactivated(bubble.getIconView(), true, mClippingParameters); animateInFlyoutForBubble(bubble); updatePointerPosition(); - updateOverflowBtnVisibility( /*apply */ true); requestUpdate(); logBubbleEvent(bubble, SysUiStatsLog.BUBBLE_UICHANGED__ACTION__POSTED); } @@ -951,16 +950,18 @@ public class BubbleStackView extends FrameLayout { Log.d(TAG, "removeBubble: " + bubble); } // Remove it from the views - int removedIndex = mBubbleContainer.indexOfChild(bubble.getIconView()); - 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); + for (int i = 0; i < getBubbleCount(); i++) { + View v = mBubbleContainer.getChildAt(i); + if (v instanceof BadgedImageView + && ((BadgedImageView) v).getKey().equals(bubble.getKey())) { + mBubbleContainer.removeViewAt(i); + bubble.cleanupExpandedState(); + bubble.setInflated(false); + logBubbleEvent(bubble, SysUiStatsLog.BUBBLE_UICHANGED__ACTION__DISMISSED); + return; + } } - updateOverflowBtnVisibility(/* apply */ true); + Log.d(TAG, "was asked to remove Bubble, but didn't find the view! " + bubble); } private void updateOverflowBtnVisibility(boolean apply) {