diff options
-rw-r--r-- | src/com/android/launcher3/BubbleTextView.java | 91 | ||||
-rw-r--r-- | src/com/android/launcher3/folder/FolderAnimationManager.java | 6 |
2 files changed, 54 insertions, 43 deletions
diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java index 41bfcb7ae..fb7c0ced4 100644 --- a/src/com/android/launcher3/BubbleTextView.java +++ b/src/com/android/launcher3/BubbleTextView.java @@ -65,27 +65,6 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, private static final int[] STATE_PRESSED = new int[] {android.R.attr.state_pressed}; - private final BaseDraggingActivity mActivity; - private Drawable mIcon; - private final boolean mCenterVertically; - - private final CheckLongPressHelper mLongPressHelper; - private final StylusEventHelper mStylusEventHelper; - private final float mSlop; - - private final boolean mLayoutHorizontal; - private final int mIconSize; - @ViewDebug.ExportedProperty(category = "launcher") - private int mTextColor; - private boolean mIsIconVisible = true; - - private BadgeInfo mBadgeInfo; - private BadgeRenderer mBadgeRenderer; - private int mBadgeColor; - private float mBadgeScale; - private boolean mForceHideBadge; - private Point mTempSpaceForBadgeOffset = new Point(); - private Rect mTempIconBounds = new Rect(); private static final Property<BubbleTextView, Float> BADGE_SCALE_PROPERTY = new Property<BubbleTextView, Float>(Float.TYPE, "badgeScale") { @@ -101,19 +80,45 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, } }; - public static final Property<BubbleTextView, Integer> TEXT_ALPHA_PROPERTY - = new Property<BubbleTextView, Integer>(Integer.class, "textAlpha") { + public static final Property<BubbleTextView, Float> TEXT_ALPHA_PROPERTY + = new Property<BubbleTextView, Float>(Float.class, "textAlpha") { @Override - public Integer get(BubbleTextView bubbleTextView) { - return bubbleTextView.getTextAlpha(); + public Float get(BubbleTextView bubbleTextView) { + return bubbleTextView.mTextAlpha; } @Override - public void set(BubbleTextView bubbleTextView, Integer alpha) { + public void set(BubbleTextView bubbleTextView, Float alpha) { bubbleTextView.setTextAlpha(alpha); } }; + private final BaseDraggingActivity mActivity; + private Drawable mIcon; + private final boolean mCenterVertically; + + private final CheckLongPressHelper mLongPressHelper; + private final StylusEventHelper mStylusEventHelper; + private final float mSlop; + + private final boolean mLayoutHorizontal; + private final int mIconSize; + + @ViewDebug.ExportedProperty(category = "launcher") + private boolean mIsIconVisible = true; + @ViewDebug.ExportedProperty(category = "launcher") + private int mTextColor; + @ViewDebug.ExportedProperty(category = "launcher") + private float mTextAlpha = 1; + + private BadgeInfo mBadgeInfo; + private BadgeRenderer mBadgeRenderer; + private int mBadgeColor; + private float mBadgeScale; + private boolean mForceHideBadge; + private Point mTempSpaceForBadgeOffset = new Point(); + private Rect mTempIconBounds = new Rect(); + @ViewDebug.ExportedProperty(category = "launcher") private boolean mStayPressed; @ViewDebug.ExportedProperty(category = "launcher") @@ -166,7 +171,7 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, setEllipsize(TruncateAt.END); setAccessibilityDelegate(mActivity.getAccessibilityDelegate()); - + setTextAlpha(1f); } @Override @@ -404,13 +409,17 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, @Override public void setTextColor(int color) { mTextColor = color; - super.setTextColor(color); + super.setTextColor(getModifiedColor()); } @Override public void setTextColor(ColorStateList colors) { mTextColor = colors.getDefaultColor(); - super.setTextColor(colors); + if (Float.compare(mTextAlpha, 1) == 0) { + super.setTextColor(colors); + } else { + super.setTextColor(getModifiedColor()); + } } public boolean shouldTextBeVisible() { @@ -421,19 +430,21 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, } public void setTextVisibility(boolean visible) { - if (visible) { - super.setTextColor(mTextColor); - } else { - setTextAlpha(0); - } + setTextAlpha(visible ? 1 : 0); } - public void setTextAlpha(int alpha) { - super.setTextColor(ColorUtils.setAlphaComponent(mTextColor, alpha)); + private void setTextAlpha(float alpha) { + mTextAlpha = alpha; + super.setTextColor(getModifiedColor()); } - private int getTextAlpha() { - return Color.alpha(getCurrentTextColor()); + private int getModifiedColor() { + if (mTextAlpha == 0) { + // Special case to prevent text shadows in high contrast mode + return Color.TRANSPARENT; + } + return ColorUtils.setAlphaComponent( + mTextColor, Math.round(Color.alpha(mTextColor) * mTextAlpha)); } /** @@ -441,8 +452,8 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, * @param fadeIn Whether the text should fade in or fade out. */ public ObjectAnimator createTextAlphaAnimator(boolean fadeIn) { - int toAlpha = shouldTextBeVisible() && fadeIn ? Color.alpha(mTextColor) : 0; - return ObjectAnimator.ofInt(this, TEXT_ALPHA_PROPERTY, toAlpha); + float toAlpha = shouldTextBeVisible() && fadeIn ? 1 : 0; + return ObjectAnimator.ofFloat(this, TEXT_ALPHA_PROPERTY, toAlpha); } @Override diff --git a/src/com/android/launcher3/folder/FolderAnimationManager.java b/src/com/android/launcher3/folder/FolderAnimationManager.java index ec448e997..9ae377535 100644 --- a/src/com/android/launcher3/folder/FolderAnimationManager.java +++ b/src/com/android/launcher3/folder/FolderAnimationManager.java @@ -16,6 +16,7 @@ package com.android.launcher3.folder; +import static com.android.launcher3.BubbleTextView.TEXT_ALPHA_PROPERTY; import static com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY; import static com.android.launcher3.folder.ClippedFolderIconLayoutRule.MAX_NUM_ITEMS_IN_PREVIEW; @@ -172,9 +173,8 @@ public class FolderAnimationManager { AnimatorSet a = LauncherAnimUtils.createAnimatorSet(); // Initialize the Folder items' text. - PropertyResetListener colorResetListener = new PropertyResetListener<>( - BubbleTextView.TEXT_ALPHA_PROPERTY, - Color.alpha(Themes.getAttrColor(mContext, android.R.attr.textColorSecondary))); + PropertyResetListener colorResetListener = + new PropertyResetListener<>(TEXT_ALPHA_PROPERTY, 1f); for (BubbleTextView icon : mFolder.getItemsOnPage(mFolder.mContent.getCurrentPage())) { if (mIsOpening) { icon.setTextVisibility(false); |