From cb98af9d9b6b02102cf50e758d7a6d9e65ff11ed Mon Sep 17 00:00:00 2001 From: Daniel Chapin Date: Thu, 21 Oct 2021 17:49:20 +0000 Subject: [PATCH] Revert "Adding support for dynamic letter spacing for icon labels" This reverts commit 0d69cb6ef7cfa1cf1c99575d61ba336782a45f66. Reason for revert: Droidfood blocking bug: 203740844 Change-Id: Ied4383744194601115c42ec43e12a94542d9ca35 (cherry picked from commit 1e872e150d62a3db94a24943f2cc4484aeac72e6) --- src/com/android/launcher3/BubbleTextView.java | 74 ------------------- .../launcher3/config/FeatureFlags.java | 4 - 2 files changed, 78 deletions(-) diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java index 78110474fd..0d01343a6d 100644 --- a/src/com/android/launcher3/BubbleTextView.java +++ b/src/com/android/launcher3/BubbleTextView.java @@ -16,7 +16,6 @@ package com.android.launcher3; -import static com.android.launcher3.config.FeatureFlags.ENABLE_ICON_LABEL_AUTO_SCALING; import static com.android.launcher3.graphics.PreloadIconDrawable.newPendingIcon; import static com.android.launcher3.icons.GraphicsUtils.setColorAlphaBound; @@ -34,7 +33,6 @@ import android.graphics.Rect; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; import android.icu.text.MessageFormat; -import android.text.TextPaint; import android.text.TextUtils.TruncateAt; import android.util.AttributeSet; import android.util.Property; @@ -90,9 +88,6 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, private static final int DISPLAY_SEARCH_RESULT = 6; private static final int DISPLAY_SEARCH_RESULT_SMALL = 7; - private static final float MIN_LETTER_SPACING = -0.5f; - private static final int MAX_SEARCH_LOOP_COUNT = 20; - private static final int[] STATE_PRESSED = new int[]{android.R.attr.state_pressed}; private static final float HIGHLIGHT_SCALE = 1.16f; @@ -465,75 +460,6 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, return result; } - @Override - protected void onSizeChanged(int w, int h, int oldw, int oldh) { - super.onSizeChanged(w, h, oldw, oldh); - checkForEllipsis(); - } - - @Override - protected void onTextChanged(CharSequence text, int start, int lengthBefore, int lengthAfter) { - super.onTextChanged(text, start, lengthBefore, lengthAfter); - checkForEllipsis(); - } - - private void checkForEllipsis() { - if (!ENABLE_ICON_LABEL_AUTO_SCALING.get()) { - return; - } - float width = getWidth() - getCompoundPaddingLeft() - getCompoundPaddingRight(); - if (width <= 0) { - return; - } - setLetterSpacing(0); - - String text = getText().toString(); - TextPaint paint = getPaint(); - if (paint.measureText(text) < width) { - return; - } - - float spacing = findBestSpacingValue(paint, text, width, MIN_LETTER_SPACING); - // Reset the paint value so that the call to TextView does appropriate diff. - paint.setLetterSpacing(0); - setLetterSpacing(spacing); - } - - /** - * Find the appropriate text spacing to display the provided text - * @param paint the paint used by the text view - * @param text the text to display - * @param allowedWidthPx available space to render the text - * @param minSpacingEm minimum spacing allowed between characters - * @return the final textSpacing value - * - * @see #setLetterSpacing(float) - */ - private float findBestSpacingValue(TextPaint paint, String text, float allowedWidthPx, - float minSpacingEm) { - paint.setLetterSpacing(minSpacingEm); - if (paint.measureText(text) > allowedWidthPx) { - // If there is no result at high limit, we can do anything more - return minSpacingEm; - } - - float lowLimit = 0; - float highLimit = minSpacingEm; - - for (int i = 0; i < MAX_SEARCH_LOOP_COUNT; i++) { - float value = (lowLimit + highLimit) / 2; - paint.setLetterSpacing(value); - if (paint.measureText(text) < allowedWidthPx) { - highLimit = value; - } else { - lowLimit = value; - } - } - - // At the end error on the higher side - return highLimit; - } - @SuppressWarnings("wrongcall") protected void drawWithoutDot(Canvas canvas) { super.onDraw(canvas); diff --git a/src/com/android/launcher3/config/FeatureFlags.java b/src/com/android/launcher3/config/FeatureFlags.java index 796c91213e..a3d9ba70ff 100644 --- a/src/com/android/launcher3/config/FeatureFlags.java +++ b/src/com/android/launcher3/config/FeatureFlags.java @@ -252,10 +252,6 @@ public final class FeatureFlags { "ENABLE_BACK_SWIPE_HOME_ANIMATION", true, "Enables home animation to icon when user swipes back."); - public static final BooleanFlag ENABLE_ICON_LABEL_AUTO_SCALING = getDebugFlag( - "ENABLE_ICON_LABEL_AUTO_SCALING", true, - "Enables scaling/spacing for icon labels to make more characters visible"); - public static void initialize(Context context) { synchronized (sDebugFlags) { for (DebugFlag flag : sDebugFlags) {