From: Damyan Ivanov Date: Sat, 25 Jan 2020 12:46:29 +0000 (+0200) Subject: limit the number of launcher shortcuts to the maximum supported X-Git-Tag: v0.12.0~94 X-Git-Url: https://git.ktnx.net/?a=commitdiff_plain;h=3b48622074fe2d9bd481601a745e819cd171aa60;p=mobile-ledger.git limit the number of launcher shortcuts to the maximum supported instead of crashing attempting th breach the limit --- 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) {