diff options
author | Sunny Goyal <sunnygoyal@google.com> | 2017-01-13 18:34:52 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2017-01-13 18:34:53 +0000 |
commit | 761d49a7a1c51de256a1b0e6181e9ad46c9347e1 (patch) | |
tree | 8ee6445e9244dd1e813b279d7caa0e4460abe278 /src/com | |
parent | e495056bd31c7803e44544237ec89460a1272387 (diff) | |
parent | e6e7200791c28472c9335a187a85dbeda1a77d24 (diff) | |
download | android_packages_apps_Trebuchet-761d49a7a1c51de256a1b0e6181e9ad46c9347e1.tar.gz android_packages_apps_Trebuchet-761d49a7a1c51de256a1b0e6181e9ad46c9347e1.tar.bz2 android_packages_apps_Trebuchet-761d49a7a1c51de256a1b0e6181e9ad46c9347e1.zip |
Merge "Removing promiseIntent property from ShortuctInfo" into ub-launcher3-master
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/android/launcher3/InfoDropTarget.java | 13 | ||||
-rw-r--r-- | src/com/android/launcher3/Launcher.java | 61 | ||||
-rw-r--r-- | src/com/android/launcher3/LauncherModel.java | 5 | ||||
-rw-r--r-- | src/com/android/launcher3/ShortcutInfo.java | 12 | ||||
-rw-r--r-- | src/com/android/launcher3/model/AddWorkspaceItemsTask.java | 6 | ||||
-rw-r--r-- | src/com/android/launcher3/model/LoaderCursor.java | 2 | ||||
-rw-r--r-- | src/com/android/launcher3/model/PackageUpdatedTask.java | 4 |
7 files changed, 47 insertions, 56 deletions
diff --git a/src/com/android/launcher3/InfoDropTarget.java b/src/com/android/launcher3/InfoDropTarget.java index db14e2e81..d831a3a03 100644 --- a/src/com/android/launcher3/InfoDropTarget.java +++ b/src/com/android/launcher3/InfoDropTarget.java @@ -96,9 +96,14 @@ public class InfoDropTarget extends UninstallDropTarget { // Only show the App Info drop target if developer settings are enabled. boolean developmentSettingsEnabled = Settings.Global.getInt(context.getContentResolver(), Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0) == 1; - return developmentSettingsEnabled - && (info instanceof AppInfo || info instanceof ShortcutInfo - || info instanceof PendingAddItemInfo || info instanceof LauncherAppWidgetInfo) - && info.itemType != LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT; + if (!developmentSettingsEnabled) { + return false; + } + return info.itemType != LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT && + (info instanceof AppInfo || + (info instanceof ShortcutInfo && !((ShortcutInfo) info).isPromise()) || + (info instanceof LauncherAppWidgetInfo && + ((LauncherAppWidgetInfo) info).restoreStatus == 0) || + info instanceof PendingAddItemInfo); } } diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 8322f66cd..fc112f380 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -2331,20 +2331,9 @@ public class Launcher extends Activity startRestoredWidgetReconfigActivity(appWidgetInfo, info); } } - } else if (info.installProgress < 0) { - // The install has not been queued - final String packageName = info.providerName.getPackageName(); - showBrokenAppInstallDialog(packageName, - new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int id) { - startActivitySafely( - v, PackageManagerHelper.getMarketIntent(packageName), info); - } - }); } else { - // Download has started. final String packageName = info.providerName.getPackageName(); - startActivitySafely(v, PackageManagerHelper.getMarketIntent(packageName), info); + onClickPendingAppItem(v, packageName, info.installProgress >= 0); } } @@ -2381,12 +2370,22 @@ public class Launcher extends Activity } } - private void showBrokenAppInstallDialog(final String packageName, - DialogInterface.OnClickListener onSearchClickListener) { + private void onClickPendingAppItem(final View v, final String packageName, + boolean downloadStarted) { + if (downloadStarted) { + // If the download has started, simply direct to the market app. + startMarketIntentForPackage(v, packageName); + return; + } new AlertDialog.Builder(this) .setTitle(R.string.abandoned_promises_title) .setMessage(R.string.abandoned_promise_explanation) - .setPositiveButton(R.string.abandoned_search, onSearchClickListener) + .setPositiveButton(R.string.abandoned_search, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + startMarketIntentForPackage(v, packageName); + } + }) .setNeutralButton(R.string.abandoned_clean_this, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { @@ -2395,7 +2394,16 @@ public class Launcher extends Activity } }) .create().show(); - return; + } + + private void startMarketIntentForPackage(View v, String packageName) { + ItemInfo item = (ItemInfo) v.getTag(); + Intent intent = PackageManagerHelper.getMarketIntent(packageName); + boolean success = startActivitySafely(v, intent, item); + if (success && v instanceof BubbleTextView) { + mWaitingForResume = (BubbleTextView) v; + mWaitingForResume.setStayPressed(true); + } } /** @@ -2439,17 +2447,14 @@ public class Launcher extends Activity } // Check for abandoned promise - if ((v instanceof BubbleTextView) - && shortcut.isPromise() - && !shortcut.hasStatusFlag(ShortcutInfo.FLAG_INSTALL_SESSION_ACTIVE)) { - showBrokenAppInstallDialog( - shortcut.getTargetComponent().getPackageName(), - new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int id) { - startAppShortcutOrInfoActivity(v); - } - }); - return; + if ((v instanceof BubbleTextView) && shortcut.isPromise()) { + String packageName = shortcut.intent.getComponent() != null ? + shortcut.intent.getComponent().getPackageName() : shortcut.intent.getPackage(); + if (!TextUtils.isEmpty(packageName)) { + onClickPendingAppItem(v, packageName, + shortcut.hasStatusFlag(ShortcutInfo.FLAG_INSTALL_SESSION_ACTIVE)); + return; + } } // Start activities @@ -2715,7 +2720,7 @@ public class Launcher extends Activity if (Utilities.ATLEAST_MARSHMALLOW && item != null && (item.itemType == Favorites.ITEM_TYPE_SHORTCUT || item.itemType == Favorites.ITEM_TYPE_DEEP_SHORTCUT) - && ((ShortcutInfo) item).promisedIntent == null) { + && !((ShortcutInfo) item).isPromise()) { // Shortcuts need some special checks due to legacy reasons. startShortcutIntentSafely(intent, optsBundle, item); } else if (user == null || user.equals(Process.myUserHandle())) { diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java index 0907c8cad..693861184 100644 --- a/src/com/android/launcher3/LauncherModel.java +++ b/src/com/android/launcher3/LauncherModel.java @@ -1321,8 +1321,6 @@ public class LauncherModel extends BroadcastReceiver if (restored) { if (c.user.equals(Process.myUserHandle())) { info = c.getRestoredItemInfo(intent, promiseType); - intent = PackageManagerHelper.getMarketIntent( - intent.getComponent().getPackageName()); } else { // Don't restore items for other profiles. c.markDeleted("Restore from managed profile not supported"); @@ -1382,9 +1380,6 @@ public class LauncherModel extends BroadcastReceiver // TODO: Remove this extra. Instead we should be using // itemInfo#user. info.intent.putExtra(ItemInfo.EXTRA_PROFILE, c.serialNumber); - if (info.promisedIntent != null) { - info.promisedIntent.putExtra(ItemInfo.EXTRA_PROFILE, c.serialNumber); - } info.isDisabled |= disabledState; if (isSafeMode && !Utilities.isSystemApp(context, intent)) { info.isDisabled |= ShortcutInfo.FLAG_DISABLED_SAFEMODE; diff --git a/src/com/android/launcher3/ShortcutInfo.java b/src/com/android/launcher3/ShortcutInfo.java index 8c83dff2b..c76217d3d 100644 --- a/src/com/android/launcher3/ShortcutInfo.java +++ b/src/com/android/launcher3/ShortcutInfo.java @@ -131,13 +131,6 @@ public class ShortcutInfo extends ItemInfoWithIcon { */ private int mInstallProgress; - /** - * If this shortcut is a placeholder, then intent will be a market intent for the package, and - * this will hold the original intent from the database. Otherwise, null. - * Refer {@link #FLAG_RESTORED_ICON}, {@link #FLAG_AUTOINTALL_ICON} - */ - public Intent promisedIntent; - public ShortcutInfo() { itemType = LauncherSettings.BaseLauncherColumns.ITEM_TYPE_SHORTCUT; } @@ -190,12 +183,9 @@ public class ShortcutInfo extends ItemInfoWithIcon { } } - /** - * Returns {@link #promisedIntent}, or {@link #intent} if promisedIntent is null. - */ @Override public Intent getIntent() { - return promisedIntent != null ? promisedIntent : intent; + return intent; } public boolean hasStatusFlag(int flag) { diff --git a/src/com/android/launcher3/model/AddWorkspaceItemsTask.java b/src/com/android/launcher3/model/AddWorkspaceItemsTask.java index a9ceb0256..a03dd8f34 100644 --- a/src/com/android/launcher3/model/AddWorkspaceItemsTask.java +++ b/src/com/android/launcher3/model/AddWorkspaceItemsTask.java @@ -163,10 +163,8 @@ public class AddWorkspaceItemsTask extends ExtendedModelTask { for (ItemInfo item : dataModel.itemsIdMap) { if (item instanceof ShortcutInfo) { ShortcutInfo info = (ShortcutInfo) item; - Intent targetIntent = info.promisedIntent == null - ? info.intent : info.promisedIntent; - if (targetIntent != null && info.user.equals(user)) { - Intent copyIntent = new Intent(targetIntent); + if (item.getIntent() != null && info.user.equals(user)) { + Intent copyIntent = new Intent(item.getIntent()); copyIntent.setSourceBounds(intent.getSourceBounds()); String s = copyIntent.toUri(0); if (intentWithPkg.equals(s) || intentWithoutPkg.equals(s)) { diff --git a/src/com/android/launcher3/model/LoaderCursor.java b/src/com/android/launcher3/model/LoaderCursor.java index 43e1bd611..b271e6fbd 100644 --- a/src/com/android/launcher3/model/LoaderCursor.java +++ b/src/com/android/launcher3/model/LoaderCursor.java @@ -188,7 +188,7 @@ public class LoaderCursor extends CursorWrapper { public ShortcutInfo getRestoredItemInfo(Intent intent, int promiseType) { final ShortcutInfo info = new ShortcutInfo(); info.user = user; - info.promisedIntent = intent; + info.intent = intent; info.iconBitmap = loadIcon(info); // the fallback icon diff --git a/src/com/android/launcher3/model/PackageUpdatedTask.java b/src/com/android/launcher3/model/PackageUpdatedTask.java index f5de6508e..211b9793f 100644 --- a/src/com/android/launcher3/model/PackageUpdatedTask.java +++ b/src/com/android/launcher3/model/PackageUpdatedTask.java @@ -242,12 +242,10 @@ public class PackageUpdatedTask extends ExtendedModelTask { removedShortcuts.add(si); continue; } - si.promisedIntent = intent; + si.intent = intent; } } - si.intent = si.promisedIntent; - si.promisedIntent = null; si.status = ShortcutInfo.DEFAULT; infoUpdated = true; if (si.itemType == Favorites.ITEM_TYPE_APPLICATION) { |