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

Commit ae6e4330 authored by Mady Mellor's avatar Mady Mellor Committed by Android (Google) Code Review
Browse files

Merge "Add the priority person highlight back to bubbles badge" into sc-dev

parents df2e7b88 1f6d6d5d
Loading
Loading
Loading
Loading
+9 −8
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
 */
package com.android.wm.shell.bubbles;

import static android.graphics.Paint.ANTI_ALIAS_FLAG;
import static android.graphics.Paint.DITHER_FLAG;
import static android.graphics.Paint.FILTER_BITMAP_FLAG;

@@ -22,10 +23,10 @@ import android.annotation.Nullable;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.PaintFlagsDrawFilter;
import android.graphics.Path;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.util.PathParser;
import android.widget.ImageView;
@@ -75,13 +76,13 @@ public class BadgedImageView extends ImageView {

    private BubbleViewProvider mBubble;
    private BubblePositioner mPositioner;
    private boolean mOnLeft;

    private DotRenderer mDotRenderer;
    private DotRenderer.DrawParams mDrawParams;
    private boolean mOnLeft;

    private int mDotColor;

    private Paint mPaint = new Paint(ANTI_ALIAS_FLAG);
    private Rect mTempBounds = new Rect();

    public BadgedImageView(Context context) {
@@ -305,7 +306,7 @@ public class BadgedImageView extends ImageView {
    }

    void showBadge() {
        Drawable badge = mBubble.getAppBadge();
        Bitmap badge = mBubble.getAppBadge();
        if (badge == null) {
            setImageBitmap(mBubble.getBubbleIcon());
            return;
@@ -318,13 +319,13 @@ public class BadgedImageView extends ImageView {
        bubbleCanvas.setBitmap(bubble);
        final int bubbleSize = bubble.getWidth();
        final int badgeSize = (int) (ICON_BADGE_SCALE * bubbleSize);
        Rect dest = new Rect();
        if (mOnLeft) {
            badge.setBounds(0, bubbleSize - badgeSize, badgeSize, bubbleSize);
            dest.set(0, bubbleSize - badgeSize, badgeSize, bubbleSize);
        } else {
            badge.setBounds(bubbleSize - badgeSize, bubbleSize - badgeSize,
                    bubbleSize, bubbleSize);
            dest.set(bubbleSize - badgeSize, bubbleSize - badgeSize, bubbleSize, bubbleSize);
        }
        badge.draw(bubbleCanvas);
        bubbleCanvas.drawBitmap(badge, null /* src */, dest, mPaint);
        bubbleCanvas.setBitmap(null);
        setImageBitmap(bubble);
    }
+6 −5
Original line number Diff line number Diff line
@@ -104,9 +104,10 @@ public class Bubble implements BubbleViewProvider {
    }

    private FlyoutMessage mFlyoutMessage;
    private Drawable mBadgeDrawable;
    // Bitmap with no badge, no dot
    // The developer provided image for the bubble
    private Bitmap mBubbleBitmap;
    // The app badge for the bubble
    private Bitmap mBadgeBitmap;
    private int mDotColor;
    private Path mDotPath;
    private int mFlags;
@@ -242,8 +243,8 @@ public class Bubble implements BubbleViewProvider {
    }

    @Override
    public Drawable getAppBadge() {
        return mBadgeDrawable;
    public Bitmap getAppBadge() {
        return mBadgeBitmap;
    }

    @Override
@@ -398,7 +399,7 @@ public class Bubble implements BubbleViewProvider {
        mAppName = info.appName;
        mFlyoutMessage = info.flyoutMessage;

        mBadgeDrawable = info.badgeDrawable;
        mBadgeBitmap = info.badgeBitmap;
        mBubbleBitmap = info.bubbleBitmap;

        mDotColor = info.dotColor;
+6 −8
Original line number Diff line number Diff line
@@ -101,6 +101,12 @@ public class BubbleIconFactory extends BaseIconFactory {
                    userBadgedBitmap.getHeight(), userBadgedBitmap.getConfig());
            Canvas c = new Canvas(badgeAndRing);

            Paint ringPaint = new Paint();
            ringPaint.setStyle(Paint.Style.FILL);
            ringPaint.setColor(importantConversationColor);
            ringPaint.setAntiAlias(true);
            c.drawCircle(c.getWidth() / 2, c.getHeight() / 2, c.getWidth() / 2, ringPaint);

            final int bitmapTop = (int) ringStrokeWidth;
            final int bitmapLeft = (int) ringStrokeWidth;
            final int bitmapWidth = c.getWidth() - 2 * (int) ringStrokeWidth;
@@ -110,14 +116,6 @@ public class BubbleIconFactory extends BaseIconFactory {
                    bitmapHeight, /* filter */ true);
            c.drawBitmap(scaledBitmap, bitmapTop, bitmapLeft, /* paint */null);

            Paint ringPaint = new Paint();
            ringPaint.setStyle(Paint.Style.STROKE);
            ringPaint.setColor(importantConversationColor);
            ringPaint.setAntiAlias(true);
            ringPaint.setStrokeWidth(ringStrokeWidth);
            c.drawCircle(c.getWidth() / 2, c.getHeight() / 2, c.getWidth() / 2 - ringStrokeWidth,
                    ringPaint);

            shadowGenerator.recreateIcon(Bitmap.createBitmap(badgeAndRing), c);
            return createIconBitmap(badgeAndRing);
        } else {
+1 −2
Original line number Diff line number Diff line
@@ -24,7 +24,6 @@ import android.graphics.Matrix
import android.graphics.Path
import android.graphics.drawable.AdaptiveIconDrawable
import android.graphics.drawable.ColorDrawable
import android.graphics.drawable.Drawable
import android.graphics.drawable.InsetDrawable
import android.util.PathParser
import android.util.TypedValue
@@ -151,7 +150,7 @@ class BubbleOverflow(
        return dotColor
    }

    override fun getAppBadge(): Drawable? {
    override fun getAppBadge(): Bitmap? {
        return null
    }

+1 −1
Original line number Diff line number Diff line
@@ -2487,7 +2487,7 @@ public class BubbleStackView extends FrameLayout
        // name and icon.
        if (show && mBubbleData.hasBubbleInStackWithKey(mExpandedBubble.getKey())) {
            final Bubble bubble = mBubbleData.getBubbleInStackWithKey(mExpandedBubble.getKey());
            mManageSettingsIcon.setImageDrawable(bubble.getAppBadge());
            mManageSettingsIcon.setImageBitmap(bubble.getAppBadge());
            mManageSettingsText.setText(getResources().getString(
                    R.string.bubbles_app_settings, bubble.getAppName()));
        }
Loading