summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/icons
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/launcher3/icons')
-rw-r--r--src/com/android/launcher3/icons/BaseIconCache.java2
-rw-r--r--src/com/android/launcher3/icons/BaseIconFactory.java4
-rw-r--r--src/com/android/launcher3/icons/BitmapInfo.java7
-rw-r--r--src/com/android/launcher3/icons/IconCache.java2
-rw-r--r--src/com/android/launcher3/icons/IconNormalizer.java17
-rw-r--r--src/com/android/launcher3/icons/ShadowGenerator.java13
6 files changed, 12 insertions, 33 deletions
diff --git a/src/com/android/launcher3/icons/BaseIconCache.java b/src/com/android/launcher3/icons/BaseIconCache.java
index 6433103f9..9198c2482 100644
--- a/src/com/android/launcher3/icons/BaseIconCache.java
+++ b/src/com/android/launcher3/icons/BaseIconCache.java
@@ -261,7 +261,7 @@ public class BaseIconCache {
protected void applyCacheEntry(CacheEntry entry, ItemInfoWithIcon info) {
info.title = Utilities.trim(entry.title);
info.contentDescription = entry.contentDescription;
- ((entry.icon == null) ? getDefaultIcon(info.user) : entry).applyTo(info);
+ info.applyFrom((entry.icon == null) ? getDefaultIcon(info.user) : entry);
}
public synchronized BitmapInfo getDefaultIcon(UserHandle user) {
diff --git a/src/com/android/launcher3/icons/BaseIconFactory.java b/src/com/android/launcher3/icons/BaseIconFactory.java
index db723b720..c8c961827 100644
--- a/src/com/android/launcher3/icons/BaseIconFactory.java
+++ b/src/com/android/launcher3/icons/BaseIconFactory.java
@@ -69,14 +69,14 @@ public class BaseIconFactory {
public ShadowGenerator getShadowGenerator() {
if (mShadowGenerator == null) {
- mShadowGenerator = new ShadowGenerator(mContext);
+ mShadowGenerator = new ShadowGenerator(mIconBitmapSize);
}
return mShadowGenerator;
}
public IconNormalizer getNormalizer() {
if (mNormalizer == null) {
- mNormalizer = new IconNormalizer(mContext);
+ mNormalizer = new IconNormalizer(mContext, mIconBitmapSize);
}
return mNormalizer;
}
diff --git a/src/com/android/launcher3/icons/BitmapInfo.java b/src/com/android/launcher3/icons/BitmapInfo.java
index ebe05113e..245561ea5 100644
--- a/src/com/android/launcher3/icons/BitmapInfo.java
+++ b/src/com/android/launcher3/icons/BitmapInfo.java
@@ -18,8 +18,6 @@ package com.android.launcher3.icons;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
-import com.android.launcher3.ItemInfoWithIcon;
-
public class BitmapInfo {
public static final Bitmap LOW_RES_ICON = Bitmap.createBitmap(1, 1, Config.ALPHA_8);
@@ -27,11 +25,6 @@ public class BitmapInfo {
public Bitmap icon;
public int color;
- public void applyTo(ItemInfoWithIcon info) {
- info.iconBitmap = icon;
- info.iconColor = color;
- }
-
public void applyTo(BitmapInfo info) {
info.icon = icon;
info.color = color;
diff --git a/src/com/android/launcher3/icons/IconCache.java b/src/com/android/launcher3/icons/IconCache.java
index 434945550..41a53e572 100644
--- a/src/com/android/launcher3/icons/IconCache.java
+++ b/src/com/android/launcher3/icons/IconCache.java
@@ -139,7 +139,7 @@ public class IconCache extends BaseIconCache {
// null info means not installed, but if we have a component from the intent then
// we should still look in the cache for restored app icons.
if (info.getTargetComponent() == null) {
- getDefaultIcon(info.user).applyTo(info);
+ info.applyFrom(getDefaultIcon(info.user));
info.title = "";
info.contentDescription = "";
} else {
diff --git a/src/com/android/launcher3/icons/IconNormalizer.java b/src/com/android/launcher3/icons/IconNormalizer.java
index 73177825b..4052a5514 100644
--- a/src/com/android/launcher3/icons/IconNormalizer.java
+++ b/src/com/android/launcher3/icons/IconNormalizer.java
@@ -28,14 +28,9 @@ import android.graphics.PorterDuffXfermode;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.drawable.AdaptiveIconDrawable;
-import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.util.Log;
-import com.android.launcher3.LauncherAppState;
-import com.android.launcher3.Utilities;
-import com.android.launcher3.dragndrop.FolderAdaptiveIcon;
-
import java.nio.ByteBuffer;
import androidx.annotation.NonNull;
@@ -84,9 +79,9 @@ public class IconNormalizer {
private final Matrix mMatrix;
/** package private **/
- IconNormalizer(Context context) {
+ IconNormalizer(Context context, int iconBitmapSize) {
// Use twice the icon size as maximum size to avoid scaling down twice.
- mMaxSize = LauncherAppState.getIDP(context).iconBitmapSize * 2;
+ mMaxSize = iconBitmapSize * 2;
mBitmap = Bitmap.createBitmap(mMaxSize, mMaxSize, Bitmap.Config.ALPHA_8);
mCanvas = new Canvas(mBitmap);
mPixels = new byte[mMaxSize * mMaxSize];
@@ -193,17 +188,13 @@ public class IconNormalizer {
*/
public synchronized float getScale(@NonNull Drawable d, @Nullable RectF outBounds,
@Nullable Path path, @Nullable boolean[] outMaskShape) {
- if (Utilities.ATLEAST_OREO && d instanceof AdaptiveIconDrawable) {
+ if (BaseIconFactory.ATLEAST_OREO && d instanceof AdaptiveIconDrawable) {
if (mAdaptiveIconScale != SCALE_NOT_INITIALIZED) {
if (outBounds != null) {
outBounds.set(mAdaptiveIconBounds);
}
return mAdaptiveIconScale;
}
- if (d instanceof FolderAdaptiveIcon) {
- // Since we just want the scale, avoid heavy drawing operations
- d = new AdaptiveIconDrawable(new ColorDrawable(Color.BLACK), null);
- }
}
int width = d.getIntrinsicWidth();
int height = d.getIntrinsicHeight();
@@ -314,7 +305,7 @@ public class IconNormalizer {
float areaScale = area / (width * height);
// Use sqrt of the final ratio as the images is scaled across both width and height.
float scale = areaScale > scaleRequired ? (float) Math.sqrt(scaleRequired / areaScale) : 1;
- if (Utilities.ATLEAST_OREO && d instanceof AdaptiveIconDrawable &&
+ if (BaseIconFactory.ATLEAST_OREO && d instanceof AdaptiveIconDrawable &&
mAdaptiveIconScale == SCALE_NOT_INITIALIZED) {
mAdaptiveIconScale = scale;
mAdaptiveIconBounds.set(mBounds);
diff --git a/src/com/android/launcher3/icons/ShadowGenerator.java b/src/com/android/launcher3/icons/ShadowGenerator.java
index 57d463a80..6491b7ec1 100644
--- a/src/com/android/launcher3/icons/ShadowGenerator.java
+++ b/src/com/android/launcher3/icons/ShadowGenerator.java
@@ -16,7 +16,6 @@
package com.android.launcher3.icons;
-import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.BlurMaskFilter;
@@ -28,23 +27,19 @@ import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
import android.graphics.RectF;
-import com.android.launcher3.LauncherAppState;
-
import androidx.core.graphics.ColorUtils;
/**
* Utility class to add shadows to bitmaps.
*/
public class ShadowGenerator {
-
- // Percent of actual icon size
- private static final float HALF_DISTANCE = 0.5f;
public static final float BLUR_FACTOR = 0.5f/48;
// Percent of actual icon size
public static final float KEY_SHADOW_DISTANCE = 1f/48;
private static final int KEY_SHADOW_ALPHA = 61;
-
+ // Percent of actual icon size
+ private static final float HALF_DISTANCE = 0.5f;
private static final int AMBIENT_SHADOW_ALPHA = 30;
private final int mIconSize;
@@ -53,8 +48,8 @@ public class ShadowGenerator {
private final Paint mDrawPaint;
private final BlurMaskFilter mDefaultBlurMaskFilter;
- public ShadowGenerator(Context context) {
- mIconSize = LauncherAppState.getIDP(context).iconBitmapSize;
+ public ShadowGenerator(int iconSize) {
+ mIconSize = iconSize;
mBlurPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);
mDrawPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);
mDefaultBlurMaskFilter = new BlurMaskFilter(mIconSize * BLUR_FACTOR, Blur.NORMAL);