Loading core/java/android/widget/TextView.java +24 −19 Original line number Diff line number Diff line Loading @@ -681,8 +681,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener private static final int DEFAULT_AUTO_SIZE_GRANULARITY_IN_PX = 1; // Contains the sorted set of desired text sizes in pixels to pick from when auto-sizing text. private int[] mAutoSizeTextSizesInPx; // Specifies if the current TextView needs to be auto-sized. private boolean mNeedsTextAutoResize = false; /** * Kick-start the font cache for the zygote process (to pay the cost of Loading Loading @@ -1562,7 +1560,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } Arrays.sort(mAutoSizeTextSizesInPx); mNeedsTextAutoResize = true; break; default: throw new IllegalArgumentException( Loading Loading @@ -7525,7 +7522,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener scrollTo(0, 0); } if (mNeedsTextAutoResize) { if (isAutoSizeEnabled()) { // Call auto-size after the width and height have been calculated. autoSizeText(); } Loading @@ -7537,20 +7534,21 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener * Automatically computes and sets the text size. */ private void autoSizeText() { synchronized (TEMP_RECTF) { TEMP_RECTF.setEmpty(); final int maxWidth = getMeasuredWidth() - getPaddingLeft() - getPaddingRight(); final int maxHeight = getMeasuredHeight() - getPaddingBottom() - getPaddingTop(); final int maxWidth = getMeasuredWidth() - getTotalPaddingLeft() - getTotalPaddingRight(); final int maxHeight = getMeasuredHeight() - getTotalPaddingBottom() - getTotalPaddingTop(); if (maxWidth <= 0 || maxHeight <= 0) { return; } synchronized (TEMP_RECTF) { TEMP_RECTF.setEmpty(); TEMP_RECTF.right = maxWidth; TEMP_RECTF.bottom = maxHeight; final float textSize = findLargestTextSizeWhichFits(TEMP_RECTF); if (textSize != getTextSize()) { setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize); mNeedsTextAutoResize = false; } } } Loading Loading @@ -7595,13 +7593,12 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener if ((mLayout instanceof BoringLayout) && BoringLayout.isBoring( text, mTempTextPaint, getTextDirectionHeuristic(), mBoring) != null) { return mTempTextPaint.getFontSpacing() + getPaddingTop() + getPaddingBottom() <= availableSpace.bottom && mTempTextPaint.measureText(text, 0, text.length()) + getPaddingLeft() + getPaddingRight() <= availableSpace.right; return mTempTextPaint.getFontSpacing() <= availableSpace.bottom && mTempTextPaint.measureText(text, 0, text.length()) <= availableSpace.right; } else { StaticLayout.Builder layoutBuilder = StaticLayout.Builder.obtain(text, 0, text.length(), mTempTextPaint, getMeasuredWidth() - getPaddingLeft() - getPaddingRight()); mTempTextPaint, getMeasuredWidth() - getTotalPaddingLeft() - getTotalPaddingRight()); layoutBuilder.setAlignment(getLayoutAlignment()); layoutBuilder.setLineSpacing(getLineSpacingExtra(), getLineSpacingMultiplier()); layoutBuilder.setIncludePad(true); Loading Loading @@ -9271,7 +9268,15 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } /** * @return {@code true} if this TextView supports autosizing text to fit within its container. * @return {@code true} if this widget supports auto-sizing text and has been configured to * auto-size. */ private boolean isAutoSizeEnabled() { return supportsAutoSizeText() && mAutoSizeType != AUTO_SIZE_TYPE_NONE; } /** * @return {@code true} if this TextView supports auto-sizing text to fit within its container. * @hide */ protected boolean supportsAutoSizeText() { Loading Loading
core/java/android/widget/TextView.java +24 −19 Original line number Diff line number Diff line Loading @@ -681,8 +681,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener private static final int DEFAULT_AUTO_SIZE_GRANULARITY_IN_PX = 1; // Contains the sorted set of desired text sizes in pixels to pick from when auto-sizing text. private int[] mAutoSizeTextSizesInPx; // Specifies if the current TextView needs to be auto-sized. private boolean mNeedsTextAutoResize = false; /** * Kick-start the font cache for the zygote process (to pay the cost of Loading Loading @@ -1562,7 +1560,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } Arrays.sort(mAutoSizeTextSizesInPx); mNeedsTextAutoResize = true; break; default: throw new IllegalArgumentException( Loading Loading @@ -7525,7 +7522,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener scrollTo(0, 0); } if (mNeedsTextAutoResize) { if (isAutoSizeEnabled()) { // Call auto-size after the width and height have been calculated. autoSizeText(); } Loading @@ -7537,20 +7534,21 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener * Automatically computes and sets the text size. */ private void autoSizeText() { synchronized (TEMP_RECTF) { TEMP_RECTF.setEmpty(); final int maxWidth = getMeasuredWidth() - getPaddingLeft() - getPaddingRight(); final int maxHeight = getMeasuredHeight() - getPaddingBottom() - getPaddingTop(); final int maxWidth = getMeasuredWidth() - getTotalPaddingLeft() - getTotalPaddingRight(); final int maxHeight = getMeasuredHeight() - getTotalPaddingBottom() - getTotalPaddingTop(); if (maxWidth <= 0 || maxHeight <= 0) { return; } synchronized (TEMP_RECTF) { TEMP_RECTF.setEmpty(); TEMP_RECTF.right = maxWidth; TEMP_RECTF.bottom = maxHeight; final float textSize = findLargestTextSizeWhichFits(TEMP_RECTF); if (textSize != getTextSize()) { setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize); mNeedsTextAutoResize = false; } } } Loading Loading @@ -7595,13 +7593,12 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener if ((mLayout instanceof BoringLayout) && BoringLayout.isBoring( text, mTempTextPaint, getTextDirectionHeuristic(), mBoring) != null) { return mTempTextPaint.getFontSpacing() + getPaddingTop() + getPaddingBottom() <= availableSpace.bottom && mTempTextPaint.measureText(text, 0, text.length()) + getPaddingLeft() + getPaddingRight() <= availableSpace.right; return mTempTextPaint.getFontSpacing() <= availableSpace.bottom && mTempTextPaint.measureText(text, 0, text.length()) <= availableSpace.right; } else { StaticLayout.Builder layoutBuilder = StaticLayout.Builder.obtain(text, 0, text.length(), mTempTextPaint, getMeasuredWidth() - getPaddingLeft() - getPaddingRight()); mTempTextPaint, getMeasuredWidth() - getTotalPaddingLeft() - getTotalPaddingRight()); layoutBuilder.setAlignment(getLayoutAlignment()); layoutBuilder.setLineSpacing(getLineSpacingExtra(), getLineSpacingMultiplier()); layoutBuilder.setIncludePad(true); Loading Loading @@ -9271,7 +9268,15 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } /** * @return {@code true} if this TextView supports autosizing text to fit within its container. * @return {@code true} if this widget supports auto-sizing text and has been configured to * auto-size. */ private boolean isAutoSizeEnabled() { return supportsAutoSizeText() && mAutoSizeType != AUTO_SIZE_TYPE_NONE; } /** * @return {@code true} if this TextView supports auto-sizing text to fit within its container. * @hide */ protected boolean supportsAutoSizeText() { Loading