summaryrefslogtreecommitdiffstats
path: root/src/com/android
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2018-04-13 11:41:50 -0700
committerSunny Goyal <sunnygoyal@google.com>2018-04-17 20:08:10 +0000
commited7a6937cbe11179403b31079d8c54ffa8f30019 (patch)
tree4a70112d89ef5e5ffb713b582a84a8926b97222c /src/com/android
parentde967a2355752c2653ed14a1d57a7a8c8c2eef57 (diff)
downloadandroid_packages_apps_Trebuchet-ed7a6937cbe11179403b31079d8c54ffa8f30019.tar.gz
android_packages_apps_Trebuchet-ed7a6937cbe11179403b31079d8c54ffa8f30019.tar.bz2
android_packages_apps_Trebuchet-ed7a6937cbe11179403b31079d8c54ffa8f30019.zip
Unifying and maintaining the text-alpha and text visibility property
Bug: 76228194 Change-Id: I70be5f9fd22c53864a9a0308f256baa7dc1f3ab7
Diffstat (limited to 'src/com/android')
-rw-r--r--src/com/android/launcher3/BubbleTextView.java91
-rw-r--r--src/com/android/launcher3/folder/FolderAnimationManager.java6
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);