Loading api/current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -52188,6 +52188,7 @@ package android.view.textclassifier { field public static final int STATUS_LINKS_APPLIED = 0; // 0x0 field public static final int STATUS_NO_LINKS_APPLIED = 2; // 0x2 field public static final int STATUS_NO_LINKS_FOUND = 1; // 0x1 field public static final int STATUS_UNSUPPORTED_CHARACTER = 4; // 0x4 } public static final class TextLinks.Builder { core/java/android/text/util/Linkify.java +37 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ import android.text.Spanned; import android.text.method.LinkMovementMethod; import android.text.method.MovementMethod; import android.text.style.URLSpan; import android.util.Log; import android.util.Patterns; import android.webkit.WebView; import android.widget.TextView; Loading Loading @@ -72,6 +73,9 @@ import java.util.regex.Pattern; */ public class Linkify { private static final String LOG_TAG = "Linkify"; /** * Bit field indicating that web URLs should be matched in methods that * take an options mask Loading Loading @@ -310,6 +314,11 @@ public class Linkify { */ private static boolean addLinks(@NonNull Spannable text, @LinkifyMask int mask, @Nullable Context context, @Nullable UrlSpanFactory urlSpanFactory) { if (text != null && containsUnsupportedCharacters(text.toString())) { android.util.EventLog.writeEvent(0x534e4554, "116321860", -1, ""); return false; } if (mask == 0) { return false; } Loading Loading @@ -355,6 +364,29 @@ public class Linkify { return true; } /** * Returns true if the specified text contains at least one unsupported character for applying * links. Also logs the error. * * @param text the text to apply links to * @hide */ public static boolean containsUnsupportedCharacters(String text) { if (text.contains("\u202C")) { Log.e(LOG_TAG, "Unsupported character for applying links: u202C"); return true; } if (text.contains("\u202D")) { Log.e(LOG_TAG, "Unsupported character for applying links: u202D"); return true; } if (text.contains("\u202E")) { Log.e(LOG_TAG, "Unsupported character for applying links: u202E"); return true; } return false; } /** * Scans the text of the provided TextView and turns all occurrences of * the link types indicated in the mask into clickable links. If matches Loading Loading @@ -560,6 +592,11 @@ public class Linkify { @Nullable String defaultScheme, @Nullable String[] schemes, @Nullable MatchFilter matchFilter, @Nullable TransformFilter transformFilter, @Nullable UrlSpanFactory urlSpanFactory) { if (spannable != null && containsUnsupportedCharacters(spannable.toString())) { android.util.EventLog.writeEvent(0x534e4554, "116321860", -1, ""); return false; } final String[] schemesCopy; if (defaultScheme == null) defaultScheme = ""; if (schemes == null || schemes.length < 1) { Loading core/java/android/view/textclassifier/TextClassification.java +1 −1 Original line number Diff line number Diff line Loading @@ -105,7 +105,7 @@ public final class TextClassification implements Parcelable { /** * @hide */ static final TextClassification EMPTY = new TextClassification.Builder().build(); public static final TextClassification EMPTY = new TextClassification.Builder().build(); private static final String LOG_TAG = "TextClassification"; // TODO(toki): investigate a way to derive this based on device properties. Loading core/java/android/view/textclassifier/TextLinks.java +4 −1 Original line number Diff line number Diff line Loading @@ -59,7 +59,7 @@ public final class TextLinks implements Parcelable { */ @Retention(RetentionPolicy.SOURCE) @IntDef({STATUS_LINKS_APPLIED, STATUS_NO_LINKS_FOUND, STATUS_NO_LINKS_APPLIED, STATUS_DIFFERENT_TEXT}) STATUS_DIFFERENT_TEXT, STATUS_UNSUPPORTED_CHARACTER}) public @interface Status {} /** Links were successfully applied to the text. */ Loading @@ -74,6 +74,9 @@ public final class TextLinks implements Parcelable { /** The specified text does not match the text used to generate the links. */ public static final int STATUS_DIFFERENT_TEXT = 3; /** The specified text contains unsupported characters. */ public static final int STATUS_UNSUPPORTED_CHARACTER = 4; /** @hide */ @Retention(RetentionPolicy.SOURCE) @IntDef({APPLY_STRATEGY_IGNORE, APPLY_STRATEGY_REPLACE}) Loading core/java/android/view/textclassifier/TextLinksParams.java +7 −0 Original line number Diff line number Diff line Loading @@ -107,6 +107,13 @@ public final class TextLinksParams { Preconditions.checkNotNull(textLinks); final String textString = text.toString(); if (Linkify.containsUnsupportedCharacters(textString)) { // Do not apply links to text containing unsupported characters. android.util.EventLog.writeEvent(0x534e4554, "116321860", -1, ""); return TextLinks.STATUS_UNSUPPORTED_CHARACTER; } if (!textString.startsWith(textLinks.getText())) { return TextLinks.STATUS_DIFFERENT_TEXT; } Loading Loading
api/current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -52188,6 +52188,7 @@ package android.view.textclassifier { field public static final int STATUS_LINKS_APPLIED = 0; // 0x0 field public static final int STATUS_NO_LINKS_APPLIED = 2; // 0x2 field public static final int STATUS_NO_LINKS_FOUND = 1; // 0x1 field public static final int STATUS_UNSUPPORTED_CHARACTER = 4; // 0x4 } public static final class TextLinks.Builder {
core/java/android/text/util/Linkify.java +37 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ import android.text.Spanned; import android.text.method.LinkMovementMethod; import android.text.method.MovementMethod; import android.text.style.URLSpan; import android.util.Log; import android.util.Patterns; import android.webkit.WebView; import android.widget.TextView; Loading Loading @@ -72,6 +73,9 @@ import java.util.regex.Pattern; */ public class Linkify { private static final String LOG_TAG = "Linkify"; /** * Bit field indicating that web URLs should be matched in methods that * take an options mask Loading Loading @@ -310,6 +314,11 @@ public class Linkify { */ private static boolean addLinks(@NonNull Spannable text, @LinkifyMask int mask, @Nullable Context context, @Nullable UrlSpanFactory urlSpanFactory) { if (text != null && containsUnsupportedCharacters(text.toString())) { android.util.EventLog.writeEvent(0x534e4554, "116321860", -1, ""); return false; } if (mask == 0) { return false; } Loading Loading @@ -355,6 +364,29 @@ public class Linkify { return true; } /** * Returns true if the specified text contains at least one unsupported character for applying * links. Also logs the error. * * @param text the text to apply links to * @hide */ public static boolean containsUnsupportedCharacters(String text) { if (text.contains("\u202C")) { Log.e(LOG_TAG, "Unsupported character for applying links: u202C"); return true; } if (text.contains("\u202D")) { Log.e(LOG_TAG, "Unsupported character for applying links: u202D"); return true; } if (text.contains("\u202E")) { Log.e(LOG_TAG, "Unsupported character for applying links: u202E"); return true; } return false; } /** * Scans the text of the provided TextView and turns all occurrences of * the link types indicated in the mask into clickable links. If matches Loading Loading @@ -560,6 +592,11 @@ public class Linkify { @Nullable String defaultScheme, @Nullable String[] schemes, @Nullable MatchFilter matchFilter, @Nullable TransformFilter transformFilter, @Nullable UrlSpanFactory urlSpanFactory) { if (spannable != null && containsUnsupportedCharacters(spannable.toString())) { android.util.EventLog.writeEvent(0x534e4554, "116321860", -1, ""); return false; } final String[] schemesCopy; if (defaultScheme == null) defaultScheme = ""; if (schemes == null || schemes.length < 1) { Loading
core/java/android/view/textclassifier/TextClassification.java +1 −1 Original line number Diff line number Diff line Loading @@ -105,7 +105,7 @@ public final class TextClassification implements Parcelable { /** * @hide */ static final TextClassification EMPTY = new TextClassification.Builder().build(); public static final TextClassification EMPTY = new TextClassification.Builder().build(); private static final String LOG_TAG = "TextClassification"; // TODO(toki): investigate a way to derive this based on device properties. Loading
core/java/android/view/textclassifier/TextLinks.java +4 −1 Original line number Diff line number Diff line Loading @@ -59,7 +59,7 @@ public final class TextLinks implements Parcelable { */ @Retention(RetentionPolicy.SOURCE) @IntDef({STATUS_LINKS_APPLIED, STATUS_NO_LINKS_FOUND, STATUS_NO_LINKS_APPLIED, STATUS_DIFFERENT_TEXT}) STATUS_DIFFERENT_TEXT, STATUS_UNSUPPORTED_CHARACTER}) public @interface Status {} /** Links were successfully applied to the text. */ Loading @@ -74,6 +74,9 @@ public final class TextLinks implements Parcelable { /** The specified text does not match the text used to generate the links. */ public static final int STATUS_DIFFERENT_TEXT = 3; /** The specified text contains unsupported characters. */ public static final int STATUS_UNSUPPORTED_CHARACTER = 4; /** @hide */ @Retention(RetentionPolicy.SOURCE) @IntDef({APPLY_STRATEGY_IGNORE, APPLY_STRATEGY_REPLACE}) Loading
core/java/android/view/textclassifier/TextLinksParams.java +7 −0 Original line number Diff line number Diff line Loading @@ -107,6 +107,13 @@ public final class TextLinksParams { Preconditions.checkNotNull(textLinks); final String textString = text.toString(); if (Linkify.containsUnsupportedCharacters(textString)) { // Do not apply links to text containing unsupported characters. android.util.EventLog.writeEvent(0x534e4554, "116321860", -1, ""); return TextLinks.STATUS_UNSUPPORTED_CHARACTER; } if (!textString.startsWith(textLinks.getText())) { return TextLinks.STATUS_DIFFERENT_TEXT; } Loading