Skip to content

Commit

Permalink
Merge pull request #2210 from CatimaLoyalty/fix/transparentThumbnails3
Browse files Browse the repository at this point in the history
Fix background colour for shortcuts
  • Loading branch information
TheLastProject authored Dec 5, 2024
2 parents 8382d19 + 4dd85f8 commit 630bf14
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions app/src/main/java/protect/card_locker/ShortcutHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ class ShortcutHelper {
private static final int ADAPTIVE_BITMAP_SIZE = 108 * ADAPTIVE_BITMAP_SCALE;
private static final int ADAPTIVE_BITMAP_VISIBLE_SIZE = 72 * ADAPTIVE_BITMAP_SCALE;
private static final int ADAPTIVE_BITMAP_IMAGE_SIZE = ADAPTIVE_BITMAP_VISIBLE_SIZE + 5 * ADAPTIVE_BITMAP_SCALE;
private static final int PADDING_COLOR_OVERLAY = Color.argb(127, 0, 0, 0);

/**
* Add a card to the app shortcuts, and maintain a list of the most
Expand Down Expand Up @@ -120,7 +119,7 @@ static void removeShortcut(Context context, int cardId) {
Bitmap createAdaptiveBitmap(@NotNull Bitmap in, int paddingColor) {
Bitmap ret = Bitmap.createBitmap(ADAPTIVE_BITMAP_SIZE, ADAPTIVE_BITMAP_SIZE, Bitmap.Config.ARGB_8888);
Canvas output = new Canvas(ret);
output.drawColor(ColorUtils.compositeColors(PADDING_COLOR_OVERLAY, paddingColor));
output.drawColor(paddingColor);
Bitmap resized = Utils.resizeBitmap(in, ADAPTIVE_BITMAP_IMAGE_SIZE);
output.drawBitmap(resized, (ADAPTIVE_BITMAP_SIZE - resized.getWidth()) / 2f, (ADAPTIVE_BITMAP_SIZE - resized.getHeight()) / 2f, null);
return ret;
Expand All @@ -140,7 +139,7 @@ static ShortcutInfoCompat.Builder createShortcutBuilder(Context context, Loyalty
if (iconBitmap == null) {
iconBitmap = Utils.generateIcon(context, loyaltyCard, true).getLetterTile();
} else {
iconBitmap = createAdaptiveBitmap(iconBitmap, Utils.getHeaderColor(context, loyaltyCard));
iconBitmap = createAdaptiveBitmap(iconBitmap, Utils.needsDarkForeground(Utils.getHeaderColor(context, loyaltyCard)) ? Color.BLACK : Color.WHITE);
}

IconCompat icon = IconCompat.createWithAdaptiveBitmap(iconBitmap);
Expand Down

0 comments on commit 630bf14

Please sign in to comment.