summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/ShortcutInfo.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/launcher3/ShortcutInfo.java')
-rw-r--r--src/com/android/launcher3/ShortcutInfo.java54
1 files changed, 42 insertions, 12 deletions
diff --git a/src/com/android/launcher3/ShortcutInfo.java b/src/com/android/launcher3/ShortcutInfo.java
index f40cf9fa1..dc019b272 100644
--- a/src/com/android/launcher3/ShortcutInfo.java
+++ b/src/com/android/launcher3/ShortcutInfo.java
@@ -16,13 +16,9 @@
package com.android.launcher3;
-import android.content.ComponentName;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
-import android.content.pm.PackageInfo;
-import android.content.pm.PackageManager;
-import android.content.pm.PackageManager.NameNotFoundException;
import android.graphics.Bitmap;
import android.util.Log;
@@ -36,22 +32,22 @@ import java.util.Arrays;
*/
public class ShortcutInfo extends ItemInfo {
- /** This package is not installed, and there is no other information available. */
+ /** {@link #mState} meaning this package is not installed, and there is no other information. */
public static final int PACKAGE_STATE_UNKNOWN = -2;
- /** This package is not installed, because installation failed. */
+ /** {@link #mState} meaning this package is not installed, because installation failed. */
public static final int PACKAGE_STATE_ERROR = -1;
- /** This package is installed. This is the typical case */
+ /** {@link #mState} meaning this package is installed. This is the typical case. */
public static final int PACKAGE_STATE_DEFAULT = 0;
- /** This package is not installed, but some external entity has promised to install it. */
+ /** {@link #mState} meaning some external entity has promised to install this package. */
public static final int PACKAGE_STATE_ENQUEUED = 1;
- /** This package is not installed, but some external entity is downloading it. */
+ /** {@link #mState} meaning but some external entity is downloading this package. */
public static final int PACKAGE_STATE_DOWNLOADING = 2;
- /** This package is not installed, but some external entity is installing it. */
+ /** {@link #mState} meaning some external entity is installing this package. */
public static final int PACKAGE_STATE_INSTALLING = 3;
/**
@@ -82,6 +78,17 @@ public class ShortcutInfo extends ItemInfo {
*/
private Bitmap mIcon;
+ /**
+ * Could be disabled, if the the app is installed but unavailable (eg. in safe mode or when
+ * sd-card is not available).
+ */
+ boolean isDisabled = false;
+
+ /**
+ * The installation state of the package that this shortcut represents.
+ */
+ protected int mState;
+
long firstInstallTime;
int flags = 0;
@@ -91,6 +98,11 @@ public class ShortcutInfo extends ItemInfo {
*/
Intent restoredIntent;
+ /**
+ * This is set once to indicate that it was a promise info at some point of its life.
+ */
+ boolean wasPromise = false;
+
ShortcutInfo() {
itemType = LauncherSettings.BaseLauncherColumns.ITEM_TYPE_SHORTCUT;
}
@@ -110,13 +122,16 @@ public class ShortcutInfo extends ItemInfo {
if (restoredIntent != null) {
intent = restoredIntent;
restoredIntent = null;
+ mState = PACKAGE_STATE_DEFAULT;
}
}
- ShortcutInfo(Intent intent, CharSequence title, Bitmap icon, UserHandleCompat user) {
+ ShortcutInfo(Intent intent, CharSequence title, CharSequence contentDescription,
+ Bitmap icon, UserHandleCompat user) {
this();
this.intent = intent;
this.title = title;
+ this.contentDescription = contentDescription;
mIcon = icon;
this.user = user;
}
@@ -170,7 +185,8 @@ public class ShortcutInfo extends ItemInfo {
String titleStr = title != null ? title.toString() : null;
values.put(LauncherSettings.BaseLauncherColumns.TITLE, titleStr);
- String uri = intent != null ? intent.toUri(0) : null;
+ String uri = restoredIntent != null ? restoredIntent.toUri(0)
+ : (intent != null ? intent.toUri(0) : null);
values.put(LauncherSettings.BaseLauncherColumns.INTENT, uri);
if (customIcon) {
@@ -218,5 +234,19 @@ public class ShortcutInfo extends ItemInfo {
&& pkgName != null
&& pkgName.equals(restoredIntent.getComponent().getPackageName());
}
+
+ public boolean isAbandoned() {
+ return isPromise()
+ && (mState == ShortcutInfo.PACKAGE_STATE_ERROR
+ || mState == ShortcutInfo.PACKAGE_STATE_UNKNOWN);
+ }
+
+ public int getState() {
+ return mState;
+ }
+
+ public void setState(int state) {
+ mState = state;
+ }
}