From 8e10dc7bda0c5a059959047be8e3d7aefb4b487d Mon Sep 17 00:00:00 2001 From: Thibault Deckers Date: Wed, 14 Apr 2021 21:57:20 +0900 Subject: [PATCH] shortcuts: allow shorcuts with same filters but different label/icon --- .../thibault/aves/channel/calls/AppShortcutHandler.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/android/app/src/main/kotlin/deckers/thibault/aves/channel/calls/AppShortcutHandler.kt b/android/app/src/main/kotlin/deckers/thibault/aves/channel/calls/AppShortcutHandler.kt index 1adcba3bc..684edfc12 100644 --- a/android/app/src/main/kotlin/deckers/thibault/aves/channel/calls/AppShortcutHandler.kt +++ b/android/app/src/main/kotlin/deckers/thibault/aves/channel/calls/AppShortcutHandler.kt @@ -15,6 +15,7 @@ import io.flutter.plugin.common.MethodChannel.MethodCallHandler import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch +import java.util.* class AppShortcutHandler(private val context: Context) : MethodCallHandler { override fun onMethodCall(call: MethodCall, result: MethodChannel.Result) { @@ -53,7 +54,9 @@ class AppShortcutHandler(private val context: Context) : MethodCallHandler { .putExtra("page", "/collection") .putExtra("filters", filters.toTypedArray()) - val shortcut = ShortcutInfoCompat.Builder(context, "collection-${filters.joinToString("-")}") + // multiple shortcuts sharing the same ID cannot be created with different labels or icons + // so we provide a unique ID for each one, and let the user manage duplicates (i.e. same filter set), if any + val shortcut = ShortcutInfoCompat.Builder(context, UUID.randomUUID().toString()) .setShortLabel(label) .setIcon(icon) .setIntent(intent)