From 1812924a53ca6a14a97025d5291ac57b5127d452 Mon Sep 17 00:00:00 2001 From: Mady Mellor Date: Mon, 10 Jul 2023 13:25:12 -0700 Subject: [PATCH] Handle any image / label changes for bubble updates in bubble bar When we get an update to a bubble it could mean that there's a new message OR that something about the visual representation changed. This CL modifies BubbleBarController to handle any visual changes that might have occurred to an updated bubble (e.g. bubble image changed). It does this by updating the bubbleInfo on the existing bubble. Test: manual Bug: 269670235 Change-Id: I03d2510aef335dafccb32d6adcd4c6adf8b3297d --- .../taskbar/bubbles/BubbleBarController.java | 40 +++++++++++++------ .../taskbar/bubbles/BubbleBarItem.kt | 18 ++++----- 2 files changed, 37 insertions(+), 21 deletions(-) diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarController.java b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarController.java index 056fc74c30..029c23f872 100644 --- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarController.java +++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarController.java @@ -243,17 +243,21 @@ public class BubbleBarController extends IBubblesListener.Stub { BUBBLE_STATE_EXECUTOR.execute(() -> { createAndAddOverflowIfNeeded(); if (update.addedBubble != null) { - viewUpdate.addedBubble = populateBubble(update.addedBubble, mContext, mBarView); + viewUpdate.addedBubble = populateBubble(mContext, update.addedBubble, mBarView, + null /* existingBubble */); } if (update.updatedBubble != null) { + BubbleBarBubble existingBubble = mBubbles.get(update.updatedBubble.getKey()); viewUpdate.updatedBubble = - populateBubble(update.updatedBubble, mContext, mBarView); + populateBubble(mContext, update.updatedBubble, mBarView, + existingBubble); } if (update.currentBubbleList != null && !update.currentBubbleList.isEmpty()) { List currentBubbles = new ArrayList<>(); for (int i = 0; i < update.currentBubbleList.size(); i++) { BubbleBarBubble b = - populateBubble(update.currentBubbleList.get(i), mContext, mBarView); + populateBubble(mContext, update.currentBubbleList.get(i), mBarView, + null /* existingBubble */); currentBubbles.add(b); } viewUpdate.currentBubbles = currentBubbles; @@ -407,7 +411,8 @@ public class BubbleBarController extends IBubblesListener.Stub { // @Nullable - private BubbleBarBubble populateBubble(BubbleInfo b, Context context, BubbleBarView bbv) { + private BubbleBarBubble populateBubble(Context context, BubbleInfo b, BubbleBarView bbv, + @Nullable BubbleBarBubble existingBubble) { String appName; Bitmap badgeBitmap; Bitmap bubbleBitmap; @@ -476,16 +481,27 @@ public class BubbleBarController extends IBubblesListener.Stub { iconPath.transform(matrix); dotPath = iconPath; dotColor = ColorUtils.blendARGB(badgeBitmapInfo.color, - Color.WHITE, WHITE_SCRIM_ALPHA); + Color.WHITE, WHITE_SCRIM_ALPHA / 255f); - LayoutInflater inflater = LayoutInflater.from(context); - BubbleView bubbleView = (BubbleView) inflater.inflate( - R.layout.bubblebar_item_view, bbv, false /* attachToRoot */); + if (existingBubble == null) { + LayoutInflater inflater = LayoutInflater.from(context); + BubbleView bubbleView = (BubbleView) inflater.inflate( + R.layout.bubblebar_item_view, bbv, false /* attachToRoot */); - BubbleBarBubble bubble = new BubbleBarBubble(b, bubbleView, - badgeBitmap, bubbleBitmap, dotColor, dotPath, appName); - bubbleView.setBubble(bubble); - return bubble; + BubbleBarBubble bubble = new BubbleBarBubble(b, bubbleView, + badgeBitmap, bubbleBitmap, dotColor, dotPath, appName); + bubbleView.setBubble(bubble); + return bubble; + } else { + // If we already have a bubble (so it already has an inflated view), update it. + existingBubble.setInfo(b); + existingBubble.setBadge(badgeBitmap); + existingBubble.setIcon(bubbleBitmap); + existingBubble.setDotColor(dotColor); + existingBubble.setDotPath(dotPath); + existingBubble.setAppName(appName); + return existingBubble; + } } private BubbleBarOverflow createOverflow(Context context) { diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarItem.kt b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarItem.kt index 582dcc750f..43e21f4085 100644 --- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarItem.kt +++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarItem.kt @@ -20,18 +20,18 @@ import android.graphics.Path import com.android.wm.shell.common.bubbles.BubbleInfo /** An entity in the bubble bar. */ -sealed class BubbleBarItem(open val key: String, open val view: BubbleView) +sealed class BubbleBarItem(open var key: String, open var view: BubbleView) /** Contains state info about a bubble in the bubble bar as well as presentation information. */ data class BubbleBarBubble( - val info: BubbleInfo, - override val view: BubbleView, - val badge: Bitmap, - val icon: Bitmap, - val dotColor: Int, - val dotPath: Path, - val appName: String + var info: BubbleInfo, + override var view: BubbleView, + var badge: Bitmap, + var icon: Bitmap, + var dotColor: Int, + var dotPath: Path, + var appName: String ) : BubbleBarItem(info.key, view) /** Represents the overflow bubble in the bubble bar. */ -data class BubbleBarOverflow(override val view: BubbleView) : BubbleBarItem("Overflow", view) +data class BubbleBarOverflow(override var view: BubbleView) : BubbleBarItem("Overflow", view)