summaryrefslogtreecommitdiffstats
path: root/iconloaderlib/src/com/android/launcher3/icons/BaseIconFactory.java
diff options
context:
space:
mode:
Diffstat (limited to 'iconloaderlib/src/com/android/launcher3/icons/BaseIconFactory.java')
-rw-r--r--iconloaderlib/src/com/android/launcher3/icons/BaseIconFactory.java21
1 files changed, 14 insertions, 7 deletions
diff --git a/iconloaderlib/src/com/android/launcher3/icons/BaseIconFactory.java b/iconloaderlib/src/com/android/launcher3/icons/BaseIconFactory.java
index 7cd99efff..60320d63b 100644
--- a/iconloaderlib/src/com/android/launcher3/icons/BaseIconFactory.java
+++ b/iconloaderlib/src/com/android/launcher3/icons/BaseIconFactory.java
@@ -46,13 +46,15 @@ public class BaseIconFactory implements AutoCloseable {
private IconNormalizer mNormalizer;
private ShadowGenerator mShadowGenerator;
+ private final boolean mShapeDetection;
private Drawable mWrapperIcon;
private int mWrapperBackgroundColor = DEFAULT_WRAPPER_BACKGROUND;
- protected BaseIconFactory(Context context, int fillResIconDpi, int iconBitmapSize) {
+ protected BaseIconFactory(Context context, int fillResIconDpi, int iconBitmapSize,
+ boolean shapeDetection) {
mContext = context.getApplicationContext();
-
+ mShapeDetection = shapeDetection;
mFillResIconDpi = fillResIconDpi;
mIconBitmapSize = iconBitmapSize;
@@ -64,6 +66,10 @@ public class BaseIconFactory implements AutoCloseable {
clear();
}
+ protected BaseIconFactory(Context context, int fillResIconDpi, int iconBitmapSize) {
+ this(context, fillResIconDpi, iconBitmapSize, false);
+ }
+
protected void clear() {
mWrapperBackgroundColor = DEFAULT_WRAPPER_BACKGROUND;
mDisableColorExtractor = false;
@@ -78,7 +84,7 @@ public class BaseIconFactory implements AutoCloseable {
public IconNormalizer getNormalizer() {
if (mNormalizer == null) {
- mNormalizer = new IconNormalizer(mIconBitmapSize);
+ mNormalizer = new IconNormalizer(mContext, mIconBitmapSize, mShapeDetection);
}
return mNormalizer;
}
@@ -209,18 +215,19 @@ public class BaseIconFactory implements AutoCloseable {
}
AdaptiveIconDrawable dr = (AdaptiveIconDrawable) mWrapperIcon;
dr.setBounds(0, 0, 1, 1);
- scale = getNormalizer().getScale(icon, outIconBounds);
- if (!(icon instanceof AdaptiveIconDrawable)) {
+ boolean[] outShape = new boolean[1];
+ scale = getNormalizer().getScale(icon, outIconBounds, dr.getIconMask(), outShape);
+ if (!(icon instanceof AdaptiveIconDrawable) && !outShape[0]) {
FixedScaleDrawable fsd = ((FixedScaleDrawable) dr.getForeground());
fsd.setDrawable(icon);
fsd.setScale(scale);
icon = dr;
- scale = getNormalizer().getScale(icon, outIconBounds);
+ scale = getNormalizer().getScale(icon, outIconBounds, null, null);
((ColorDrawable) dr.getBackground()).setColor(mWrapperBackgroundColor);
}
} else {
- scale = getNormalizer().getScale(icon, outIconBounds);
+ scale = getNormalizer().getScale(icon, outIconBounds, null, null);
}
outScale[0] = scale;