/** * Removes the given shortcut from the current list of pinned shortcuts. * (Runs on background thread) */ @TargetApi(25) public void unpinShortcut(final ShortcutKey key) { if (AndroidVersion.isAtLeastNougatMR1) { String packageName = key.componentName.getPackageName(); String id = key.getId(); UserHandle user = key.user; List<String> pinnedIds = extractIds(queryForPinnedShortcuts(packageName, user)); pinnedIds.remove(id); try { mLauncherApps.pinShortcuts(packageName, pinnedIds, user); mWasLastCallSuccess = true; } catch (SecurityException|IllegalStateException e) { e.printStackTrace(); mWasLastCallSuccess = false; } } }
/** * Adds the given shortcut to the current list of pinned shortcuts. * (Runs on background thread) */ @TargetApi(25) public void pinShortcut(final ShortcutKey key) { if (AndroidVersion.isAtLeastNougatMR1) { String packageName = key.componentName.getPackageName(); String id = key.getId(); UserHandle user = key.user; List<String> pinnedIds = extractIds(queryForPinnedShortcuts(packageName, user)); pinnedIds.add(id); try { mLauncherApps.pinShortcuts(packageName, pinnedIds, user); mWasLastCallSuccess = true; } catch (SecurityException|IllegalStateException e) { e.printStackTrace(); mWasLastCallSuccess = false; } } }
/** * Adds the given shortcut to the current list of pinned shortcuts. * (Runs on background thread) */ @TargetApi(25) public void pinShortcut(final ShortcutKey key) { if (Utilities.isNycMR1OrAbove()) { String packageName = key.componentName.getPackageName(); String id = key.getId(); UserHandleCompat user = key.user; List<String> pinnedIds = extractIds(queryForPinnedShortcuts(packageName, user)); pinnedIds.add(id); try { mLauncherApps.pinShortcuts(packageName, pinnedIds, user.getUser()); mWasLastCallSuccess = true; } catch (SecurityException|IllegalStateException e) { Log.w(TAG, "Failed to pin shortcut", e); mWasLastCallSuccess = false; } } }
/** * Removes the given shortcut from the current list of pinned shortcuts. * (Runs on background thread) */ @TargetApi(25) public void unpinShortcut(final ShortcutKey key) { if (Utilities.isNycMR1OrAbove()) { String packageName = key.componentName.getPackageName(); String id = key.getId(); UserHandleCompat user = key.user; List<String> pinnedIds = extractIds(queryForPinnedShortcuts(packageName, user)); pinnedIds.remove(id); try { mLauncherApps.pinShortcuts(packageName, pinnedIds, user.getUser()); mWasLastCallSuccess = true; } catch (SecurityException|IllegalStateException e) { Log.w(TAG, "Failed to unpin shortcut", e); mWasLastCallSuccess = false; } } }
/** * Adds the given shortcut to the current list of pinned shortcuts. * (Runs on background thread) */ @TargetApi(25) public void pinShortcut(final ShortcutKey key) { if (Utilities.isNycMR1OrAbove()) { String packageName = key.componentName.getPackageName(); String id = key.getId(); UserHandleCompat user = key.user; List<String> pinnedIds = extractIds(queryForPinnedShortcuts(packageName, user)); pinnedIds.add(id); try { mLauncherApps.pinShortcuts(packageName, pinnedIds, user.getUser()); mWasLastCallSuccess = true; } catch (SecurityException|IllegalStateException e) { Log.w(TAG, "Failed to pin shortcut", e); mWasLastCallSuccess = false; } } }
/** * Removes the given shortcut from the current list of pinned shortcuts. * (Runs on background thread) */ @TargetApi(25) public void unpinShortcut(final ShortcutKey key) { if (Utilities.isNycMR1OrAbove()) { String packageName = key.componentName.getPackageName(); String id = key.getId(); UserHandleCompat user = key.user; List<String> pinnedIds = extractIds(queryForPinnedShortcuts(packageName, user)); pinnedIds.remove(id); try { mLauncherApps.pinShortcuts(packageName, pinnedIds, user.getUser()); mWasLastCallSuccess = true; } catch (SecurityException|IllegalStateException e) { Log.w(TAG, "Failed to unpin shortcut", e); mWasLastCallSuccess = false; } } }