summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/icons/IconNormalizer.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/launcher3/icons/IconNormalizer.java')
-rw-r--r--src/com/android/launcher3/icons/IconNormalizer.java17
1 files changed, 4 insertions, 13 deletions
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);