Merge "Set upper-limit for the single line edit text." into rvc-qpr-dev

This commit is contained in:
TreeHugger Robot
2020-07-16 19:52:14 +00:00
committed by Android (Google) Code Review
2 changed files with 15 additions and 1 deletions

View File

@@ -395,6 +395,9 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
private static final int EMS = LINES;
private static final int PIXELS = 2;
// Maximum text length for single line input.
private static final int MAX_LENGTH_FOR_SINGLE_LINE_EDIT_TEXT = 5000;
private static final RectF TEMP_RECTF = new RectF();
/** @hide */
@@ -1633,6 +1636,12 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
setTransformationMethod(PasswordTransformationMethod.getInstance());
}
// For addressing b/145128646
// For the performance reason, we limit characters for single line text field.
if (bufferType == BufferType.EDITABLE && singleLine && maxlength == -1) {
maxlength = MAX_LENGTH_FOR_SINGLE_LINE_EDIT_TEXT;
}
if (maxlength >= 0) {
setFilters(new InputFilter[] { new InputFilter.LengthFilter(maxlength) });
} else {

View File

@@ -1259,7 +1259,12 @@
<!-- Can be combined with <var>text</var> and its variations to
allow multiple lines of text in the field. If this flag is not set,
the text field will be constrained to a single line. Corresponds to
{@link android.text.InputType#TYPE_TEXT_FLAG_MULTI_LINE}. -->
{@link android.text.InputType#TYPE_TEXT_FLAG_MULTI_LINE}.
Note: If this flag is not set and the text field doesn't have max length limit, the
framework automatically set maximum length of the characters to 5000 for the
performance reasons.
-->
<flag name="textMultiLine" value="0x00020001" />
<!-- Can be combined with <var>text</var> and its variations to
indicate that though the regular text view should not be multiple