Add the priority person highlight back to bubbles badge
In BubbleViewInfo task where the icons are fetched, we were creating
the ringed badge for priority people but we weren't using it. Instead
the original badge drawable was being used.
This switched the app badge to be a bitmap & uses the bitmap with the
priority person ring.
Also fixes an issue where the ring would draw through a badge that
also had the work profile indicator. This is done by drawing the
highlight first and then drawing the badge on top.
Test: manual 1) have a conversation notif that can bubble
2) mark it as priority
=> Observe that the bubble is created and it has the
ringed bitmap
3) dismiss the bubble
=> check that the ring is present on the bubble in the
bubble overflow
4) repeat above steps with a bubble from workprofile,
ensure it has the ring and the workprofile badge
Bug: 185202938
Change-Id: Ief297f073f9684930b3a08fd93e90bbaae3180ca
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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()));
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ public class BubbleViewInfoTask extends AsyncTask<Void, Void, BubbleViewInfoTask
|
||||
ShortcutInfo shortcutInfo;
|
||||
String appName;
|
||||
Bitmap bubbleBitmap;
|
||||
Drawable badgeDrawable;
|
||||
Bitmap badgeBitmap;
|
||||
int dotColor;
|
||||
Path dotPath;
|
||||
Bubble.FlyoutMessage flyoutMessage;
|
||||
@@ -188,7 +188,7 @@ public class BubbleViewInfoTask extends AsyncTask<Void, Void, BubbleViewInfoTask
|
||||
|
||||
BitmapInfo badgeBitmapInfo = iconFactory.getBadgeBitmap(badgedIcon,
|
||||
b.isImportantConversation());
|
||||
info.badgeDrawable = badgedIcon;
|
||||
info.badgeBitmap = badgeBitmapInfo.icon;
|
||||
info.bubbleBitmap = iconFactory.createBadgedIconBitmap(bubbleDrawable,
|
||||
null /* user */,
|
||||
true /* shrinkNonAdaptiveIcons */).icon;
|
||||
|
||||
@@ -18,7 +18,6 @@ package com.android.wm.shell.bubbles;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Path;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
@@ -48,7 +47,7 @@ public interface BubbleViewProvider {
|
||||
Bitmap getBubbleIcon();
|
||||
|
||||
/** App badge drawable to draw above bubble icon. */
|
||||
@Nullable Drawable getAppBadge();
|
||||
@Nullable Bitmap getAppBadge();
|
||||
|
||||
/** Path of normalized bubble icon to draw dot on. */
|
||||
Path getDotPath();
|
||||
|
||||
Reference in New Issue
Block a user