Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3efda950 authored by Roozbeh Pournader's avatar Roozbeh Pournader
Browse files

Cleanup android.text.TextUtils a little.

- Clarify that getTrimmedLength() only considers ASCII control
  characters as control characters.

- Deprecate getReverse() instead of trying to fix it, as it's really
  not meaningful for internationalized text.

- Support non-BMP characters in isDigitsOnly().

Change-Id: I947c449b48c252ecc7f7299145f6f8fbad86004f
parent 9dffc27b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -32512,7 +32512,7 @@ package android.text {
    method public static int getLayoutDirectionFromLocale(java.util.Locale);
    method public static int getOffsetAfter(java.lang.CharSequence, int);
    method public static int getOffsetBefore(java.lang.CharSequence, int);
    method public static java.lang.CharSequence getReverse(java.lang.CharSequence, int, int);
    method public static deprecated java.lang.CharSequence getReverse(java.lang.CharSequence, int, int);
    method public static int getTrimmedLength(java.lang.CharSequence);
    method public static java.lang.String htmlEncode(java.lang.String);
    method public static int indexOf(java.lang.CharSequence, char);
+1 −1
Original line number Diff line number Diff line
@@ -34845,7 +34845,7 @@ package android.text {
    method public static int getLayoutDirectionFromLocale(java.util.Locale);
    method public static int getOffsetAfter(java.lang.CharSequence, int);
    method public static int getOffsetBefore(java.lang.CharSequence, int);
    method public static java.lang.CharSequence getReverse(java.lang.CharSequence, int, int);
    method public static deprecated java.lang.CharSequence getReverse(java.lang.CharSequence, int, int);
    method public static int getTrimmedLength(java.lang.CharSequence);
    method public static java.lang.String htmlEncode(java.lang.String);
    method public static int indexOf(java.lang.CharSequence, char);
+11 −4
Original line number Diff line number Diff line
@@ -462,7 +462,7 @@ public class TextUtils {

    /**
     * Returns the length that the specified CharSequence would have if
     * spaces and control characters were trimmed from the start and end,
     * spaces and ASCII control characters were trimmed from the start and end,
     * as by {@link String#trim}.
     */
    public static int getTrimmedLength(CharSequence s) {
@@ -505,7 +505,13 @@ public class TextUtils {
        return false;
    }

    // XXX currently this only reverses chars, not spans
    /*
     * @deprecated
     * Do not use. This function only reverses individual {@code char}s and not their associated
     * spans. It doesn't support surrogate pairs (that correspond to non-BMP code points),
     * combining sequences or conjuncts either.
     */
    @Deprecated
    public static CharSequence getReverse(CharSequence source,
                                          int start, int end) {
        return new Reverser(source, start, end);
@@ -1470,8 +1476,9 @@ public class TextUtils {
     */
    public static boolean isDigitsOnly(CharSequence str) {
        final int len = str.length();
        for (int i = 0; i < len; i++) {
            if (!Character.isDigit(str.charAt(i))) {
        for (int cp, i = 0; i < len; i += Character.charCount(cp)) {
            cp = Character.codePointAt(str, i);
            if (!Character.isDigit(cp)) {
                return false;
            }
        }