]> git.ktnx.net Git - mobile-ledger.git/blobdiff - app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java
limit the number of launcher shortcuts to the maximum supported
[mobile-ledger.git] / app / src / main / java / net / ktnx / mobileledger / ui / activity / MainActivity.java
index 3fd2a7c7f1740ea3c552c776273844ad61fe7d09..0d800fce3e920e3b7193c43ed87da58f936bcf18 100644 (file)
@@ -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<ShortcutInfo> 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<MobileLedgerProfile> newList) {
@@ -399,7 +402,7 @@ public class MainActivity extends ProfileThemedActivity {
 
         mProfileListAdapter.notifyDataSetChanged();
 
-        int newProfileTheme = haveProfile ? profile.getThemeId() : -1;
+        int newProfileTheme = haveProfile ? profile.getThemeHue() : -1;
         if (newProfileTheme != Colors.profileThemeId) {
             debug("profiles",
                     String.format(Locale.ENGLISH, "profile theme %d → %d", Colors.profileThemeId,
@@ -458,7 +461,7 @@ public class MainActivity extends ProfileThemedActivity {
         Bundle bundle = new Bundle();
         onSaveInstanceState(bundle);
 
-        storeThemeIdInPrefs(profile.getThemeId());
+        storeThemeIdInPrefs(profile.getThemeHue());
 
         // restart activity to reflect theme change
         finish();
@@ -505,11 +508,6 @@ public class MainActivity extends ProfileThemedActivity {
         startActivity(intent);
         overridePendingTransition(R.anim.slide_in_up, R.anim.dummy);
     }
-    public void navSettingsClicked(View view) {
-        Intent intent = new Intent(this, SettingsActivity.class);
-        startActivity(intent);
-        drawer.closeDrawers();
-    }
     public void markDrawerItemCurrent(int id) {
         TextView item = drawer.findViewById(id);
         item.setBackgroundColor(Colors.tableRowDarkBG);