Update scrim controller to bubble state when bubbles are expanded
There's one issue with this where if you expand status bar
on top of the expanded bubble there is no scrim in between.
Test: manual / existing tests pass (atest SystemUITests)
Bug: 111236845
Change-Id: I2510758366999131ac7ffbb7505026727f4e40e1
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java
index ddb8166..e868f96 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java
@@ -60,6 +60,7 @@
private Context mContext;
private BubbleDismissListener mDismissListener;
private BubbleStateChangeListener mStateChangeListener;
+ private BubbleExpandListener mExpandListener;
private Map<String, BubbleView> mBubbles = new HashMap<>();
private BubbleStackView mStackView;
@@ -96,6 +97,19 @@
void onHasBubblesChanged(boolean hasBubbles);
}
+ /**
+ * Listener to find out about stack expansion / collapse events.
+ */
+ public interface BubbleExpandListener {
+ /**
+ * Called when the expansion state of the bubble stack changes.
+ *
+ * @param isExpanding whether it's expanding or collapsing
+ * @param amount fraction of how expanded or collapsed it is, 1 being fully, 0 at the start
+ */
+ void onBubbleExpandChanged(boolean isExpanding, float amount);
+ }
+
public BubbleController(Context context) {
mContext = context;
WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
@@ -119,6 +133,16 @@
}
/**
+ * Set a listener to be notified of bubble expand events.
+ */
+ public void setExpandListener(BubbleExpandListener listener) {
+ mExpandListener = listener;
+ if (mStackView != null) {
+ mStackView.setExpandListener(mExpandListener);
+ }
+ }
+
+ /**
* Whether or not there are bubbles present, regardless of them being visible on the
* screen (e.g. if on AOD).
*/
@@ -185,6 +209,9 @@
int bubblePosition = sbv.indexOfChild(sbv.findViewById(R.id.scrim_behind)) + 1;
sbv.addView(mStackView, bubblePosition,
new FrameLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT));
+ if (mExpandListener != null) {
+ mStackView.setExpandListener(mExpandListener);
+ }
}
mStackView.addBubble(bubble);
if (setPosition) {
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java
index b6a8a08..365dbda 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java
@@ -61,6 +61,7 @@
private BubbleView mExpandedBubble;
private Point mCollapsedPosition;
private BubbleTouchHandler mTouchHandler;
+ private BubbleController.BubbleExpandListener mExpandListener;
private boolean mViewUpdatedRequested = false;
private boolean mIsAnimating = false;
@@ -176,6 +177,13 @@
}
/**
+ * Sets the listener to notify when the bubble stack is expanded.
+ */
+ public void setExpandListener(BubbleController.BubbleExpandListener listener) {
+ mExpandListener = listener;
+ }
+
+ /**
* Whether the stack of bubbles is expanded or not.
*/
public boolean isExpanded() {
@@ -225,6 +233,9 @@
}
mIsExpanded = wasExpanded && mBubbleContainer.getChildCount() > 0;
requestUpdate();
+ if (wasExpanded && !mIsExpanded && mExpandListener != null) {
+ mExpandListener.onBubbleExpandChanged(mIsExpanded, 1 /* amount */);
+ }
}
/**
@@ -275,6 +286,9 @@
mExpandedBubble = shouldExpand ? getTopBubble() : null;
updateExpandedBubble();
+ if (mExpandListener != null) {
+ mExpandListener.onBubbleExpandChanged(mIsExpanded, 1 /* amount */);
+ }
if (shouldExpand) {
// Save current position so that we might return there
savePosition();