diff options
author | Tony <twickham@google.com> | 2017-06-16 17:24:54 -0700 |
---|---|---|
committer | Tony <twickham@google.com> | 2017-06-16 17:24:54 -0700 |
commit | 8f402808e499194df90b6d984f18c12fb762799f (patch) | |
tree | 06b02a06d2f1bbd5caed4cf79ff91aba54f1fa85 /src/com/android/launcher3/BubbleTextView.java | |
parent | f4087bbab4c508332ea9f722c511aaabf6550a11 (diff) | |
download | android_packages_apps_Trebuchet-8f402808e499194df90b6d984f18c12fb762799f.tar.gz android_packages_apps_Trebuchet-8f402808e499194df90b6d984f18c12fb762799f.tar.bz2 android_packages_apps_Trebuchet-8f402808e499194df90b6d984f18c12fb762799f.zip |
Fade original icon's text in as popup closes
Bug: 62444131
Change-Id: If8f91d8455a5952d252f9cdd1b211afb5ee035c7
Diffstat (limited to 'src/com/android/launcher3/BubbleTextView.java')
-rw-r--r-- | src/com/android/launcher3/BubbleTextView.java | 35 |
1 files changed, 32 insertions, 3 deletions
diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java index 27e190e5d..b6e73287f 100644 --- a/src/com/android/launcher3/BubbleTextView.java +++ b/src/com/android/launcher3/BubbleTextView.java @@ -16,10 +16,10 @@ package com.android.launcher3; +import android.animation.Animator; import android.animation.ObjectAnimator; import android.content.Context; import android.content.res.ColorStateList; -import android.content.res.Resources; import android.content.res.TypedArray; import android.graphics.Bitmap; import android.graphics.Canvas; @@ -30,6 +30,7 @@ import android.graphics.Rect; import android.graphics.Region; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; +import android.support.v4.graphics.ColorUtils; import android.util.AttributeSet; import android.util.Property; import android.util.TypedValue; @@ -119,6 +120,19 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver { } }; + private static final Property<BubbleTextView, Integer> TEXT_ALPHA_PROPERTY + = new Property<BubbleTextView, Integer>(Integer.class, "textAlpha") { + @Override + public Integer get(BubbleTextView bubbleTextView) { + return bubbleTextView.getTextAlpha(); + } + + @Override + public void set(BubbleTextView bubbleTextView, Integer alpha) { + bubbleTextView.setTextAlpha(alpha); + } + }; + @ViewDebug.ExportedProperty(category = "launcher") private boolean mStayPressed; @ViewDebug.ExportedProperty(category = "launcher") @@ -533,14 +547,29 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver { } public void setTextVisibility(boolean visible) { - Resources res = getResources(); if (visible) { super.setTextColor(mTextColor); } else { - super.setTextColor(res.getColor(android.R.color.transparent)); + setTextAlpha(0); } } + private void setTextAlpha(int alpha) { + super.setTextColor(ColorUtils.setAlphaComponent(mTextColor, alpha)); + } + + private int getTextAlpha() { + return Color.alpha(getCurrentTextColor()); + } + + /** + * Creates an animator to fade the text in or out. + * @param fadeIn Whether the text should fade in or fade out. + */ + public Animator createTextAlphaAnimator(boolean fadeIn) { + return ObjectAnimator.ofInt(this, TEXT_ALPHA_PROPERTY, fadeIn ? Color.alpha(mTextColor) : 0); + } + @Override public void cancelLongPress() { super.cancelLongPress(); |