From c39224ba555c5b93307e778612c46f71dd913c0f Mon Sep 17 00:00:00 2001 From: Santhosh Thangaraj Date: Thu, 18 Jun 2020 10:05:54 -0700 Subject: [PATCH] Fix the gold highlight encircles the app badge in the bubble. In regarding to this change Idbb747dd5a5a9f3e4f4d5ecdcefe080ed5df25bb Details: Submitted this Change Ie899c44dfdbd81ad942c050ccf5ce36561856078 and it broke because entry variable not found. Cause: Change I1180954a76bee9782df46de0f202c614f05d560f removed entry. Not sure how this change was not affected even though it was submitted later. Solution: Anyway, Took those change and applied my fix by adding the separate field in the Bubble.java Bug: 158310637 Test: Manual test on device Change-Id: I5204a85fe4bf573576e8d3272d005a85450dce72 --- .../com/android/systemui/bubbles/Bubble.java | 10 ++++++ .../systemui/bubbles/BubbleIconFactory.java | 35 +++++++++++++++---- .../systemui/bubbles/BubbleViewInfoTask.java | 3 +- 3 files changed, 41 insertions(+), 7 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/Bubble.java b/packages/SystemUI/src/com/android/systemui/bubbles/Bubble.java index 6377b4f0a9c5b..6bb8f68550001 100644 --- a/packages/SystemUI/src/com/android/systemui/bubbles/Bubble.java +++ b/packages/SystemUI/src/com/android/systemui/bubbles/Bubble.java @@ -77,6 +77,7 @@ class Bubble implements BubbleViewProvider { private BubbleViewInfoTask mInflationTask; private boolean mInflateSynchronously; private boolean mPendingIntentCanceled; + private boolean mIsImportantConversation; /** * Presentational info about the flyout. @@ -362,6 +363,8 @@ class Bubble implements BubbleViewProvider { mIntent = entry.getBubbleMetadata().getIntent(); mDeleteIntent = entry.getBubbleMetadata().getDeleteIntent(); } + mIsImportantConversation = + entry.getChannel() == null ? false : entry.getChannel().isImportantConversation(); } @Nullable @@ -431,6 +434,13 @@ class Bubble implements BubbleViewProvider { return !shouldSuppressNotification() || !mIsClearable; } + /** + * Whether this notification conversation is important. + */ + boolean isImportantConversation() { + return mIsImportantConversation; + } + /** * Sets whether this notification should be suppressed in the shade. */ diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleIconFactory.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleIconFactory.java index a799f2d739e5d..40a93e1cdc47f 100644 --- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleIconFactory.java +++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleIconFactory.java @@ -23,6 +23,8 @@ import android.content.pm.LauncherApps; import android.content.pm.ShortcutInfo; import android.graphics.Bitmap; import android.graphics.Canvas; +import android.graphics.Paint; +import android.graphics.Rect; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.graphics.drawable.Icon; @@ -76,15 +78,36 @@ public class BubbleIconFactory extends BaseIconFactory { * 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. */ - BitmapInfo getBadgeBitmap(Drawable userBadgedAppIcon) { + BitmapInfo getBadgeBitmap(Drawable userBadgedAppIcon, boolean isImportantConversation) { Bitmap userBadgedBitmap = createIconBitmap( userBadgedAppIcon, 1f, getBadgeSize()); - - Canvas c = new Canvas(); ShadowGenerator shadowGenerator = new ShadowGenerator(getBadgeSize()); - c.setBitmap(userBadgedBitmap); - shadowGenerator.recreateIcon(Bitmap.createBitmap(userBadgedBitmap), c); - return createIconBitmap(userBadgedBitmap); + if (!isImportantConversation) { + Canvas c = new Canvas(); + 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); + } } /** diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleViewInfoTask.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleViewInfoTask.java index 3e4ff5262bbdf..1929fc4e9dbfe 100644 --- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleViewInfoTask.java +++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleViewInfoTask.java @@ -176,7 +176,8 @@ public class BubbleViewInfoTask extends AsyncTask