summaryrefslogtreecommitdiff
path: root/core/java/android/widget/TextView.java
diff options
context:
space:
mode:
authorRichard Ledley <rledley@google.com>2018-03-01 12:34:55 +0000
committerRichard Ledley <rledley@google.com>2018-03-05 15:56:34 +0000
commitbda1d9e740f2a1db186baedc41524cd2d56d145a (patch)
tree27554b4859885f033d2049ee571458cfb11e1cda /core/java/android/widget/TextView.java
parenta597260ba2bd75851c38ec300b68d973025e2b16 (diff)
Don't use highlighting in non-selectable text. Also fixes potential discrepancy in indexes for Linkified entities.
Test: atest CtsWidgetTestCases:TextViewTest FrameworksCoreTests:android.widget.TextViewActivityTest CtsViewTestCases:android.view.textclassifier.cts.TextClassificationManagerTest FrameworksCoreTests:android.view.textclassifier.TextLinksTest Change-Id: Ib479afa9af2b921e6a217a34322a766561867b79
Diffstat (limited to 'core/java/android/widget/TextView.java')
-rw-r--r--core/java/android/widget/TextView.java19
1 files changed, 17 insertions, 2 deletions
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index b482d4715d48..6e40ea85e34a 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -11499,12 +11499,27 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
* @return Whether or not we're attempting to start the action mode.
* @hide
*/
- public boolean requestActionMode(@NonNull TextLinks.TextLink link) {
+ public boolean requestActionMode(@NonNull TextLinks.TextLinkSpan clickedSpan) {
+ Preconditions.checkNotNull(clickedSpan);
+ final TextLinks.TextLink link = clickedSpan.getTextLink();
Preconditions.checkNotNull(link);
createEditorIfNeeded();
- mEditor.startLinkActionModeAsync(link);
+
+ if (!(mText instanceof Spanned)) {
+ return false;
+ }
+
+ final int start = ((Spanned) mText).getSpanStart(clickedSpan);
+ final int end = ((Spanned) mText).getSpanEnd(clickedSpan);
+
+ if (start < 0 || end < 1) {
+ return false;
+ }
+
+ mEditor.startLinkActionModeAsync(start, end);
return true;
}
+
/**
* @hide
*/