diff options
Diffstat (limited to 'core/java/android/widget/TextView.java')
| -rw-r--r-- | core/java/android/widget/TextView.java | 40 |
1 files changed, 30 insertions, 10 deletions
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java index 3c8fcb978fbd..6f83a45ce7c6 100644 --- a/core/java/android/widget/TextView.java +++ b/core/java/android/widget/TextView.java @@ -12363,9 +12363,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } // A view should not be exposed as clickable/long-clickable to a service because of a - // LinkMovementMethod. + // LinkMovementMethod or because it has selectable and non-editable text. if ((info.isClickable() || info.isLongClickable()) - && mMovement instanceof LinkMovementMethod) { + && (mMovement instanceof LinkMovementMethod + || (isTextSelectable() && !isTextEditable()))) { if (!hasOnClickListeners()) { info.setClickable(false); info.removeAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_CLICK); @@ -12597,11 +12598,9 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener return true; } if (start >= 0 && start <= end && end <= text.length()) { + requestFocusOnNonEditableSelectableText(); Selection.setSelection((Spannable) text, start, end); - // Make sure selection mode is engaged. - if (mEditor != null) { - mEditor.startSelectionActionModeAsync(false); - } + hideAccessibilitySelectionControllers(); return true; } } @@ -12695,6 +12694,18 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener return handled; } + private void requestFocusOnNonEditableSelectableText() { + if (!isTextEditable() && isTextSelectable()) { + if (!isEnabled()) { + return; + } + + if (isFocusable() && !isFocused()) { + requestFocus(); + } + } + } + private boolean hasSpannableText() { return mText != null && mText instanceof Spannable; } @@ -12723,9 +12734,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener /** * Returns the text that should be exposed to accessibility services. * <p> - * This approximates what is displayed visually. If the user has specified - * that accessibility services should speak passwords, this method will - * bypass any password transformation method and return unobscured text. + * This approximates what is displayed visually. * * @return the text that should be exposed to accessibility services, may * be {@code null} if no text is set @@ -13706,6 +13715,13 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener /** * @hide */ + public void prepareForExtendedAccessibilitySelection() { + requestFocusOnNonEditableSelectableText(); + } + + /** + * @hide + */ @Override public int getAccessibilitySelectionEnd() { return getSelectionEnd(); @@ -13727,8 +13743,12 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener Selection.removeSelection((Spannable) text); } // Hide all selection controllers used for adjusting selection - // since we are doing so explicitlty by other means and these + // since we are doing so explicitly by other means and these // controllers interact with how selection behaves. + hideAccessibilitySelectionControllers(); + } + + private void hideAccessibilitySelectionControllers() { if (mEditor != null) { mEditor.hideCursorAndSpanControllers(); mEditor.stopTextActionMode(); |
