From d5e7a8542beedec137939721495c3232f588c65d Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Fri, 5 Nov 2021 12:48:27 +0100 Subject: [PATCH] Limit the number of pushed shortcuts --- .../java/im/vector/app/features/home/ShortcutsHandler.kt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) 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 612e2dcf87..e63d8cf5b2 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 @@ -41,6 +41,7 @@ class ShortcutsHandler @Inject constructor( private val pinCodeStore: PinCodeStore ) : PinCodeStoreListener { private val isRequestPinShortcutSupported = ShortcutManagerCompat.isRequestPinShortcutSupported(context) + private val maxShortcutCountPerActivity = ShortcutManagerCompat.getMaxShortcutCountPerActivity(context) // Value will be set correctly if necessary private var hasPinCode = true @@ -93,9 +94,11 @@ class ShortcutsHandler @Inject constructor( // No shortcut in this case (privacy) ShortcutManagerCompat.removeAllDynamicShortcuts(context) } else { - val shortcuts = rooms.mapIndexed { index, room -> - shortcutCreator.create(room, index) - } + val shortcuts = rooms + .take(maxShortcutCountPerActivity) + .mapIndexed { index, room -> + shortcutCreator.create(room, index) + } shortcuts.forEach { shortcut -> ShortcutManagerCompat.pushDynamicShortcut(context, shortcut)