From 3b48622074fe2d9bd481601a745e819cd171aa60 Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Sat, 25 Jan 2020 14:46:29 +0200 Subject: [PATCH] limit the number of launcher shortcuts to the maximum supported instead of crashing attempting th breach the limit --- .../java/net/ktnx/mobileledger/ui/activity/MainActivity.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java b/app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java index 876f8da8..0d800fce 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java @@ -325,9 +325,13 @@ public class MainActivity extends ProfileThemedActivity { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N_MR1) return; + ShortcutManager sm = getSystemService(ShortcutManager.class); List shortcuts = new ArrayList<>(); int i = 0; for (MobileLedgerProfile p : list) { + if (shortcuts.size() >= sm.getMaxShortcutCountPerActivity()) + break; + if (!p.isPostingPermitted()) continue; @@ -351,7 +355,6 @@ public class MainActivity extends ProfileThemedActivity { shortcuts.add(si); i++; } - ShortcutManager sm = getSystemService(ShortcutManager.class); sm.setDynamicShortcuts(shortcuts); } private void onProfileListChanged(List newList) { -- 2.39.5