diff options
author | Chris Wren <cwren@android.com> | 2014-02-14 16:59:24 -0500 |
---|---|---|
committer | Chris Wren <cwren@android.com> | 2014-03-11 13:41:05 -0400 |
commit | aeff7ea43409d817490fbb8c22b8d4b9725bb54f (patch) | |
tree | 15d620ddc1b70e02d82852aae7000b69935c6c5c /src/com/android/launcher3/BubbleTextView.java | |
parent | bfbd52a5e618a86dc7a13bb5e4866759e181a7cb (diff) | |
download | android_packages_apps_Trebuchet-aeff7ea43409d817490fbb8c22b8d4b9725bb54f.tar.gz android_packages_apps_Trebuchet-aeff7ea43409d817490fbb8c22b8d4b9725bb54f.tar.bz2 android_packages_apps_Trebuchet-aeff7ea43409d817490fbb8c22b8d4b9725bb54f.zip |
update promise icon status
also fix a crash in LauncherModel.DEBUG_LOADERS
Bug: 10778992
Change-Id: Iafc28c1e0c2f2a1283783a7ce27e181634b62993
Diffstat (limited to 'src/com/android/launcher3/BubbleTextView.java')
-rw-r--r-- | src/com/android/launcher3/BubbleTextView.java | 65 |
1 files changed, 63 insertions, 2 deletions
diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java index ee42904dd..c180d3227 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); + } + } + } } |