Handle any image / label changes for bubble updates in bubble bar am: 1812924a53

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/24010038

Change-Id: Ib7d204f2bd06f8474613b134d25e9ff08e32c74d
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Mady Mellor
2023-07-12 01:17:25 +00:00
committed by Automerger Merge Worker
2 changed files with 37 additions and 21 deletions
@@ -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<BubbleBarBubble> 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) {
@@ -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)