diff options
author | Tony Wickham <twickham@google.com> | 2016-08-29 23:38:03 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2016-08-29 23:38:03 +0000 |
commit | 765ff3d7c9f52a6383ae72887b54ae79de118173 (patch) | |
tree | 52fe7b14987694cedb007471a43a1ef24b1454cf /src/com/android | |
parent | b05a00a441d7e608fd709fae62bde1c661936e2a (diff) | |
parent | fc02c1b446ee54561ac7351fb6ff0f8294785f0e (diff) | |
download | android_packages_apps_Trebuchet-765ff3d7c9f52a6383ae72887b54ae79de118173.tar.gz android_packages_apps_Trebuchet-765ff3d7c9f52a6383ae72887b54ae79de118173.tar.bz2 android_packages_apps_Trebuchet-765ff3d7c9f52a6383ae72887b54ae79de118173.zip |
Merge "Use promisedIntent instead of intent when deep shortcuts are restored." into ub-launcher3-calgary-polish
Diffstat (limited to 'src/com/android')
-rw-r--r-- | src/com/android/launcher3/Launcher.java | 5 | ||||
-rw-r--r-- | src/com/android/launcher3/LauncherModel.java | 11 | ||||
-rw-r--r-- | src/com/android/launcher3/ShortcutInfo.java | 7 | ||||
-rw-r--r-- | src/com/android/launcher3/shortcuts/ShortcutKey.java | 6 | ||||
-rw-r--r-- | src/com/android/launcher3/util/ItemInfoMatcher.java | 3 |
5 files changed, 21 insertions, 11 deletions
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index f125287bb..e1c64a72d 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -2932,7 +2932,8 @@ public class Launcher extends Activity try { if (Utilities.ATLEAST_MARSHMALLOW && item != null && (item.itemType == Favorites.ITEM_TYPE_SHORTCUT - || item.itemType == Favorites.ITEM_TYPE_DEEP_SHORTCUT)) { + || item.itemType == Favorites.ITEM_TYPE_DEEP_SHORTCUT) + && ((ShortcutInfo) item).promisedIntent == null) { // Shortcuts need some special checks due to legacy reasons. startShortcutIntentSafely(intent, optsBundle, item); } else if (user == null || user.equals(UserHandleCompat.myUserHandle())) { @@ -4238,7 +4239,7 @@ public class Launcher extends Activity for (ShortcutInfo si : removed) { if (si.itemType == Favorites.ITEM_TYPE_DEEP_SHORTCUT) { - removedDeepShortcuts.add(ShortcutKey.fromItemInfo(si)); + removedDeepShortcuts.add(ShortcutKey.fromShortcutInfo(si)); } else { removedComponents.add(si.getTargetComponent()); } diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java index 59c823b4b..68450e7a7 100644 --- a/src/com/android/launcher3/LauncherModel.java +++ b/src/com/android/launcher3/LauncherModel.java @@ -930,7 +930,8 @@ public class LauncherModel extends BroadcastReceiver } if (item.itemType == LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT) { incrementPinnedShortcutCount( - ShortcutKey.fromItemInfo(item), true /* shouldPin */); + ShortcutKey.fromShortcutInfo((ShortcutInfo) item), + true /* shouldPin */); } break; case LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET: @@ -999,7 +1000,8 @@ public class LauncherModel extends BroadcastReceiver sBgWorkspaceItems.remove(item); break; case LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT: - decrementPinnedShortcutCount(ShortcutKey.fromItemInfo(item)); + decrementPinnedShortcutCount(ShortcutKey.fromShortcutInfo( + (ShortcutInfo) item)); // Fall through. case LauncherSettings.Favorites.ITEM_TYPE_APPLICATION: case LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT: @@ -3388,7 +3390,8 @@ public class LauncherModel extends BroadcastReceiver for (ItemInfo itemInfo : sBgItemsIdMap) { if (itemInfo.itemType == LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT) { ShortcutInfo si = (ShortcutInfo) itemInfo; - if (si.getIntent().getPackage().equals(mPackageName) && si.user.equals(mUser)) { + if (si.getPromisedIntent().getPackage().equals(mPackageName) + && si.user.equals(mUser)) { String shortcutId = si.getDeepShortcutId(); if (idsToShortcuts.containsKey(shortcutId)) { idsToWorkspaceShortcutInfos.addToList(shortcutId, si); @@ -3461,7 +3464,7 @@ public class LauncherModel extends BroadcastReceiver ShortcutInfo si = (ShortcutInfo) itemInfo; if (isUserUnlocked) { ShortcutInfoCompat shortcut = - pinnedShortcuts.get(ShortcutKey.fromItemInfo(si)); + pinnedShortcuts.get(ShortcutKey.fromShortcutInfo(si)); // We couldn't verify the shortcut during loader. If its no longer available // (probably due to clear data), delete the workspace item as well if (shortcut == null) { diff --git a/src/com/android/launcher3/ShortcutInfo.java b/src/com/android/launcher3/ShortcutInfo.java index 8c466b2b0..21fa8a05e 100644 --- a/src/com/android/launcher3/ShortcutInfo.java +++ b/src/com/android/launcher3/ShortcutInfo.java @@ -167,6 +167,11 @@ public class ShortcutInfo extends ItemInfo { return intent; } + /** Returns {@link #promisedIntent}, or {@link #intent} if promisedIntent is null. */ + public Intent getPromisedIntent() { + return promisedIntent != null ? promisedIntent : intent; + } + ShortcutInfo(Intent intent, CharSequence title, CharSequence contentDescription, Bitmap icon, UserHandleCompat user) { this(); @@ -349,7 +354,7 @@ public class ShortcutInfo extends ItemInfo { /** Returns the ShortcutInfo id associated with the deep shortcut. */ public String getDeepShortcutId() { return itemType == Favorites.ITEM_TYPE_DEEP_SHORTCUT ? - intent.getStringExtra(ShortcutInfoCompat.EXTRA_SHORTCUT_ID) : null; + getPromisedIntent().getStringExtra(ShortcutInfoCompat.EXTRA_SHORTCUT_ID) : null; } @Override diff --git a/src/com/android/launcher3/shortcuts/ShortcutKey.java b/src/com/android/launcher3/shortcuts/ShortcutKey.java index 405303042..a219c5494 100644 --- a/src/com/android/launcher3/shortcuts/ShortcutKey.java +++ b/src/com/android/launcher3/shortcuts/ShortcutKey.java @@ -3,7 +3,7 @@ package com.android.launcher3.shortcuts; import android.content.ComponentName; import android.content.Intent; -import com.android.launcher3.ItemInfo; +import com.android.launcher3.ShortcutInfo; import com.android.launcher3.compat.UserHandleCompat; import com.android.launcher3.util.ComponentKey; @@ -32,7 +32,7 @@ public class ShortcutKey extends ComponentKey { return new ShortcutKey(intent.getPackage(), user, shortcutId); } - public static ShortcutKey fromItemInfo(ItemInfo info) { - return fromIntent(info.getIntent(), info.user); + public static ShortcutKey fromShortcutInfo(ShortcutInfo info) { + return fromIntent(info.getPromisedIntent(), info.user); } } diff --git a/src/com/android/launcher3/util/ItemInfoMatcher.java b/src/com/android/launcher3/util/ItemInfoMatcher.java index 6189bf2f4..46e9184b4 100644 --- a/src/com/android/launcher3/util/ItemInfoMatcher.java +++ b/src/com/android/launcher3/util/ItemInfoMatcher.java @@ -20,6 +20,7 @@ import android.content.ComponentName; import com.android.launcher3.ItemInfo; import com.android.launcher3.LauncherSettings.Favorites; +import com.android.launcher3.ShortcutInfo; import com.android.launcher3.compat.UserHandleCompat; import com.android.launcher3.shortcuts.ShortcutKey; @@ -57,7 +58,7 @@ public abstract class ItemInfoMatcher { @Override public boolean matches(ItemInfo info, ComponentName cn) { return info.itemType == Favorites.ITEM_TYPE_DEEP_SHORTCUT && - keys.contains(ShortcutKey.fromItemInfo(info)); + keys.contains(ShortcutKey.fromShortcutInfo((ShortcutInfo) info)); } }; } |