Only draw double shadows of BubbleTextView if both shadow color's alpha
value is non-zero.
Bug: 63331170
Change-Id: Ia9f06c1d6fb217d264cece805826faf123e9d5f3
Signed-off-by: Mario Bertschler <bmario@google.com>
diff --git a/src/com/android/launcher3/views/DoubleShadowBubbleTextView.java b/src/com/android/launcher3/views/DoubleShadowBubbleTextView.java
index c0b5fe1..c8203f7 100644
--- a/src/com/android/launcher3/views/DoubleShadowBubbleTextView.java
+++ b/src/com/android/launcher3/views/DoubleShadowBubbleTextView.java
@@ -23,6 +23,7 @@
import android.graphics.Region;
import android.support.v4.graphics.ColorUtils;
import android.util.AttributeSet;
+import android.widget.TextView;
import com.android.launcher3.BubbleTextView;
import com.android.launcher3.R;
@@ -50,13 +51,12 @@
@Override
public void onDraw(Canvas canvas) {
- // If text is transparent, don't draw any shadow
- int alpha = Color.alpha(getCurrentTextColor());
- if (alpha == 0) {
- getPaint().clearShadowLayer();
+ // If text is transparent or shadow alpha is 0, don't draw any shadow
+ if (mShadowInfo.skipDoubleShadow(this)) {
super.onDraw(canvas);
return;
}
+ int alpha = Color.alpha(getCurrentTextColor());
// We enhance the shadow by drawing the shadow twice
getPaint().setShadowLayer(mShadowInfo.ambientShadowBlur, 0, 0,
@@ -97,5 +97,25 @@
keyShadowColor = a.getColor(R.styleable.ShadowInfo_keyShadowColor, 0);
a.recycle();
}
+
+ public boolean skipDoubleShadow(TextView textView) {
+ int textAlpha = Color.alpha(textView.getCurrentTextColor());
+ int keyShadowAlpha = Color.alpha(keyShadowColor);
+ int ambientShadowAlpha = Color.alpha(ambientShadowColor);
+ if (textAlpha == 0 || (keyShadowAlpha == 0 && ambientShadowAlpha == 0)) {
+ textView.getPaint().clearShadowLayer();
+ return true;
+ } else if (ambientShadowAlpha > 0) {
+ textView.getPaint().setShadowLayer(ambientShadowBlur, 0, 0,
+ ColorUtils.setAlphaComponent(ambientShadowColor, textAlpha));
+ return true;
+ } else if (keyShadowAlpha > 0) {
+ textView.getPaint().setShadowLayer(keyShadowBlur, 0.0f, keyShadowOffset,
+ ColorUtils.setAlphaComponent(keyShadowColor, textAlpha));
+ return true;
+ } else {
+ return false;
+ }
+ }
}
}