From 1d08202cc1404fa44536c3e6a8bfb4f7ce902a13 Mon Sep 17 00:00:00 2001 From: Mady Mellor Date: Tue, 12 May 2020 16:35:39 +0000 Subject: [PATCH] Revert "Atomic updates, icon cleanup for overflow" This reverts commit e4274beadbad39dea3c9807ca0d8e10baf352fbe. Reason for revert: causes b/156276800 -- lets revert in beta Bug: 156115497 Change-Id: Ie3c8c5f0599ac4e2119553611ffd2f2cf9cf58f2 --- .../systemui/bubbles/BubbleController.java | 16 +++-- .../android/systemui/bubbles/BubbleData.java | 14 +--- .../bubbles/BubbleOverflowActivity.java | 65 ++++++------------- 3 files changed, 31 insertions(+), 64 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java index df9effdf73fea..4d7eb758f7338 100644 --- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java +++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java @@ -171,7 +171,7 @@ public class BubbleController implements ConfigurationController.ConfigurationLi private INotificationManager mINotificationManager; // Callback that updates BubbleOverflowActivity on data change. - @Nullable private BubbleData.Listener mOverflowListener = null; + @Nullable private Runnable mOverflowCallback = null; private final NotificationInterruptStateProvider mNotificationInterruptStateProvider; private IStatusBarService mBarService; @@ -581,8 +581,8 @@ public class BubbleController implements ConfigurationController.ConfigurationLi mInflateSynchronously = inflateSynchronously; } - void setOverflowListener(BubbleData.Listener listener) { - mOverflowListener = listener; + void setOverflowCallback(Runnable updateOverflow) { + mOverflowCallback = updateOverflow; } /** @@ -959,8 +959,8 @@ public class BubbleController implements ConfigurationController.ConfigurationLi @Override public void applyUpdate(BubbleData.Update update) { // Update bubbles in overflow. - if (mOverflowListener != null) { - mOverflowListener.applyUpdate(update); + if (mOverflowCallback != null) { + mOverflowCallback.run(); } // Collapsing? Do this first before remaining steps. @@ -984,8 +984,7 @@ public class BubbleController implements ConfigurationController.ConfigurationLi if (!mBubbleData.hasOverflowBubbleWithKey(bubble.getKey()) && (!bubble.showInShade() || reason == DISMISS_NOTIF_CANCEL - || reason == DISMISS_GROUP_CANCELLED - || reason == DISMISS_OVERFLOW_MAX_REACHED)) { + || reason == DISMISS_GROUP_CANCELLED)) { // The bubble is now gone & the notification is hidden from the shade, so // time to actually remove it for (NotifCallback cb : mCallbacks) { @@ -1052,6 +1051,9 @@ public class BubbleController implements ConfigurationController.ConfigurationLi Log.d(TAG, BubbleDebugConfig.formatBubblesString(mStackView.getBubblesOnScreen(), mStackView.getExpandedBubble())); } + Log.d(TAG, "\n[BubbleData] overflow:"); + Log.d(TAG, BubbleDebugConfig.formatBubblesString(mBubbleData.getOverflowBubbles(), + null) + "\n"); } } }; diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleData.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleData.java index 16140f79efd7e..35a4811110a83 100644 --- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleData.java +++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleData.java @@ -73,8 +73,6 @@ public class BubbleData { @Nullable Bubble selectedBubble; @Nullable Bubble addedBubble; @Nullable Bubble updatedBubble; - @Nullable Bubble addedOverflowBubble; - @Nullable Bubble removedOverflowBubble; // Pair with Bubble and @DismissReason Integer final List> removedBubbles = new ArrayList<>(); @@ -93,12 +91,10 @@ public class BubbleData { || addedBubble != null || updatedBubble != null || !removedBubbles.isEmpty() - || addedOverflowBubble != null - || removedOverflowBubble != null || orderChanged; } - void bubbleRemoved(Bubble bubbleToRemove, @DismissReason int reason) { + void bubbleRemoved(Bubble bubbleToRemove, @DismissReason int reason) { removedBubbles.add(new Pair<>(bubbleToRemove, reason)); } } @@ -236,7 +232,6 @@ public class BubbleData { private void moveOverflowBubbleToPending(Bubble b) { mOverflowBubbles.remove(b); - mStateChange.removedOverflowBubble = b; mPendingBubbles.add(b); } @@ -444,9 +439,8 @@ public class BubbleData { if (DEBUG_BUBBLE_DATA) { Log.d(TAG, "Cancel overflow bubble: " + b); } - mOverflowBubbles.remove(b); mStateChange.bubbleRemoved(b, reason); - mStateChange.removedOverflowBubble = b; + mOverflowBubbles.remove(b); } return; } @@ -487,7 +481,6 @@ public class BubbleData { Log.d(TAG, "Overflowing: " + bubble); } mOverflowBubbles.add(0, bubble); - mStateChange.addedOverflowBubble = bubble; bubble.stopInflation(); if (mOverflowBubbles.size() == mMaxOverflowBubbles + 1) { // Remove oldest bubble. @@ -495,9 +488,8 @@ public class BubbleData { if (DEBUG_BUBBLE_DATA) { Log.d(TAG, "Overflow full. Remove: " + oldest); } - mOverflowBubbles.remove(oldest); - mStateChange.removedOverflowBubble = oldest; mStateChange.bubbleRemoved(oldest, BubbleController.DISMISS_OVERFLOW_MAX_REACHED); + mOverflowBubbles.remove(oldest); } } diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleOverflowActivity.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleOverflowActivity.java index 131ece16a42f9..37841f24a3cfc 100644 --- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleOverflowActivity.java +++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleOverflowActivity.java @@ -95,12 +95,11 @@ public class BubbleOverflowActivity extends Activity { mAdapter = new BubbleOverflowAdapter(mOverflowBubbles, mBubbleController::promoteBubbleFromOverflow, viewWidth, viewHeight); mRecyclerView.setAdapter(mAdapter); - - mOverflowBubbles.addAll(mBubbleController.getOverflowBubbles()); - mAdapter.notifyDataSetChanged(); - setEmptyStateVisibility(); - - mBubbleController.setOverflowListener(mDataListener); + onDataChanged(mBubbleController.getOverflowBubbles()); + mBubbleController.setOverflowCallback(() -> { + onDataChanged(mBubbleController.getOverflowBubbles()); + }); + onThemeChanged(); } /** @@ -127,14 +126,6 @@ public class BubbleOverflowActivity extends Activity { } } - void setEmptyStateVisibility() { - if (mOverflowBubbles.isEmpty()) { - mEmptyState.setVisibility(View.VISIBLE); - } else { - mEmptyState.setVisibility(View.GONE); - } - } - void setBackgroundColor() { final TypedArray ta = getApplicationContext().obtainStyledAttributes( new int[]{android.R.attr.colorBackgroundFloating}); @@ -143,40 +134,22 @@ public class BubbleOverflowActivity extends Activity { findViewById(android.R.id.content).setBackgroundColor(bgColor); } - private final BubbleData.Listener mDataListener = new BubbleData.Listener() { + void onDataChanged(List bubbles) { + mOverflowBubbles.clear(); + mOverflowBubbles.addAll(bubbles); + mAdapter.notifyDataSetChanged(); - @Override - public void applyUpdate(BubbleData.Update update) { - - Bubble toRemove = update.removedOverflowBubble; - if (toRemove != null) { - if (DEBUG_OVERFLOW) { - Log.d(TAG, "remove: " + toRemove); - } - toRemove.cleanupViews(); - int i = mOverflowBubbles.indexOf(toRemove); - mOverflowBubbles.remove(toRemove); - mAdapter.notifyItemRemoved(i); - } - - Bubble toAdd = update.addedOverflowBubble; - if (toAdd != null) { - if (DEBUG_OVERFLOW) { - Log.d(TAG, "add: " + toAdd); - } - mOverflowBubbles.add(0, toAdd); - mAdapter.notifyItemInserted(0); - } - - setEmptyStateVisibility(); - - if (DEBUG_OVERFLOW) { - Log.d(TAG, BubbleDebugConfig.formatBubblesString( - mBubbleController.getOverflowBubbles(), - null)); - } + if (mOverflowBubbles.isEmpty()) { + mEmptyState.setVisibility(View.VISIBLE); + } else { + mEmptyState.setVisibility(View.GONE); } - }; + + if (DEBUG_OVERFLOW) { + Log.d(TAG, "Updated overflow bubbles:\n" + BubbleDebugConfig.formatBubblesString( + mOverflowBubbles, /*selected*/ null)); + } + } @Override public void onStart() {