summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2017-01-12 16:55:36 -0800
committerSunny Goyal <sunnygoyal@google.com>2017-01-12 18:54:21 -0800
commite6e7200791c28472c9335a187a85dbeda1a77d24 (patch)
tree46bab436bccab7c4d545ea76b1348c7b5b172e20
parent3e9be43b6ea75c8b82b57aa58508a0c3e8e1d721 (diff)
downloadandroid_packages_apps_Trebuchet-e6e7200791c28472c9335a187a85dbeda1a77d24.tar.gz
android_packages_apps_Trebuchet-e6e7200791c28472c9335a187a85dbeda1a77d24.tar.bz2
android_packages_apps_Trebuchet-e6e7200791c28472c9335a187a85dbeda1a77d24.zip
Removing promiseIntent property from ShortuctInfo
> Instead of checking promiseIntent != null, using isPromise() for consistency > Fixing bug where clicking a pending icon does not launch anything > Fixing bug where draging an icon on Info target, permanently hides the icon Change-Id: Ic8f6b56042dba42d5ed9aedb0f5947186e1a4208
-rw-r--r--src/com/android/launcher3/InfoDropTarget.java13
-rw-r--r--src/com/android/launcher3/Launcher.java61
-rw-r--r--src/com/android/launcher3/LauncherModel.java5
-rw-r--r--src/com/android/launcher3/ShortcutInfo.java12
-rw-r--r--src/com/android/launcher3/model/AddWorkspaceItemsTask.java6
-rw-r--r--src/com/android/launcher3/model/LoaderCursor.java2
-rw-r--r--src/com/android/launcher3/model/PackageUpdatedTask.java4
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) {