Merge "Hit back button in overflow to collapse stack" into rvc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
17d4f35326
@@ -279,7 +279,8 @@ class Bubble implements BubbleViewProvider {
|
||||
/**
|
||||
* @return the display id of the virtual display on which bubble contents is drawn.
|
||||
*/
|
||||
int getDisplayId() {
|
||||
@Override
|
||||
public int getDisplayId() {
|
||||
return mExpandedView != null ? mExpandedView.getVirtualDisplayId() : INVALID_DISPLAY;
|
||||
}
|
||||
|
||||
|
||||
@@ -1175,23 +1175,17 @@ public class BubbleController implements ConfigurationController.ConfigurationLi
|
||||
* status bar, otherwise returns {@link Display#INVALID_DISPLAY}.
|
||||
*/
|
||||
public int getExpandedDisplayId(Context context) {
|
||||
final Bubble bubble = getExpandedBubble(context);
|
||||
return bubble != null ? bubble.getDisplayId() : INVALID_DISPLAY;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Bubble getExpandedBubble(Context context) {
|
||||
if (mStackView == null) {
|
||||
return null;
|
||||
return INVALID_DISPLAY;
|
||||
}
|
||||
final boolean defaultDisplay = context.getDisplay() != null
|
||||
&& context.getDisplay().getDisplayId() == DEFAULT_DISPLAY;
|
||||
final Bubble expandedBubble = mStackView.getExpandedBubble();
|
||||
if (defaultDisplay && expandedBubble != null && isStackExpanded()
|
||||
final BubbleViewProvider expandedViewProvider = mStackView.getExpandedBubble();
|
||||
if (defaultDisplay && expandedViewProvider != null && isStackExpanded()
|
||||
&& !mNotificationShadeWindowController.getPanelExpanded()) {
|
||||
return expandedBubble;
|
||||
return expandedViewProvider.getDisplayId();
|
||||
}
|
||||
return null;
|
||||
return INVALID_DISPLAY;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
@@ -1256,7 +1250,7 @@ public class BubbleController implements ConfigurationController.ConfigurationLi
|
||||
|
||||
@Override
|
||||
public void onSingleTaskDisplayEmpty(int displayId) {
|
||||
final Bubble expandedBubble = mStackView != null
|
||||
final BubbleViewProvider expandedBubble = mStackView != null
|
||||
? mStackView.getExpandedBubble()
|
||||
: null;
|
||||
int expandedId = expandedBubble != null ? expandedBubble.getDisplayId() : -1;
|
||||
|
||||
@@ -59,13 +59,15 @@ public class BubbleDebugConfig {
|
||||
return FORCE_SHOW_USER_EDUCATION || forceShow;
|
||||
}
|
||||
|
||||
static String formatBubblesString(List<Bubble> bubbles, Bubble selected) {
|
||||
static String formatBubblesString(List<Bubble> bubbles, BubbleViewProvider selected) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (Bubble bubble : bubbles) {
|
||||
if (bubble == null) {
|
||||
sb.append(" <null> !!!!!\n");
|
||||
} else {
|
||||
boolean isSelected = (selected != null && bubble == selected);
|
||||
boolean isSelected = (selected != null
|
||||
&& selected.getKey() != BubbleOverflow.KEY
|
||||
&& bubble == selected);
|
||||
String arrow = isSelected ? "=>" : " ";
|
||||
sb.append(String.format("%s Bubble{act=%12d, ongoing=%d, key=%s}\n",
|
||||
arrow,
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.android.systemui.bubbles;
|
||||
|
||||
import static android.view.Display.INVALID_DISPLAY;
|
||||
import static android.view.View.GONE;
|
||||
|
||||
import static com.android.systemui.bubbles.BadgedImageView.DEFAULT_PATH_SIZE;
|
||||
@@ -45,7 +46,7 @@ public class BubbleOverflow implements BubbleViewProvider {
|
||||
public static final String KEY = "Overflow";
|
||||
|
||||
private BadgedImageView mOverflowBtn;
|
||||
private BubbleExpandedView mOverflowExpandedView;
|
||||
private BubbleExpandedView mExpandedView;
|
||||
private LayoutInflater mInflater;
|
||||
private Context mContext;
|
||||
private Bitmap mIcon;
|
||||
@@ -63,11 +64,11 @@ public class BubbleOverflow implements BubbleViewProvider {
|
||||
}
|
||||
|
||||
void setUpOverflow(ViewGroup parentViewGroup, BubbleStackView stackView) {
|
||||
mOverflowExpandedView = (BubbleExpandedView) mInflater.inflate(
|
||||
mExpandedView = (BubbleExpandedView) mInflater.inflate(
|
||||
R.layout.bubble_expanded_view, parentViewGroup /* root */,
|
||||
false /* attachToRoot */);
|
||||
mOverflowExpandedView.setOverflow(true);
|
||||
mOverflowExpandedView.setStackView(stackView);
|
||||
mExpandedView.setOverflow(true);
|
||||
mExpandedView.setStackView(stackView);
|
||||
|
||||
updateIcon(mContext, parentViewGroup);
|
||||
}
|
||||
@@ -124,7 +125,7 @@ public class BubbleOverflow implements BubbleViewProvider {
|
||||
|
||||
@Override
|
||||
public BubbleExpandedView getExpandedView() {
|
||||
return mOverflowExpandedView;
|
||||
return mExpandedView;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -149,7 +150,7 @@ public class BubbleOverflow implements BubbleViewProvider {
|
||||
|
||||
@Override
|
||||
public void setContentVisibility(boolean visible) {
|
||||
mOverflowExpandedView.setContentVisibility(visible);
|
||||
mExpandedView.setContentVisibility(visible);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -167,4 +168,9 @@ public class BubbleOverflow implements BubbleViewProvider {
|
||||
public String getKey() {
|
||||
return BubbleOverflow.KEY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDisplayId() {
|
||||
return mExpandedView != null ? mExpandedView.getVirtualDisplayId() : INVALID_DISPLAY;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -908,14 +908,8 @@ public class BubbleStackView extends FrameLayout {
|
||||
* The {@link Bubble} that is expanded, null if one does not exist.
|
||||
*/
|
||||
@Nullable
|
||||
Bubble getExpandedBubble() {
|
||||
if (mExpandedBubble == null
|
||||
|| (BubbleExperimentConfig.allowBubbleOverflow(mContext)
|
||||
&& mExpandedBubble.getIconView() == mBubbleOverflow.getBtn()
|
||||
&& BubbleOverflow.KEY.equals(mExpandedBubble.getKey()))) {
|
||||
return null;
|
||||
}
|
||||
return (Bubble) mExpandedBubble;
|
||||
BubbleViewProvider getExpandedBubble() {
|
||||
return mExpandedBubble;
|
||||
}
|
||||
|
||||
// via BubbleData.Listener
|
||||
@@ -1288,7 +1282,7 @@ public class BubbleStackView extends FrameLayout {
|
||||
if (DEBUG_BUBBLE_STACK_VIEW) {
|
||||
Log.d(TAG, "animateCollapse");
|
||||
Log.d(TAG, BubbleDebugConfig.formatBubblesString(getBubblesOnScreen(),
|
||||
getExpandedBubble()));
|
||||
mExpandedBubble));
|
||||
}
|
||||
updateOverflowBtnVisibility(/* apply */ false);
|
||||
mBubbleContainer.cancelAllAnimations();
|
||||
@@ -1862,17 +1856,16 @@ public class BubbleStackView extends FrameLayout {
|
||||
}
|
||||
|
||||
private void updatePointerPosition() {
|
||||
Bubble expandedBubble = getExpandedBubble();
|
||||
if (expandedBubble == null) {
|
||||
if (mExpandedBubble == null) {
|
||||
return;
|
||||
}
|
||||
int index = getBubbleIndex(expandedBubble);
|
||||
int index = getBubbleIndex(mExpandedBubble);
|
||||
float bubbleLeftFromScreenLeft = mExpandedAnimationController.getBubbleLeft(index);
|
||||
float halfBubble = mBubbleSize / 2f;
|
||||
float bubbleCenter = bubbleLeftFromScreenLeft + halfBubble;
|
||||
// Padding might be adjusted for insets, so get it directly from the view
|
||||
bubbleCenter -= mExpandedViewContainer.getPaddingLeft();
|
||||
expandedBubble.getExpandedView().setPointerPosition(bubbleCenter);
|
||||
mExpandedBubble.getExpandedView().setPointerPosition(bubbleCenter);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1894,11 +1887,10 @@ public class BubbleStackView extends FrameLayout {
|
||||
* is between 0 and the bubble count minus 1.
|
||||
*/
|
||||
int getBubbleIndex(@Nullable BubbleViewProvider provider) {
|
||||
if (provider == null || provider.getKey() == BubbleOverflow.KEY) {
|
||||
if (provider == null) {
|
||||
return 0;
|
||||
}
|
||||
Bubble b = (Bubble) provider;
|
||||
return mBubbleContainer.indexOfChild(b.getIconView());
|
||||
return mBubbleContainer.indexOfChild(provider.getIconView());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -41,4 +41,6 @@ interface BubbleViewProvider {
|
||||
Path getDotPath();
|
||||
|
||||
boolean showDot();
|
||||
|
||||
int getDisplayId();
|
||||
}
|
||||
|
||||
@@ -399,7 +399,8 @@ public class BubbleControllerTest extends SysuiTestCase {
|
||||
// Switch which bubble is expanded
|
||||
mBubbleController.selectBubble(mRow.getEntry().getKey());
|
||||
mBubbleData.setExpanded(true);
|
||||
assertEquals(mRow.getEntry(), stackView.getExpandedBubble().getEntry());
|
||||
assertEquals(mRow.getEntry(),
|
||||
mBubbleData.getBubbleWithKey(stackView.getExpandedBubble().getKey()).getEntry());
|
||||
assertTrue(mBubbleController.isBubbleNotificationSuppressedFromShade(
|
||||
mRow.getEntry()));
|
||||
|
||||
@@ -492,21 +493,25 @@ public class BubbleControllerTest extends SysuiTestCase {
|
||||
verify(mBubbleExpandListener).onBubbleExpandChanged(true, mRow2.getEntry().getKey());
|
||||
|
||||
// Last added is the one that is expanded
|
||||
assertEquals(mRow2.getEntry(), stackView.getExpandedBubble().getEntry());
|
||||
assertEquals(mRow2.getEntry(),
|
||||
mBubbleData.getBubbleWithKey(stackView.getExpandedBubble().getKey()).getEntry());
|
||||
assertTrue(mBubbleController.isBubbleNotificationSuppressedFromShade(
|
||||
mRow2.getEntry()));
|
||||
|
||||
// Dismiss currently expanded
|
||||
mBubbleController.removeBubble(stackView.getExpandedBubble().getEntry(),
|
||||
mBubbleController.removeBubble(
|
||||
mBubbleData.getBubbleWithKey(stackView.getExpandedBubble().getKey()).getEntry(),
|
||||
BubbleController.DISMISS_USER_GESTURE);
|
||||
verify(mBubbleExpandListener).onBubbleExpandChanged(false, mRow2.getEntry().getKey());
|
||||
|
||||
// Make sure first bubble is selected
|
||||
assertEquals(mRow.getEntry(), stackView.getExpandedBubble().getEntry());
|
||||
assertEquals(mRow.getEntry(),
|
||||
mBubbleData.getBubbleWithKey(stackView.getExpandedBubble().getKey()).getEntry());
|
||||
verify(mBubbleExpandListener).onBubbleExpandChanged(true, mRow.getEntry().getKey());
|
||||
|
||||
// Dismiss that one
|
||||
mBubbleController.removeBubble(stackView.getExpandedBubble().getEntry(),
|
||||
mBubbleController.removeBubble(
|
||||
mBubbleData.getBubbleWithKey(stackView.getExpandedBubble().getKey()).getEntry(),
|
||||
BubbleController.DISMISS_USER_GESTURE);
|
||||
|
||||
// Make sure state changes and collapse happens
|
||||
|
||||
@@ -130,19 +130,15 @@ public class NewNotifPipelineBubbleControllerTest extends SysuiTestCase {
|
||||
private KeyguardBypassController mKeyguardBypassController;
|
||||
@Mock
|
||||
private FloatingContentCoordinator mFloatingContentCoordinator;
|
||||
|
||||
@Captor
|
||||
private ArgumentCaptor<NotifCollectionListener> mNotifListenerCaptor;
|
||||
|
||||
private TestableBubbleController mBubbleController;
|
||||
private NotificationShadeWindowController mNotificationShadeWindowController;
|
||||
private NotifCollectionListener mEntryListener;
|
||||
|
||||
private NotificationTestHelper mNotificationTestHelper;
|
||||
private ExpandableNotificationRow mRow;
|
||||
private ExpandableNotificationRow mRow2;
|
||||
private ExpandableNotificationRow mNonBubbleNotifRow;
|
||||
|
||||
@Mock
|
||||
private BubbleController.BubbleStateChangeListener mBubbleStateChangeListener;
|
||||
@Mock
|
||||
@@ -309,7 +305,7 @@ public class NewNotifPipelineBubbleControllerTest extends SysuiTestCase {
|
||||
verify(mNotifCallback, times(1)).invalidateNotifications(anyString());
|
||||
assertNotNull(mBubbleData.getBubbleWithKey(mRow.getEntry().getKey()));
|
||||
mBubbleController.updateBubble(mRow2.getEntry());
|
||||
verify(mNotifCallback, times(2)).invalidateNotifications(anyString());
|
||||
verify(mNotifCallback, times(2)).invalidateNotifications(anyString());
|
||||
assertNotNull(mBubbleData.getBubbleWithKey(mRow2.getEntry().getKey()));
|
||||
assertTrue(mBubbleController.hasBubbles());
|
||||
|
||||
@@ -379,7 +375,8 @@ public class NewNotifPipelineBubbleControllerTest extends SysuiTestCase {
|
||||
// Switch which bubble is expanded
|
||||
mBubbleController.selectBubble(mRow.getEntry().getKey());
|
||||
mBubbleData.setExpanded(true);
|
||||
assertEquals(mRow.getEntry(), stackView.getExpandedBubble().getEntry());
|
||||
assertEquals(mRow.getEntry(),
|
||||
mBubbleData.getBubbleWithKey(stackView.getExpandedBubble().getKey()).getEntry());
|
||||
assertTrue(mBubbleController.isBubbleNotificationSuppressedFromShade(
|
||||
mRow.getEntry()));
|
||||
|
||||
@@ -471,21 +468,25 @@ public class NewNotifPipelineBubbleControllerTest extends SysuiTestCase {
|
||||
verify(mBubbleExpandListener).onBubbleExpandChanged(true, mRow2.getEntry().getKey());
|
||||
|
||||
// Last added is the one that is expanded
|
||||
assertEquals(mRow2.getEntry(), stackView.getExpandedBubble().getEntry());
|
||||
assertEquals(mRow2.getEntry(),
|
||||
mBubbleData.getBubbleWithKey(stackView.getExpandedBubble().getKey()).getEntry());
|
||||
assertTrue(mBubbleController.isBubbleNotificationSuppressedFromShade(
|
||||
mRow2.getEntry()));
|
||||
|
||||
// Dismiss currently expanded
|
||||
mBubbleController.removeBubble(stackView.getExpandedBubble().getEntry(),
|
||||
mBubbleController.removeBubble(
|
||||
mBubbleData.getBubbleWithKey(stackView.getExpandedBubble().getKey()).getEntry(),
|
||||
BubbleController.DISMISS_USER_GESTURE);
|
||||
verify(mBubbleExpandListener).onBubbleExpandChanged(false, mRow2.getEntry().getKey());
|
||||
|
||||
// Make sure first bubble is selected
|
||||
assertEquals(mRow.getEntry(), stackView.getExpandedBubble().getEntry());
|
||||
assertEquals(mRow.getEntry(),
|
||||
mBubbleData.getBubbleWithKey(stackView.getExpandedBubble().getKey()).getEntry());
|
||||
verify(mBubbleExpandListener).onBubbleExpandChanged(true, mRow.getEntry().getKey());
|
||||
|
||||
// Dismiss that one
|
||||
mBubbleController.removeBubble(stackView.getExpandedBubble().getEntry(),
|
||||
mBubbleController.removeBubble(
|
||||
mBubbleData.getBubbleWithKey(stackView.getExpandedBubble().getKey()).getEntry(),
|
||||
BubbleController.DISMISS_USER_GESTURE);
|
||||
|
||||
// Make sure state changes and collapse happens
|
||||
@@ -645,7 +646,7 @@ public class NewNotifPipelineBubbleControllerTest extends SysuiTestCase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void removeBubble_intercepted() {
|
||||
public void removeBubble_intercepted() {
|
||||
mEntryListener.onEntryAdded(mRow.getEntry());
|
||||
mBubbleController.updateBubble(mRow.getEntry());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user