diff options
| author | 2020-02-19 21:16:40 +0000 | |
|---|---|---|
| committer | 2020-02-19 21:16:40 +0000 | |
| commit | 80def300765428bcfc2e96e1afed23dcf8a2dd4f (patch) | |
| tree | 620e1d59eccbcb9f7acc4c3510f70635b0b759bd | |
| parent | 5cbf9d68561987cc421406675c2c20fcb27cb38e (diff) | |
| parent | d698186a6464096bdad86150d751f7122785ecd0 (diff) | |
Merge "Dismiss bubbles into overflow"
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/bubbles/BubbleData.java | 34 | ||||
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/bubbles/BubbleOverflowActivity.java | 8 |
2 files changed, 20 insertions, 22 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleData.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleData.java index 8a5aad875979..cf5a4d3840cc 100644 --- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleData.java +++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleData.java @@ -443,11 +443,26 @@ public class BubbleData { mStateChange.orderChanged |= repackAll(); } - if (reason == BubbleController.DISMISS_AGED) { + overflowBubble(reason, bubbleToRemove); + + // Note: If mBubbles.isEmpty(), then mSelectedBubble is now null. + if (Objects.equals(mSelectedBubble, bubbleToRemove)) { + // Move selection to the new bubble at the same position. + int newIndex = Math.min(indexToRemove, mBubbles.size() - 1); + Bubble newSelected = mBubbles.get(newIndex); + setSelectedBubbleInternal(newSelected); + } + 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: " + bubbleToRemove); + Log.d(TAG, "overflowing bubble: " + bubble); } - mOverflowBubbles.add(0, bubbleToRemove); + mOverflowBubbles.add(0, bubble); + if (mOverflowBubbles.size() == mMaxOverflowBubbles + 1) { // Remove oldest bubble. if (DEBUG_BUBBLE_DATA) { @@ -457,15 +472,6 @@ public class BubbleData { mOverflowBubbles.remove(mOverflowBubbles.size() - 1); } } - - // Note: If mBubbles.isEmpty(), then mSelectedBubble is now null. - if (Objects.equals(mSelectedBubble, bubbleToRemove)) { - // Move selection to the new bubble at the same position. - int newIndex = Math.min(indexToRemove, mBubbles.size() - 1); - Bubble newSelected = mBubbles.get(newIndex); - setSelectedBubbleInternal(newSelected); - } - maybeSendDeleteIntent(reason, bubbleToRemove.getEntry()); } public void dismissAll(@DismissReason int 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 756c5981fe38..eb836b1a21f9 100644 --- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleOverflowActivity.java +++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleOverflowActivity.java @@ -55,7 +55,6 @@ public class BubbleOverflowActivity extends Activity { private BubbleOverflowAdapter mAdapter; private RecyclerView mRecyclerView; private List<Bubble> mOverflowBubbles = new ArrayList<>(); - private int mMaxBubbles; @Inject public BubbleOverflowActivity(BubbleController controller) { @@ -68,7 +67,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( @@ -95,11 +93,7 @@ public class BubbleOverflowActivity extends Activity { void onDataChanged(List<Bubble> 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()) { |