summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/BubbleTextView.java
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2014-07-22 13:48:29 -0700
committerSunny Goyal <sunnygoyal@google.com>2014-08-01 14:45:39 -0700
commite755d469d40b95e763a9dcb67d0e4f511d1948dd (patch)
treeefeb5b14ebf555a41f37bac96b8eb198e61c7899 /src/com/android/launcher3/BubbleTextView.java
parentc5b6ac7215329d9f827731a43c330451f38b9965 (diff)
downloadandroid_packages_apps_Trebuchet-e755d469d40b95e763a9dcb67d0e4f511d1948dd.tar.gz
android_packages_apps_Trebuchet-e755d469d40b95e763a9dcb67d0e4f511d1948dd.tar.bz2
android_packages_apps_Trebuchet-e755d469d40b95e763a9dcb67d0e4f511d1948dd.zip
Implementing a package install progress listener for L
issue: 15835307 Change-Id: I71aaea087963f2e0e1206447190cbe23c174057d
Diffstat (limited to 'src/com/android/launcher3/BubbleTextView.java')
-rw-r--r--src/com/android/launcher3/BubbleTextView.java93
1 files changed, 38 insertions, 55 deletions
diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java
index ffa7ec37e..ab94814c3 100644
--- a/src/com/android/launcher3/BubbleTextView.java
+++ b/src/com/android/launcher3/BubbleTextView.java
@@ -434,65 +434,48 @@ public class BubbleTextView extends TextView {
}
public void applyState() {
- final int progressLevel;
- final int state = getState();
- if (DEBUG) Log.d(TAG, "applying icon state: " + state);
-
- switch(state) {
- case ShortcutInfo.PACKAGE_STATE_DEFAULT:
- super.setText(mDefaultText);
- progressLevel = 100;
- break;
-
- case ShortcutInfo.PACKAGE_STATE_ENQUEUED:
- setText(R.string.package_state_enqueued);
- progressLevel = 0;
- break;
-
- case ShortcutInfo.PACKAGE_STATE_DOWNLOADING:
- setText(R.string.package_state_downloading);
- // TODO(sunnygoyal): fix progress
- progressLevel = 30;
- break;
-
- case ShortcutInfo.PACKAGE_STATE_INSTALLING:
- setText(R.string.package_state_installing);
- progressLevel = 100;
- break;
+ if (getTag() instanceof ShortcutInfo) {
+ ShortcutInfo info = (ShortcutInfo) getTag();
+ final int state = info.getState();
+
+ final int progressLevel;
+ if (DEBUG) Log.d(TAG, "applying icon state: " + state);
+
+ switch(state) {
+ case ShortcutInfo.PACKAGE_STATE_DEFAULT:
+ progressLevel = 100;
+ break;
+
+ case ShortcutInfo.PACKAGE_STATE_INSTALLING:
+ setText(R.string.package_state_installing);
+ progressLevel = info.getProgress();
+ break;
+
+ case ShortcutInfo.PACKAGE_STATE_ERROR:
+ case ShortcutInfo.PACKAGE_STATE_UNKNOWN:
+ default:
+ progressLevel = 0;
+ setText(R.string.package_state_unknown);
+ break;
+ }
- case ShortcutInfo.PACKAGE_STATE_ERROR:
- setText(R.string.package_state_error);
- progressLevel = 0;
- break;
+ Drawable[] drawables = getCompoundDrawables();
+ Drawable top = drawables[1];
+ if (top != null) {
+ final PreloadIconDrawable preloadDrawable;
+ if (top instanceof PreloadIconDrawable) {
+ preloadDrawable = (PreloadIconDrawable) top;
+ } else {
+ preloadDrawable = new PreloadIconDrawable(top, getResources());
+ setCompoundDrawables(drawables[0], preloadDrawable, drawables[2], drawables[3]);
+ }
- case ShortcutInfo.PACKAGE_STATE_UNKNOWN:
- default:
- progressLevel = 0;
- setText(R.string.package_state_unknown);
- break;
- }
+ preloadDrawable.setLevel(progressLevel);
+ if (state == ShortcutInfo.PACKAGE_STATE_DEFAULT) {
+ preloadDrawable.maybePerformFinishedAnimation();
+ }
- Drawable[] drawables = getCompoundDrawables();
- Drawable top = drawables[1];
- if ((top != null) && !(top instanceof PreloadIconDrawable)) {
- top = new PreloadIconDrawable(top, getResources());
- setCompoundDrawables(drawables[0], top, drawables[2], drawables[3]);
- }
- if (top != null) {
- top.setLevel(progressLevel);
- if ((top instanceof PreloadIconDrawable)
- && (state == ShortcutInfo.PACKAGE_STATE_DEFAULT)) {
- ((PreloadIconDrawable) top).maybePerformFinishedAnimation();
}
}
}
-
- private int getState() {
- if (! (getTag() instanceof ShortcutInfo)) {
- return ShortcutInfo.PACKAGE_STATE_DEFAULT;
- } else {
- ShortcutInfo info = (ShortcutInfo) getTag();
- return info.getState();
- }
- }
}