diff --git a/res/values/integers.xml b/res/values/integers.xml
new file mode 100644
index 0000000000..7d26d85955
--- /dev/null
+++ b/res/values/integers.xml
@@ -0,0 +1,22 @@
+
+
+
+
+ 127
+
\ No newline at end of file
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 9cb6c293b0..8ba58e56f1 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -262,4 +262,15 @@ s -->
Wallpapers
Settings
+
+
+ Waiting
+
+ Downloading
+
+ Installing
+
+ Unknown
+
+ Error
diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java
index ee42904dd6..c180d32275 100644
--- a/src/com/android/launcher3/BubbleTextView.java
+++ b/src/com/android/launcher3/BubbleTextView.java
@@ -25,6 +25,7 @@ import android.graphics.Region;
import android.graphics.Region.Op;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
+import android.util.Log;
import android.util.TypedValue;
import android.view.MotionEvent;
import android.widget.TextView;
@@ -43,6 +44,10 @@ public class BubbleTextView extends TextView {
static final float PADDING_H = 8.0f;
static final float PADDING_V = 3.0f;
+ private static final String TAG = "BubbleTextView";
+
+ private static final boolean DEBUG = false;
+
private int mPrevAlpha = -1;
private HolographicOutlineHelper mOutlineHelper;
@@ -64,6 +69,11 @@ public class BubbleTextView extends TextView {
private boolean mStayPressed;
private CheckLongPressHelper mLongPressHelper;
+ private int mInstallState;
+
+ private int mState;
+
+ private CharSequence mDefaultText = "";
public BubbleTextView(Context context) {
super(context);
@@ -108,11 +118,14 @@ public class BubbleTextView extends TextView {
LauncherAppState app = LauncherAppState.getInstance();
DeviceProfile grid = app.getDynamicGrid().getDeviceProfile();
- setCompoundDrawables(null,
- Utilities.createIconDrawable(b), null, null);
+ Drawable iconDrawable = Utilities.createIconDrawable(b);
+ setCompoundDrawables(null, iconDrawable, null, null);
setCompoundDrawablePadding(grid.iconDrawablePaddingPx);
setText(info.title);
setTag(info);
+ if (info.isPromise()) {
+ setState(ShortcutInfo.PACKAGE_STATE_UNKNOWN); // TODO: persist this state somewhere
+ }
}
@Override
@@ -392,4 +405,52 @@ public class BubbleTextView extends TextView {
mLongPressHelper.cancelLongPress();
}
+
+ public void setState(int state) {
+ if (mState == ShortcutInfo.PACKAGE_STATE_DEFAULT && mState != state) {
+ mDefaultText = getText();
+ }
+ mState = state;
+ applyState();
+ }
+
+ private void applyState() {
+ int alpha = getResources().getInteger(R.integer.promise_icon_alpha);
+ if (DEBUG) Log.d(TAG, "applying icon state: " + mState);
+
+ switch(mState) {
+ case ShortcutInfo.PACKAGE_STATE_DEFAULT:
+ super.setText(mDefaultText);
+ alpha = 255;
+ break;
+
+ case ShortcutInfo.PACKAGE_STATE_ENQUEUED:
+ setText(R.string.package_state_enqueued);
+ break;
+
+ case ShortcutInfo.PACKAGE_STATE_DOWNLOADING:
+ setText(R.string.package_state_downloading);
+ break;
+
+ case ShortcutInfo.PACKAGE_STATE_INSTALLING:
+ setText(R.string.package_state_installing);
+ break;
+
+ case ShortcutInfo.PACKAGE_STATE_ERROR:
+ setText(R.string.package_state_error);
+ break;
+
+ case ShortcutInfo.PACKAGE_STATE_UNKNOWN:
+ default:
+ setText(R.string.package_state_unknown);
+ break;
+ }
+ if (DEBUG) Log.d(TAG, "setting icon alpha to: " + alpha);
+ Drawable[] drawables = getCompoundDrawables();
+ for (int i = 0; i < drawables.length; i++) {
+ if (drawables[i] != null) {
+ drawables[i].setAlpha(alpha);
+ }
+ }
+ }
}
diff --git a/src/com/android/launcher3/IconCache.java b/src/com/android/launcher3/IconCache.java
index 827718b9ee..ee9f4d4b0b 100644
--- a/src/com/android/launcher3/IconCache.java
+++ b/src/com/android/launcher3/IconCache.java
@@ -387,20 +387,6 @@ public class IconCache {
}
}
- if (icon != null) {
- // TODO: handle alpha mask in the view layer
- Bitmap b = Bitmap.createBitmap(Math.max(icon.getWidth(), 1),
- Math.max(icon.getHeight(), 1),
- Bitmap.Config.ARGB_8888);
- Canvas c = new Canvas(b);
- Paint paint = new Paint();
- paint.setAlpha(127);
- c.drawBitmap(icon, 0, 0, paint);
- c.setBitmap(null);
- icon.recycle();
- icon = b;
- }
-
return icon;
}
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 986fa2162c..bd1ef321a8 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -4222,6 +4222,17 @@ public class Launcher extends Activity
}
}
+ /**
+ * Update the state of a package, typically related to install state.
+ *
+ * Implementation of the method from LauncherModel.Callbacks.
+ */
+ public void updatePackageState(String pkgName, int state) {
+ if (mWorkspace != null) {
+ mWorkspace.updatePackageState(pkgName, state);
+ }
+ }
+
/**
* A package was uninstalled. We take both the super set of packageNames
* in addition to specific applications to remove, the reason being that
diff --git a/src/com/android/launcher3/LauncherAppState.java b/src/com/android/launcher3/LauncherAppState.java
index 29e18f9c03..ba10f51ad9 100644
--- a/src/com/android/launcher3/LauncherAppState.java
+++ b/src/com/android/launcher3/LauncherAppState.java
@@ -30,6 +30,8 @@ public class LauncherAppState implements DeviceProfile.DeviceProfileCallbacks {
private static final String TAG = "LauncherAppState";
private static final String SHARED_PREFERENCES_KEY = "com.android.launcher3.prefs";
+ private static final boolean DEBUG = true; // TODO STOPSHIP: set this to false
+
private final AppFilter mAppFilter;
private final BuildInfo mBuildInfo;
private LauncherModel mModel;
@@ -249,4 +251,9 @@ public class LauncherAppState implements DeviceProfile.DeviceProfileCallbacks {
public static boolean isDogfoodBuild() {
return getInstance().mBuildInfo.isDogfoodBuild();
}
+
+ public void setPackageState(String pkgName, int state) {
+ if (DEBUG) Log.d(TAG, "setPackageState(" + pkgName + ", " + state + ")");
+ mModel.setPackageState(pkgName, state);
+ }
}
diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java
index 5f8f80cea4..145d225dc9 100644
--- a/src/com/android/launcher3/LauncherModel.java
+++ b/src/com/android/launcher3/LauncherModel.java
@@ -173,6 +173,7 @@ public class LauncherModel extends BroadcastReceiver {
ArrayList addAnimated,
ArrayList addedApps);
public void bindAppsUpdated(ArrayList apps);
+ public void updatePackageState(String pkgName, int state);
public void bindComponentsRemoved(ArrayList packageNames,
ArrayList appInfos);
public void bindPackagesUpdated(ArrayList