am 24815124: am 7a2e4b8f: Merge "Let TextView clear accessibility selection index" into mnc-dev

* commit '24815124600a12a9a0ef1d7a8883ab2c8e5c1525':
  Let TextView clear accessibility selection index
This commit is contained in:
Maxim Bogatov
2015-06-30 19:07:50 +00:00
committed by Android Git Automerger

View File

@@ -8837,12 +8837,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
| AccessibilityNodeInfo.MOVEMENT_GRANULARITY_LINE
| AccessibilityNodeInfo.MOVEMENT_GRANULARITY_PARAGRAPH
| AccessibilityNodeInfo.MOVEMENT_GRANULARITY_PAGE);
info.addAction(AccessibilityNodeInfo.ACTION_SET_SELECTION);
}
if (isFocused()) {
if (canSelectText()) {
info.addAction(AccessibilityNodeInfo.ACTION_SET_SELECTION);
}
if (canCopy()) {
info.addAction(AccessibilityNodeInfo.ACTION_COPY);
}
@@ -8931,30 +8929,28 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
}
} return false;
case AccessibilityNodeInfo.ACTION_SET_SELECTION: {
if (isFocused() && canSelectText()) {
ensureIterableTextForAccessibilitySelectable();
CharSequence text = getIterableTextForAccessibility();
if (text == null) {
return false;
ensureIterableTextForAccessibilitySelectable();
CharSequence text = getIterableTextForAccessibility();
if (text == null) {
return false;
}
final int start = (arguments != null) ? arguments.getInt(
AccessibilityNodeInfo.ACTION_ARGUMENT_SELECTION_START_INT, -1) : -1;
final int end = (arguments != null) ? arguments.getInt(
AccessibilityNodeInfo.ACTION_ARGUMENT_SELECTION_END_INT, -1) : -1;
if ((getSelectionStart() != start || getSelectionEnd() != end)) {
// No arguments clears the selection.
if (start == end && end == -1) {
Selection.removeSelection((Spannable) text);
return true;
}
final int start = (arguments != null) ? arguments.getInt(
AccessibilityNodeInfo.ACTION_ARGUMENT_SELECTION_START_INT, -1) : -1;
final int end = (arguments != null) ? arguments.getInt(
AccessibilityNodeInfo.ACTION_ARGUMENT_SELECTION_END_INT, -1) : -1;
if ((getSelectionStart() != start || getSelectionEnd() != end)) {
// No arguments clears the selection.
if (start == end && end == -1) {
Selection.removeSelection((Spannable) text);
return true;
}
if (start >= 0 && start <= end && end <= text.length()) {
Selection.setSelection((Spannable) text, start, end);
// Make sure selection mode is engaged.
if (mEditor != null) {
mEditor.startSelectionActionMode();
}
return true;
if (start >= 0 && start <= end && end <= text.length()) {
Selection.setSelection((Spannable) text, start, end);
// Make sure selection mode is engaged.
if (mEditor != null) {
mEditor.startSelectionActionMode();
}
return true;
}
}
} return false;