Support optional bubble overflow in bubble bar

This is similar to the animations that add / remove a bubble at the
same time -- the overflow is generally added when a bubble is removed.
The overflow is generally removed when a bubble is added (i.e. user
promotes a bubble out of the overflow).

There are a couple of additional cases:
- when bubbles are first added to the bar -- if there were saved
  bubbles in the overflow, the view should be added
- an app could cancel its bubbles / remove its shortcuts and not have
  any in the stack but could have some in the overflow & it could
  become empty without an addition.

Flag: com.android.wm.shell.enable_optional_bubble_overflow
Flag: com.android.wm.shell.enable_bubble_bar
Test: manual - add bubbles to the bubble bar for first time
             => observe there is no overflow
             - dismiss a bubble
             => observe the overflow is added, tap on it, tap on the
                bubble in it
             => observe that bubble is added & the overflow disappears
             - dismiss all the bubbles
             - add a bubble
             => observe the overflow is there & has the previously
                dismissed bubbles
             - cancel all the bubbles that are in the overflow via
               adb
             => observe the overflow is remvoed
Bug: 334175587
Change-Id: I2b6e855e65520b4b2b1fde7757d46f00a468b4a6
This commit is contained in:
Mady Mellor committed 2024-08-05 12:25:33 -07:00
1 parent d9873c1039
commit 8c629fd8b5
4 files changed
+121 -40

No files matched your search

@@ -138,6 +138,8 @@ public class BubbleBarController extends IBubblesListener.Stub {
List<RemovedBubble> removedBubbles;
List<String> bubbleKeysInOrder;
Point expandedViewDropTargetSize;
boolean showOverflow;
boolean showOverflowChanged;
// These need to be loaded in the background
BubbleBarBubble addedBubble;
@@ -156,6 +158,8 @@ public class BubbleBarController extends IBubblesListener.Stub {
removedBubbles = update.removedBubbles;
bubbleKeysInOrder = update.bubbleKeysInOrder;
expandedViewDropTargetSize = update.expandedViewDropTargetSize;
showOverflow = update.showOverflow;
showOverflowChanged = update.showOverflowChanged;
}
}
@@ -271,7 +275,13 @@ public class BubbleBarController extends IBubblesListener.Stub {
BubbleBarBubble bubbleToSelect = null;
if (update.addedBubble != null && update.removedBubbles.size() == 1) {
if (Flags.enableOptionalBubbleOverflow()
&& update.showOverflowChanged && !update.showOverflow && update.addedBubble != null
&& update.removedBubbles.isEmpty()) {
// A bubble was added from the overflow (& now it's empty / not showing)
mBubbles.put(update.addedBubble.getKey(), update.addedBubble);
mBubbleBarViewController.removeOverflowAndAddBubble(update.addedBubble);
} else if (update.addedBubble != null && update.removedBubbles.size() == 1) {
// we're adding and removing a bubble at the same time. handle this as a single update.
RemovedBubble removedBubble = update.removedBubbles.get(0);
BubbleBarBubble bubbleToRemove = mBubbles.remove(removedBubble.getKey());
@@ -285,11 +295,17 @@ public class BubbleBarController extends IBubblesListener.Stub {
Log.w(TAG, "trying to remove bubble that doesn't exist: " + removedBubble.getKey());
}
} else {
boolean overflowNeedsToBeAdded = Flags.enableOptionalBubbleOverflow()
&& update.showOverflowChanged && update.showOverflow;
if (!update.removedBubbles.isEmpty()) {
for (int i = 0; i < update.removedBubbles.size(); i++) {
RemovedBubble removedBubble = update.removedBubbles.get(i);
BubbleBarBubble bubble = mBubbles.remove(removedBubble.getKey());
if (bubble != null) {
if (bubble != null && overflowNeedsToBeAdded) {
// First removal, show the overflow
overflowNeedsToBeAdded = false;
mBubbleBarViewController.addOverflowAndRemoveBubble(bubble);
} else if (bubble != null) {
mBubbleBarViewController.removeBubble(bubble);
} else {
Log.w(TAG, "trying to remove bubble that doesn't exist: "
@@ -302,6 +318,11 @@ public class BubbleBarController extends IBubblesListener.Stub {
mBubbleBarViewController.addBubble(update.addedBubble, isExpanding,
suppressAnimation);
}
if (Flags.enableOptionalBubbleOverflow()
&& update.showOverflowChanged
&& update.showOverflow != mBubbleBarViewController.isOverflowAdded()) {
mBubbleBarViewController.showOverflow(update.showOverflow);
}
}
// if a bubble was updated upstream, but removed before the update was received, add it back
@@ -333,6 +354,9 @@ public class BubbleBarController extends IBubblesListener.Stub {
}
}
}
if (Flags.enableOptionalBubbleOverflow() && update.initialState && update.showOverflow) {
mBubbleBarViewController.showOverflow(true);
}
// Adds and removals have happened, update visibility before any other visual changes.
mBubbleBarViewController.setHiddenForBubbles(mBubbles.isEmpty());