Merge "Fix the gold highlight encircles the app badge in the bubble." into rvc-dev am: c6bc7086e6 am: b2d3b2188d

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11875619

Change-Id: I5fa94948b0bd0875b5c4c0a51910a2e0bce787d4
This commit is contained in:
Santhosh Thangaraj
2020-06-18 00:57:34 +00:00
committed by Automerger Merge Worker
2 changed files with 34 additions and 7 deletions

View File

@@ -23,6 +23,8 @@ import android.content.pm.LauncherApps;
import android.content.pm.ShortcutInfo; import android.content.pm.ShortcutInfo;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.graphics.drawable.Icon; import android.graphics.drawable.Icon;
@@ -76,15 +78,37 @@ public class BubbleIconFactory extends BaseIconFactory {
* Returns a {@link BitmapInfo} for the app-badge that is shown on top of each bubble. This * Returns a {@link BitmapInfo} for the app-badge that is shown on top of each bubble. This
* will include the workprofile indicator on the badge if appropriate. * will include the workprofile indicator on the badge if appropriate.
*/ */
BitmapInfo getBadgeBitmap(Drawable userBadgedAppIcon) { BitmapInfo getBadgeBitmap(Drawable userBadgedAppIcon, boolean isImportantConversation) {
Bitmap userBadgedBitmap = createIconBitmap( Bitmap userBadgedBitmap = createIconBitmap(
userBadgedAppIcon, 1f, getBadgeSize()); userBadgedAppIcon, 1f, getBadgeSize());
Canvas c = new Canvas();
ShadowGenerator shadowGenerator = new ShadowGenerator(getBadgeSize()); ShadowGenerator shadowGenerator = new ShadowGenerator(getBadgeSize());
c.setBitmap(userBadgedBitmap); if (!isImportantConversation) {
shadowGenerator.recreateIcon(Bitmap.createBitmap(userBadgedBitmap), c); Canvas c = new Canvas();
return createIconBitmap(userBadgedBitmap); c.setBitmap(userBadgedBitmap);
shadowGenerator.recreateIcon(Bitmap.createBitmap(userBadgedBitmap), c);
return createIconBitmap(userBadgedBitmap);
} else {
float ringStrokeWidth = mContext.getResources().getDimensionPixelSize(
com.android.internal.R.dimen.importance_ring_stroke_width);
int importantConversationColor = mContext.getResources().getColor(
com.android.settingslib.R.color.important_conversation, null);
Bitmap badgeAndRing = Bitmap.createBitmap(userBadgedBitmap.getWidth(),
userBadgedBitmap.getHeight(), userBadgedBitmap.getConfig());
Canvas c = new Canvas(badgeAndRing);
Rect dest = new Rect((int) ringStrokeWidth, (int) ringStrokeWidth,
c.getHeight() - (int) ringStrokeWidth, c.getWidth() - (int) ringStrokeWidth);
c.drawBitmap(userBadgedBitmap, null, dest, 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);
}
} }
/** /**

View File

@@ -176,7 +176,10 @@ public class BubbleViewInfoTask extends AsyncTask<Void, Void, BubbleViewInfoTask
bubbleDrawable = appIcon; bubbleDrawable = appIcon;
} }
BitmapInfo badgeBitmapInfo = iconFactory.getBadgeBitmap(badgedIcon); boolean isImportantConversation = (entry == null || entry.getChannel() == null) ? false
: entry.getChannel().isImportantConversation();
BitmapInfo badgeBitmapInfo = iconFactory.getBadgeBitmap(badgedIcon,
isImportantConversation);
info.badgedAppIcon = badgedIcon; info.badgedAppIcon = badgedIcon;
info.badgedBubbleImage = iconFactory.getBubbleBitmap(bubbleDrawable, info.badgedBubbleImage = iconFactory.getBubbleBitmap(bubbleDrawable,
badgeBitmapInfo).icon; badgeBitmapInfo).icon;