diff options
Diffstat (limited to 'src/com/android/launcher3/BubbleTextView.java')
-rw-r--r-- | src/com/android/launcher3/BubbleTextView.java | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java index 95300c133..992ac5897 100644 --- a/src/com/android/launcher3/BubbleTextView.java +++ b/src/com/android/launcher3/BubbleTextView.java @@ -74,8 +74,6 @@ public class BubbleTextView extends TextView { private CheckLongPressHelper mLongPressHelper; private int mInstallState; - private int mState; - private CharSequence mDefaultText = ""; public BubbleTextView(Context context) { @@ -124,10 +122,9 @@ public class BubbleTextView extends TextView { 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 + applyState(); } } @@ -150,6 +147,11 @@ public class BubbleTextView extends TextView { LauncherModel.checkItemInfo((ItemInfo) tag); } super.setTag(tag); + if (tag instanceof ShortcutInfo) { + final ShortcutInfo info = (ShortcutInfo) tag; + mDefaultText = info.title; + setText(mDefaultText); + } } @Override @@ -415,19 +417,12 @@ 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() { + public void applyState() { int alpha = getResources().getInteger(R.integer.promise_icon_alpha); - if (DEBUG) Log.d(TAG, "applying icon state: " + mState); + final int state = getState(); + if (DEBUG) Log.d(TAG, "applying icon state: " + state); - switch(mState) { + switch(state) { case ShortcutInfo.PACKAGE_STATE_DEFAULT: super.setText(mDefaultText); alpha = 255; @@ -462,4 +457,13 @@ public class BubbleTextView extends TextView { } } } + + private int getState() { + if (! (getTag() instanceof ShortcutInfo)) { + return ShortcutInfo.PACKAGE_STATE_DEFAULT; + } else { + ShortcutInfo info = (ShortcutInfo) getTag(); + return info.getState(); + } + } } |