From 977a1d4a3c9e6e3e0c97872efd06c0bf7b456748 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sat, 21 Mar 2020 13:25:55 -0700 Subject: [PATCH] Fix IllegalArgumentException when trying to repin a disabled shortcut --- app/src/main/java/com/limelight/AppView.java | 6 ++++++ .../main/java/com/limelight/utils/ShortcutHelper.java | 9 +++++++++ 2 files changed, 15 insertions(+) diff --git a/app/src/main/java/com/limelight/AppView.java b/app/src/main/java/com/limelight/AppView.java index 284a4a62..0e68b9f8 100644 --- a/app/src/main/java/com/limelight/AppView.java +++ b/app/src/main/java/com/limelight/AppView.java @@ -517,6 +517,12 @@ public class AppView extends Activity implements AdapterFragmentCallbacks { if (!foundExistingApp) { // This app must be new appGridAdapter.addApp(new AppObject(app)); + + // We could have a leftover shortcut from last time this PC was paired + // or if this app was removed then added again. Enable those shortcuts + // again if present. + shortcutHelper.enableAppShortcut(computer, app); + updated = true; } } diff --git a/app/src/main/java/com/limelight/utils/ShortcutHelper.java b/app/src/main/java/com/limelight/utils/ShortcutHelper.java index 7510e516..fb620bb0 100644 --- a/app/src/main/java/com/limelight/utils/ShortcutHelper.java +++ b/app/src/main/java/com/limelight/utils/ShortcutHelper.java @@ -192,4 +192,13 @@ public class ShortcutHelper { } } } + + public void enableAppShortcut(ComputerDetails computer, NvApp app) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) { + String id = getShortcutIdForGame(computer, app); + if (getInfoForId(id) != null) { + sm.enableShortcuts(Collections.singletonList(id)); + } + } + } }