Skip to content

Commit

Permalink
Shade: Skip wrapping when creating masked icon pack icons
Browse files Browse the repository at this point in the history
  • Loading branch information
amirzaidi committed May 16, 2020
1 parent cf34dab commit 09482a4
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions shade/src/amirz/shade/icons/pack/IconResolverMasked.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,10 @@
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;

import com.android.launcher3.icons.BaseIconFactory;
import com.android.launcher3.icons.LauncherIcons;

import amirz.shade.icons.clock.CustomClock;

import static com.android.launcher3.icons.BaseIconFactory.CONFIG_HINT_NO_WRAP;

public class IconResolverMasked implements IconResolver {
private final Context mContext;
private final IconPack.Data mData;
Expand Down Expand Up @@ -63,8 +60,13 @@ public Drawable getIcon(int iconDpi, DefaultDrawableProvider fallback) {
try {
Resources res = pm.getResourcesForApplication(mPackInfo);

// Scale the bitmap using the icon pack scale.
// Re-render without scaling after creating the bitmap in the right dimensions.
Bitmap iconBm = li.createScaledBitmapWithoutShadow(icon, 0);
mCanvas.setBitmap(iconBm);
icon.setBounds(0, 0, iconBm.getWidth(), iconBm.getHeight());
icon.draw(mCanvas);

// Scale the bitmap using the icon pack scale.
scaleBitmap(iconBm, mData.scale);

// Cut parts off using the mask image.
Expand Down Expand Up @@ -136,8 +138,12 @@ private void maskBitmap(Bitmap bitmap, Drawable mask) {
@SuppressLint("WrongConstant")
private void backBitmap(Bitmap bitmap, Drawable back, LauncherIcons li) {
if (back != null) {
back.setChangingConfigurations(back.getChangingConfigurations() | CONFIG_HINT_NO_WRAP);
Bitmap backBm = li.createScaledBitmapWithoutShadow(back, 0);
Bitmap backBm = Bitmap.createBitmap(
bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888);

mCanvas.setBitmap(backBm);
back.setBounds(0, 0, bitmap.getWidth(), bitmap.getHeight());
back.draw(mCanvas);

mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_OVER));
mCanvas.setBitmap(bitmap);
Expand Down

0 comments on commit 09482a4

Please sign in to comment.