summaryrefslogtreecommitdiff
path: root/core/java/android/widget/TextView.java
diff options
context:
space:
mode:
authorsallyyuen <sallyyuen@google.com>2019-05-03 17:51:29 -0700
committerSally Yuen <sallyyuen@google.com>2019-05-28 22:56:12 +0000
commit8f223c591e8d0844fd169a0a35716882899e1f56 (patch)
treed295d3f3a376c01dc270327b17f004cd2786240c /core/java/android/widget/TextView.java
parentcaaddf135bd17da58005692a6a017ba912684576 (diff)
Set the a11yNodeInfo unclickable if the TextView has a
LinkMovementMethod and there are no onClickListeners or onLongClickListeners A view with links shouldn't be exposing itself as clickable to an a11yService if only the links are clickable. If a movement method is set, the view turns both clickable and long-clickable. This has brought a number of bugs where an a11yService will notify users the element is clickable but performing the action does nothing. We can't delete years-old code without breaking a lot of things, so try to minimize the consequences by adding logic in onInitializeA11yNodeInfo. Add checks so a view with links and no click listeners will be made un-clickable. Bug: b/131758159 Test: Tested on several bugs with TalkBack, CtsAccessibilityTests, CtsTextTestCases, CtsWidgetTestCases:TextViewTest Change-Id: I53b695139ecea2c34d125e7077fd2077593adbe1
Diffstat (limited to 'core/java/android/widget/TextView.java')
-rw-r--r--core/java/android/widget/TextView.java14
1 files changed, 14 insertions, 0 deletions
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index cdbec293a96d..4da334b86010 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -11735,6 +11735,20 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
if (!isSingleLine()) {
info.setMultiLine(true);
}
+
+ // A view should not be exposed as clickable/long-clickable to a service because of a
+ // LinkMovementMethod.
+ if ((info.isClickable() || info.isLongClickable())
+ && mMovement instanceof LinkMovementMethod) {
+ if (!hasOnClickListeners()) {
+ info.setClickable(false);
+ info.removeAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_CLICK);
+ }
+ if (!hasOnLongClickListeners()) {
+ info.setLongClickable(false);
+ info.removeAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_LONG_CLICK);
+ }
+ }
}
@Override