Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1812924a authored by Mady Mellor's avatar Mady Mellor
Browse files

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
parent 3e952e03
Loading
Loading
Loading
Loading
+28 −12
Original line number Diff line number Diff line
@@ -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,8 +481,9 @@ 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);

        if (existingBubble == null) {
            LayoutInflater inflater = LayoutInflater.from(context);
            BubbleView bubbleView = (BubbleView) inflater.inflate(
                    R.layout.bubblebar_item_view, bbv, false /* attachToRoot */);
@@ -486,6 +492,16 @@ public class BubbleBarController extends IBubblesListener.Stub {
                    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) {
+9 −9
Original line number Diff line number Diff line
@@ -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)