summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/views
diff options
context:
space:
mode:
authorMario Bertschler <bmario@google.com>2017-07-05 12:03:24 -0700
committerMario Bertschler <bmario@google.com>2017-07-06 10:23:55 -0700
commitbbc139188a4ac90cb9371e2b823821063d96f273 (patch)
tree81bea6f71cde6464a6bf28a43f595596631acd14 /src/com/android/launcher3/views
parent35005ef213aa1e52fbffad9af61e1c1973e557d9 (diff)
downloadandroid_packages_apps_Trebuchet-bbc139188a4ac90cb9371e2b823821063d96f273.tar.gz
android_packages_apps_Trebuchet-bbc139188a4ac90cb9371e2b823821063d96f273.tar.bz2
android_packages_apps_Trebuchet-bbc139188a4ac90cb9371e2b823821063d96f273.zip
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>
Diffstat (limited to 'src/com/android/launcher3/views')
-rw-r--r--src/com/android/launcher3/views/DoubleShadowBubbleTextView.java28
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;
+ }
+ }
}
}