Loading packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java +6 −4 Original line number Diff line number Diff line Loading @@ -237,6 +237,10 @@ public class BubbleStackView extends FrameLayout implements BubbleTouchHandler.F * Sets the bubble that should be expanded and expands if needed. */ public void setExpandedBubble(BubbleView bubbleToExpand) { if (mIsExpanded && !bubbleToExpand.equals(mExpandedBubble)) { // Previously expanded, notify that this bubble is no longer expanded notifyExpansionChanged(mExpandedBubble, false /* expanded */); } mExpandedBubble = bubbleToExpand; if (!mIsExpanded) { // If we weren't previously expanded we should animate open. Loading Loading @@ -291,12 +295,12 @@ public class BubbleStackView extends FrameLayout implements BubbleTouchHandler.F int nextIndex = bubbleCount > removedIndex ? removedIndex : bubbleCount - 1; BubbleView expandedBubble = (BubbleView) mBubbleContainer.getChildAt(nextIndex); setExpandedBubble(expandedBubble); requestUpdate(); } mIsExpanded = wasExpanded && mBubbleContainer.getChildCount() > 0; if (wasExpanded != mIsExpanded) { notifyExpansionChanged(mExpandedBubble, mIsExpanded); } requestUpdate(); } /** Loading Loading @@ -373,9 +377,7 @@ public class BubbleStackView extends FrameLayout implements BubbleTouchHandler.F public void expandStack() { if (!mIsExpanded) { mExpandedBubble = getTopBubble(); mExpandedBubble.getEntry().setShowInShadeWhenBubble(false); animateExpansion(true /* shouldExpand */); notifyExpansionChanged(mExpandedBubble, true /* expanded */); setExpandedBubble(mExpandedBubble); } } Loading packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleControllerTest.java +109 −5 Original line number Diff line number Diff line Loading @@ -77,6 +77,10 @@ public class BubbleControllerTest extends SysuiTestCase { @Mock private NotificationData mNotificationData; @Mock private BubbleController.BubbleStateChangeListener mBubbleStateChangeListener; @Mock private BubbleController.BubbleExpandListener mBubbleExpandListener; @Before public void setUp() throws Exception { Loading @@ -101,6 +105,8 @@ public class BubbleControllerTest extends SysuiTestCase { when(mNotificationData.getChannel(mNoChannelRow.getEntry().key)).thenReturn(null); mBubbleController = new TestableBubbleController(mContext, mStatusBarWindowController); mBubbleController.setBubbleStateChangeListener(mBubbleStateChangeListener); mBubbleController.setExpandListener(mBubbleExpandListener); // Get a reference to the BubbleController's entry listener verify(mNotificationEntryManager, atLeastOnce()) Loading @@ -112,6 +118,8 @@ public class BubbleControllerTest extends SysuiTestCase { public void testAddBubble() { mBubbleController.updateBubble(mRow.getEntry(), true /* updatePosition */); assertTrue(mBubbleController.hasBubbles()); verify(mBubbleStateChangeListener).onHasBubblesChanged(true); } @Test Loading @@ -126,10 +134,14 @@ public class BubbleControllerTest extends SysuiTestCase { mBubbleController.updateBubble(mRow.getEntry(), true /* updatePosition */); assertTrue(mBubbleController.hasBubbles()); verify(mBubbleStateChangeListener).onHasBubblesChanged(true); mBubbleController.removeBubble(mRow.getEntry().key); assertFalse(mStatusBarWindowController.getBubblesShowing()); assertTrue(mRow.getEntry().isBubbleDismissed()); verify(mNotificationEntryManager).updateNotifications(); verify(mBubbleStateChangeListener).onHasBubblesChanged(false); } @Test Loading @@ -141,40 +153,132 @@ public class BubbleControllerTest extends SysuiTestCase { mBubbleController.dismissStack(); assertFalse(mStatusBarWindowController.getBubblesShowing()); verify(mNotificationEntryManager).updateNotifications(); assertTrue(mRow.getEntry().isBubbleDismissed()); assertTrue(mRow2.getEntry().isBubbleDismissed()); } @Test public void testIsStackExpanded() { public void testExpandCollapseStack() { assertFalse(mBubbleController.isStackExpanded()); // Mark it as a bubble and add it explicitly mEntryListener.onPendingEntryAdded(mRow.getEntry()); mBubbleController.updateBubble(mRow.getEntry(), true /* updatePosition */); // We should have bubbles & their notifs should show in the shade assertTrue(mBubbleController.hasBubbles()); assertTrue(mRow.getEntry().showInShadeWhenBubble()); // Expand the stack BubbleStackView stackView = mBubbleController.getStackView(); stackView.expandStack(); assertTrue(mBubbleController.isStackExpanded()); verify(mBubbleExpandListener).onBubbleExpandChanged(true, mRow.getEntry().key); // Make sure it's no longer in the shade assertFalse(mRow.getEntry().showInShadeWhenBubble()); // Collapse stackView.collapseStack(); verify(mBubbleExpandListener).onBubbleExpandChanged(false, mRow.getEntry().key); assertFalse(mBubbleController.isStackExpanded()); } @Test public void testCollapseStack() { public void testCollapseAfterChangingExpandedBubble() { // Mark it as a bubble and add it explicitly mEntryListener.onPendingEntryAdded(mRow.getEntry()); mEntryListener.onPendingEntryAdded(mRow2.getEntry()); mBubbleController.updateBubble(mRow.getEntry(), true /* updatePosition */); mBubbleController.updateBubble(mRow2.getEntry(), true /* updatePosition */); // We should have bubbles & their notifs should show in the shade assertTrue(mBubbleController.hasBubbles()); assertTrue(mRow.getEntry().showInShadeWhenBubble()); assertTrue(mRow2.getEntry().showInShadeWhenBubble()); // Expand BubbleStackView stackView = mBubbleController.getStackView(); stackView.expandStack(); assertTrue(mBubbleController.isStackExpanded()); verify(mBubbleExpandListener).onBubbleExpandChanged(true, mRow2.getEntry().key); // Last added is the one that is expanded assertEquals(mRow2.getEntry(), stackView.getExpandedBubble().getEntry()); assertFalse(mRow2.getEntry().showInShadeWhenBubble()); // Switch which bubble is expanded stackView.setExpandedBubble(mRow.getEntry()); assertEquals(stackView.getExpandedBubble().getEntry(), mRow.getEntry()); assertEquals(mRow.getEntry(), stackView.getExpandedBubble().getEntry()); assertFalse(mRow.getEntry().showInShadeWhenBubble()); stackView.setExpandedBubble(mRow2.getEntry()); assertEquals(stackView.getExpandedBubble().getEntry(), mRow2.getEntry()); // collapse for previous bubble verify(mBubbleExpandListener).onBubbleExpandChanged(false, mRow2.getEntry().key); // expand for selected bubble verify(mBubbleExpandListener).onBubbleExpandChanged(true, mRow.getEntry().key); // Collapse mBubbleController.collapseStack(); assertFalse(mBubbleController.isStackExpanded()); } @Test public void testExpansionRemovesShowInShade() { // Mark it as a bubble and add it explicitly mEntryListener.onPendingEntryAdded(mRow.getEntry()); mBubbleController.updateBubble(mRow.getEntry(), true /* updatePosition */); // We should have bubbles & their notifs should show in the shade assertTrue(mBubbleController.hasBubbles()); assertTrue(mRow.getEntry().showInShadeWhenBubble()); // Expand BubbleStackView stackView = mBubbleController.getStackView(); stackView.expandStack(); assertTrue(mBubbleController.isStackExpanded()); verify(mBubbleExpandListener).onBubbleExpandChanged(true, mRow.getEntry().key); // No longer show shade in notif after expansion assertFalse(mRow.getEntry().showInShadeWhenBubble()); } @Test public void testRemoveLastExpandedCollapses() { // Mark it as a bubble and add it explicitly mEntryListener.onPendingEntryAdded(mRow.getEntry()); mEntryListener.onPendingEntryAdded(mRow2.getEntry()); mBubbleController.updateBubble(mRow.getEntry(), true /* updatePosition */); mBubbleController.updateBubble(mRow2.getEntry(), true /* updatePosition */); verify(mBubbleStateChangeListener).onHasBubblesChanged(true); // Expand BubbleStackView stackView = mBubbleController.getStackView(); stackView.expandStack(); assertTrue(mBubbleController.isStackExpanded()); verify(mBubbleExpandListener).onBubbleExpandChanged(true, mRow2.getEntry().key); // Last added is the one that is expanded assertEquals(mRow2.getEntry(), stackView.getExpandedBubble().getEntry()); assertFalse(mRow2.getEntry().showInShadeWhenBubble()); // Dismiss currently expanded mBubbleController.removeBubble(stackView.getExpandedBubble().getKey()); verify(mBubbleExpandListener).onBubbleExpandChanged(false, mRow2.getEntry().key); // Make sure next bubble is selected assertEquals(mRow.getEntry(), stackView.getExpandedBubble().getEntry()); verify(mBubbleExpandListener).onBubbleExpandChanged(true, mRow.getEntry().key); // Dismiss that one mBubbleController.removeBubble(stackView.getExpandedBubble().getKey()); // Make sure state changes and collapse happens verify(mBubbleExpandListener).onBubbleExpandChanged(false, mRow.getEntry().key); verify(mBubbleStateChangeListener).onHasBubblesChanged(false); assertFalse(mBubbleController.hasBubbles()); } @Test public void testMarkNewNotificationAsBubble() { mEntryListener.onPendingEntryAdded(mRow.getEntry()); Loading Loading
packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java +6 −4 Original line number Diff line number Diff line Loading @@ -237,6 +237,10 @@ public class BubbleStackView extends FrameLayout implements BubbleTouchHandler.F * Sets the bubble that should be expanded and expands if needed. */ public void setExpandedBubble(BubbleView bubbleToExpand) { if (mIsExpanded && !bubbleToExpand.equals(mExpandedBubble)) { // Previously expanded, notify that this bubble is no longer expanded notifyExpansionChanged(mExpandedBubble, false /* expanded */); } mExpandedBubble = bubbleToExpand; if (!mIsExpanded) { // If we weren't previously expanded we should animate open. Loading Loading @@ -291,12 +295,12 @@ public class BubbleStackView extends FrameLayout implements BubbleTouchHandler.F int nextIndex = bubbleCount > removedIndex ? removedIndex : bubbleCount - 1; BubbleView expandedBubble = (BubbleView) mBubbleContainer.getChildAt(nextIndex); setExpandedBubble(expandedBubble); requestUpdate(); } mIsExpanded = wasExpanded && mBubbleContainer.getChildCount() > 0; if (wasExpanded != mIsExpanded) { notifyExpansionChanged(mExpandedBubble, mIsExpanded); } requestUpdate(); } /** Loading Loading @@ -373,9 +377,7 @@ public class BubbleStackView extends FrameLayout implements BubbleTouchHandler.F public void expandStack() { if (!mIsExpanded) { mExpandedBubble = getTopBubble(); mExpandedBubble.getEntry().setShowInShadeWhenBubble(false); animateExpansion(true /* shouldExpand */); notifyExpansionChanged(mExpandedBubble, true /* expanded */); setExpandedBubble(mExpandedBubble); } } Loading
packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleControllerTest.java +109 −5 Original line number Diff line number Diff line Loading @@ -77,6 +77,10 @@ public class BubbleControllerTest extends SysuiTestCase { @Mock private NotificationData mNotificationData; @Mock private BubbleController.BubbleStateChangeListener mBubbleStateChangeListener; @Mock private BubbleController.BubbleExpandListener mBubbleExpandListener; @Before public void setUp() throws Exception { Loading @@ -101,6 +105,8 @@ public class BubbleControllerTest extends SysuiTestCase { when(mNotificationData.getChannel(mNoChannelRow.getEntry().key)).thenReturn(null); mBubbleController = new TestableBubbleController(mContext, mStatusBarWindowController); mBubbleController.setBubbleStateChangeListener(mBubbleStateChangeListener); mBubbleController.setExpandListener(mBubbleExpandListener); // Get a reference to the BubbleController's entry listener verify(mNotificationEntryManager, atLeastOnce()) Loading @@ -112,6 +118,8 @@ public class BubbleControllerTest extends SysuiTestCase { public void testAddBubble() { mBubbleController.updateBubble(mRow.getEntry(), true /* updatePosition */); assertTrue(mBubbleController.hasBubbles()); verify(mBubbleStateChangeListener).onHasBubblesChanged(true); } @Test Loading @@ -126,10 +134,14 @@ public class BubbleControllerTest extends SysuiTestCase { mBubbleController.updateBubble(mRow.getEntry(), true /* updatePosition */); assertTrue(mBubbleController.hasBubbles()); verify(mBubbleStateChangeListener).onHasBubblesChanged(true); mBubbleController.removeBubble(mRow.getEntry().key); assertFalse(mStatusBarWindowController.getBubblesShowing()); assertTrue(mRow.getEntry().isBubbleDismissed()); verify(mNotificationEntryManager).updateNotifications(); verify(mBubbleStateChangeListener).onHasBubblesChanged(false); } @Test Loading @@ -141,40 +153,132 @@ public class BubbleControllerTest extends SysuiTestCase { mBubbleController.dismissStack(); assertFalse(mStatusBarWindowController.getBubblesShowing()); verify(mNotificationEntryManager).updateNotifications(); assertTrue(mRow.getEntry().isBubbleDismissed()); assertTrue(mRow2.getEntry().isBubbleDismissed()); } @Test public void testIsStackExpanded() { public void testExpandCollapseStack() { assertFalse(mBubbleController.isStackExpanded()); // Mark it as a bubble and add it explicitly mEntryListener.onPendingEntryAdded(mRow.getEntry()); mBubbleController.updateBubble(mRow.getEntry(), true /* updatePosition */); // We should have bubbles & their notifs should show in the shade assertTrue(mBubbleController.hasBubbles()); assertTrue(mRow.getEntry().showInShadeWhenBubble()); // Expand the stack BubbleStackView stackView = mBubbleController.getStackView(); stackView.expandStack(); assertTrue(mBubbleController.isStackExpanded()); verify(mBubbleExpandListener).onBubbleExpandChanged(true, mRow.getEntry().key); // Make sure it's no longer in the shade assertFalse(mRow.getEntry().showInShadeWhenBubble()); // Collapse stackView.collapseStack(); verify(mBubbleExpandListener).onBubbleExpandChanged(false, mRow.getEntry().key); assertFalse(mBubbleController.isStackExpanded()); } @Test public void testCollapseStack() { public void testCollapseAfterChangingExpandedBubble() { // Mark it as a bubble and add it explicitly mEntryListener.onPendingEntryAdded(mRow.getEntry()); mEntryListener.onPendingEntryAdded(mRow2.getEntry()); mBubbleController.updateBubble(mRow.getEntry(), true /* updatePosition */); mBubbleController.updateBubble(mRow2.getEntry(), true /* updatePosition */); // We should have bubbles & their notifs should show in the shade assertTrue(mBubbleController.hasBubbles()); assertTrue(mRow.getEntry().showInShadeWhenBubble()); assertTrue(mRow2.getEntry().showInShadeWhenBubble()); // Expand BubbleStackView stackView = mBubbleController.getStackView(); stackView.expandStack(); assertTrue(mBubbleController.isStackExpanded()); verify(mBubbleExpandListener).onBubbleExpandChanged(true, mRow2.getEntry().key); // Last added is the one that is expanded assertEquals(mRow2.getEntry(), stackView.getExpandedBubble().getEntry()); assertFalse(mRow2.getEntry().showInShadeWhenBubble()); // Switch which bubble is expanded stackView.setExpandedBubble(mRow.getEntry()); assertEquals(stackView.getExpandedBubble().getEntry(), mRow.getEntry()); assertEquals(mRow.getEntry(), stackView.getExpandedBubble().getEntry()); assertFalse(mRow.getEntry().showInShadeWhenBubble()); stackView.setExpandedBubble(mRow2.getEntry()); assertEquals(stackView.getExpandedBubble().getEntry(), mRow2.getEntry()); // collapse for previous bubble verify(mBubbleExpandListener).onBubbleExpandChanged(false, mRow2.getEntry().key); // expand for selected bubble verify(mBubbleExpandListener).onBubbleExpandChanged(true, mRow.getEntry().key); // Collapse mBubbleController.collapseStack(); assertFalse(mBubbleController.isStackExpanded()); } @Test public void testExpansionRemovesShowInShade() { // Mark it as a bubble and add it explicitly mEntryListener.onPendingEntryAdded(mRow.getEntry()); mBubbleController.updateBubble(mRow.getEntry(), true /* updatePosition */); // We should have bubbles & their notifs should show in the shade assertTrue(mBubbleController.hasBubbles()); assertTrue(mRow.getEntry().showInShadeWhenBubble()); // Expand BubbleStackView stackView = mBubbleController.getStackView(); stackView.expandStack(); assertTrue(mBubbleController.isStackExpanded()); verify(mBubbleExpandListener).onBubbleExpandChanged(true, mRow.getEntry().key); // No longer show shade in notif after expansion assertFalse(mRow.getEntry().showInShadeWhenBubble()); } @Test public void testRemoveLastExpandedCollapses() { // Mark it as a bubble and add it explicitly mEntryListener.onPendingEntryAdded(mRow.getEntry()); mEntryListener.onPendingEntryAdded(mRow2.getEntry()); mBubbleController.updateBubble(mRow.getEntry(), true /* updatePosition */); mBubbleController.updateBubble(mRow2.getEntry(), true /* updatePosition */); verify(mBubbleStateChangeListener).onHasBubblesChanged(true); // Expand BubbleStackView stackView = mBubbleController.getStackView(); stackView.expandStack(); assertTrue(mBubbleController.isStackExpanded()); verify(mBubbleExpandListener).onBubbleExpandChanged(true, mRow2.getEntry().key); // Last added is the one that is expanded assertEquals(mRow2.getEntry(), stackView.getExpandedBubble().getEntry()); assertFalse(mRow2.getEntry().showInShadeWhenBubble()); // Dismiss currently expanded mBubbleController.removeBubble(stackView.getExpandedBubble().getKey()); verify(mBubbleExpandListener).onBubbleExpandChanged(false, mRow2.getEntry().key); // Make sure next bubble is selected assertEquals(mRow.getEntry(), stackView.getExpandedBubble().getEntry()); verify(mBubbleExpandListener).onBubbleExpandChanged(true, mRow.getEntry().key); // Dismiss that one mBubbleController.removeBubble(stackView.getExpandedBubble().getKey()); // Make sure state changes and collapse happens verify(mBubbleExpandListener).onBubbleExpandChanged(false, mRow.getEntry().key); verify(mBubbleStateChangeListener).onHasBubblesChanged(false); assertFalse(mBubbleController.hasBubbles()); } @Test public void testMarkNewNotificationAsBubble() { mEntryListener.onPendingEntryAdded(mRow.getEntry()); Loading