diff options
Diffstat (limited to 'src/com/android/launcher3')
-rw-r--r-- | src/com/android/launcher3/views/DoubleShadowBubbleTextView.java | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/src/com/android/launcher3/views/DoubleShadowBubbleTextView.java b/src/com/android/launcher3/views/DoubleShadowBubbleTextView.java index c0b5fe156..c8203f7f2 100644 --- a/src/com/android/launcher3/views/DoubleShadowBubbleTextView.java +++ b/src/com/android/launcher3/views/DoubleShadowBubbleTextView.java @@ -23,6 +23,7 @@ import android.graphics.Color; 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 @@ public class DoubleShadowBubbleTextView extends BubbleTextView { @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 @@ public class DoubleShadowBubbleTextView extends BubbleTextView { 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; + } + } } } |