diff options
author | Sunny Goyal <sunnygoyal@google.com> | 2019-01-25 15:10:18 -0800 |
---|---|---|
committer | Sunny Goyal <sunnygoyal@google.com> | 2019-01-29 11:29:52 -0800 |
commit | 8c48d8bea64b95916b18bd41a4fdb58d4d7477be (patch) | |
tree | 1a3538863bdb43b87eef0b1238d17ac908f045c5 /src_shortcuts_overrides | |
parent | 9752705e92593adfb60568ac4d059cc776cfceaa (diff) | |
download | packages_apps_Trebuchet-8c48d8bea64b95916b18bd41a4fdb58d4d7477be.tar.gz packages_apps_Trebuchet-8c48d8bea64b95916b18bd41a4fdb58d4d7477be.tar.bz2 packages_apps_Trebuchet-8c48d8bea64b95916b18bd41a4fdb58d4d7477be.zip |
Changing min sdk to 25
Change-Id: I0d28069967854357ca755bf25dec19d4979bdecf
Diffstat (limited to 'src_shortcuts_overrides')
-rw-r--r-- | src_shortcuts_overrides/com/android/launcher3/shortcuts/DeepShortcutManager.java | 147 |
1 files changed, 62 insertions, 85 deletions
diff --git a/src_shortcuts_overrides/com/android/launcher3/shortcuts/DeepShortcutManager.java b/src_shortcuts_overrides/com/android/launcher3/shortcuts/DeepShortcutManager.java index e70aac68f..6c0c4295a 100644 --- a/src_shortcuts_overrides/com/android/launcher3/shortcuts/DeepShortcutManager.java +++ b/src_shortcuts_overrides/com/android/launcher3/shortcuts/DeepShortcutManager.java @@ -16,7 +16,6 @@ package com.android.launcher3.shortcuts; -import android.annotation.TargetApi; import android.content.ComponentName; import android.content.Context; import android.content.pm.LauncherApps; @@ -30,7 +29,6 @@ import android.util.Log; import com.android.launcher3.ItemInfo; import com.android.launcher3.LauncherSettings; -import com.android.launcher3.Utilities; import java.util.ArrayList; import java.util.Collections; @@ -94,7 +92,6 @@ public class DeepShortcutManager { * Gets all the manifest and dynamic shortcuts associated with the given package and user, * to be displayed in the shortcuts container on long press. */ - @TargetApi(25) public List<ShortcutInfoCompat> queryForShortcutsContainer(ComponentName activity, UserHandle user) { return query(ShortcutQuery.FLAG_MATCH_MANIFEST | ShortcutQuery.FLAG_MATCH_DYNAMIC, @@ -105,21 +102,18 @@ public class DeepShortcutManager { * 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.ATLEAST_NOUGAT_MR1) { - 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) { - Log.w(TAG, "Failed to unpin shortcut", e); - mWasLastCallSuccess = false; - } + 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) { + Log.w(TAG, "Failed to unpin shortcut", e); + mWasLastCallSuccess = false; } } @@ -127,51 +121,42 @@ public class DeepShortcutManager { * 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.ATLEAST_NOUGAT_MR1) { - 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) { - Log.w(TAG, "Failed to pin shortcut", e); - mWasLastCallSuccess = false; - } + 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) { + Log.w(TAG, "Failed to pin shortcut", e); + mWasLastCallSuccess = false; } } - @TargetApi(25) public void startShortcut(String packageName, String id, Rect sourceBounds, Bundle startActivityOptions, UserHandle user) { - if (Utilities.ATLEAST_NOUGAT_MR1) { - try { - mLauncherApps.startShortcut(packageName, id, sourceBounds, - startActivityOptions, user); - mWasLastCallSuccess = true; - } catch (SecurityException|IllegalStateException e) { - Log.e(TAG, "Failed to start shortcut", e); - mWasLastCallSuccess = false; - } + try { + mLauncherApps.startShortcut(packageName, id, sourceBounds, + startActivityOptions, user); + mWasLastCallSuccess = true; + } catch (SecurityException|IllegalStateException e) { + Log.e(TAG, "Failed to start shortcut", e); + mWasLastCallSuccess = false; } } - @TargetApi(25) public Drawable getShortcutIconDrawable(ShortcutInfoCompat shortcutInfo, int density) { - if (Utilities.ATLEAST_NOUGAT_MR1) { - try { - Drawable icon = mLauncherApps.getShortcutIconDrawable( - shortcutInfo.getShortcutInfo(), density); - mWasLastCallSuccess = true; - return icon; - } catch (SecurityException|IllegalStateException e) { - Log.e(TAG, "Failed to get shortcut icon", e); - mWasLastCallSuccess = false; - } + try { + Drawable icon = mLauncherApps.getShortcutIconDrawable( + shortcutInfo.getShortcutInfo(), density); + mWasLastCallSuccess = true; + return icon; + } catch (SecurityException|IllegalStateException e) { + Log.e(TAG, "Failed to get shortcut icon", e); + mWasLastCallSuccess = false; } return null; } @@ -208,46 +193,38 @@ public class DeepShortcutManager { * * TODO: Use the cache to optimize this so we don't make an RPC every time. */ - @TargetApi(25) private List<ShortcutInfoCompat> query(int flags, String packageName, ComponentName activity, List<String> shortcutIds, UserHandle user) { - if (Utilities.ATLEAST_NOUGAT_MR1) { - ShortcutQuery q = new ShortcutQuery(); - q.setQueryFlags(flags); - if (packageName != null) { - q.setPackage(packageName); - q.setActivity(activity); - q.setShortcutIds(shortcutIds); - } - List<ShortcutInfo> shortcutInfos = null; - try { - shortcutInfos = mLauncherApps.getShortcuts(q, user); - mWasLastCallSuccess = true; - } catch (SecurityException|IllegalStateException e) { - Log.e(TAG, "Failed to query for shortcuts", e); - mWasLastCallSuccess = false; - } - if (shortcutInfos == null) { - return Collections.EMPTY_LIST; - } - List<ShortcutInfoCompat> shortcutInfoCompats = new ArrayList<>(shortcutInfos.size()); - for (ShortcutInfo shortcutInfo : shortcutInfos) { - shortcutInfoCompats.add(new ShortcutInfoCompat(shortcutInfo)); - } - return shortcutInfoCompats; - } else { + ShortcutQuery q = new ShortcutQuery(); + q.setQueryFlags(flags); + if (packageName != null) { + q.setPackage(packageName); + q.setActivity(activity); + q.setShortcutIds(shortcutIds); + } + List<ShortcutInfo> shortcutInfos = null; + try { + shortcutInfos = mLauncherApps.getShortcuts(q, user); + mWasLastCallSuccess = true; + } catch (SecurityException|IllegalStateException e) { + Log.e(TAG, "Failed to query for shortcuts", e); + mWasLastCallSuccess = false; + } + if (shortcutInfos == null) { return Collections.EMPTY_LIST; } + List<ShortcutInfoCompat> shortcutInfoCompats = new ArrayList<>(shortcutInfos.size()); + for (ShortcutInfo shortcutInfo : shortcutInfos) { + shortcutInfoCompats.add(new ShortcutInfoCompat(shortcutInfo)); + } + return shortcutInfoCompats; } - @TargetApi(25) public boolean hasHostPermission() { - if (Utilities.ATLEAST_NOUGAT_MR1) { - try { - return mLauncherApps.hasShortcutHostPermission(); - } catch (SecurityException|IllegalStateException e) { - Log.e(TAG, "Failed to make shortcut manager call", e); - } + try { + return mLauncherApps.hasShortcutHostPermission(); + } catch (SecurityException|IllegalStateException e) { + Log.e(TAG, "Failed to make shortcut manager call", e); } return false; } |