Loading libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java +11 −3 Original line number Diff line number Diff line Loading @@ -1275,10 +1275,18 @@ public class BubbleController implements ConfigurationChangeListener, mBubbleData.setSelectedBubble(existingAppBubble); mBubbleData.setExpanded(true); } } else { // Check if it exists in the overflow Bubble b = mBubbleData.getOverflowBubbleWithKey(appBubbleKey); if (b != null) { // It's in the overflow, so remove it & reinflate Log.i(TAG, " showOrHideAppBubble, expanding app bubble from overflow"); mBubbleData.removeOverflowBubble(b); } else { // App bubble does not exist, lets add and expand it Log.i(TAG, " showOrHideAppBubble, creating and expanding app bubble"); Bubble b = Bubble.createAppBubble(intent, user, icon, mMainExecutor); b = Bubble.createAppBubble(intent, user, icon, mMainExecutor); } b.setShouldAutoExpand(true); inflateAndAdd(b, /* suppressFlyout= */ true, /* showInShade= */ false); } Loading libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleData.java +13 −1 Original line number Diff line number Diff line Loading @@ -490,6 +490,19 @@ public class BubbleData { dispatchPendingChanges(); } /** * Explicitly removes a bubble from the overflow, if it exists. * * @param bubble the bubble to remove. */ public void removeOverflowBubble(Bubble bubble) { if (bubble == null) return; if (mOverflowBubbles.remove(bubble)) { mStateChange.removedOverflowBubble = bubble; dispatchPendingChanges(); } } /** * Adds a group key indicating that the summary for this group should be suppressed. * Loading Loading @@ -1145,7 +1158,6 @@ public class BubbleData { return null; } @VisibleForTesting(visibility = PRIVATE) public Bubble getOverflowBubbleWithKey(String key) { for (int i = 0; i < mOverflowBubbles.size(); i++) { Bubble bubble = mOverflowBubbles.get(i); Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/bubbles/BubbleDataTest.java +17 −0 Original line number Diff line number Diff line Loading @@ -1190,6 +1190,23 @@ public class BubbleDataTest extends ShellTestCase { assertThat(mBubbleData.getBubbleInStackWithKey(appBubbleKey)).isNull(); } @Test public void test_removeOverflowBubble() { sendUpdatedEntryAtTime(mEntryA1, 2000); mBubbleData.setListener(mListener); mBubbleData.dismissBubbleWithKey(mEntryA1.getKey(), Bubbles.DISMISS_USER_GESTURE); verifyUpdateReceived(); assertOverflowChangedTo(ImmutableList.of(mBubbleA1)); mBubbleData.removeOverflowBubble(mBubbleA1); verifyUpdateReceived(); BubbleData.Update update = mUpdateCaptor.getValue(); assertThat(update.removedOverflowBubble).isEqualTo(mBubbleA1); assertOverflowChangedTo(ImmutableList.of()); } private void verifyUpdateReceived() { verify(mListener).applyUpdate(mUpdateCaptor.capture()); reset(mListener); Loading packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java +20 −0 Original line number Diff line number Diff line Loading @@ -2097,6 +2097,26 @@ public class BubblesTest extends SysuiTestCase { assertThat(mBubbleData.getBubbles().size()).isEqualTo(2); } @Test public void testShowOrHideAppBubble_addsFromOverflow() { String appBubbleKey = Bubble.getAppBubbleKeyForApp(mAppBubbleIntent.getPackage(), mUser0); mBubbleController.showOrHideAppBubble(mAppBubbleIntent, mUser0, mAppBubbleIcon); // Collapse the stack so we don't need to wait for the dismiss animation in the test mBubbleController.collapseStack(); // Dismiss the app bubble so it's in the overflow mBubbleController.dismissBubble(appBubbleKey, Bubbles.DISMISS_USER_GESTURE); assertThat(mBubbleData.getOverflowBubbleWithKey(appBubbleKey)).isNotNull(); // Calling this while collapsed will re-add and expand the app bubble mBubbleController.showOrHideAppBubble(mAppBubbleIntent, mUser0, mAppBubbleIcon); assertThat(mBubbleData.getSelectedBubble().getKey()).isEqualTo(appBubbleKey); assertThat(mBubbleController.isStackExpanded()).isTrue(); assertThat(mBubbleData.getBubbles().size()).isEqualTo(1); assertThat(mBubbleData.getOverflowBubbleWithKey(appBubbleKey)).isNull(); } @Test public void testCreateBubbleFromOngoingNotification() { NotificationEntry notif = new NotificationEntryBuilder() Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java +11 −3 Original line number Diff line number Diff line Loading @@ -1275,10 +1275,18 @@ public class BubbleController implements ConfigurationChangeListener, mBubbleData.setSelectedBubble(existingAppBubble); mBubbleData.setExpanded(true); } } else { // Check if it exists in the overflow Bubble b = mBubbleData.getOverflowBubbleWithKey(appBubbleKey); if (b != null) { // It's in the overflow, so remove it & reinflate Log.i(TAG, " showOrHideAppBubble, expanding app bubble from overflow"); mBubbleData.removeOverflowBubble(b); } else { // App bubble does not exist, lets add and expand it Log.i(TAG, " showOrHideAppBubble, creating and expanding app bubble"); Bubble b = Bubble.createAppBubble(intent, user, icon, mMainExecutor); b = Bubble.createAppBubble(intent, user, icon, mMainExecutor); } b.setShouldAutoExpand(true); inflateAndAdd(b, /* suppressFlyout= */ true, /* showInShade= */ false); } Loading
libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleData.java +13 −1 Original line number Diff line number Diff line Loading @@ -490,6 +490,19 @@ public class BubbleData { dispatchPendingChanges(); } /** * Explicitly removes a bubble from the overflow, if it exists. * * @param bubble the bubble to remove. */ public void removeOverflowBubble(Bubble bubble) { if (bubble == null) return; if (mOverflowBubbles.remove(bubble)) { mStateChange.removedOverflowBubble = bubble; dispatchPendingChanges(); } } /** * Adds a group key indicating that the summary for this group should be suppressed. * Loading Loading @@ -1145,7 +1158,6 @@ public class BubbleData { return null; } @VisibleForTesting(visibility = PRIVATE) public Bubble getOverflowBubbleWithKey(String key) { for (int i = 0; i < mOverflowBubbles.size(); i++) { Bubble bubble = mOverflowBubbles.get(i); Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/bubbles/BubbleDataTest.java +17 −0 Original line number Diff line number Diff line Loading @@ -1190,6 +1190,23 @@ public class BubbleDataTest extends ShellTestCase { assertThat(mBubbleData.getBubbleInStackWithKey(appBubbleKey)).isNull(); } @Test public void test_removeOverflowBubble() { sendUpdatedEntryAtTime(mEntryA1, 2000); mBubbleData.setListener(mListener); mBubbleData.dismissBubbleWithKey(mEntryA1.getKey(), Bubbles.DISMISS_USER_GESTURE); verifyUpdateReceived(); assertOverflowChangedTo(ImmutableList.of(mBubbleA1)); mBubbleData.removeOverflowBubble(mBubbleA1); verifyUpdateReceived(); BubbleData.Update update = mUpdateCaptor.getValue(); assertThat(update.removedOverflowBubble).isEqualTo(mBubbleA1); assertOverflowChangedTo(ImmutableList.of()); } private void verifyUpdateReceived() { verify(mListener).applyUpdate(mUpdateCaptor.capture()); reset(mListener); Loading
packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java +20 −0 Original line number Diff line number Diff line Loading @@ -2097,6 +2097,26 @@ public class BubblesTest extends SysuiTestCase { assertThat(mBubbleData.getBubbles().size()).isEqualTo(2); } @Test public void testShowOrHideAppBubble_addsFromOverflow() { String appBubbleKey = Bubble.getAppBubbleKeyForApp(mAppBubbleIntent.getPackage(), mUser0); mBubbleController.showOrHideAppBubble(mAppBubbleIntent, mUser0, mAppBubbleIcon); // Collapse the stack so we don't need to wait for the dismiss animation in the test mBubbleController.collapseStack(); // Dismiss the app bubble so it's in the overflow mBubbleController.dismissBubble(appBubbleKey, Bubbles.DISMISS_USER_GESTURE); assertThat(mBubbleData.getOverflowBubbleWithKey(appBubbleKey)).isNotNull(); // Calling this while collapsed will re-add and expand the app bubble mBubbleController.showOrHideAppBubble(mAppBubbleIntent, mUser0, mAppBubbleIcon); assertThat(mBubbleData.getSelectedBubble().getKey()).isEqualTo(appBubbleKey); assertThat(mBubbleController.isStackExpanded()).isTrue(); assertThat(mBubbleData.getBubbles().size()).isEqualTo(1); assertThat(mBubbleData.getOverflowBubbleWithKey(appBubbleKey)).isNull(); } @Test public void testCreateBubbleFromOngoingNotification() { NotificationEntry notif = new NotificationEntryBuilder() Loading