Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b7d619aa authored by Sunny Goyal's avatar Sunny Goyal Committed by Automerger Merge Worker
Browse files

Merge "Apdating getShapePath to avoid creating new bitmaps via...

Merge "Apdating getShapePath to avoid creating new bitmaps via AdaptiveIconDrawable" into tm-qpr-dev am: bc87240a am: 0c2ff0b9

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/libs/systemui/+/21353691



Change-Id: I6109e091cbf2a9301b1c46496a98340ebeb9cb71
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents ec15838f 0c2ff0b9
Loading
Loading
Loading
Loading
+19 −1
Original line number Diff line number Diff line
@@ -16,9 +16,11 @@
package com.android.launcher3.icons;

import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.Path;
import android.graphics.Rect;
import android.graphics.Region;
@@ -28,6 +30,8 @@ import android.graphics.drawable.ColorDrawable;
import android.util.Log;

import androidx.annotation.ColorInt;
import androidx.annotation.NonNull;
import androidx.core.graphics.PathParser;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -35,6 +39,7 @@ import java.io.IOException;
public class GraphicsUtils {

    private static final String TAG = "GraphicsUtils";
    private static final float MASK_SIZE = 100f;

    public static Runnable sOnNewBitmapRunnable = () -> { };

@@ -98,7 +103,20 @@ public class GraphicsUtils {
    /**
     * Returns the default path to be used by an icon
     */
    public static Path getShapePath(int size) {
    public static Path getShapePath(@NonNull Context context, int size) {
        if (IconProvider.CONFIG_ICON_MASK_RES_ID != Resources.ID_NULL) {
            Path path = PathParser.createPathFromPathData(
                    context.getString(IconProvider.CONFIG_ICON_MASK_RES_ID));
            if (path != null) {
                if (size != MASK_SIZE) {
                    Matrix m = new Matrix();
                    float scale = ((float) size) / MASK_SIZE;
                    m.setScale(scale, scale);
                    path.transform(m);
                }
                return path;
            }
        }
        AdaptiveIconDrawable drawable = new AdaptiveIconDrawable(
                new ColorDrawable(Color.BLACK), new ColorDrawable(Color.BLACK));
        drawable.setBounds(0, 0, size, size);
+1 −1
Original line number Diff line number Diff line
@@ -61,7 +61,7 @@ import java.util.function.Supplier;
public class IconProvider {

    private final String ACTION_OVERLAY_CHANGED = "android.intent.action.OVERLAY_CHANGED";
    private static final int CONFIG_ICON_MASK_RES_ID = Resources.getSystem().getIdentifier(
    static final int CONFIG_ICON_MASK_RES_ID = Resources.getSystem().getIdentifier(
            "config_icon_mask", "string", "android");

    private static final String TAG = "IconProvider";
+1 −1
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@ public class PlaceHolderIconDrawable extends FastBitmapDrawable {
    public PlaceHolderIconDrawable(BitmapInfo info, Context context) {
        super(info);

        mProgressPath = GraphicsUtils.getShapePath(100);
        mProgressPath = GraphicsUtils.getShapePath(context, 100);
        mPaint.setColor(ColorUtils.compositeColors(
                GraphicsUtils.getAttrColor(context, R.attr.loadingIconColor), info.color));
    }