From 4ff68edea913f74c732dba6f00ce6fff4e914237 Mon Sep 17 00:00:00 2001 From: Ana Salazar Maldonado Date: Wed, 12 Feb 2025 11:03:41 -0800 Subject: [PATCH] Fix contrast tile measurement calculation for folders When creating a folder, the element name begins empty. Because of this, while layout is happening, the paddings for the text and the bubble are not considered. Fix the condition within onMeasure to add the respective paddings when the bubble could be drawn. Bug: 341217082 Flag: com.android.launcher3.enable_contrast_tiles Test: Manual, visual change Change-Id: Ie707102fa3d4827568a9db247ea5ebf5f8e1ae0d --- src/com/android/launcher3/BubbleTextView.java | 5 +++-- .../android/launcher3/views/DoubleShadowBubbleTextView.java | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java index fb847f9133..e6b34574a9 100644 --- a/src/com/android/launcher3/BubbleTextView.java +++ b/src/com/android/launcher3/BubbleTextView.java @@ -964,7 +964,8 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, @Override public void setTextColor(ColorStateList colors) { - mTextColor = shouldDrawAppContrastTile() ? PillColorProvider.getInstance( + mTextColor = (shouldDrawAppContrastTile() && !TextUtils.isEmpty(getText())) + ? PillColorProvider.getInstance( getContext()).getAppTitleTextPaint().getColor() : colors.getDefaultColor(); mTextColorStateList = colors; @@ -989,7 +990,7 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, public boolean shouldDrawAppContrastTile() { return mDisplay == DISPLAY_WORKSPACE && shouldTextBeVisible() && PillColorProvider.getInstance(getContext()).isMatchaEnabled() - && enableContrastTiles() && !TextUtils.isEmpty(getText()); + && enableContrastTiles(); } public void setTextVisibility(boolean visible) { diff --git a/src/com/android/launcher3/views/DoubleShadowBubbleTextView.java b/src/com/android/launcher3/views/DoubleShadowBubbleTextView.java index 392d9a7014..05bc4d86a7 100644 --- a/src/com/android/launcher3/views/DoubleShadowBubbleTextView.java +++ b/src/com/android/launcher3/views/DoubleShadowBubbleTextView.java @@ -25,6 +25,7 @@ import android.graphics.drawable.Drawable; import android.os.Build; import android.text.Spannable; import android.text.SpannableString; +import android.text.TextUtils; import android.text.style.ImageSpan; import android.util.AttributeSet; import android.util.Log; @@ -102,7 +103,7 @@ public class DoubleShadowBubbleTextView extends BubbleTextView { @Override public void onDraw(Canvas canvas) { - if (shouldDrawAppContrastTile()) { + if (shouldDrawAppContrastTile() && !TextUtils.isEmpty(getText())) { drawAppContrastTile(canvas); } // If text is transparent or shadow alpha is 0, don't draw any shadow