summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java39
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleData.java29
2 files changed, 64 insertions, 4 deletions
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java
index da8eb479a77b..6aba5132e740 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java
@@ -1052,7 +1052,27 @@ public class BubbleController implements ConfigurationChangeListener,
* Expands and selects the provided bubble as long as it already exists in the stack or the
* overflow.
*
- * This is currently only used when opening a bubble via clicking on a conversation widget.
+ * This is used by external callers (launcher).
+ */
+ public void expandStackAndSelectBubbleFromLauncher(String key) {
+ Bubble b = mBubbleData.getAnyBubbleWithkey(key);
+ if (b == null) {
+ return;
+ }
+ if (mBubbleData.hasBubbleInStackWithKey(b.getKey())) {
+ // already in the stack
+ mBubbleData.setSelectedBubbleFromLauncher(b);
+ mLayerView.showExpandedView(b);
+ } else if (mBubbleData.hasOverflowBubbleWithKey(b.getKey())) {
+ // TODO: (b/271468319) handle overflow
+ } else {
+ Log.w(TAG, "didn't add bubble from launcher: " + key);
+ }
+ }
+
+ /**
+ * Expands and selects the provided bubble as long as it already exists in the stack or the
+ * overflow. This is currently used when opening a bubble via clicking on a conversation widget.
*/
public void expandStackAndSelectBubble(Bubble b) {
if (b == null) {
@@ -1703,6 +1723,14 @@ public class BubbleController implements ConfigurationChangeListener,
// Update the cached state for queries from SysUI
mImpl.mCachedState.update(update);
+
+ if (isShowingAsBubbleBar() && mBubbleStateListener != null) {
+ BubbleBarUpdate bubbleBarUpdate = update.toBubbleBarUpdate();
+ // Some updates aren't relevant to the bubble bar so check first.
+ if (bubbleBarUpdate.anythingChanged()) {
+ mBubbleStateListener.onBubbleStateChange(bubbleBarUpdate);
+ }
+ }
}
};
@@ -1972,17 +2000,20 @@ public class BubbleController implements ConfigurationChangeListener,
@Override
public void showBubble(String key, boolean onLauncherHome) {
- // TODO
+ mMainExecutor.execute(() -> {
+ mBubblePositioner.setShowingInBubbleBar(onLauncherHome);
+ mController.expandStackAndSelectBubbleFromLauncher(key);
+ });
}
@Override
public void removeBubble(String key, int reason) {
- // TODO
+ // TODO (b/271466616) allow removals from launcher
}
@Override
public void collapseBubbles() {
- // TODO
+ mMainExecutor.execute(() -> mController.collapseStack());
}
@Override
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleData.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleData.java
index a26c0c487d19..f9cf9d34ec31 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleData.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleData.java
@@ -334,6 +334,35 @@ public class BubbleData {
dispatchPendingChanges();
}
+ /**
+ * Sets the selected bubble and expands it, but doesn't dispatch changes
+ * to {@link BubbleData.Listener}. This is used for updates coming from launcher whose views
+ * will already be updated so we don't need to notify them again, but BubbleData should be
+ * updated to have the correct state.
+ */
+ public void setSelectedBubbleFromLauncher(BubbleViewProvider bubble) {
+ if (DEBUG_BUBBLE_DATA) {
+ Log.d(TAG, "setSelectedBubbleFromLauncher: " + bubble);
+ }
+ mExpanded = true;
+ if (Objects.equals(bubble, mSelectedBubble)) {
+ return;
+ }
+ boolean isOverflow = bubble != null && BubbleOverflow.KEY.equals(bubble.getKey());
+ if (bubble != null
+ && !mBubbles.contains(bubble)
+ && !mOverflowBubbles.contains(bubble)
+ && !isOverflow) {
+ Log.e(TAG, "Cannot select bubble which doesn't exist!"
+ + " (" + bubble + ") bubbles=" + mBubbles);
+ return;
+ }
+ if (bubble != null && !isOverflow) {
+ ((Bubble) bubble).markAsAccessedAt(mTimeSource.currentTimeMillis());
+ }
+ mSelectedBubble = bubble;
+ }
+
public void setSelectedBubble(BubbleViewProvider bubble) {
if (DEBUG_BUBBLE_DATA) {
Log.d(TAG, "setSelectedBubble: " + bubble);