From 5038d58c8340baa020578f879a6ca51e899e5fd0 Mon Sep 17 00:00:00 2001 From: Andrei Stingaceanu Date: Mon, 28 Nov 2016 15:51:13 +0000 Subject: [PATCH] AutoSize TextView (part 3) - define who supports autosize Introduces a new protected hidden method that specifies if the TextView (or descendant) widget supports the autosize feature. All direct children of TextView (besides EditText) support it. Bug: 33098425 Bug: 32221168 Test: attached in the topic Change-Id: I6f0092b4c9948afb427fe597b0515a39b1f258f6 --- core/java/android/widget/EditText.java | 6 ++++++ core/java/android/widget/TextView.java | 14 +++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/core/java/android/widget/EditText.java b/core/java/android/widget/EditText.java index a8d3984adc7e5..043eb348a7062 100644 --- a/core/java/android/widget/EditText.java +++ b/core/java/android/widget/EditText.java @@ -140,6 +140,12 @@ public class EditText extends TextView { return EditText.class.getName(); } + /** @hide */ + @Override + protected boolean supportsAutoSizeText() { + return false; + } + /** @hide */ @Override public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) { diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java index b85175d655f8a..44655f18f3eb8 100644 --- a/core/java/android/widget/TextView.java +++ b/core/java/android/widget/TextView.java @@ -1534,7 +1534,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } // Setup auto-size. - if (mEditor == null) { + if (supportsAutoSizeText()) { switch (mAutoSizeType) { case AUTO_SIZE_TYPE_NONE: // Nothing to do. @@ -9261,14 +9261,22 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } /** - * @return true if this TextView is specialized for showing and interacting with the extracted - * text in a full-screen input method. + * @return {@code true} if this TextView is specialized for showing and interacting with the + * extracted text in a full-screen input method. * @hide */ public boolean isInExtractedMode() { return false; } + /** + * @return {@code true} if this TextView supports autosizing text to fit within its container. + * @hide + */ + protected boolean supportsAutoSizeText() { + return true; + } + /** * This is a temporary method. Future versions may support multi-locale text. * Caveat: This method may not return the latest spell checker locale, but this should be