summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/graphics/LauncherIcons.java
diff options
context:
space:
mode:
authorHyunyoung Song <hyunyoungs@google.com>2017-04-05 15:01:06 -0700
committerHyunyoung Song <hyunyoungs@google.com>2017-04-05 15:20:00 -0700
commit830cca665ca0ffeef839ad808b78dc3edc2ee4fd (patch)
tree1f2c15dadebca60470c37481805c747018c4b600 /src/com/android/launcher3/graphics/LauncherIcons.java
parentd02a29a502c8640fc3937b8d671d393be855d81a (diff)
downloadandroid_packages_apps_Trebuchet-830cca665ca0ffeef839ad808b78dc3edc2ee4fd.tar.gz
android_packages_apps_Trebuchet-830cca665ca0ffeef839ad808b78dc3edc2ee4fd.tar.bz2
android_packages_apps_Trebuchet-830cca665ca0ffeef839ad808b78dc3edc2ee4fd.zip
[cleanup] Shadows should not be clipped on AdaptiveIconDrawable
b/36702964 Change-Id: I28d460eee6de84cd74866223b92d43274d64d334
Diffstat (limited to 'src/com/android/launcher3/graphics/LauncherIcons.java')
-rw-r--r--src/com/android/launcher3/graphics/LauncherIcons.java30
1 files changed, 16 insertions, 14 deletions
diff --git a/src/com/android/launcher3/graphics/LauncherIcons.java b/src/com/android/launcher3/graphics/LauncherIcons.java
index b1081eb2d..2d987cc4a 100644
--- a/src/com/android/launcher3/graphics/LauncherIcons.java
+++ b/src/com/android/launcher3/graphics/LauncherIcons.java
@@ -28,6 +28,7 @@ import android.graphics.Paint;
import android.graphics.PaintFlagsDrawFilter;
import android.graphics.Rect;
import android.graphics.RectF;
+import android.graphics.drawable.AdaptiveIconDrawable;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.PaintDrawable;
@@ -97,6 +98,10 @@ public class LauncherIcons {
float scale = FeatureFlags.LAUNCHER3_DISABLE_ICON_NORMALIZATION ?
1 : IconNormalizer.getInstance(context).getScale(icon, null);
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);
}
@@ -158,7 +163,17 @@ public class LauncherIcons {
* 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;
}
/**
@@ -185,16 +200,6 @@ public class LauncherIcons {
}
}
- 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) {
@@ -228,9 +233,6 @@ public class LauncherIcons {
icon.setBounds(sOldBounds);
canvas.setBitmap(null);
- if (iconClass != null && iconClass.isAssignableFrom(icon.getClass())) {
- bitmap = ShadowGenerator.getInstance(context).recreateIcon(bitmap);
- }
return bitmap;
}
}