aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorMohamed <mohamed.zenadi@biomerieux.com>2017-05-25 16:44:52 +0100
committerMohamed <mohamed@zenadi.com>2017-05-25 17:42:31 +0100
commit0043c82b23fcc803807b7c8ade38c3757247a208 (patch)
tree3301be29501f4d7caae9eb6f60bfb38a20e47c68 /app
parent81c63e9402b4dbff616547e7aad054a7e8a5c026 (diff)
Fix an issue with the number of shortcuts
Diffstat (limited to 'app')
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/PasswordStore.java14
1 files changed, 12 insertions, 2 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java
index 4f2649b5..af5567c4 100644
--- a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java
+++ b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java
@@ -44,9 +44,10 @@ import org.eclipse.jgit.lib.Repository;
import java.io.File;
import java.util.ArrayList;
-import java.util.Arrays;
+import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.List;
import java.util.Set;
public class PasswordStore extends AppCompatActivity {
@@ -409,7 +410,16 @@ public class PasswordStore extends AppCompatActivity {
.setIcon(Icon.createWithResource(this, R.drawable.ic_launcher))
.setIntent(intent.setAction("DECRYPT_PASS")) // Needs action
.build();
- shortcutManager.addDynamicShortcuts(Arrays.asList(shortcut));
+ List<ShortcutInfo> shortcuts = shortcutManager.getDynamicShortcuts();
+
+ if (shortcuts.size() >= shortcutManager.getMaxShortcutCountPerActivity() &&
+ shortcuts.size() > 0) {
+ shortcuts.remove(shortcuts.size() - 1);
+ shortcuts.add(0, shortcut);
+ shortcutManager.setDynamicShortcuts(shortcuts);
+ } else {
+ shortcutManager.addDynamicShortcuts(Collections.singletonList(shortcut));
+ }
}
startActivityForResult(intent, PgpHandler.REQUEST_CODE_DECRYPT_AND_VERIFY);
}