diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9f0f16711..63c2c950d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,7 @@ Changes:
- Add option to set a separate barcode value from card ID
- Simplify font sizing configuration
- Several small UI fixes
+- Use letter icon for shortcuts too
## v1.12 (2021-03-30)
diff --git a/app/src/main/java/protect/card_locker/CardShortcutConfigure.java b/app/src/main/java/protect/card_locker/CardShortcutConfigure.java
index a90cc9a6d..0310e51f0 100644
--- a/app/src/main/java/protect/card_locker/CardShortcutConfigure.java
+++ b/app/src/main/java/protect/card_locker/CardShortcutConfigure.java
@@ -2,10 +2,14 @@ package protect.card_locker;
import android.content.Intent;
import android.database.Cursor;
+import android.graphics.Bitmap;
import android.os.Bundle;
-import android.os.Parcelable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
+import androidx.core.content.pm.ShortcutInfoCompat;
+import androidx.core.content.pm.ShortcutManagerCompat;
+import androidx.core.graphics.drawable.IconCompat;
+
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
@@ -75,11 +79,15 @@ public class CardShortcutConfigure extends AppCompatActivity
bundle.putBoolean("view", true);
shortcutIntent.putExtras(bundle);
- Parcelable icon = Intent.ShortcutIconResource.fromContext(CardShortcutConfigure.this, R.mipmap.ic_launcher);
- Intent intent = new Intent();
- intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
- intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, loyaltyCard.store);
- intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, icon);
+ Bitmap icon = Utils.generateIcon(CardShortcutConfigure.this, loyaltyCard.store, loyaltyCard.headerColor, true).getLetterTile();
+
+ ShortcutInfoCompat shortcutInfo = new ShortcutInfoCompat.Builder(CardShortcutConfigure.this, String.valueOf(loyaltyCard.id))
+ .setIntent(shortcutIntent)
+ .setIcon(IconCompat.createWithAdaptiveBitmap(icon))
+ .setShortLabel(loyaltyCard.store)
+ .build();
+
+ Intent intent = ShortcutManagerCompat.createShortcutResultIntent(CardShortcutConfigure.this, shortcutInfo);
setResult(RESULT_OK, intent);
finish();
diff --git a/app/src/main/java/protect/card_locker/Utils.java b/app/src/main/java/protect/card_locker/Utils.java
index 1c69d55ae..9f7a91f3b 100644
--- a/app/src/main/java/protect/card_locker/Utils.java
+++ b/app/src/main/java/protect/card_locker/Utils.java
@@ -40,11 +40,21 @@ public class Utils {
static final double LUMINANCE_MIDPOINT = 0.5;
static public LetterBitmap generateIcon(Context context, String store, Integer backgroundColor) {
+ return generateIcon(context, store, backgroundColor, false);
+ }
+
+ static public LetterBitmap generateIcon(Context context, String store, Integer backgroundColor, boolean forShortcut) {
if (store.length() == 0) {
return null;
}
- int tileLetterFontSize = context.getResources().getDimensionPixelSize(R.dimen.tileLetterFontSize);
+ int tileLetterFontSize;
+ if (forShortcut) {
+ tileLetterFontSize = context.getResources().getDimensionPixelSize(R.dimen.tileLetterFontSizeForShortcut);
+ } else {
+ tileLetterFontSize = context.getResources().getDimensionPixelSize(R.dimen.tileLetterFontSize);
+ }
+
int pixelSize = context.getResources().getDimensionPixelSize(R.dimen.cardThumbnailSize);
if (backgroundColor == null) {
diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml
index 3528e779d..d55246521 100644
--- a/app/src/main/res/values/dimens.xml
+++ b/app/src/main/res/values/dimens.xml
@@ -34,5 +34,6 @@
33sp
+ 24dp
100sp