From aa68ab828873274a141f6463091abd4fa7315a9b Mon Sep 17 00:00:00 2001 From: "Torne (Richard Coles)" Date: Tue, 4 Jun 2019 14:14:05 -0400 Subject: [PATCH] Clarify problems with Linkify.MAP_ADDRESSES. Update the documentation for WebView.findAddress, as well as the related functionality in Linkify and TextView, to clarify why the method is deprecated, why it should not be used, and that it can cause unexpected exceptions to be thrown from several places on older OS versions. Fixes: 24676033 Test: m offline-sdk-docs Change-Id: I45d82b9a4c9cf62d9566898dd21cd2139ad98f37 --- core/java/android/text/util/Linkify.java | 17 +++++++++++++---- core/java/android/webkit/WebView.java | 16 ++++++++++++---- core/java/android/widget/TextView.java | 4 ++++ core/res/res/values/attrs.xml | 3 ++- 4 files changed, 31 insertions(+), 9 deletions(-) diff --git a/core/java/android/text/util/Linkify.java b/core/java/android/text/util/Linkify.java index 50e7ec30ec3a6..df54209bc0433 100644 --- a/core/java/android/text/util/Linkify.java +++ b/core/java/android/text/util/Linkify.java @@ -67,6 +67,14 @@ import java.util.regex.Pattern; * create http://example.com when the clickable URL link is * created. * + *

Note: When using {@link #MAP_ADDRESSES} or {@link #ALL} + * to match street addresses on API level {@link android.os.Build.VERSION_CODES#O_MR1} + * and earlier, methods in this class may throw + * {@link android.util.AndroidRuntimeException} or other exceptions if the + * device's WebView implementation is currently being updated, because + * {@link android.webkit.WebView#findAddress} is required to match street + * addresses. + * * @see MatchFilter * @see TransformFilter */ @@ -95,10 +103,11 @@ public class Linkify { /** * Bit field indicating that street addresses should be matched in methods that - * take an options mask. Note that this uses the - * {@link android.webkit.WebView#findAddress(String) findAddress()} method in - * {@link android.webkit.WebView} for finding addresses, which has various - * limitations and has been deprecated. + * take an options mask. Note that this should be avoided, as it uses the + * {@link android.webkit.WebView#findAddress(String)} method, which has various + * limitations and has been deprecated: see the documentation for + * {@link android.webkit.WebView#findAddress(String)} for more information. + * * @deprecated use {@link android.view.textclassifier.TextClassifier#generateLinks( * TextLinks.Request)} instead and avoid it even when targeting API levels where no alternative * is available. diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java index 137b67c6e63e0..14be73dec41cd 100644 --- a/core/java/android/webkit/WebView.java +++ b/core/java/android/webkit/WebView.java @@ -1603,9 +1603,9 @@ public class WebView extends AbsoluteLayout } /** - * Gets the first substring consisting of the address of a physical - * location. Currently, only addresses in the United States are detected, - * and consist of: + * Gets the first substring which appears to be the address of a physical + * location. Only addresses in the United States can be detected, which + * must consist of: *