diff options
author | Sunny Goyal <sunnygoyal@google.com> | 2014-07-09 00:09:28 -0700 |
---|---|---|
committer | Sunny Goyal <sunnygoyal@google.com> | 2014-07-16 13:37:56 -0700 |
commit | 3484638cad97e255a412b0489a63873fb3ca4218 (patch) | |
tree | dbc210a2298262bb8df5c1149a80d35e7c71af7f /src/com/android/launcher3/BubbleTextView.java | |
parent | f599ccfe96eae7e4854bddfedd3df945feb9b7f5 (diff) | |
download | android_packages_apps_Trebuchet-3484638cad97e255a412b0489a63873fb3ca4218.tar.gz android_packages_apps_Trebuchet-3484638cad97e255a412b0489a63873fb3ca4218.tar.bz2 android_packages_apps_Trebuchet-3484638cad97e255a412b0489a63873fb3ca4218.zip |
Adding a circular progress bar for preloader icons
Change-Id: I1b5ba61c01a16a8cb5d3f9e31f827f8c99a1ffc9
Diffstat (limited to 'src/com/android/launcher3/BubbleTextView.java')
-rw-r--r-- | src/com/android/launcher3/BubbleTextView.java | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java index 57dcea044..3f619a812 100644 --- a/src/com/android/launcher3/BubbleTextView.java +++ b/src/com/android/launcher3/BubbleTextView.java @@ -136,7 +136,8 @@ public class BubbleTextView extends TextView { setContentDescription(info.contentDescription); } setTag(info); - if (info.isPromise()) { + + if (info.wasPromise) { applyState(); } } @@ -431,42 +432,55 @@ public class BubbleTextView extends TextView { } public void applyState() { - int alpha = getResources().getInteger(R.integer.promise_icon_alpha); + 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); - alpha = 255; + 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; case ShortcutInfo.PACKAGE_STATE_ERROR: setText(R.string.package_state_error); + progressLevel = 0; break; case ShortcutInfo.PACKAGE_STATE_UNKNOWN: default: + progressLevel = 0; 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); + 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(); } } } |