From d698186a6464096bdad86150d751f7122785ecd0 Mon Sep 17 00:00:00 2001 From: Lyn Han Date: Tue, 18 Feb 2020 18:01:43 -0800 Subject: [PATCH] Dismiss bubbles into overflow Fixes: 149716471 Test: manual -> dismiss single bubble -> bubble in overflow Test: manual -> dismiss stack -> create bubble -> expand stack -> previous bubbles in stack now in overflow Change-Id: I6897a369f734af18029872c65b6f104eb701b202 --- .../android/systemui/bubbles/BubbleData.java | 38 ++++++++++--------- .../bubbles/BubbleOverflowActivity.java | 8 +--- 2 files changed, 22 insertions(+), 24 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleData.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleData.java index 8a5aad8759798..cf5a4d3840cca 100644 --- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleData.java +++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleData.java @@ -443,20 +443,7 @@ public class BubbleData { mStateChange.orderChanged |= repackAll(); } - if (reason == BubbleController.DISMISS_AGED) { - if (DEBUG_BUBBLE_DATA) { - Log.d(TAG, "overflowing bubble: " + bubbleToRemove); - } - 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); - } - } + overflowBubble(reason, bubbleToRemove); // Note: If mBubbles.isEmpty(), then mSelectedBubble is now null. if (Objects.equals(mSelectedBubble, bubbleToRemove)) { @@ -468,6 +455,25 @@ public class BubbleData { maybeSendDeleteIntent(reason, bubbleToRemove.getEntry()); } + void overflowBubble(@DismissReason int reason, Bubble bubble) { + if (reason == BubbleController.DISMISS_AGED + || reason == BubbleController.DISMISS_USER_GESTURE) { + if (DEBUG_BUBBLE_DATA) { + Log.d(TAG, "overflowing bubble: " + bubble); + } + mOverflowBubbles.add(0, bubble); + + 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); + } + } + } + public void dismissAll(@DismissReason int reason) { if (DEBUG_BUBBLE_DATA) { Log.d(TAG, "dismissAll: reason=" + reason); @@ -478,9 +484,7 @@ public class BubbleData { setExpandedInternal(false); setSelectedBubbleInternal(null); while (!mBubbles.isEmpty()) { - Bubble bubble = mBubbles.remove(0); - maybeSendDeleteIntent(reason, bubble.getEntry()); - mStateChange.bubbleRemoved(bubble, reason); + doRemove(mBubbles.get(0).getKey(), reason); } dispatchPendingChanges(); } diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleOverflowActivity.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleOverflowActivity.java index f3cfa834dfc16..419cd87339079 100644 --- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleOverflowActivity.java +++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleOverflowActivity.java @@ -54,7 +54,6 @@ public class BubbleOverflowActivity extends Activity { private BubbleOverflowAdapter mAdapter; private RecyclerView mRecyclerView; private List mOverflowBubbles = new ArrayList<>(); - private int mMaxBubbles; @Inject public BubbleOverflowActivity(BubbleController controller) { @@ -67,7 +66,6 @@ public class BubbleOverflowActivity extends Activity { setContentView(R.layout.bubble_overflow_activity); setBackgroundColor(); - mMaxBubbles = getResources().getInteger(R.integer.bubbles_max_rendered); mEmptyState = findViewById(R.id.bubble_overflow_empty_state); mRecyclerView = findViewById(R.id.bubble_overflow_recycler); mRecyclerView.setLayoutManager( @@ -94,11 +92,7 @@ public class BubbleOverflowActivity extends Activity { void onDataChanged(List bubbles) { mOverflowBubbles.clear(); - if (bubbles.size() > mMaxBubbles) { - mOverflowBubbles.addAll(bubbles.subList(mMaxBubbles, bubbles.size())); - } else { - mOverflowBubbles.addAll(bubbles); - } + mOverflowBubbles.addAll(bubbles); mAdapter.notifyDataSetChanged(); if (mOverflowBubbles.isEmpty()) {