From b2049196b977b22244f4aa5e2f4265da6f123e0b Mon Sep 17 00:00:00 2001 From: Hyunyoung Song Date: Fri, 22 Nov 2019 14:43:20 -0800 Subject: [PATCH] Align badging logic with platform IconDrawableFactory. The current logic in BaseIconFactory is only trying to add the user badge if the user passed in isn't null and isn't the current user, then if no such attempt is made, try to add an instant app badge. This is causing user badge to disappear if the current user is a work profile. Meanwhile, the badging logic in IconDrawableFactory is to try to add the instant app badge first, and then always try to add the user badge. Bug: 132625654 Test: manually test as in b/128625591 Change-Id: I2241bdb524ca6bc66e545a0ec8433119e0448358 Signed-off-by: Hyunyoung Song --- .../launcher3/icons/BaseIconFactory.java | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/iconloaderlib/src/com/android/launcher3/icons/BaseIconFactory.java b/iconloaderlib/src/com/android/launcher3/icons/BaseIconFactory.java index 8bd9dba1f9..bce4e0f330 100644 --- a/iconloaderlib/src/com/android/launcher3/icons/BaseIconFactory.java +++ b/iconloaderlib/src/com/android/launcher3/icons/BaseIconFactory.java @@ -173,25 +173,22 @@ public class BaseIconFactory implements AutoCloseable { mCanvas.setBitmap(null); } - final Bitmap result; - if (user != null && !Process.myUserHandle().equals(user)) { + if (isInstantApp) { + badgeWithDrawable(bitmap, mContext.getDrawable(R.drawable.ic_instant_app_badge)); + } + if (user != null) { BitmapDrawable drawable = new FixedSizeBitmapDrawable(bitmap); Drawable badged = mPm.getUserBadgedIcon(drawable, user); if (badged instanceof BitmapDrawable) { - result = ((BitmapDrawable) badged).getBitmap(); + bitmap = ((BitmapDrawable) badged).getBitmap(); } else { - result = createIconBitmap(badged, 1f); + bitmap = createIconBitmap(badged, 1f); } - } else if (isInstantApp) { - badgeWithDrawable(bitmap, mContext.getDrawable(R.drawable.ic_instant_app_badge)); - result = bitmap; - } else { - result = bitmap; } - int color = extractColor(result); + int color = extractColor(bitmap); return icon instanceof BitmapInfo.Extender - ? ((BitmapInfo.Extender) icon).getExtendedInfo(result, color, this) - : BitmapInfo.of(result, color); + ? ((BitmapInfo.Extender) icon).getExtendedInfo(bitmap, color, this) + : BitmapInfo.of(bitmap, color); } public Bitmap createScaledBitmapWithoutShadow(Drawable icon, boolean shrinkNonAdaptiveIcons) {