Merge "Support SET_TEXT for editable text views." into nyc-dev

am: 2bf5f20

* commit '2bf5f20a2b9aeed688a9b0ffbf82f0368aae8023':
  Support SET_TEXT for editable text views.

Change-Id: Ief9820d9bb9f15f10fbcb6aaf660eee447a2fc6b
This commit is contained in:
Phil Weaver
2016-04-04 16:43:02 +00:00
committed by android-build-merger
2 changed files with 17 additions and 0 deletions

View File

@@ -155,6 +155,9 @@ public class EditText extends TextView {
public boolean performAccessibilityActionInternal(int action, Bundle arguments) { public boolean performAccessibilityActionInternal(int action, Bundle arguments) {
switch (action) { switch (action) {
case AccessibilityNodeInfo.ACTION_SET_TEXT: { case AccessibilityNodeInfo.ACTION_SET_TEXT: {
if (!isEnabled()) {
return false;
}
CharSequence text = (arguments != null) ? arguments.getCharSequence( CharSequence text = (arguments != null) ? arguments.getCharSequence(
AccessibilityNodeInfo.ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE) : null; AccessibilityNodeInfo.ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE) : null;
setText(text); setText(text);

View File

@@ -9094,6 +9094,9 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
if (mBufferType == BufferType.EDITABLE) { if (mBufferType == BufferType.EDITABLE) {
info.setEditable(true); info.setEditable(true);
if (isEnabled()) {
info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_SET_TEXT);
}
} }
if (mEditor != null) { if (mEditor != null) {
@@ -9225,6 +9228,17 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
} }
} }
} return false; } return false;
case AccessibilityNodeInfo.ACTION_SET_TEXT: {
if (!isEnabled() || (mBufferType != BufferType.EDITABLE)) {
return false;
}
CharSequence text = (arguments != null) ? arguments.getCharSequence(
AccessibilityNodeInfo.ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE) : null;
setText(text);
if (text != null && text.length() > 0) {
Selection.setSelection((Spannable) mText, text.length());
}
} return true;
default: { default: {
return super.performAccessibilityActionInternal(action, arguments); return super.performAccessibilityActionInternal(action, arguments);
} }