Loading api/current.txt +5 −0 Original line number Diff line number Diff line Loading @@ -26305,12 +26305,15 @@ package android.view.accessibility { method public java.lang.CharSequence getPackageName(); method public android.view.accessibility.AccessibilityNodeInfo getParent(); method public java.lang.CharSequence getText(); method public int getTextSelectionEnd(); method public int getTextSelectionStart(); method public java.lang.CharSequence getViewIdResourceName(); method public int getWindowId(); method public boolean isAccessibilityFocused(); method public boolean isCheckable(); method public boolean isChecked(); method public boolean isClickable(); method public boolean isEditable(); method public boolean isEnabled(); method public boolean isFocusable(); method public boolean isFocused(); Loading @@ -26335,6 +26338,7 @@ package android.view.accessibility { method public void setClassName(java.lang.CharSequence); method public void setClickable(boolean); method public void setContentDescription(java.lang.CharSequence); method public void setEditable(boolean); method public void setEnabled(boolean); method public void setFocusable(boolean); method public void setFocused(boolean); Loading @@ -26353,6 +26357,7 @@ package android.view.accessibility { method public void setSource(android.view.View); method public void setSource(android.view.View, int); method public void setText(java.lang.CharSequence); method public void setTextSelection(int, int); method public void setViewIdResourceName(java.lang.CharSequence); method public void setVisibleToUser(boolean); method public void writeToParcel(android.os.Parcel, int); core/java/android/view/View.java +27 −8 Original line number Diff line number Diff line Loading @@ -4859,14 +4859,26 @@ public class View implements Drawable.Callback, KeyEvent.Callback, event.setEnabled(isEnabled()); event.setContentDescription(mContentDescription); if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_FOCUSED && mAttachInfo != null) { ArrayList<View> focusablesTempList = mAttachInfo.mTempArrayList; getRootView().addFocusables(focusablesTempList, View.FOCUS_FORWARD, FOCUSABLES_ALL); switch (event.getEventType()) { case AccessibilityEvent.TYPE_VIEW_FOCUSED: { ArrayList<View> focusablesTempList = (mAttachInfo != null) ? mAttachInfo.mTempArrayList : new ArrayList<View>(); getRootView().addFocusables(focusablesTempList, View.FOCUS_FORWARD, FOCUSABLES_ALL); event.setItemCount(focusablesTempList.size()); event.setCurrentItemIndex(focusablesTempList.indexOf(this)); if (mAttachInfo != null) { focusablesTempList.clear(); } } break; case AccessibilityEvent.TYPE_VIEW_TEXT_SELECTION_CHANGED: { CharSequence text = getIterableTextForAccessibility(); if (text != null && text.length() > 0) { event.setFromIndex(getAccessibilitySelectionStart()); event.setToIndex(getAccessibilitySelectionEnd()); event.setItemCount(text.length()); } } break; } } /** Loading Loading @@ -5081,7 +5093,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback, info.addAction(AccessibilityNodeInfo.ACTION_LONG_CLICK); } if (mContentDescription != null && mContentDescription.length() > 0) { CharSequence text = getIterableTextForAccessibility(); if (text != null && text.length() > 0) { info.setTextSelection(getAccessibilitySelectionStart(), getAccessibilitySelectionEnd()); info.addAction(AccessibilityNodeInfo.ACTION_SET_SELECTION); info.addAction(AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY); info.addAction(AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY); Loading Loading @@ -7153,11 +7168,15 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * @hide */ public void setAccessibilitySelection(int start, int end) { if (start == end && end == mAccessibilityCursorPosition) { return; } if (start >= 0 && start == end && end <= getIterableTextForAccessibility().length()) { mAccessibilityCursorPosition = start; } else { mAccessibilityCursorPosition = ACCESSIBILITY_CURSOR_POSITION_UNDEFINED; } sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_TEXT_SELECTION_CHANGED); } private void sendViewTextTraversedAtGranularityEvent(int action, int granularity, Loading core/java/android/view/accessibility/AccessibilityNodeInfo.java +113 −36 Original line number Diff line number Diff line Loading @@ -372,29 +372,31 @@ public class AccessibilityNodeInfo implements Parcelable { // Boolean attributes. private static final int PROPERTY_CHECKABLE = 0x00000001; private static final int BOOLEAN_PROPERTY_CHECKABLE = 0x00000001; private static final int PROPERTY_CHECKED = 0x00000002; private static final int BOOLEAN_PROPERTY_CHECKED = 0x00000002; private static final int PROPERTY_FOCUSABLE = 0x00000004; private static final int BOOLEAN_PROPERTY_FOCUSABLE = 0x00000004; private static final int PROPERTY_FOCUSED = 0x00000008; private static final int BOOLEAN_PROPERTY_FOCUSED = 0x00000008; private static final int PROPERTY_SELECTED = 0x00000010; private static final int BOOLEAN_PROPERTY_SELECTED = 0x00000010; private static final int PROPERTY_CLICKABLE = 0x00000020; private static final int BOOLEAN_PROPERTY_CLICKABLE = 0x00000020; private static final int PROPERTY_LONG_CLICKABLE = 0x00000040; private static final int BOOLEAN_PROPERTY_LONG_CLICKABLE = 0x00000040; private static final int PROPERTY_ENABLED = 0x00000080; private static final int BOOLEAN_PROPERTY_ENABLED = 0x00000080; private static final int PROPERTY_PASSWORD = 0x00000100; private static final int BOOLEAN_PROPERTY_PASSWORD = 0x00000100; private static final int PROPERTY_SCROLLABLE = 0x00000200; private static final int BOOLEAN_PROPERTY_SCROLLABLE = 0x00000200; private static final int PROPERTY_ACCESSIBILITY_FOCUSED = 0x00000400; private static final int BOOLEAN_PROPERTY_ACCESSIBILITY_FOCUSED = 0x00000400; private static final int PROPERTY_VISIBLE_TO_USER = 0x00000800; private static final int BOOLEAN_PROPERTY_VISIBLE_TO_USER = 0x00000800; private static final int BOOLEAN_PROPERTY_EDITABLE = 0x00001000; /** * Bits that provide the id of a virtual descendant of a view. Loading Loading @@ -478,6 +480,9 @@ public class AccessibilityNodeInfo implements Parcelable { private int mMovementGranularities; private int mTextSelectionStart = UNDEFINED; private int mTextSelectionEnd = UNDEFINED; private int mConnectionId = UNDEFINED; /** Loading Loading @@ -987,7 +992,7 @@ public class AccessibilityNodeInfo implements Parcelable { * @return True if the node is checkable. */ public boolean isCheckable() { return getBooleanProperty(PROPERTY_CHECKABLE); return getBooleanProperty(BOOLEAN_PROPERTY_CHECKABLE); } /** Loading @@ -1003,7 +1008,7 @@ public class AccessibilityNodeInfo implements Parcelable { * @throws IllegalStateException If called from an AccessibilityService. */ public void setCheckable(boolean checkable) { setBooleanProperty(PROPERTY_CHECKABLE, checkable); setBooleanProperty(BOOLEAN_PROPERTY_CHECKABLE, checkable); } /** Loading @@ -1012,7 +1017,7 @@ public class AccessibilityNodeInfo implements Parcelable { * @return True if the node is checked. */ public boolean isChecked() { return getBooleanProperty(PROPERTY_CHECKED); return getBooleanProperty(BOOLEAN_PROPERTY_CHECKED); } /** Loading @@ -1028,7 +1033,7 @@ public class AccessibilityNodeInfo implements Parcelable { * @throws IllegalStateException If called from an AccessibilityService. */ public void setChecked(boolean checked) { setBooleanProperty(PROPERTY_CHECKED, checked); setBooleanProperty(BOOLEAN_PROPERTY_CHECKED, checked); } /** Loading @@ -1037,7 +1042,7 @@ public class AccessibilityNodeInfo implements Parcelable { * @return True if the node is focusable. */ public boolean isFocusable() { return getBooleanProperty(PROPERTY_FOCUSABLE); return getBooleanProperty(BOOLEAN_PROPERTY_FOCUSABLE); } /** Loading @@ -1053,7 +1058,7 @@ public class AccessibilityNodeInfo implements Parcelable { * @throws IllegalStateException If called from an AccessibilityService. */ public void setFocusable(boolean focusable) { setBooleanProperty(PROPERTY_FOCUSABLE, focusable); setBooleanProperty(BOOLEAN_PROPERTY_FOCUSABLE, focusable); } /** Loading @@ -1062,7 +1067,7 @@ public class AccessibilityNodeInfo implements Parcelable { * @return True if the node is focused. */ public boolean isFocused() { return getBooleanProperty(PROPERTY_FOCUSED); return getBooleanProperty(BOOLEAN_PROPERTY_FOCUSED); } /** Loading @@ -1078,7 +1083,7 @@ public class AccessibilityNodeInfo implements Parcelable { * @throws IllegalStateException If called from an AccessibilityService. */ public void setFocused(boolean focused) { setBooleanProperty(PROPERTY_FOCUSED, focused); setBooleanProperty(BOOLEAN_PROPERTY_FOCUSED, focused); } /** Loading @@ -1087,7 +1092,7 @@ public class AccessibilityNodeInfo implements Parcelable { * @return Whether the node is visible to the user. */ public boolean isVisibleToUser() { return getBooleanProperty(PROPERTY_VISIBLE_TO_USER); return getBooleanProperty(BOOLEAN_PROPERTY_VISIBLE_TO_USER); } /** Loading @@ -1103,7 +1108,7 @@ public class AccessibilityNodeInfo implements Parcelable { * @throws IllegalStateException If called from an AccessibilityService. */ public void setVisibleToUser(boolean visibleToUser) { setBooleanProperty(PROPERTY_VISIBLE_TO_USER, visibleToUser); setBooleanProperty(BOOLEAN_PROPERTY_VISIBLE_TO_USER, visibleToUser); } /** Loading @@ -1112,7 +1117,7 @@ public class AccessibilityNodeInfo implements Parcelable { * @return True if the node is accessibility focused. */ public boolean isAccessibilityFocused() { return getBooleanProperty(PROPERTY_ACCESSIBILITY_FOCUSED); return getBooleanProperty(BOOLEAN_PROPERTY_ACCESSIBILITY_FOCUSED); } /** Loading @@ -1128,7 +1133,7 @@ public class AccessibilityNodeInfo implements Parcelable { * @throws IllegalStateException If called from an AccessibilityService. */ public void setAccessibilityFocused(boolean focused) { setBooleanProperty(PROPERTY_ACCESSIBILITY_FOCUSED, focused); setBooleanProperty(BOOLEAN_PROPERTY_ACCESSIBILITY_FOCUSED, focused); } /** Loading @@ -1137,7 +1142,7 @@ public class AccessibilityNodeInfo implements Parcelable { * @return True if the node is selected. */ public boolean isSelected() { return getBooleanProperty(PROPERTY_SELECTED); return getBooleanProperty(BOOLEAN_PROPERTY_SELECTED); } /** Loading @@ -1153,7 +1158,7 @@ public class AccessibilityNodeInfo implements Parcelable { * @throws IllegalStateException If called from an AccessibilityService. */ public void setSelected(boolean selected) { setBooleanProperty(PROPERTY_SELECTED, selected); setBooleanProperty(BOOLEAN_PROPERTY_SELECTED, selected); } /** Loading @@ -1162,7 +1167,7 @@ public class AccessibilityNodeInfo implements Parcelable { * @return True if the node is clickable. */ public boolean isClickable() { return getBooleanProperty(PROPERTY_CLICKABLE); return getBooleanProperty(BOOLEAN_PROPERTY_CLICKABLE); } /** Loading @@ -1178,7 +1183,7 @@ public class AccessibilityNodeInfo implements Parcelable { * @throws IllegalStateException If called from an AccessibilityService. */ public void setClickable(boolean clickable) { setBooleanProperty(PROPERTY_CLICKABLE, clickable); setBooleanProperty(BOOLEAN_PROPERTY_CLICKABLE, clickable); } /** Loading @@ -1187,7 +1192,7 @@ public class AccessibilityNodeInfo implements Parcelable { * @return True if the node is long clickable. */ public boolean isLongClickable() { return getBooleanProperty(PROPERTY_LONG_CLICKABLE); return getBooleanProperty(BOOLEAN_PROPERTY_LONG_CLICKABLE); } /** Loading @@ -1203,7 +1208,7 @@ public class AccessibilityNodeInfo implements Parcelable { * @throws IllegalStateException If called from an AccessibilityService. */ public void setLongClickable(boolean longClickable) { setBooleanProperty(PROPERTY_LONG_CLICKABLE, longClickable); setBooleanProperty(BOOLEAN_PROPERTY_LONG_CLICKABLE, longClickable); } /** Loading @@ -1212,7 +1217,7 @@ public class AccessibilityNodeInfo implements Parcelable { * @return True if the node is enabled. */ public boolean isEnabled() { return getBooleanProperty(PROPERTY_ENABLED); return getBooleanProperty(BOOLEAN_PROPERTY_ENABLED); } /** Loading @@ -1228,7 +1233,7 @@ public class AccessibilityNodeInfo implements Parcelable { * @throws IllegalStateException If called from an AccessibilityService. */ public void setEnabled(boolean enabled) { setBooleanProperty(PROPERTY_ENABLED, enabled); setBooleanProperty(BOOLEAN_PROPERTY_ENABLED, enabled); } /** Loading @@ -1237,7 +1242,7 @@ public class AccessibilityNodeInfo implements Parcelable { * @return True if the node is a password. */ public boolean isPassword() { return getBooleanProperty(PROPERTY_PASSWORD); return getBooleanProperty(BOOLEAN_PROPERTY_PASSWORD); } /** Loading @@ -1253,7 +1258,7 @@ public class AccessibilityNodeInfo implements Parcelable { * @throws IllegalStateException If called from an AccessibilityService. */ public void setPassword(boolean password) { setBooleanProperty(PROPERTY_PASSWORD, password); setBooleanProperty(BOOLEAN_PROPERTY_PASSWORD, password); } /** Loading @@ -1262,7 +1267,7 @@ public class AccessibilityNodeInfo implements Parcelable { * @return True if the node is scrollable, false otherwise. */ public boolean isScrollable() { return getBooleanProperty(PROPERTY_SCROLLABLE); return getBooleanProperty(BOOLEAN_PROPERTY_SCROLLABLE); } /** Loading @@ -1279,7 +1284,32 @@ public class AccessibilityNodeInfo implements Parcelable { */ public void setScrollable(boolean scrollable) { enforceNotSealed(); setBooleanProperty(PROPERTY_SCROLLABLE, scrollable); setBooleanProperty(BOOLEAN_PROPERTY_SCROLLABLE, scrollable); } /** * Gets if the node is editable. * * @return True if the node is editable, false otherwise. */ public boolean isEditable() { return getBooleanProperty(BOOLEAN_PROPERTY_EDITABLE); } /** * Sets whether this node is editable. * <p> * <strong>Note:</strong> Cannot be called from an * {@link android.accessibilityservice.AccessibilityService}. * This class is made immutable before being delivered to an AccessibilityService. * </p> * * @param editable True if the node is editable. * * @throws IllegalStateException If called from an AccessibilityService. */ public void setEditable(boolean editable) { setBooleanProperty(BOOLEAN_PROPERTY_EDITABLE, editable); } /** Loading Loading @@ -1532,6 +1562,43 @@ public class AccessibilityNodeInfo implements Parcelable { return mViewIdResourceName; } /** * Gets the text selection start. * * @return The text selection start if there is selection or -1. */ public int getTextSelectionStart() { return mTextSelectionStart; } /** * Gets the text selection end. * * @return The text selection end if there is selection or -1. */ public int getTextSelectionEnd() { return mTextSelectionEnd; } /** * Sets the text selection start and end. * <p> * <strong>Note:</strong> Cannot be called from an * {@link android.accessibilityservice.AccessibilityService}. * This class is made immutable before being delivered to an AccessibilityService. * </p> * * @param start The text selection start. * @param end The text selection end. * * @throws IllegalStateException If called from an AccessibilityService. */ public void setTextSelection(int start, int end) { enforceNotSealed(); mTextSelectionStart = start; mTextSelectionEnd = end; } /** * Gets the value of a boolean property. * Loading Loading @@ -1776,6 +1843,9 @@ public class AccessibilityNodeInfo implements Parcelable { parcel.writeCharSequence(mContentDescription); parcel.writeCharSequence(mViewIdResourceName); parcel.writeInt(mTextSelectionStart); parcel.writeInt(mTextSelectionEnd); // Since instances of this class are fetched via synchronous i.e. blocking // calls in IPCs we always recycle as soon as the instance is marshaled. recycle(); Loading Loading @@ -1808,6 +1878,8 @@ public class AccessibilityNodeInfo implements Parcelable { for (int i = 0; i < otherChildIdCount; i++) { mChildNodeIds.put(i, other.mChildNodeIds.valueAt(i)); } mTextSelectionStart = other.mTextSelectionStart; mTextSelectionEnd = other.mTextSelectionEnd; } /** Loading Loading @@ -1852,6 +1924,9 @@ public class AccessibilityNodeInfo implements Parcelable { mText = parcel.readCharSequence(); mContentDescription = parcel.readCharSequence(); mViewIdResourceName = parcel.readCharSequence(); mTextSelectionStart = parcel.readInt(); mTextSelectionEnd = parcel.readInt(); } /** Loading @@ -1876,6 +1951,8 @@ public class AccessibilityNodeInfo implements Parcelable { mContentDescription = null; mViewIdResourceName = null; mActions = 0; mTextSelectionStart = UNDEFINED; mTextSelectionEnd = UNDEFINED; } /** Loading core/java/android/widget/TextView.java +5 −0 Original line number Diff line number Diff line Loading @@ -7165,6 +7165,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener */ protected void onSelectionChanged(int selStart, int selEnd) { sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_TEXT_SELECTION_CHANGED); notifyAccessibilityStateChanged(); } /** Loading Loading @@ -7976,6 +7977,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener info.setText(getTextForAccessibility()); } if (mBufferType == BufferType.EDITABLE) { info.setEditable(true); } if (TextUtils.isEmpty(getContentDescription()) && !TextUtils.isEmpty(mText)) { info.addAction(AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY); info.addAction(AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY); Loading Loading
api/current.txt +5 −0 Original line number Diff line number Diff line Loading @@ -26305,12 +26305,15 @@ package android.view.accessibility { method public java.lang.CharSequence getPackageName(); method public android.view.accessibility.AccessibilityNodeInfo getParent(); method public java.lang.CharSequence getText(); method public int getTextSelectionEnd(); method public int getTextSelectionStart(); method public java.lang.CharSequence getViewIdResourceName(); method public int getWindowId(); method public boolean isAccessibilityFocused(); method public boolean isCheckable(); method public boolean isChecked(); method public boolean isClickable(); method public boolean isEditable(); method public boolean isEnabled(); method public boolean isFocusable(); method public boolean isFocused(); Loading @@ -26335,6 +26338,7 @@ package android.view.accessibility { method public void setClassName(java.lang.CharSequence); method public void setClickable(boolean); method public void setContentDescription(java.lang.CharSequence); method public void setEditable(boolean); method public void setEnabled(boolean); method public void setFocusable(boolean); method public void setFocused(boolean); Loading @@ -26353,6 +26357,7 @@ package android.view.accessibility { method public void setSource(android.view.View); method public void setSource(android.view.View, int); method public void setText(java.lang.CharSequence); method public void setTextSelection(int, int); method public void setViewIdResourceName(java.lang.CharSequence); method public void setVisibleToUser(boolean); method public void writeToParcel(android.os.Parcel, int);
core/java/android/view/View.java +27 −8 Original line number Diff line number Diff line Loading @@ -4859,14 +4859,26 @@ public class View implements Drawable.Callback, KeyEvent.Callback, event.setEnabled(isEnabled()); event.setContentDescription(mContentDescription); if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_FOCUSED && mAttachInfo != null) { ArrayList<View> focusablesTempList = mAttachInfo.mTempArrayList; getRootView().addFocusables(focusablesTempList, View.FOCUS_FORWARD, FOCUSABLES_ALL); switch (event.getEventType()) { case AccessibilityEvent.TYPE_VIEW_FOCUSED: { ArrayList<View> focusablesTempList = (mAttachInfo != null) ? mAttachInfo.mTempArrayList : new ArrayList<View>(); getRootView().addFocusables(focusablesTempList, View.FOCUS_FORWARD, FOCUSABLES_ALL); event.setItemCount(focusablesTempList.size()); event.setCurrentItemIndex(focusablesTempList.indexOf(this)); if (mAttachInfo != null) { focusablesTempList.clear(); } } break; case AccessibilityEvent.TYPE_VIEW_TEXT_SELECTION_CHANGED: { CharSequence text = getIterableTextForAccessibility(); if (text != null && text.length() > 0) { event.setFromIndex(getAccessibilitySelectionStart()); event.setToIndex(getAccessibilitySelectionEnd()); event.setItemCount(text.length()); } } break; } } /** Loading Loading @@ -5081,7 +5093,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback, info.addAction(AccessibilityNodeInfo.ACTION_LONG_CLICK); } if (mContentDescription != null && mContentDescription.length() > 0) { CharSequence text = getIterableTextForAccessibility(); if (text != null && text.length() > 0) { info.setTextSelection(getAccessibilitySelectionStart(), getAccessibilitySelectionEnd()); info.addAction(AccessibilityNodeInfo.ACTION_SET_SELECTION); info.addAction(AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY); info.addAction(AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY); Loading Loading @@ -7153,11 +7168,15 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * @hide */ public void setAccessibilitySelection(int start, int end) { if (start == end && end == mAccessibilityCursorPosition) { return; } if (start >= 0 && start == end && end <= getIterableTextForAccessibility().length()) { mAccessibilityCursorPosition = start; } else { mAccessibilityCursorPosition = ACCESSIBILITY_CURSOR_POSITION_UNDEFINED; } sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_TEXT_SELECTION_CHANGED); } private void sendViewTextTraversedAtGranularityEvent(int action, int granularity, Loading
core/java/android/view/accessibility/AccessibilityNodeInfo.java +113 −36 Original line number Diff line number Diff line Loading @@ -372,29 +372,31 @@ public class AccessibilityNodeInfo implements Parcelable { // Boolean attributes. private static final int PROPERTY_CHECKABLE = 0x00000001; private static final int BOOLEAN_PROPERTY_CHECKABLE = 0x00000001; private static final int PROPERTY_CHECKED = 0x00000002; private static final int BOOLEAN_PROPERTY_CHECKED = 0x00000002; private static final int PROPERTY_FOCUSABLE = 0x00000004; private static final int BOOLEAN_PROPERTY_FOCUSABLE = 0x00000004; private static final int PROPERTY_FOCUSED = 0x00000008; private static final int BOOLEAN_PROPERTY_FOCUSED = 0x00000008; private static final int PROPERTY_SELECTED = 0x00000010; private static final int BOOLEAN_PROPERTY_SELECTED = 0x00000010; private static final int PROPERTY_CLICKABLE = 0x00000020; private static final int BOOLEAN_PROPERTY_CLICKABLE = 0x00000020; private static final int PROPERTY_LONG_CLICKABLE = 0x00000040; private static final int BOOLEAN_PROPERTY_LONG_CLICKABLE = 0x00000040; private static final int PROPERTY_ENABLED = 0x00000080; private static final int BOOLEAN_PROPERTY_ENABLED = 0x00000080; private static final int PROPERTY_PASSWORD = 0x00000100; private static final int BOOLEAN_PROPERTY_PASSWORD = 0x00000100; private static final int PROPERTY_SCROLLABLE = 0x00000200; private static final int BOOLEAN_PROPERTY_SCROLLABLE = 0x00000200; private static final int PROPERTY_ACCESSIBILITY_FOCUSED = 0x00000400; private static final int BOOLEAN_PROPERTY_ACCESSIBILITY_FOCUSED = 0x00000400; private static final int PROPERTY_VISIBLE_TO_USER = 0x00000800; private static final int BOOLEAN_PROPERTY_VISIBLE_TO_USER = 0x00000800; private static final int BOOLEAN_PROPERTY_EDITABLE = 0x00001000; /** * Bits that provide the id of a virtual descendant of a view. Loading Loading @@ -478,6 +480,9 @@ public class AccessibilityNodeInfo implements Parcelable { private int mMovementGranularities; private int mTextSelectionStart = UNDEFINED; private int mTextSelectionEnd = UNDEFINED; private int mConnectionId = UNDEFINED; /** Loading Loading @@ -987,7 +992,7 @@ public class AccessibilityNodeInfo implements Parcelable { * @return True if the node is checkable. */ public boolean isCheckable() { return getBooleanProperty(PROPERTY_CHECKABLE); return getBooleanProperty(BOOLEAN_PROPERTY_CHECKABLE); } /** Loading @@ -1003,7 +1008,7 @@ public class AccessibilityNodeInfo implements Parcelable { * @throws IllegalStateException If called from an AccessibilityService. */ public void setCheckable(boolean checkable) { setBooleanProperty(PROPERTY_CHECKABLE, checkable); setBooleanProperty(BOOLEAN_PROPERTY_CHECKABLE, checkable); } /** Loading @@ -1012,7 +1017,7 @@ public class AccessibilityNodeInfo implements Parcelable { * @return True if the node is checked. */ public boolean isChecked() { return getBooleanProperty(PROPERTY_CHECKED); return getBooleanProperty(BOOLEAN_PROPERTY_CHECKED); } /** Loading @@ -1028,7 +1033,7 @@ public class AccessibilityNodeInfo implements Parcelable { * @throws IllegalStateException If called from an AccessibilityService. */ public void setChecked(boolean checked) { setBooleanProperty(PROPERTY_CHECKED, checked); setBooleanProperty(BOOLEAN_PROPERTY_CHECKED, checked); } /** Loading @@ -1037,7 +1042,7 @@ public class AccessibilityNodeInfo implements Parcelable { * @return True if the node is focusable. */ public boolean isFocusable() { return getBooleanProperty(PROPERTY_FOCUSABLE); return getBooleanProperty(BOOLEAN_PROPERTY_FOCUSABLE); } /** Loading @@ -1053,7 +1058,7 @@ public class AccessibilityNodeInfo implements Parcelable { * @throws IllegalStateException If called from an AccessibilityService. */ public void setFocusable(boolean focusable) { setBooleanProperty(PROPERTY_FOCUSABLE, focusable); setBooleanProperty(BOOLEAN_PROPERTY_FOCUSABLE, focusable); } /** Loading @@ -1062,7 +1067,7 @@ public class AccessibilityNodeInfo implements Parcelable { * @return True if the node is focused. */ public boolean isFocused() { return getBooleanProperty(PROPERTY_FOCUSED); return getBooleanProperty(BOOLEAN_PROPERTY_FOCUSED); } /** Loading @@ -1078,7 +1083,7 @@ public class AccessibilityNodeInfo implements Parcelable { * @throws IllegalStateException If called from an AccessibilityService. */ public void setFocused(boolean focused) { setBooleanProperty(PROPERTY_FOCUSED, focused); setBooleanProperty(BOOLEAN_PROPERTY_FOCUSED, focused); } /** Loading @@ -1087,7 +1092,7 @@ public class AccessibilityNodeInfo implements Parcelable { * @return Whether the node is visible to the user. */ public boolean isVisibleToUser() { return getBooleanProperty(PROPERTY_VISIBLE_TO_USER); return getBooleanProperty(BOOLEAN_PROPERTY_VISIBLE_TO_USER); } /** Loading @@ -1103,7 +1108,7 @@ public class AccessibilityNodeInfo implements Parcelable { * @throws IllegalStateException If called from an AccessibilityService. */ public void setVisibleToUser(boolean visibleToUser) { setBooleanProperty(PROPERTY_VISIBLE_TO_USER, visibleToUser); setBooleanProperty(BOOLEAN_PROPERTY_VISIBLE_TO_USER, visibleToUser); } /** Loading @@ -1112,7 +1117,7 @@ public class AccessibilityNodeInfo implements Parcelable { * @return True if the node is accessibility focused. */ public boolean isAccessibilityFocused() { return getBooleanProperty(PROPERTY_ACCESSIBILITY_FOCUSED); return getBooleanProperty(BOOLEAN_PROPERTY_ACCESSIBILITY_FOCUSED); } /** Loading @@ -1128,7 +1133,7 @@ public class AccessibilityNodeInfo implements Parcelable { * @throws IllegalStateException If called from an AccessibilityService. */ public void setAccessibilityFocused(boolean focused) { setBooleanProperty(PROPERTY_ACCESSIBILITY_FOCUSED, focused); setBooleanProperty(BOOLEAN_PROPERTY_ACCESSIBILITY_FOCUSED, focused); } /** Loading @@ -1137,7 +1142,7 @@ public class AccessibilityNodeInfo implements Parcelable { * @return True if the node is selected. */ public boolean isSelected() { return getBooleanProperty(PROPERTY_SELECTED); return getBooleanProperty(BOOLEAN_PROPERTY_SELECTED); } /** Loading @@ -1153,7 +1158,7 @@ public class AccessibilityNodeInfo implements Parcelable { * @throws IllegalStateException If called from an AccessibilityService. */ public void setSelected(boolean selected) { setBooleanProperty(PROPERTY_SELECTED, selected); setBooleanProperty(BOOLEAN_PROPERTY_SELECTED, selected); } /** Loading @@ -1162,7 +1167,7 @@ public class AccessibilityNodeInfo implements Parcelable { * @return True if the node is clickable. */ public boolean isClickable() { return getBooleanProperty(PROPERTY_CLICKABLE); return getBooleanProperty(BOOLEAN_PROPERTY_CLICKABLE); } /** Loading @@ -1178,7 +1183,7 @@ public class AccessibilityNodeInfo implements Parcelable { * @throws IllegalStateException If called from an AccessibilityService. */ public void setClickable(boolean clickable) { setBooleanProperty(PROPERTY_CLICKABLE, clickable); setBooleanProperty(BOOLEAN_PROPERTY_CLICKABLE, clickable); } /** Loading @@ -1187,7 +1192,7 @@ public class AccessibilityNodeInfo implements Parcelable { * @return True if the node is long clickable. */ public boolean isLongClickable() { return getBooleanProperty(PROPERTY_LONG_CLICKABLE); return getBooleanProperty(BOOLEAN_PROPERTY_LONG_CLICKABLE); } /** Loading @@ -1203,7 +1208,7 @@ public class AccessibilityNodeInfo implements Parcelable { * @throws IllegalStateException If called from an AccessibilityService. */ public void setLongClickable(boolean longClickable) { setBooleanProperty(PROPERTY_LONG_CLICKABLE, longClickable); setBooleanProperty(BOOLEAN_PROPERTY_LONG_CLICKABLE, longClickable); } /** Loading @@ -1212,7 +1217,7 @@ public class AccessibilityNodeInfo implements Parcelable { * @return True if the node is enabled. */ public boolean isEnabled() { return getBooleanProperty(PROPERTY_ENABLED); return getBooleanProperty(BOOLEAN_PROPERTY_ENABLED); } /** Loading @@ -1228,7 +1233,7 @@ public class AccessibilityNodeInfo implements Parcelable { * @throws IllegalStateException If called from an AccessibilityService. */ public void setEnabled(boolean enabled) { setBooleanProperty(PROPERTY_ENABLED, enabled); setBooleanProperty(BOOLEAN_PROPERTY_ENABLED, enabled); } /** Loading @@ -1237,7 +1242,7 @@ public class AccessibilityNodeInfo implements Parcelable { * @return True if the node is a password. */ public boolean isPassword() { return getBooleanProperty(PROPERTY_PASSWORD); return getBooleanProperty(BOOLEAN_PROPERTY_PASSWORD); } /** Loading @@ -1253,7 +1258,7 @@ public class AccessibilityNodeInfo implements Parcelable { * @throws IllegalStateException If called from an AccessibilityService. */ public void setPassword(boolean password) { setBooleanProperty(PROPERTY_PASSWORD, password); setBooleanProperty(BOOLEAN_PROPERTY_PASSWORD, password); } /** Loading @@ -1262,7 +1267,7 @@ public class AccessibilityNodeInfo implements Parcelable { * @return True if the node is scrollable, false otherwise. */ public boolean isScrollable() { return getBooleanProperty(PROPERTY_SCROLLABLE); return getBooleanProperty(BOOLEAN_PROPERTY_SCROLLABLE); } /** Loading @@ -1279,7 +1284,32 @@ public class AccessibilityNodeInfo implements Parcelable { */ public void setScrollable(boolean scrollable) { enforceNotSealed(); setBooleanProperty(PROPERTY_SCROLLABLE, scrollable); setBooleanProperty(BOOLEAN_PROPERTY_SCROLLABLE, scrollable); } /** * Gets if the node is editable. * * @return True if the node is editable, false otherwise. */ public boolean isEditable() { return getBooleanProperty(BOOLEAN_PROPERTY_EDITABLE); } /** * Sets whether this node is editable. * <p> * <strong>Note:</strong> Cannot be called from an * {@link android.accessibilityservice.AccessibilityService}. * This class is made immutable before being delivered to an AccessibilityService. * </p> * * @param editable True if the node is editable. * * @throws IllegalStateException If called from an AccessibilityService. */ public void setEditable(boolean editable) { setBooleanProperty(BOOLEAN_PROPERTY_EDITABLE, editable); } /** Loading Loading @@ -1532,6 +1562,43 @@ public class AccessibilityNodeInfo implements Parcelable { return mViewIdResourceName; } /** * Gets the text selection start. * * @return The text selection start if there is selection or -1. */ public int getTextSelectionStart() { return mTextSelectionStart; } /** * Gets the text selection end. * * @return The text selection end if there is selection or -1. */ public int getTextSelectionEnd() { return mTextSelectionEnd; } /** * Sets the text selection start and end. * <p> * <strong>Note:</strong> Cannot be called from an * {@link android.accessibilityservice.AccessibilityService}. * This class is made immutable before being delivered to an AccessibilityService. * </p> * * @param start The text selection start. * @param end The text selection end. * * @throws IllegalStateException If called from an AccessibilityService. */ public void setTextSelection(int start, int end) { enforceNotSealed(); mTextSelectionStart = start; mTextSelectionEnd = end; } /** * Gets the value of a boolean property. * Loading Loading @@ -1776,6 +1843,9 @@ public class AccessibilityNodeInfo implements Parcelable { parcel.writeCharSequence(mContentDescription); parcel.writeCharSequence(mViewIdResourceName); parcel.writeInt(mTextSelectionStart); parcel.writeInt(mTextSelectionEnd); // Since instances of this class are fetched via synchronous i.e. blocking // calls in IPCs we always recycle as soon as the instance is marshaled. recycle(); Loading Loading @@ -1808,6 +1878,8 @@ public class AccessibilityNodeInfo implements Parcelable { for (int i = 0; i < otherChildIdCount; i++) { mChildNodeIds.put(i, other.mChildNodeIds.valueAt(i)); } mTextSelectionStart = other.mTextSelectionStart; mTextSelectionEnd = other.mTextSelectionEnd; } /** Loading Loading @@ -1852,6 +1924,9 @@ public class AccessibilityNodeInfo implements Parcelable { mText = parcel.readCharSequence(); mContentDescription = parcel.readCharSequence(); mViewIdResourceName = parcel.readCharSequence(); mTextSelectionStart = parcel.readInt(); mTextSelectionEnd = parcel.readInt(); } /** Loading @@ -1876,6 +1951,8 @@ public class AccessibilityNodeInfo implements Parcelable { mContentDescription = null; mViewIdResourceName = null; mActions = 0; mTextSelectionStart = UNDEFINED; mTextSelectionEnd = UNDEFINED; } /** Loading
core/java/android/widget/TextView.java +5 −0 Original line number Diff line number Diff line Loading @@ -7165,6 +7165,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener */ protected void onSelectionChanged(int selStart, int selEnd) { sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_TEXT_SELECTION_CHANGED); notifyAccessibilityStateChanged(); } /** Loading Loading @@ -7976,6 +7977,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener info.setText(getTextForAccessibility()); } if (mBufferType == BufferType.EDITABLE) { info.setEditable(true); } if (TextUtils.isEmpty(getContentDescription()) && !TextUtils.isEmpty(mText)) { info.addAction(AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY); info.addAction(AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY); Loading