[cleanup] Shadows should not be clipped on AdaptiveIconDrawable b/36702964
am: 830cca665c
Change-Id: Ib2a0e622cd480dbfea2ce59adc8a82f98ef2dac3
diff --git a/src/com/android/launcher3/graphics/LauncherIcons.java b/src/com/android/launcher3/graphics/LauncherIcons.java
index 25f8f2e..f652a5c 100644
--- a/src/com/android/launcher3/graphics/LauncherIcons.java
+++ b/src/com/android/launcher3/graphics/LauncherIcons.java
@@ -119,6 +119,10 @@
}
}
Bitmap bitmap = createIconBitmap(icon, context, scale);
+ if (FeatureFlags.ADAPTIVE_ICON_SHADOW && Utilities.isAtLeastO() &&
+ icon instanceof AdaptiveIconDrawable) {
+ bitmap = ShadowGenerator.getInstance(context).recreateIcon(bitmap);
+ }
return badgeIconForUser(bitmap, user, context);
}
@@ -201,7 +205,17 @@
* Returns a bitmap suitable for the all apps view.
*/
public static Bitmap createIconBitmap(Drawable icon, Context context) {
- return createIconBitmap(icon, context, 1.0f /* scale */);
+ float scale = 1f;
+ if (FeatureFlags.ADAPTIVE_ICON_SHADOW && Utilities.isAtLeastO() &&
+ icon instanceof AdaptiveIconDrawable) {
+ scale = ShadowGenerator.getScaleForBounds(new RectF(0, 0, 0, 0));
+ }
+ Bitmap bitmap = createIconBitmap(icon, context, scale);
+ if (FeatureFlags.ADAPTIVE_ICON_SHADOW && Utilities.isAtLeastO() &&
+ icon instanceof AdaptiveIconDrawable) {
+ bitmap = ShadowGenerator.getInstance(context).recreateIcon(bitmap);
+ }
+ return bitmap;
}
/**
@@ -226,16 +240,6 @@
}
}
- Class iconClass = null;
- if (FeatureFlags.ADAPTIVE_ICON_SHADOW && Utilities.isAtLeastO()) {
- try {
- iconClass = Class.forName("android.graphics.drawable.AdaptiveIconDrawable");
- } catch (Exception e) {
- }
- }
- if (iconClass != null && iconClass.isAssignableFrom(icon.getClass())) {
- scale *= ShadowGenerator.getScaleForBounds(new RectF(0, 0, 0, 0));
- }
int sourceWidth = icon.getIntrinsicWidth();
int sourceHeight = icon.getIntrinsicHeight();
if (sourceWidth > 0 && sourceHeight > 0) {
@@ -269,9 +273,6 @@
icon.setBounds(sOldBounds);
canvas.setBitmap(null);
- if (iconClass != null && iconClass.isAssignableFrom(icon.getClass())) {
- bitmap = ShadowGenerator.getInstance(context).recreateIcon(bitmap);
- }
return bitmap;
}
}