Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
/.idea/copilot.*
/docs/plans
/docs/android
.DS_Store
/build
/captures
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@
<data android:host="*" />
<data android:mimeType="application/vnd.apple.pkpass" />
</intent-filter>

<meta-data
android:name="android.app.shortcuts"
android:resource="@xml/shortcuts" />
Comment on lines +47 to +49
Copy link

Copilot AI Apr 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

android.app.shortcuts meta-data is declared inside the MainActivity element. The platform reads the android.app.shortcuts resource from the <application> meta-data, so placing it on an <activity> can prevent the shortcuts/capabilities from being discovered. Move this <meta-data> to the <application> element (and remove it from the activity).

Copilot uses AI. Check for mistakes.
</activity>

<activity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import de.pawcode.cardstore.utils.calculateCardScore
import de.pawcode.cardstore.utils.isLightColor
import kotlinx.coroutines.flow.first

private const val MAX_SHORTCUTS = 3
internal const val SHORTCUT_ACTION = "de.pawcode.cardstore.ACTION_VIEW_CARD"

internal fun cardShortcutId(cardId: String) = "card_shortcut_$cardId"
Expand All @@ -39,9 +38,10 @@ suspend fun updateShortcuts(context: Context) {
SortAttribute.MOST_USED -> allCards.sortedByDescending { it.useCount }
}

val topCards = sortedCards.take(MAX_SHORTCUTS)

val maxShortcuts = ShortcutManagerCompat.getMaxShortcutCountPerActivity(context)
val topCards = sortedCards.take(maxShortcuts)
val newShortcutIds = topCards.map { cardShortcutId(it.cardId) }.toSet()

val existingShortcuts = ShortcutManagerCompat.getDynamicShortcuts(context)
val staleIds = existingShortcuts.filter { it.id !in newShortcutIds }.map { it.id }
if (staleIds.isNotEmpty()) ShortcutManagerCompat.removeDynamicShortcuts(context, staleIds)
Expand All @@ -62,6 +62,11 @@ suspend fun updateShortcuts(context: Context) {
.setLongLabel(card.storeName)
.setIcon(icon)
.setIntent(intent)
.addCapabilityBinding(
"actions.intent.OPEN_APP_FEATURE",
"feature.name",
listOf(card.storeName),
)
.build()

ShortcutManagerCompat.pushDynamicShortcut(context, shortcut)
Expand Down
11 changes: 11 additions & 0 deletions app/src/main/res/xml/shortcuts.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<shortcuts xmlns:android="http://schemas.android.com/apk/res/android">
<capability android:name="actions.intent.OPEN_APP_FEATURE">
<shortcut-fulfillment>
<parameter android:name="feature.name" />
</shortcut-fulfillment>
<intent
android:action="de.pawcode.cardstore.ACTION_VIEW_CARD"
android:targetClass="de.pawcode.cardstore.CardOverlayActivity" />
</capability>
Comment on lines +3 to +10
Copy link

Copilot AI Apr 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The capability intent launches CardOverlayActivity without providing CardOverlayActivity.EXTRA_CARD_ID. As implemented, CardOverlayActivity immediately calls finish() when the extra is missing, so this fulfillment intent can never successfully display a card. Either target an activity/route that can handle the feature.name parameter, or update the launched activity to gracefully handle missing card_id (e.g., resolve by store name and show a selector).

Suggested change
<capability android:name="actions.intent.OPEN_APP_FEATURE">
<shortcut-fulfillment>
<parameter android:name="feature.name" />
</shortcut-fulfillment>
<intent
android:action="de.pawcode.cardstore.ACTION_VIEW_CARD"
android:targetClass="de.pawcode.cardstore.CardOverlayActivity" />
</capability>

Copilot uses AI. Check for mistakes.
</shortcuts>