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

Commit 79a197af authored by Abhishek Aggarwal's avatar Abhishek Aggarwal Committed by Mohammed Althaf T
Browse files

beautiful icons

parent 2ed03af5
Loading
Loading
Loading
Loading
+26 −0
Original line number Diff line number Diff line
package com.android.launcher3.icons

import android.graphics.Bitmap
import android.graphics.drawable.Drawable
import androidx.core.graphics.drawable.toBitmap

object AdaptiveIconGenerator {
    private const val ICON_SCALE = 1.46f

    @JvmStatic
    fun toBitmap(drawable: Drawable) = drawable.toBitmap()

    @JvmStatic
    fun getScale(bitmap: Bitmap, scale: Float): Float {
        val topRightPx = bitmap.getPixel(0, 0)
        val topLeftPx = bitmap.getPixel(0, bitmap.height - 1)
        val bottomRightPx = bitmap.getPixel(bitmap.width - 1, 0)
        val bottomLeftPx = bitmap.getPixel(bitmap.width - 1, bitmap.height - 1)

        return if (!(topRightPx != 0 && topLeftPx != 0 && bottomRightPx != 0 && bottomLeftPx != 0)) {
            scale
        } else {
            ICON_SCALE
        }
    }
}
+7 −1
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ import androidx.annotation.ColorInt;
import androidx.annotation.IntDef;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.graphics.ColorUtils;

import com.android.launcher3.icons.BitmapInfo.Extender;
import com.android.launcher3.util.FlagOp;
@@ -333,8 +334,13 @@ public class BaseIconFactory implements AutoCloseable {
            if (!outShape[0]) {
                foreground.setDrawable(createScaledDrawable(icon, scale * LEGACY_ICON_SCALE));
                icon = dr;
                if (icon.getIntrinsicHeight() > 0 && icon.getIntrinsicWidth() > 0) {
                    Bitmap bitmap = AdaptiveIconGenerator.toBitmap(icon);
                    scale = AdaptiveIconGenerator.getScale(bitmap, scale);
                } else {
                    scale = getNormalizer().getScale(icon, outIconBounds, null, null);
                }
            }
        } else {
            scale = getNormalizer().getScale(icon, outIconBounds, null, null);
        }