Push shortcuts

pull/202/head
M66B 3 years ago
parent cf26e3d433
commit 7cb2635594

@ -263,6 +263,7 @@ dependencies {
def appcompat_version = "1.3.1" def appcompat_version = "1.3.1"
def activity_version = "1.3.1" def activity_version = "1.3.1"
def fragment_version = "1.3.6" def fragment_version = "1.3.6"
def shortcuts_version = "1.0.0"
def webkit_version = "1.4.0" def webkit_version = "1.4.0"
def recyclerview_version = "1.2.1" def recyclerview_version = "1.2.1"
def coordinatorlayout_version = "1.1.0" def coordinatorlayout_version = "1.1.0"
@ -316,9 +317,11 @@ dependencies {
// https://mvnrepository.com/artifact/androidx.appcompat/appcompat // https://mvnrepository.com/artifact/androidx.appcompat/appcompat
// https://mvnrepository.com/artifact/androidx.activity/activity // https://mvnrepository.com/artifact/androidx.activity/activity
// https://mvnrepository.com/artifact/androidx.fragment/fragment // https://mvnrepository.com/artifact/androidx.fragment/fragment
// https://mvnrepository.com/artifact/androidx.core/core-google-shortcuts
implementation "androidx.appcompat:appcompat:$appcompat_version" implementation "androidx.appcompat:appcompat:$appcompat_version"
implementation "androidx.activity:activity:$activity_version" implementation "androidx.activity:activity:$activity_version"
implementation "androidx.fragment:fragment:$fragment_version" implementation "androidx.fragment:fragment:$fragment_version"
implementation "androidx.core:core-google-shortcuts:$shortcuts_version"
// https://developer.android.com/jetpack/androidx/releases/webkit // https://developer.android.com/jetpack/androidx/releases/webkit
// https://mvnrepository.com/artifact/androidx.webkit/webkit // https://mvnrepository.com/artifact/androidx.webkit/webkit

@ -57,6 +57,9 @@ import java.util.Set;
import javax.mail.internet.InternetAddress; import javax.mail.internet.InternetAddress;
// https://developer.android.com/guide/topics/ui/shortcuts/creating-shortcuts
// https://developer.android.com/guide/topics/ui/shortcuts/managing-shortcuts
class Shortcuts { class Shortcuts {
private static final int MAX_SHORTCUTS = 4; private static final int MAX_SHORTCUTS = 4;
@ -150,9 +153,9 @@ class Shortcuts {
if (remove.size() > 0) if (remove.size() > 0)
ShortcutManagerCompat.removeDynamicShortcuts(context, remove); ShortcutManagerCompat.removeDynamicShortcuts(context, remove);
if (add.size() > 0) { for (ShortcutInfoCompat shortcut : add) {
boolean ok = ShortcutManagerCompat.addDynamicShortcuts(context, add); Log.i("Push shortcut id=" + shortcut.getId());
Log.i("Shortcuts=" + add.size() + " updated=" + ok); ShortcutManagerCompat.pushDynamicShortcut(context, shortcut);
} }
} }

Loading…
Cancel
Save