From 95247f8b102fa8bada8d02ada9bbd4cf5f1edf9c Mon Sep 17 00:00:00 2001 From: Philipp Neumann Date: Tue, 5 Oct 2021 13:22:31 +0200 Subject: [PATCH] remove also LongLivedShortcuts --- .../java/im/vector/app/features/home/ShortcutsHandler.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/vector/src/main/java/im/vector/app/features/home/ShortcutsHandler.kt b/vector/src/main/java/im/vector/app/features/home/ShortcutsHandler.kt index c3249f5b26..2fbd90ace7 100644 --- a/vector/src/main/java/im/vector/app/features/home/ShortcutsHandler.kt +++ b/vector/src/main/java/im/vector/app/features/home/ShortcutsHandler.kt @@ -75,7 +75,11 @@ class ShortcutsHandler @Inject constructor( return } - ShortcutManagerCompat.removeAllDynamicShortcuts(context) + // according to https://developer.android.com/reference/androidx/core/content/pm/ShortcutManagerCompat#removeLongLivedShortcuts(android.content.Context,%20java.util.List%3Cjava.lang.String%3E) + // removeLongLivedShortcuts for API 29 and lower should behave like removeDynamicShortcuts(Context, List) + // getDynamicShortcuts: returns all dynamic shortcuts from the app. + val shortcuts = ShortcutManagerCompat.getDynamicShortcuts(context).map { it.id } + ShortcutManagerCompat.removeLongLivedShortcuts(context, shortcuts) // We can only disabled pinned shortcuts with the API, but at least it will prevent the crash if (ShortcutManagerCompat.isRequestPinShortcutSupported(context)) {