1/* 2 * Copyright (C) 2011 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17package android.support.v4.view.accessibility; 18 19import android.graphics.Rect; 20import android.os.Build; 21import android.os.Bundle; 22import android.support.annotation.Nullable; 23import android.support.v4.accessibilityservice.AccessibilityServiceInfoCompat; 24import android.support.v4.view.ViewCompat; 25import android.text.InputType; 26import android.view.View; 27 28import java.util.ArrayList; 29import java.util.Collections; 30import java.util.List; 31 32/** 33 * Helper for accessing {@link android.view.accessibility.AccessibilityNodeInfo} 34 * introduced after API level 4 in a backwards compatible fashion. 35 */ 36public class AccessibilityNodeInfoCompat { 37 38 public static class AccessibilityActionCompat { 39 40 /** 41 * Action that gives input focus to the node. 42 */ 43 public static final AccessibilityActionCompat ACTION_FOCUS = 44 new AccessibilityActionCompat( 45 AccessibilityNodeInfoCompat.ACTION_FOCUS, null); 46 47 /** 48 * Action that clears input focus of the node. 49 */ 50 public static final AccessibilityActionCompat ACTION_CLEAR_FOCUS = 51 new AccessibilityActionCompat( 52 AccessibilityNodeInfoCompat.ACTION_CLEAR_FOCUS, null); 53 54 /** 55 * Action that selects the node. 56 */ 57 public static final AccessibilityActionCompat ACTION_SELECT = 58 new AccessibilityActionCompat( 59 AccessibilityNodeInfoCompat.ACTION_SELECT, null); 60 61 /** 62 * Action that deselects the node. 63 */ 64 public static final AccessibilityActionCompat ACTION_CLEAR_SELECTION = 65 new AccessibilityActionCompat( 66 AccessibilityNodeInfoCompat.ACTION_CLEAR_SELECTION, null); 67 68 /** 69 * Action that clicks on the node info. 70 */ 71 public static final AccessibilityActionCompat ACTION_CLICK = 72 new AccessibilityActionCompat( 73 AccessibilityNodeInfoCompat.ACTION_CLICK, null); 74 75 /** 76 * Action that long clicks on the node. 77 */ 78 public static final AccessibilityActionCompat ACTION_LONG_CLICK = 79 new AccessibilityActionCompat( 80 AccessibilityNodeInfoCompat.ACTION_LONG_CLICK, null); 81 82 /** 83 * Action that gives accessibility focus to the node. 84 */ 85 public static final AccessibilityActionCompat ACTION_ACCESSIBILITY_FOCUS = 86 new AccessibilityActionCompat( 87 AccessibilityNodeInfoCompat.ACTION_ACCESSIBILITY_FOCUS, null); 88 89 /** 90 * Action that clears accessibility focus of the node. 91 */ 92 public static final AccessibilityActionCompat ACTION_CLEAR_ACCESSIBILITY_FOCUS = 93 new AccessibilityActionCompat( 94 AccessibilityNodeInfoCompat.ACTION_CLEAR_ACCESSIBILITY_FOCUS, null); 95 96 /** 97 * Action that requests to go to the next entity in this node's text 98 * at a given movement granularity. For example, move to the next character, 99 * word, etc. 100 * <p> 101 * <strong>Arguments:</strong> 102 * {@link AccessibilityNodeInfoCompat#ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT 103 * AccessibilityNodeInfoCompat.ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT}, 104 * {@link AccessibilityNodeInfoCompat#ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN 105 * AccessibilityNodeInfoCompat.ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN}<br> 106 * <strong>Example:</strong> Move to the previous character and do not extend selection. 107 * <code><pre><p> 108 * Bundle arguments = new Bundle(); 109 * arguments.putInt(AccessibilityNodeInfoCompat.ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT, 110 * AccessibilityNodeInfoCompat.MOVEMENT_GRANULARITY_CHARACTER); 111 * arguments.putBoolean( 112 * AccessibilityNodeInfoCompat.ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN, false); 113 * info.performAction( 114 * AccessibilityActionCompat.ACTION_NEXT_AT_MOVEMENT_GRANULARITY.getId(), 115 * arguments); 116 * </code></pre></p> 117 * </p> 118 * 119 * @see AccessibilityNodeInfoCompat#ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT 120 * AccessibilityNodeInfoCompat.ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT 121 * @see AccessibilityNodeInfoCompat#ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN 122 * AccessibilityNodeInfoCompat.ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN 123 * 124 * @see AccessibilityNodeInfoCompat#setMovementGranularities(int) 125 * AccessibilityNodeInfoCompat.ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN 126 * @see AccessibilityNodeInfoCompat#getMovementGranularities() 127 * AccessibilityNodeInfoCompat.getMovementGranularities() 128 * 129 * @see AccessibilityNodeInfoCompat#MOVEMENT_GRANULARITY_CHARACTER 130 * AccessibilityNodeInfoCompat.MOVEMENT_GRANULARITY_CHARACTER 131 * @see AccessibilityNodeInfoCompat#MOVEMENT_GRANULARITY_WORD 132 * AccessibilityNodeInfoCompat.MOVEMENT_GRANULARITY_WORD 133 * @see AccessibilityNodeInfoCompat#MOVEMENT_GRANULARITY_LINE 134 * AccessibilityNodeInfoCompat.MOVEMENT_GRANULARITY_LINE 135 * @see AccessibilityNodeInfoCompat#MOVEMENT_GRANULARITY_PARAGRAPH 136 * AccessibilityNodeInfoCompat.MOVEMENT_GRANULARITY_PARAGRAPH 137 * @see AccessibilityNodeInfoCompat#MOVEMENT_GRANULARITY_PAGE 138 * AccessibilityNodeInfoCompat.MOVEMENT_GRANULARITY_PAGE 139 */ 140 public static final AccessibilityActionCompat ACTION_NEXT_AT_MOVEMENT_GRANULARITY = 141 new AccessibilityActionCompat( 142 AccessibilityNodeInfoCompat.ACTION_NEXT_AT_MOVEMENT_GRANULARITY, null); 143 144 /** 145 * Action that requests to go to the previous entity in this node's text 146 * at a given movement granularity. For example, move to the next character, 147 * word, etc. 148 * <p> 149 * <strong>Arguments:</strong> 150 * {@link AccessibilityNodeInfoCompat#ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT 151 * AccessibilityNodeInfoCompat.ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT}, 152 * {@link AccessibilityNodeInfoCompat#ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN 153 * AccessibilityNodeInfoCompat.ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN}<br> 154 * <strong>Example:</strong> Move to the next character and do not extend selection. 155 * <code><pre><p> 156 * Bundle arguments = new Bundle(); 157 * arguments.putInt(AccessibilityNodeInfoCompat.ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT, 158 * AccessibilityNodeInfoCompat.MOVEMENT_GRANULARITY_CHARACTER); 159 * arguments.putBoolean( 160 * AccessibilityNodeInfoCompat.ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN, false); 161 * info.performAction( 162 * AccessibilityActionCompat.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY.getId(), 163 * arguments); 164 * </code></pre></p> 165 * </p> 166 * 167 * @see AccessibilityNodeInfoCompat#ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT 168 * AccessibilityNodeInfoCompat.ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT 169 * @see AccessibilityNodeInfoCompat#ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN 170 * AccessibilityNodeInfoCompat.ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN 171 * 172 * @see AccessibilityNodeInfoCompat#setMovementGranularities(int) 173 * AccessibilityNodeInfoCompat.setMovementGranularities(int) 174 * @see AccessibilityNodeInfoCompat#getMovementGranularities() 175 * AccessibilityNodeInfoCompat.getMovementGranularities() 176 * 177 * @see AccessibilityNodeInfoCompat#MOVEMENT_GRANULARITY_CHARACTER 178 * AccessibilityNodeInfoCompat.MOVEMENT_GRANULARITY_CHARACTER 179 * @see AccessibilityNodeInfoCompat#MOVEMENT_GRANULARITY_WORD 180 * AccessibilityNodeInfoCompat.MOVEMENT_GRANULARITY_WORD 181 * @see AccessibilityNodeInfoCompat#MOVEMENT_GRANULARITY_LINE 182 * AccessibilityNodeInfoCompat.MOVEMENT_GRANULARITY_LINE 183 * @see AccessibilityNodeInfoCompat#MOVEMENT_GRANULARITY_PARAGRAPH 184 * AccessibilityNodeInfoCompat.MOVEMENT_GRANULARITY_PARAGRAPH 185 * @see AccessibilityNodeInfoCompat#MOVEMENT_GRANULARITY_PAGE 186 * AccessibilityNodeInfoCompat.MOVEMENT_GRANULARITY_PAGE 187 */ 188 public static final AccessibilityActionCompat ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY = 189 new AccessibilityActionCompat( 190 AccessibilityNodeInfoCompat.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY, null); 191 192 /** 193 * Action to move to the next HTML element of a given type. For example, move 194 * to the BUTTON, INPUT, TABLE, etc. 195 * <p> 196 * <strong>Arguments:</strong> 197 * {@link AccessibilityNodeInfoCompat#ACTION_ARGUMENT_HTML_ELEMENT_STRING 198 * AccessibilityNodeInfoCompat.ACTION_ARGUMENT_HTML_ELEMENT_STRING}<br> 199 * <strong>Example:</strong> 200 * <code><pre><p> 201 * Bundle arguments = new Bundle(); 202 * arguments.putString( 203 * AccessibilityNodeInfoCompat.ACTION_ARGUMENT_HTML_ELEMENT_STRING, "BUTTON"); 204 * info.performAction( 205 * AccessibilityActionCompat.ACTION_NEXT_HTML_ELEMENT.getId(), arguments); 206 * </code></pre></p> 207 * </p> 208 */ 209 public static final AccessibilityActionCompat ACTION_NEXT_HTML_ELEMENT = 210 new AccessibilityActionCompat( 211 AccessibilityNodeInfoCompat.ACTION_NEXT_HTML_ELEMENT, null); 212 213 /** 214 * Action to move to the previous HTML element of a given type. For example, move 215 * to the BUTTON, INPUT, TABLE, etc. 216 * <p> 217 * <strong>Arguments:</strong> 218 * {@link AccessibilityNodeInfoCompat#ACTION_ARGUMENT_HTML_ELEMENT_STRING 219 * AccessibilityNodeInfoCompat.ACTION_ARGUMENT_HTML_ELEMENT_STRING}<br> 220 * <strong>Example:</strong> 221 * <code><pre><p> 222 * Bundle arguments = new Bundle(); 223 * arguments.putString( 224 * AccessibilityNodeInfoCompat.ACTION_ARGUMENT_HTML_ELEMENT_STRING, "BUTTON"); 225 * info.performAction( 226 * AccessibilityActionCompat.ACTION_PREVIOUS_HTML_ELEMENT.getId(), arguments); 227 * </code></pre></p> 228 * </p> 229 */ 230 public static final AccessibilityActionCompat ACTION_PREVIOUS_HTML_ELEMENT = 231 new AccessibilityActionCompat( 232 AccessibilityNodeInfoCompat.ACTION_PREVIOUS_HTML_ELEMENT, null); 233 234 /** 235 * Action to scroll the node content forward. 236 */ 237 public static final AccessibilityActionCompat ACTION_SCROLL_FORWARD = 238 new AccessibilityActionCompat( 239 AccessibilityNodeInfoCompat.ACTION_SCROLL_FORWARD, null); 240 241 /** 242 * Action to scroll the node content backward. 243 */ 244 public static final AccessibilityActionCompat ACTION_SCROLL_BACKWARD = 245 new AccessibilityActionCompat( 246 AccessibilityNodeInfoCompat.ACTION_SCROLL_BACKWARD, null); 247 248 /** 249 * Action to copy the current selection to the clipboard. 250 */ 251 public static final AccessibilityActionCompat ACTION_COPY = 252 new AccessibilityActionCompat( 253 AccessibilityNodeInfoCompat.ACTION_COPY, null); 254 255 /** 256 * Action to paste the current clipboard content. 257 */ 258 public static final AccessibilityActionCompat ACTION_PASTE = 259 new AccessibilityActionCompat( 260 AccessibilityNodeInfoCompat.ACTION_PASTE, null); 261 262 /** 263 * Action to cut the current selection and place it to the clipboard. 264 */ 265 public static final AccessibilityActionCompat ACTION_CUT = 266 new AccessibilityActionCompat( 267 AccessibilityNodeInfoCompat.ACTION_CUT, null); 268 269 /** 270 * Action to set the selection. Performing this action with no arguments 271 * clears the selection. 272 * <p> 273 * <strong>Arguments:</strong> 274 * {@link AccessibilityNodeInfoCompat#ACTION_ARGUMENT_SELECTION_START_INT 275 * AccessibilityNodeInfoCompat.ACTION_ARGUMENT_SELECTION_START_INT}, 276 * {@link AccessibilityNodeInfoCompat#ACTION_ARGUMENT_SELECTION_END_INT 277 * AccessibilityNodeInfoCompat.ACTION_ARGUMENT_SELECTION_END_INT}<br> 278 * <strong>Example:</strong> 279 * <code><pre><p> 280 * Bundle arguments = new Bundle(); 281 * arguments.putInt(AccessibilityNodeInfoCompat.ACTION_ARGUMENT_SELECTION_START_INT, 1); 282 * arguments.putInt(AccessibilityNodeInfoCompat.ACTION_ARGUMENT_SELECTION_END_INT, 2); 283 * info.performAction(AccessibilityActionCompat.ACTION_SET_SELECTION.getId(), arguments); 284 * </code></pre></p> 285 * </p> 286 * 287 * @see AccessibilityNodeInfoCompat#ACTION_ARGUMENT_SELECTION_START_INT 288 * AccessibilityNodeInfoCompat.ACTION_ARGUMENT_SELECTION_START_INT 289 * @see AccessibilityNodeInfoCompat#ACTION_ARGUMENT_SELECTION_END_INT 290 * AccessibilityNodeInfoCompat.ACTION_ARGUMENT_SELECTION_END_INT 291 */ 292 public static final AccessibilityActionCompat ACTION_SET_SELECTION = 293 new AccessibilityActionCompat( 294 AccessibilityNodeInfoCompat.ACTION_SET_SELECTION, null); 295 296 /** 297 * Action to expand an expandable node. 298 */ 299 public static final AccessibilityActionCompat ACTION_EXPAND = 300 new AccessibilityActionCompat( 301 AccessibilityNodeInfoCompat.ACTION_EXPAND, null); 302 303 /** 304 * Action to collapse an expandable node. 305 */ 306 public static final AccessibilityActionCompat ACTION_COLLAPSE = 307 new AccessibilityActionCompat( 308 AccessibilityNodeInfoCompat.ACTION_COLLAPSE, null); 309 310 /** 311 * Action to dismiss a dismissable node. 312 */ 313 public static final AccessibilityActionCompat ACTION_DISMISS = 314 new AccessibilityActionCompat( 315 AccessibilityNodeInfoCompat.ACTION_DISMISS, null); 316 317 /** 318 * Action that sets the text of the node. Performing the action without argument, 319 * using <code> null</code> or empty {@link CharSequence} will clear the text. This 320 * action will also put the cursor at the end of text. 321 * <p> 322 * <strong>Arguments:</strong> 323 * {@link AccessibilityNodeInfoCompat#ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE 324 * AccessibilityNodeInfoCompat.ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE}<br> 325 * <strong>Example:</strong> 326 * <code><pre><p> 327 * Bundle arguments = new Bundle(); 328 * arguments.putCharSequence(AccessibilityNodeInfoCompat.ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE, 329 * "android"); 330 * info.performAction(AccessibilityActionCompat.ACTION_SET_TEXT.getId(), arguments); 331 * </code></pre></p> 332 */ 333 public static final AccessibilityActionCompat ACTION_SET_TEXT = 334 new AccessibilityActionCompat( 335 AccessibilityNodeInfoCompat.ACTION_SET_TEXT, null); 336 337 private final Object mAction; 338 339 /** 340 * Creates a new instance. 341 * 342 * @param actionId The action id. 343 * @param label The action label. 344 */ 345 public AccessibilityActionCompat(int actionId, CharSequence label) { 346 this(IMPL.newAccessibilityAction(actionId, label)); 347 } 348 349 private AccessibilityActionCompat(Object action) { 350 mAction = action; 351 } 352 353 /** 354 * Gets the id for this action. 355 * 356 * @return The action id. 357 */ 358 public int getId() { 359 return IMPL.getAccessibilityActionId(mAction); 360 } 361 362 /** 363 * Gets the label for this action. Its purpose is to describe the 364 * action to user. 365 * 366 * @return The label. 367 */ 368 public CharSequence getLabel() { 369 return IMPL.getAccessibilityActionLabel(mAction); 370 } 371 } 372 373 public static class CollectionInfoCompat { 374 /** Selection mode where items are not selectable. */ 375 public static final int SELECTION_MODE_NONE = 0; 376 377 /** Selection mode where a single item may be selected. */ 378 public static final int SELECTION_MODE_SINGLE = 1; 379 380 /** Selection mode where multiple items may be selected. */ 381 public static final int SELECTION_MODE_MULTIPLE = 2; 382 383 final Object mInfo; 384 385 /** 386 * Returns a cached instance if such is available otherwise a new one. 387 * 388 * @return An instance. 389 */ 390 public static CollectionInfoCompat obtain(int rowCount, int columnCount, 391 boolean hierarchical, int selectionMode) { 392 return new CollectionInfoCompat(IMPL.obtainCollectionInfo(rowCount, columnCount, 393 hierarchical, selectionMode)); 394 } 395 396 private CollectionInfoCompat(Object info) { 397 mInfo = info; 398 } 399 400 public int getColumnCount() { 401 return IMPL.getCollectionInfoColumnCount(mInfo); 402 } 403 404 public int getRowCount() { 405 return IMPL.getCollectionInfoRowCount(mInfo); 406 } 407 408 public boolean isHierarchical() { 409 return IMPL.isCollectionInfoHierarchical(mInfo); 410 } 411 } 412 413 public static class CollectionItemInfoCompat { 414 415 private final Object mInfo; 416 417 /** 418 * Returns a cached instance if such is available otherwise a new one. 419 * 420 * @return An instance. 421 */ 422 public static CollectionItemInfoCompat obtain(int rowIndex, int rowSpan, 423 int columnIndex, int columnSpan, boolean heading, boolean selected) { 424 return new CollectionItemInfoCompat(IMPL.obtainCollectionItemInfo(rowIndex, rowSpan, 425 columnIndex, columnSpan, heading, selected)); 426 } 427 428 private CollectionItemInfoCompat(Object info) { 429 mInfo = info; 430 } 431 432 public int getColumnIndex() { 433 return IMPL.getCollectionItemColumnIndex(mInfo); 434 } 435 436 public int getColumnSpan() { 437 return IMPL.getCollectionItemColumnSpan(mInfo); 438 } 439 440 public int getRowIndex() { 441 return IMPL.getCollectionItemRowIndex(mInfo); 442 } 443 444 public int getRowSpan() { 445 return IMPL.getCollectionItemRowSpan(mInfo); 446 } 447 448 public boolean isHeading() { 449 return IMPL.isCollectionItemHeading(mInfo); 450 } 451 452 public boolean isSelected() { 453 return IMPL.isCollectionItemSelected(mInfo); 454 } 455 } 456 457 public static class RangeInfoCompat { 458 /** Range type: integer. */ 459 public static final int RANGE_TYPE_INT = 0; 460 /** Range type: float. */ 461 public static final int RANGE_TYPE_FLOAT = 1; 462 /** Range type: percent with values from zero to one.*/ 463 public static final int RANGE_TYPE_PERCENT = 2; 464 465 private final Object mInfo; 466 467 private RangeInfoCompat(Object info) { 468 mInfo = info; 469 } 470 471 public float getCurrent() { 472 return AccessibilityNodeInfoCompatKitKat.RangeInfo.getCurrent(mInfo); 473 } 474 475 public float getMax() { 476 return AccessibilityNodeInfoCompatKitKat.RangeInfo.getMax(mInfo); 477 } 478 479 public float getMin() { 480 return AccessibilityNodeInfoCompatKitKat.RangeInfo.getMin(mInfo); 481 } 482 483 public int getType() { 484 return AccessibilityNodeInfoCompatKitKat.RangeInfo.getType(mInfo); 485 } 486 } 487 488 static interface AccessibilityNodeInfoImpl { 489 public Object newAccessibilityAction(int actionId, CharSequence label); 490 public Object obtain(); 491 public Object obtain(View source); 492 public Object obtain(Object info); 493 public Object obtain(View root, int virtualDescendantId); 494 public void setSource(Object info, View source); 495 public void setSource(Object info, View root, int virtualDescendantId); 496 public Object findFocus(Object info, int focus); 497 public Object focusSearch(Object info, int direction); 498 public int getWindowId(Object info); 499 public int getChildCount(Object info); 500 public Object getChild(Object info, int index); 501 public void addChild(Object info, View child); 502 public void addChild(Object info, View child, int virtualDescendantId); 503 public boolean removeChild(Object info, View child); 504 public boolean removeChild(Object info, View root, int virtualDescendantId); 505 public int getActions(Object info); 506 public void addAction(Object info, int action); 507 public void addAction(Object info, Object action); 508 public boolean removeAction(Object info, Object action); 509 public int getAccessibilityActionId(Object action); 510 public CharSequence getAccessibilityActionLabel(Object action); 511 public boolean performAction(Object info, int action); 512 public boolean performAction(Object info, int action, Bundle arguments); 513 public void setMovementGranularities(Object info, int granularities); 514 public int getMovementGranularities(Object info); 515 public List<Object> findAccessibilityNodeInfosByText(Object info, String text); 516 public Object getParent(Object info); 517 public void setParent(Object info, View root, int virtualDescendantId); 518 public void setParent(Object info, View parent); 519 public void getBoundsInParent(Object info, Rect outBounds); 520 public void setBoundsInParent(Object info, Rect bounds); 521 public void getBoundsInScreen(Object info, Rect outBounds); 522 public void setBoundsInScreen(Object info, Rect bounds); 523 public boolean isCheckable(Object info); 524 public void setCheckable(Object info, boolean checkable); 525 public boolean isChecked(Object info); 526 public void setChecked(Object info, boolean checked); 527 public boolean isFocusable(Object info); 528 public void setFocusable(Object info, boolean focusable); 529 public boolean isFocused(Object info); 530 public void setFocused(Object info, boolean focused); 531 public boolean isVisibleToUser(Object info); 532 public void setVisibleToUser(Object info, boolean visibleToUser); 533 public boolean isAccessibilityFocused(Object info); 534 public void setAccessibilityFocused(Object info, boolean focused); 535 public boolean isSelected(Object info); 536 public void setSelected(Object info, boolean selected); 537 public boolean isClickable(Object info); 538 public void setClickable(Object info, boolean clickable); 539 public boolean isLongClickable(Object info); 540 public void setLongClickable(Object info, boolean longClickable); 541 public boolean isEnabled(Object info); 542 public void setEnabled(Object info, boolean enabled); 543 public boolean isPassword(Object info); 544 public void setPassword(Object info, boolean password); 545 public boolean isScrollable(Object info); 546 public void setScrollable(Object info, boolean scrollable); 547 public CharSequence getPackageName(Object info); 548 public void setPackageName(Object info, CharSequence packageName); 549 public CharSequence getClassName(Object info); 550 public void setClassName(Object info, CharSequence className); 551 public CharSequence getText(Object info); 552 public void setText(Object info, CharSequence text); 553 public CharSequence getContentDescription(Object info); 554 public void setContentDescription(Object info, CharSequence contentDescription); 555 public void recycle(Object info); 556 public String getViewIdResourceName(Object info); 557 public void setViewIdResourceName(Object info, String viewId); 558 public int getLiveRegion(Object info); 559 public void setLiveRegion(Object info, int mode); 560 public Object getCollectionInfo(Object info); 561 public void setCollectionInfo(Object info, Object collectionInfo); 562 public Object getCollectionItemInfo(Object info); 563 public void setCollectionItemInfo(Object info, Object collectionItemInfo); 564 public Object getRangeInfo(Object info); 565 public void setRangeInfo(Object info, Object rangeInfo); 566 public List<Object> getActionList(Object info); 567 public Object obtainCollectionInfo(int rowCount, int columnCount, boolean hierarchical, 568 int selectionMode); 569 public int getCollectionInfoColumnCount(Object info); 570 public int getCollectionInfoRowCount(Object info); 571 public boolean isCollectionInfoHierarchical(Object info); 572 public Object obtainCollectionItemInfo(int rowIndex, int rowSpan, int columnIndex, 573 int columnSpan, boolean heading, boolean selected); 574 public int getCollectionItemColumnIndex(Object info); 575 public int getCollectionItemColumnSpan(Object info); 576 public int getCollectionItemRowIndex(Object info); 577 public int getCollectionItemRowSpan(Object info); 578 public boolean isCollectionItemHeading(Object info); 579 public boolean isCollectionItemSelected(Object info); 580 public Object getTraversalBefore(Object info); 581 public void setTraversalBefore(Object info, View view); 582 public void setTraversalBefore(Object info, View root, int virtualDescendantId); 583 public Object getTraversalAfter(Object info); 584 public void setTraversalAfter(Object info, View view); 585 public void setTraversalAfter(Object info, View root, int virtualDescendantId); 586 public void setContentInvalid(Object info, boolean contentInvalid); 587 public boolean isContentInvalid(Object info); 588 public void setError(Object info, CharSequence error); 589 public CharSequence getError(Object info); 590 public void setLabelFor(Object info, View labeled); 591 public void setLabelFor(Object info, View root, int virtualDescendantId); 592 public Object getLabelFor(Object info); 593 public void setLabeledBy(Object info, View labeled); 594 public void setLabeledBy(Object info, View root, int virtualDescendantId); 595 public Object getLabeledBy(Object info); 596 public boolean canOpenPopup(Object info); 597 public void setCanOpenPopup(Object info, boolean opensPopup); 598 public List<Object> findAccessibilityNodeInfosByViewId(Object info, String viewId); 599 public Bundle getExtras(Object info); 600 public int getInputType(Object info); 601 public void setInputType(Object info, int inputType); 602 public void setMaxTextLength(Object info, int max); 603 public int getMaxTextLength(Object info); 604 public void setTextSelection(Object info, int start, int end); 605 public int getTextSelectionStart(Object info); 606 public int getTextSelectionEnd(Object info); 607 public Object getWindow(Object info); 608 public boolean isDismissable(Object info); 609 public void setDismissable(Object info, boolean dismissable); 610 public boolean isEditable(Object info); 611 public void setEditable(Object info, boolean editable); 612 public int getDrawingOrder(Object info); 613 public void setDrawingOrder(Object info, int drawingOrderInParent); 614 public boolean isImportantForAccessibility(Object info); 615 public void setImportantForAccessibility(Object info, boolean importantForAccessibility); 616 public boolean isMultiLine(Object info); 617 public void setMultiLine(Object info, boolean multiLine); 618 public boolean refresh(Object info); 619 public CharSequence getRoleDescription(Object info); 620 public void setRoleDescription(Object info, CharSequence roleDescription); 621 } 622 623 static class AccessibilityNodeInfoStubImpl implements AccessibilityNodeInfoImpl { 624 @Override 625 public Object newAccessibilityAction(int actionId, CharSequence label) { 626 return null; 627 } 628 629 @Override 630 public Object obtain() { 631 return null; 632 } 633 634 @Override 635 public Object obtain(View source) { 636 return null; 637 } 638 639 @Override 640 public Object obtain(View root, int virtualDescendantId) { 641 return null; 642 } 643 644 @Override 645 public Object obtain(Object info) { 646 return null; 647 } 648 649 @Override 650 public void addAction(Object info, int action) { 651 652 } 653 654 @Override 655 public void addAction(Object info, Object action) { 656 657 } 658 659 @Override 660 public boolean removeAction(Object info, Object action) { 661 return false; 662 } 663 664 @Override 665 public int getAccessibilityActionId(Object action) { 666 return 0; 667 } 668 669 @Override 670 public CharSequence getAccessibilityActionLabel(Object action) { 671 return null; 672 } 673 674 @Override 675 public void addChild(Object info, View child) { 676 677 } 678 679 @Override 680 public void addChild(Object info, View child, int virtualDescendantId) { 681 682 } 683 684 @Override 685 public boolean removeChild(Object info, View child) { 686 return false; 687 } 688 689 @Override 690 public boolean removeChild(Object info, View root, int virtualDescendantId) { 691 return false; 692 } 693 694 @Override 695 public List<Object> findAccessibilityNodeInfosByText(Object info, String text) { 696 return Collections.emptyList(); 697 } 698 699 @Override 700 public int getActions(Object info) { 701 return 0; 702 } 703 704 @Override 705 public void getBoundsInParent(Object info, Rect outBounds) { 706 707 } 708 709 @Override 710 public void getBoundsInScreen(Object info, Rect outBounds) { 711 712 } 713 714 @Override 715 public Object getChild(Object info, int index) { 716 return null; 717 } 718 719 @Override 720 public int getChildCount(Object info) { 721 return 0; 722 } 723 724 @Override 725 public CharSequence getClassName(Object info) { 726 return null; 727 } 728 729 @Override 730 public CharSequence getContentDescription(Object info) { 731 return null; 732 } 733 734 @Override 735 public CharSequence getPackageName(Object info) { 736 return null; 737 } 738 739 @Override 740 public Object getParent(Object info) { 741 return null; 742 } 743 744 @Override 745 public CharSequence getText(Object info) { 746 return null; 747 } 748 749 @Override 750 public int getWindowId(Object info) { 751 return 0; 752 } 753 754 @Override 755 public boolean isCheckable(Object info) { 756 return false; 757 } 758 759 @Override 760 public boolean isChecked(Object info) { 761 return false; 762 } 763 764 @Override 765 public boolean isClickable(Object info) { 766 return false; 767 } 768 769 @Override 770 public boolean isEnabled(Object info) { 771 return false; 772 } 773 774 @Override 775 public boolean isFocusable(Object info) { 776 return false; 777 } 778 779 @Override 780 public boolean isFocused(Object info) { 781 return false; 782 } 783 784 @Override 785 public boolean isVisibleToUser(Object info) { 786 return false; 787 } 788 789 @Override 790 public boolean isAccessibilityFocused(Object info) { 791 return false; 792 } 793 794 @Override 795 public boolean isLongClickable(Object info) { 796 return false; 797 } 798 799 @Override 800 public boolean isPassword(Object info) { 801 return false; 802 } 803 804 @Override 805 public boolean isScrollable(Object info) { 806 return false; 807 } 808 809 @Override 810 public boolean isSelected(Object info) { 811 return false; 812 } 813 814 @Override 815 public boolean performAction(Object info, int action) { 816 return false; 817 } 818 819 @Override 820 public boolean performAction(Object info, int action, Bundle arguments) { 821 return false; 822 } 823 824 @Override 825 public void setMovementGranularities(Object info, int granularities) { 826 827 } 828 829 @Override 830 public int getMovementGranularities(Object info) { 831 return 0; 832 } 833 834 @Override 835 public void setBoundsInParent(Object info, Rect bounds) { 836 837 } 838 839 @Override 840 public void setBoundsInScreen(Object info, Rect bounds) { 841 842 } 843 844 @Override 845 public void setCheckable(Object info, boolean checkable) { 846 847 } 848 849 @Override 850 public void setChecked(Object info, boolean checked) { 851 852 } 853 854 @Override 855 public void setClassName(Object info, CharSequence className) { 856 857 } 858 859 @Override 860 public void setClickable(Object info, boolean clickable) { 861 862 } 863 864 @Override 865 public void setContentDescription(Object info, CharSequence contentDescription) { 866 867 } 868 869 @Override 870 public void setEnabled(Object info, boolean enabled) { 871 872 } 873 874 @Override 875 public void setFocusable(Object info, boolean focusable) { 876 877 } 878 879 @Override 880 public void setFocused(Object info, boolean focused) { 881 882 } 883 884 @Override 885 public void setVisibleToUser(Object info, boolean visibleToUser) { 886 887 } 888 889 @Override 890 public void setAccessibilityFocused(Object info, boolean focused) { 891 892 } 893 894 @Override 895 public void setLongClickable(Object info, boolean longClickable) { 896 897 } 898 899 @Override 900 public void setPackageName(Object info, CharSequence packageName) { 901 902 } 903 904 @Override 905 public void setParent(Object info, View parent) { 906 907 } 908 909 @Override 910 public void setPassword(Object info, boolean password) { 911 912 } 913 914 @Override 915 public void setScrollable(Object info, boolean scrollable) { 916 917 } 918 919 @Override 920 public void setSelected(Object info, boolean selected) { 921 922 } 923 924 @Override 925 public void setSource(Object info, View source) { 926 927 } 928 929 @Override 930 public void setSource(Object info, View root, int virtualDescendantId) { 931 932 } 933 934 @Override 935 public Object findFocus(Object info, int focus) { 936 return null; 937 } 938 939 @Override 940 public Object focusSearch(Object info, int direction) { 941 return null; 942 } 943 944 @Override 945 public void setText(Object info, CharSequence text) { 946 947 } 948 949 @Override 950 public void recycle(Object info) { 951 952 } 953 954 @Override 955 public void setParent(Object info, View root, int virtualDescendantId) { 956 957 } 958 959 @Override 960 public String getViewIdResourceName(Object info) { 961 return null; 962 } 963 964 @Override 965 public void setViewIdResourceName(Object info, String viewId) { 966 967 } 968 969 @Override 970 public int getLiveRegion(Object info) { 971 return ViewCompat.ACCESSIBILITY_LIVE_REGION_NONE; 972 } 973 974 @Override 975 public void setLiveRegion(Object info, int mode) { 976 // No-op 977 } 978 979 @Override 980 public Object getCollectionInfo(Object info) { 981 return null; 982 } 983 984 @Override 985 public void setCollectionInfo(Object info, Object collectionInfo) { 986 } 987 988 @Override 989 public Object getCollectionItemInfo(Object info) { 990 return null; 991 } 992 993 @Override 994 public void setCollectionItemInfo(Object info, Object collectionItemInfo) { 995 } 996 997 @Override 998 public Object getRangeInfo(Object info) { 999 return null; 1000 } 1001 1002 @Override 1003 public void setRangeInfo(Object info, Object rangeInfo) { 1004 } 1005 1006 @Override 1007 public List<Object> getActionList(Object info) { 1008 return null; 1009 } 1010 1011 @Override 1012 public Object obtainCollectionInfo(int rowCount, int columnCount, boolean hierarchical, 1013 int selectionMode) { 1014 return null; 1015 } 1016 1017 @Override 1018 public int getCollectionInfoColumnCount(Object info) { 1019 return 0; 1020 } 1021 1022 @Override 1023 public int getCollectionInfoRowCount(Object info) { 1024 return 0; 1025 } 1026 1027 @Override 1028 public boolean isCollectionInfoHierarchical(Object info) { 1029 return false; 1030 } 1031 1032 @Override 1033 public Object obtainCollectionItemInfo(int rowIndex, int rowSpan, int columnIndex, 1034 int columnSpan, boolean heading, boolean selected) { 1035 return null; 1036 } 1037 1038 @Override 1039 public int getCollectionItemColumnIndex(Object info) { 1040 return 0; 1041 } 1042 1043 @Override 1044 public int getCollectionItemColumnSpan(Object info) { 1045 return 0; 1046 } 1047 1048 @Override 1049 public int getCollectionItemRowIndex(Object info) { 1050 return 0; 1051 } 1052 1053 @Override 1054 public int getCollectionItemRowSpan(Object info) { 1055 return 0; 1056 } 1057 1058 @Override 1059 public boolean isCollectionItemHeading(Object info) { 1060 return false; 1061 } 1062 1063 @Override 1064 public boolean isCollectionItemSelected(Object info) { 1065 return false; 1066 } 1067 1068 @Override 1069 public Object getTraversalBefore(Object info) { 1070 return null; 1071 } 1072 1073 @Override 1074 public void setTraversalBefore(Object info, View view) { 1075 } 1076 1077 @Override 1078 public void setTraversalBefore(Object info, View root, int virtualDescendantId) { 1079 } 1080 1081 @Override 1082 public Object getTraversalAfter(Object info) { 1083 return null; 1084 } 1085 1086 @Override 1087 public void setTraversalAfter(Object info, View view) { 1088 } 1089 1090 @Override 1091 public void setTraversalAfter(Object info, View root, int virtualDescendantId) { 1092 } 1093 1094 @Override 1095 public void setContentInvalid(Object info, boolean contentInvalid) { 1096 } 1097 1098 @Override 1099 public boolean isContentInvalid(Object info) { 1100 return false; 1101 } 1102 1103 @Override 1104 public void setError(Object info, CharSequence error) { 1105 } 1106 1107 @Override 1108 public CharSequence getError(Object info) { 1109 return null; 1110 } 1111 1112 @Override 1113 public void setLabelFor(Object info, View labeled) { 1114 } 1115 1116 @Override 1117 public void setLabelFor(Object info, View root, int virtualDescendantId) { 1118 } 1119 1120 @Override 1121 public Object getLabelFor(Object info) { 1122 return null; 1123 } 1124 1125 @Override 1126 public void setLabeledBy(Object info, View labeled) { 1127 } 1128 1129 @Override 1130 public void setLabeledBy(Object info, View root, int virtualDescendantId) { 1131 } 1132 1133 @Override 1134 public Object getLabeledBy(Object info){ 1135 return null; 1136 } 1137 1138 @Override 1139 public boolean canOpenPopup(Object info) { 1140 return false; 1141 } 1142 1143 @Override 1144 public void setCanOpenPopup(Object info, boolean opensPopup) { 1145 } 1146 1147 @Override 1148 public List<Object> findAccessibilityNodeInfosByViewId(Object info, String viewId) { 1149 return Collections.emptyList(); 1150 } 1151 1152 @Override 1153 public Bundle getExtras(Object info) { 1154 return new Bundle(); 1155 } 1156 1157 @Override 1158 public int getInputType(Object info) { 1159 return InputType.TYPE_NULL; 1160 } 1161 1162 @Override 1163 public void setInputType(Object info, int inputType) { 1164 } 1165 1166 @Override 1167 public void setMaxTextLength(Object info, int max) { 1168 } 1169 1170 @Override 1171 public int getMaxTextLength(Object info) { 1172 return -1; 1173 } 1174 1175 @Override 1176 public void setTextSelection(Object info, int start, int end) { 1177 } 1178 1179 @Override 1180 public int getTextSelectionStart(Object info) { 1181 return -1; 1182 } 1183 1184 @Override 1185 public int getTextSelectionEnd(Object info) { 1186 return -1; 1187 } 1188 1189 @Override 1190 public Object getWindow(Object info) { 1191 return null; 1192 } 1193 1194 @Override 1195 public boolean isDismissable(Object info) { 1196 return false; 1197 } 1198 1199 @Override 1200 public void setDismissable(Object info, boolean dismissable) { 1201 } 1202 1203 @Override 1204 public boolean isEditable(Object info) { 1205 return false; 1206 } 1207 1208 @Override 1209 public void setEditable(Object info, boolean editable) { 1210 } 1211 1212 @Override 1213 public boolean isMultiLine(Object info) { 1214 return false; 1215 } 1216 1217 @Override 1218 public void setMultiLine(Object info, boolean multiLine) { 1219 } 1220 1221 @Override 1222 public boolean refresh(Object info) { 1223 return false; 1224 } 1225 1226 @Override 1227 public CharSequence getRoleDescription(Object info) { 1228 return null; 1229 } 1230 1231 @Override 1232 public void setRoleDescription(Object info, CharSequence roleDescription) { 1233 } 1234 1235 @Override 1236 public int getDrawingOrder(Object info) { 1237 return 0; 1238 } 1239 1240 @Override 1241 public void setDrawingOrder(Object info, int drawingOrderInParent) { 1242 } 1243 1244 @Override 1245 public boolean isImportantForAccessibility(Object info) { 1246 return true; 1247 } 1248 1249 @Override 1250 public void setImportantForAccessibility(Object info, boolean importantForAccessibility) { 1251 } 1252 } 1253 1254 static class AccessibilityNodeInfoIcsImpl extends AccessibilityNodeInfoStubImpl { 1255 @Override 1256 public Object obtain() { 1257 return AccessibilityNodeInfoCompatIcs.obtain(); 1258 } 1259 1260 @Override 1261 public Object obtain(View source) { 1262 return AccessibilityNodeInfoCompatIcs.obtain(source); 1263 } 1264 1265 @Override 1266 public Object obtain(Object info) { 1267 return AccessibilityNodeInfoCompatIcs.obtain(info); 1268 } 1269 1270 @Override 1271 public void addAction(Object info, int action) { 1272 AccessibilityNodeInfoCompatIcs.addAction(info, action); 1273 } 1274 1275 @Override 1276 public void addChild(Object info, View child) { 1277 AccessibilityNodeInfoCompatIcs.addChild(info, child); 1278 } 1279 1280 @Override 1281 public List<Object> findAccessibilityNodeInfosByText(Object info, String text) { 1282 return AccessibilityNodeInfoCompatIcs.findAccessibilityNodeInfosByText(info, text); 1283 } 1284 1285 @Override 1286 public int getActions(Object info) { 1287 return AccessibilityNodeInfoCompatIcs.getActions(info); 1288 } 1289 1290 @Override 1291 public void getBoundsInParent(Object info, Rect outBounds) { 1292 AccessibilityNodeInfoCompatIcs.getBoundsInParent(info, outBounds); 1293 } 1294 1295 @Override 1296 public void getBoundsInScreen(Object info, Rect outBounds) { 1297 AccessibilityNodeInfoCompatIcs.getBoundsInScreen(info, outBounds); 1298 } 1299 1300 @Override 1301 public Object getChild(Object info, int index) { 1302 return AccessibilityNodeInfoCompatIcs.getChild(info, index); 1303 } 1304 1305 @Override 1306 public int getChildCount(Object info) { 1307 return AccessibilityNodeInfoCompatIcs.getChildCount(info); 1308 } 1309 1310 @Override 1311 public CharSequence getClassName(Object info) { 1312 return AccessibilityNodeInfoCompatIcs.getClassName(info); 1313 } 1314 1315 @Override 1316 public CharSequence getContentDescription(Object info) { 1317 return AccessibilityNodeInfoCompatIcs.getContentDescription(info); 1318 } 1319 1320 @Override 1321 public CharSequence getPackageName(Object info) { 1322 return AccessibilityNodeInfoCompatIcs.getPackageName(info); 1323 } 1324 1325 @Override 1326 public Object getParent(Object info) { 1327 return AccessibilityNodeInfoCompatIcs.getParent(info); 1328 } 1329 1330 @Override 1331 public CharSequence getText(Object info) { 1332 return AccessibilityNodeInfoCompatIcs.getText(info); 1333 } 1334 1335 @Override 1336 public int getWindowId(Object info) { 1337 return AccessibilityNodeInfoCompatIcs.getWindowId(info); 1338 } 1339 1340 @Override 1341 public boolean isCheckable(Object info) { 1342 return AccessibilityNodeInfoCompatIcs.isCheckable(info); 1343 } 1344 1345 @Override 1346 public boolean isChecked(Object info) { 1347 return AccessibilityNodeInfoCompatIcs.isChecked(info); 1348 } 1349 1350 @Override 1351 public boolean isClickable(Object info) { 1352 return AccessibilityNodeInfoCompatIcs.isClickable(info); 1353 } 1354 1355 @Override 1356 public boolean isEnabled(Object info) { 1357 return AccessibilityNodeInfoCompatIcs.isEnabled(info); 1358 } 1359 1360 @Override 1361 public boolean isFocusable(Object info) { 1362 return AccessibilityNodeInfoCompatIcs.isFocusable(info); 1363 } 1364 1365 @Override 1366 public boolean isFocused(Object info) { 1367 return AccessibilityNodeInfoCompatIcs.isFocused(info); 1368 } 1369 1370 @Override 1371 public boolean isLongClickable(Object info) { 1372 return AccessibilityNodeInfoCompatIcs.isLongClickable(info); 1373 } 1374 1375 @Override 1376 public boolean isPassword(Object info) { 1377 return AccessibilityNodeInfoCompatIcs.isPassword(info); 1378 } 1379 1380 @Override 1381 public boolean isScrollable(Object info) { 1382 return AccessibilityNodeInfoCompatIcs.isScrollable(info); 1383 } 1384 1385 @Override 1386 public boolean isSelected(Object info) { 1387 return AccessibilityNodeInfoCompatIcs.isSelected(info); 1388 } 1389 1390 @Override 1391 public boolean performAction(Object info, int action) { 1392 return AccessibilityNodeInfoCompatIcs.performAction(info, action); 1393 } 1394 1395 @Override 1396 public void setBoundsInParent(Object info, Rect bounds) { 1397 AccessibilityNodeInfoCompatIcs.setBoundsInParent(info, bounds); 1398 } 1399 1400 @Override 1401 public void setBoundsInScreen(Object info, Rect bounds) { 1402 AccessibilityNodeInfoCompatIcs.setBoundsInScreen(info, bounds); 1403 } 1404 1405 @Override 1406 public void setCheckable(Object info, boolean checkable) { 1407 AccessibilityNodeInfoCompatIcs.setCheckable(info, checkable); 1408 } 1409 1410 @Override 1411 public void setChecked(Object info, boolean checked) { 1412 AccessibilityNodeInfoCompatIcs.setChecked(info, checked); 1413 } 1414 1415 @Override 1416 public void setClassName(Object info, CharSequence className) { 1417 AccessibilityNodeInfoCompatIcs.setClassName(info, className); 1418 } 1419 1420 @Override 1421 public void setClickable(Object info, boolean clickable) { 1422 AccessibilityNodeInfoCompatIcs.setClickable(info, clickable); 1423 } 1424 1425 @Override 1426 public void setContentDescription(Object info, CharSequence contentDescription) { 1427 AccessibilityNodeInfoCompatIcs.setContentDescription(info, contentDescription); 1428 } 1429 1430 @Override 1431 public void setEnabled(Object info, boolean enabled) { 1432 AccessibilityNodeInfoCompatIcs.setEnabled(info, enabled); 1433 } 1434 1435 @Override 1436 public void setFocusable(Object info, boolean focusable) { 1437 AccessibilityNodeInfoCompatIcs.setFocusable(info, focusable); 1438 } 1439 1440 @Override 1441 public void setFocused(Object info, boolean focused) { 1442 AccessibilityNodeInfoCompatIcs.setFocused(info, focused); 1443 } 1444 1445 @Override 1446 public void setLongClickable(Object info, boolean longClickable) { 1447 AccessibilityNodeInfoCompatIcs.setLongClickable(info, longClickable); 1448 } 1449 1450 @Override 1451 public void setPackageName(Object info, CharSequence packageName) { 1452 AccessibilityNodeInfoCompatIcs.setPackageName(info, packageName); 1453 } 1454 1455 @Override 1456 public void setParent(Object info, View parent) { 1457 AccessibilityNodeInfoCompatIcs.setParent(info, parent); 1458 } 1459 1460 @Override 1461 public void setPassword(Object info, boolean password) { 1462 AccessibilityNodeInfoCompatIcs.setPassword(info, password); 1463 } 1464 1465 @Override 1466 public void setScrollable(Object info, boolean scrollable) { 1467 AccessibilityNodeInfoCompatIcs.setScrollable(info, scrollable); 1468 } 1469 1470 @Override 1471 public void setSelected(Object info, boolean selected) { 1472 AccessibilityNodeInfoCompatIcs.setSelected(info, selected); 1473 } 1474 1475 @Override 1476 public void setSource(Object info, View source) { 1477 AccessibilityNodeInfoCompatIcs.setSource(info, source); 1478 } 1479 1480 @Override 1481 public void setText(Object info, CharSequence text) { 1482 AccessibilityNodeInfoCompatIcs.setText(info, text); 1483 } 1484 1485 @Override 1486 public void recycle(Object info) { 1487 AccessibilityNodeInfoCompatIcs.recycle(info); 1488 } 1489 } 1490 1491 static class AccessibilityNodeInfoJellybeanImpl extends AccessibilityNodeInfoIcsImpl { 1492 @Override 1493 public Object obtain(View root, int virtualDescendantId) { 1494 return AccessibilityNodeInfoCompatJellyBean.obtain(root, virtualDescendantId); 1495 } 1496 1497 @Override 1498 public Object findFocus(Object info, int focus) { 1499 return AccessibilityNodeInfoCompatJellyBean.findFocus(info, focus); 1500 } 1501 1502 @Override 1503 public Object focusSearch(Object info, int direction) { 1504 return AccessibilityNodeInfoCompatJellyBean.focusSearch(info, direction); 1505 } 1506 1507 @Override 1508 public void addChild(Object info, View child, int virtualDescendantId) { 1509 AccessibilityNodeInfoCompatJellyBean.addChild(info, child, virtualDescendantId); 1510 } 1511 1512 @Override 1513 public void setSource(Object info, View root, int virtualDescendantId) { 1514 AccessibilityNodeInfoCompatJellyBean.setSource(info, root, virtualDescendantId); 1515 } 1516 1517 @Override 1518 public boolean isVisibleToUser(Object info) { 1519 return AccessibilityNodeInfoCompatJellyBean.isVisibleToUser(info); 1520 } 1521 1522 @Override 1523 public void setVisibleToUser(Object info, boolean visibleToUser) { 1524 AccessibilityNodeInfoCompatJellyBean.setVisibleToUser(info, visibleToUser); 1525 } 1526 1527 @Override 1528 public boolean isAccessibilityFocused(Object info) { 1529 return AccessibilityNodeInfoCompatJellyBean.isAccessibilityFocused(info); 1530 } 1531 1532 @Override 1533 public void setAccessibilityFocused(Object info, boolean focused) { 1534 AccessibilityNodeInfoCompatJellyBean.setAccesibilityFocused(info, focused); 1535 } 1536 1537 @Override 1538 public boolean performAction(Object info, int action, Bundle arguments) { 1539 return AccessibilityNodeInfoCompatJellyBean.performAction(info, action, arguments); 1540 } 1541 1542 @Override 1543 public void setMovementGranularities(Object info, int granularities) { 1544 AccessibilityNodeInfoCompatJellyBean.setMovementGranularities(info, granularities); 1545 } 1546 1547 @Override 1548 public int getMovementGranularities(Object info) { 1549 return AccessibilityNodeInfoCompatJellyBean.getMovementGranularities(info); 1550 } 1551 1552 @Override 1553 public void setParent(Object info, View root, int virtualDescendantId) { 1554 AccessibilityNodeInfoCompatJellyBean.setParent(info, root, virtualDescendantId); 1555 } 1556 } 1557 1558 static class AccessibilityNodeInfoJellybeanMr1Impl extends AccessibilityNodeInfoJellybeanImpl { 1559 1560 @Override 1561 public void setLabelFor(Object info, View labeled) { 1562 AccessibilityNodeInfoCompatJellybeanMr1.setLabelFor(info, labeled); 1563 } 1564 1565 @Override 1566 public void setLabelFor(Object info, View root, int virtualDescendantId) { 1567 AccessibilityNodeInfoCompatJellybeanMr1.setLabelFor(info, root, virtualDescendantId); 1568 } 1569 1570 @Override 1571 public Object getLabelFor(Object info) { 1572 return AccessibilityNodeInfoCompatJellybeanMr1.getLabelFor(info); 1573 } 1574 1575 @Override 1576 public void setLabeledBy(Object info, View labeled) { 1577 AccessibilityNodeInfoCompatJellybeanMr1.setLabeledBy(info, labeled); 1578 } 1579 1580 @Override 1581 public void setLabeledBy(Object info, View root, int virtualDescendantId) { 1582 AccessibilityNodeInfoCompatJellybeanMr1.setLabeledBy(info, root, virtualDescendantId); 1583 } 1584 1585 @Override 1586 public Object getLabeledBy(Object info) { 1587 return AccessibilityNodeInfoCompatJellybeanMr1.getLabeledBy(info); 1588 } 1589 } 1590 1591 static class AccessibilityNodeInfoJellybeanMr2Impl extends 1592 AccessibilityNodeInfoJellybeanMr1Impl { 1593 1594 @Override 1595 public String getViewIdResourceName(Object info) { 1596 return AccessibilityNodeInfoCompatJellybeanMr2.getViewIdResourceName(info); 1597 } 1598 1599 @Override 1600 public void setViewIdResourceName(Object info, String viewId) { 1601 AccessibilityNodeInfoCompatJellybeanMr2.setViewIdResourceName(info, viewId); 1602 } 1603 1604 @Override 1605 public List<Object> findAccessibilityNodeInfosByViewId(Object info, String viewId) { 1606 return AccessibilityNodeInfoCompatJellybeanMr2.findAccessibilityNodeInfosByViewId(info, 1607 viewId); 1608 } 1609 1610 @Override 1611 public void setTextSelection(Object info, int start, int end) { 1612 AccessibilityNodeInfoCompatJellybeanMr2.setTextSelection(info, start, end); 1613 } 1614 1615 @Override 1616 public int getTextSelectionStart(Object info) { 1617 return AccessibilityNodeInfoCompatJellybeanMr2.getTextSelectionStart(info); 1618 } 1619 1620 @Override 1621 public int getTextSelectionEnd(Object info) { 1622 return AccessibilityNodeInfoCompatJellybeanMr2.getTextSelectionEnd(info); 1623 } 1624 1625 @Override 1626 public boolean isEditable(Object info) { 1627 return AccessibilityNodeInfoCompatJellybeanMr2.isEditable(info); 1628 } 1629 1630 @Override 1631 public void setEditable(Object info, boolean editable) { 1632 AccessibilityNodeInfoCompatJellybeanMr2.setEditable(info, editable); 1633 } 1634 1635 @Override 1636 public boolean refresh(Object info) { 1637 return AccessibilityNodeInfoCompatJellybeanMr2.refresh(info); 1638 } 1639 } 1640 1641 static class AccessibilityNodeInfoKitKatImpl extends AccessibilityNodeInfoJellybeanMr2Impl { 1642 @Override 1643 public int getLiveRegion(Object info) { 1644 return AccessibilityNodeInfoCompatKitKat.getLiveRegion(info); 1645 } 1646 1647 @Override 1648 public void setLiveRegion(Object info, int mode) { 1649 AccessibilityNodeInfoCompatKitKat.setLiveRegion(info, mode); 1650 } 1651 1652 @Override 1653 public Object getCollectionInfo(Object info) { 1654 return AccessibilityNodeInfoCompatKitKat.getCollectionInfo(info); 1655 } 1656 1657 @Override 1658 public void setCollectionInfo(Object info, Object collectionInfo) { 1659 AccessibilityNodeInfoCompatKitKat.setCollectionInfo(info, collectionInfo); 1660 } 1661 1662 @Override 1663 public Object obtainCollectionInfo(int rowCount, int columnCount, 1664 boolean hierarchical, int selectionMode) { 1665 return AccessibilityNodeInfoCompatKitKat.obtainCollectionInfo(rowCount, columnCount, 1666 hierarchical, selectionMode); 1667 } 1668 1669 @Override 1670 public Object obtainCollectionItemInfo(int rowIndex, int rowSpan, int columnIndex, 1671 int columnSpan, boolean heading, boolean selected) { 1672 return AccessibilityNodeInfoCompatKitKat 1673 .obtainCollectionItemInfo(rowIndex, rowSpan, columnIndex, columnSpan, heading); 1674 } 1675 1676 @Override 1677 public int getCollectionInfoColumnCount(Object info) { 1678 return AccessibilityNodeInfoCompatKitKat.CollectionInfo.getColumnCount(info); 1679 } 1680 1681 @Override 1682 public int getCollectionInfoRowCount(Object info) { 1683 return AccessibilityNodeInfoCompatKitKat.CollectionInfo.getRowCount(info); 1684 } 1685 1686 @Override 1687 public boolean isCollectionInfoHierarchical(Object info) { 1688 return AccessibilityNodeInfoCompatKitKat.CollectionInfo.isHierarchical(info); 1689 } 1690 1691 @Override 1692 public Object getCollectionItemInfo(Object info) { 1693 return AccessibilityNodeInfoCompatKitKat.getCollectionItemInfo(info); 1694 } 1695 1696 @Override 1697 public Object getRangeInfo(Object info) { 1698 return AccessibilityNodeInfoCompatKitKat.getRangeInfo(info); 1699 } 1700 1701 @Override 1702 public void setRangeInfo(Object info, Object rangeInfo) { 1703 AccessibilityNodeInfoCompatKitKat.setRangeInfo(info, rangeInfo); 1704 } 1705 1706 @Override 1707 public int getCollectionItemColumnIndex(Object info) { 1708 return AccessibilityNodeInfoCompatKitKat.CollectionItemInfo.getColumnIndex(info); 1709 } 1710 1711 @Override 1712 public int getCollectionItemColumnSpan(Object info) { 1713 return AccessibilityNodeInfoCompatKitKat.CollectionItemInfo.getColumnSpan(info); 1714 } 1715 1716 @Override 1717 public int getCollectionItemRowIndex(Object info) { 1718 return AccessibilityNodeInfoCompatKitKat.CollectionItemInfo.getRowIndex(info); 1719 } 1720 1721 @Override 1722 public int getCollectionItemRowSpan(Object info) { 1723 return AccessibilityNodeInfoCompatKitKat.CollectionItemInfo.getRowSpan(info); 1724 } 1725 1726 @Override 1727 public boolean isCollectionItemHeading(Object info) { 1728 return AccessibilityNodeInfoCompatKitKat.CollectionItemInfo.isHeading(info); 1729 } 1730 1731 @Override 1732 public void setCollectionItemInfo(Object info, Object collectionItemInfo) { 1733 AccessibilityNodeInfoCompatKitKat.setCollectionItemInfo(info, collectionItemInfo); 1734 } 1735 1736 @Override 1737 public void setContentInvalid(Object info, boolean contentInvalid) { 1738 AccessibilityNodeInfoCompatKitKat.setContentInvalid(info, contentInvalid); 1739 } 1740 1741 @Override 1742 public boolean isContentInvalid(Object info) { 1743 return AccessibilityNodeInfoCompatKitKat.isContentInvalid(info); 1744 } 1745 1746 @Override 1747 public boolean canOpenPopup(Object info) { 1748 return AccessibilityNodeInfoCompatKitKat.canOpenPopup(info); 1749 } 1750 1751 @Override 1752 public void setCanOpenPopup(Object info, boolean opensPopup) { 1753 AccessibilityNodeInfoCompatKitKat.setCanOpenPopup(info, opensPopup); 1754 } 1755 1756 @Override 1757 public Bundle getExtras(Object info) { 1758 return AccessibilityNodeInfoCompatKitKat.getExtras(info); 1759 } 1760 1761 @Override 1762 public int getInputType(Object info) { 1763 return AccessibilityNodeInfoCompatKitKat.getInputType(info); 1764 } 1765 1766 @Override 1767 public void setInputType(Object info, int inputType) { 1768 AccessibilityNodeInfoCompatKitKat.setInputType(info, inputType); 1769 } 1770 1771 @Override 1772 public boolean isDismissable(Object info) { 1773 return AccessibilityNodeInfoCompatKitKat.isDismissable(info); 1774 } 1775 1776 @Override 1777 public void setDismissable(Object info, boolean dismissable) { 1778 AccessibilityNodeInfoCompatKitKat.setDismissable(info, dismissable); 1779 } 1780 1781 @Override 1782 public boolean isMultiLine(Object info) { 1783 return AccessibilityNodeInfoCompatKitKat.isMultiLine(info); 1784 } 1785 1786 @Override 1787 public void setMultiLine(Object info, boolean multiLine) { 1788 AccessibilityNodeInfoCompatKitKat.setMultiLine(info, multiLine); 1789 } 1790 1791 @Override 1792 public CharSequence getRoleDescription(Object info) { 1793 return AccessibilityNodeInfoCompatKitKat.getRoleDescription(info); 1794 } 1795 1796 @Override 1797 public void setRoleDescription(Object info, CharSequence roleDescription) { 1798 AccessibilityNodeInfoCompatKitKat.setRoleDescription(info, roleDescription); 1799 } 1800 } 1801 1802 static class AccessibilityNodeInfoApi21Impl extends AccessibilityNodeInfoKitKatImpl { 1803 @Override 1804 public Object newAccessibilityAction(int actionId, CharSequence label) { 1805 return AccessibilityNodeInfoCompatApi21.newAccessibilityAction(actionId, label); 1806 } 1807 1808 @Override 1809 public List<Object> getActionList(Object info) { 1810 return AccessibilityNodeInfoCompatApi21.getActionList(info); 1811 } 1812 1813 @Override 1814 public Object obtainCollectionInfo(int rowCount, int columnCount, boolean hierarchical, 1815 int selectionMode) { 1816 return AccessibilityNodeInfoCompatApi21.obtainCollectionInfo(rowCount, columnCount, 1817 hierarchical, selectionMode); 1818 } 1819 1820 @Override 1821 public void addAction(Object info, Object action) { 1822 AccessibilityNodeInfoCompatApi21.addAction(info, action); 1823 } 1824 1825 @Override 1826 public boolean removeAction(Object info, Object action) { 1827 return AccessibilityNodeInfoCompatApi21.removeAction(info, action); 1828 } 1829 1830 @Override 1831 public int getAccessibilityActionId(Object action) { 1832 return AccessibilityNodeInfoCompatApi21.getAccessibilityActionId(action); 1833 } 1834 1835 @Override 1836 public CharSequence getAccessibilityActionLabel(Object action) { 1837 return AccessibilityNodeInfoCompatApi21.getAccessibilityActionLabel(action); 1838 } 1839 1840 @Override 1841 public Object obtainCollectionItemInfo(int rowIndex, int rowSpan, int columnIndex, 1842 int columnSpan, boolean heading, boolean selected) { 1843 return AccessibilityNodeInfoCompatApi21.obtainCollectionItemInfo(rowIndex, rowSpan, 1844 columnIndex, columnSpan, heading, selected); 1845 } 1846 1847 @Override 1848 public boolean isCollectionItemSelected(Object info) { 1849 return AccessibilityNodeInfoCompatApi21.CollectionItemInfo.isSelected(info); 1850 } 1851 1852 @Override 1853 public CharSequence getError(Object info) { 1854 return AccessibilityNodeInfoCompatApi21.getError(info); 1855 } 1856 1857 @Override 1858 public void setError(Object info, CharSequence error) { 1859 AccessibilityNodeInfoCompatApi21.setError(info, error); 1860 } 1861 1862 @Override 1863 public void setMaxTextLength(Object info, int max) { 1864 AccessibilityNodeInfoCompatApi21.setMaxTextLength(info, max); 1865 } 1866 1867 @Override 1868 public int getMaxTextLength(Object info) { 1869 return AccessibilityNodeInfoCompatApi21.getMaxTextLength(info); 1870 } 1871 1872 @Override 1873 public Object getWindow(Object info) { 1874 return AccessibilityNodeInfoCompatApi21.getWindow(info); 1875 } 1876 1877 @Override 1878 public boolean removeChild(Object info, View child) { 1879 return AccessibilityNodeInfoCompatApi21.removeChild(info, child); 1880 } 1881 1882 @Override 1883 public boolean removeChild(Object info, View root, int virtualDescendantId) { 1884 return AccessibilityNodeInfoCompatApi21.removeChild(info, root, virtualDescendantId); 1885 } 1886 } 1887 1888 static class AccessibilityNodeInfoApi22Impl extends AccessibilityNodeInfoApi21Impl { 1889 @Override 1890 public Object getTraversalBefore(Object info) { 1891 return AccessibilityNodeInfoCompatApi22.getTraversalBefore(info); 1892 } 1893 1894 @Override 1895 public void setTraversalBefore(Object info, View view) { 1896 AccessibilityNodeInfoCompatApi22.setTraversalBefore(info, view); 1897 } 1898 1899 @Override 1900 public void setTraversalBefore(Object info, View root, int virtualDescendantId) { 1901 AccessibilityNodeInfoCompatApi22.setTraversalBefore(info, root, virtualDescendantId); 1902 } 1903 1904 @Override 1905 public Object getTraversalAfter(Object info) { 1906 return AccessibilityNodeInfoCompatApi22.getTraversalAfter(info); 1907 } 1908 1909 @Override 1910 public void setTraversalAfter(Object info, View view) { 1911 AccessibilityNodeInfoCompatApi22.setTraversalAfter(info, view); 1912 } 1913 1914 @Override 1915 public void setTraversalAfter(Object info, View root, int virtualDescendantId) { 1916 AccessibilityNodeInfoCompatApi22.setTraversalAfter(info, root, virtualDescendantId); 1917 } 1918 } 1919 1920 static class AccessibilityNodeInfoApi24Impl extends AccessibilityNodeInfoApi22Impl { 1921 @Override 1922 public int getDrawingOrder(Object info) { 1923 return AccessibilityNodeInfoCompatApi24.getDrawingOrder(info); 1924 } 1925 1926 @Override 1927 public void setDrawingOrder(Object info, int drawingOrderInParent) { 1928 AccessibilityNodeInfoCompatApi24.setDrawingOrder(info, drawingOrderInParent); 1929 } 1930 1931 @Override 1932 public boolean isImportantForAccessibility(Object info) { 1933 return AccessibilityNodeInfoCompatApi24.isImportantForAccessibility(info); 1934 } 1935 1936 @Override 1937 public void setImportantForAccessibility(Object info, boolean importantForAccessibility) { 1938 AccessibilityNodeInfoCompatApi24.setImportantForAccessibility( 1939 info, importantForAccessibility); 1940 } 1941 1942 } 1943 1944 static { 1945 if (Build.VERSION.SDK_INT >= 24) { 1946 IMPL = new AccessibilityNodeInfoApi24Impl(); 1947 } else if (Build.VERSION.SDK_INT >= 22) { 1948 IMPL = new AccessibilityNodeInfoApi22Impl(); 1949 } else if (Build.VERSION.SDK_INT >= 21) { 1950 IMPL = new AccessibilityNodeInfoApi21Impl(); 1951 } else if (Build.VERSION.SDK_INT >= 19) { // KitKat 1952 IMPL = new AccessibilityNodeInfoKitKatImpl(); 1953 } else if (Build.VERSION.SDK_INT >= 18) { // JellyBean MR2 1954 IMPL = new AccessibilityNodeInfoJellybeanMr2Impl(); 1955 } else if (Build.VERSION.SDK_INT >= 17) { // JellyBean MR1 1956 IMPL = new AccessibilityNodeInfoJellybeanMr1Impl(); 1957 } else if (Build.VERSION.SDK_INT >= 16) { // JellyBean 1958 IMPL = new AccessibilityNodeInfoJellybeanImpl(); 1959 } else if (Build.VERSION.SDK_INT >= 14) { // ICS 1960 IMPL = new AccessibilityNodeInfoIcsImpl(); 1961 } else { 1962 IMPL = new AccessibilityNodeInfoStubImpl(); 1963 } 1964 } 1965 1966 private static final AccessibilityNodeInfoImpl IMPL; 1967 1968 private final Object mInfo; 1969 1970 // Actions introduced in IceCreamSandwich 1971 1972 /** 1973 * Action that focuses the node. 1974 */ 1975 public static final int ACTION_FOCUS = 0x00000001; 1976 1977 /** 1978 * Action that unfocuses the node. 1979 */ 1980 public static final int ACTION_CLEAR_FOCUS = 0x00000002; 1981 1982 /** 1983 * Action that selects the node. 1984 */ 1985 public static final int ACTION_SELECT = 0x00000004; 1986 1987 /** 1988 * Action that unselects the node. 1989 */ 1990 public static final int ACTION_CLEAR_SELECTION = 0x00000008; 1991 1992 /** 1993 * Action that clicks on the node info. 1994 */ 1995 public static final int ACTION_CLICK = 0x00000010; 1996 1997 /** 1998 * Action that long clicks on the node. 1999 */ 2000 public static final int ACTION_LONG_CLICK = 0x00000020; 2001 2002 // Actions introduced in JellyBean 2003 2004 /** 2005 * Action that gives accessibility focus to the node. 2006 */ 2007 public static final int ACTION_ACCESSIBILITY_FOCUS = 0x00000040; 2008 2009 /** 2010 * Action that clears accessibility focus of the node. 2011 */ 2012 public static final int ACTION_CLEAR_ACCESSIBILITY_FOCUS = 0x00000080; 2013 2014 /** 2015 * Action that requests to go to the next entity in this node's text 2016 * at a given movement granularity. For example, move to the next character, 2017 * word, etc. 2018 * <p> 2019 * <strong>Arguments:</strong> {@link #ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT}<, 2020 * {@link #ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN}<br> 2021 * <strong>Example:</strong> Move to the previous character and do not extend selection. 2022 * <code><pre><p> 2023 * Bundle arguments = new Bundle(); 2024 * arguments.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT, 2025 * AccessibilityNodeInfo.MOVEMENT_GRANULARITY_CHARACTER); 2026 * arguments.putBoolean(AccessibilityNodeInfo.ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN, 2027 * false); 2028 * info.performAction(AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY, arguments); 2029 * </code></pre></p> 2030 * </p> 2031 * 2032 * @see #ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT 2033 * @see #ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN 2034 * 2035 * @see #setMovementGranularities(int) 2036 * @see #getMovementGranularities() 2037 * 2038 * @see #MOVEMENT_GRANULARITY_CHARACTER 2039 * @see #MOVEMENT_GRANULARITY_WORD 2040 * @see #MOVEMENT_GRANULARITY_LINE 2041 * @see #MOVEMENT_GRANULARITY_PARAGRAPH 2042 * @see #MOVEMENT_GRANULARITY_PAGE 2043 */ 2044 public static final int ACTION_NEXT_AT_MOVEMENT_GRANULARITY = 0x00000100; 2045 2046 /** 2047 * Action that requests to go to the previous entity in this node's text 2048 * at a given movement granularity. For example, move to the next character, 2049 * word, etc. 2050 * <p> 2051 * <strong>Arguments:</strong> {@link #ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT}<, 2052 * {@link #ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN}<br> 2053 * <strong>Example:</strong> Move to the next character and do not extend selection. 2054 * <code><pre><p> 2055 * Bundle arguments = new Bundle(); 2056 * arguments.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT, 2057 * AccessibilityNodeInfo.MOVEMENT_GRANULARITY_CHARACTER); 2058 * arguments.putBoolean(AccessibilityNodeInfo.ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN, 2059 * false); 2060 * info.performAction(AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY, 2061 * arguments); 2062 * </code></pre></p> 2063 * </p> 2064 * 2065 * @see #ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT 2066 * @see #ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN 2067 * 2068 * @see #setMovementGranularities(int) 2069 * @see #getMovementGranularities() 2070 * 2071 * @see #MOVEMENT_GRANULARITY_CHARACTER 2072 * @see #MOVEMENT_GRANULARITY_WORD 2073 * @see #MOVEMENT_GRANULARITY_LINE 2074 * @see #MOVEMENT_GRANULARITY_PARAGRAPH 2075 * @see #MOVEMENT_GRANULARITY_PAGE 2076 */ 2077 public static final int ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY = 0x00000200; 2078 2079 /** 2080 * Action to move to the next HTML element of a given type. For example, move 2081 * to the BUTTON, INPUT, TABLE, etc. 2082 * <p> 2083 * <strong>Arguments:</strong> {@link #ACTION_ARGUMENT_HTML_ELEMENT_STRING}<br> 2084 * <strong>Example:</strong> 2085 * <code><pre><p> 2086 * Bundle arguments = new Bundle(); 2087 * arguments.putString(AccessibilityNodeInfo.ACTION_ARGUMENT_HTML_ELEMENT_STRING, "BUTTON"); 2088 * info.performAction(AccessibilityNodeInfo.ACTION_NEXT_HTML_ELEMENT, arguments); 2089 * </code></pre></p> 2090 * </p> 2091 */ 2092 public static final int ACTION_NEXT_HTML_ELEMENT = 0x00000400; 2093 2094 /** 2095 * Action to move to the previous HTML element of a given type. For example, move 2096 * to the BUTTON, INPUT, TABLE, etc. 2097 * <p> 2098 * <strong>Arguments:</strong> {@link #ACTION_ARGUMENT_HTML_ELEMENT_STRING}<br> 2099 * <strong>Example:</strong> 2100 * <code><pre><p> 2101 * Bundle arguments = new Bundle(); 2102 * arguments.putString(AccessibilityNodeInfo.ACTION_ARGUMENT_HTML_ELEMENT_STRING, "BUTTON"); 2103 * info.performAction(AccessibilityNodeInfo.ACTION_PREVIOUS_HTML_ELEMENT, arguments); 2104 * </code></pre></p> 2105 * </p> 2106 */ 2107 public static final int ACTION_PREVIOUS_HTML_ELEMENT = 0x00000800; 2108 2109 /** 2110 * Action to scroll the node content forward. 2111 */ 2112 public static final int ACTION_SCROLL_FORWARD = 0x00001000; 2113 2114 /** 2115 * Action to scroll the node content backward. 2116 */ 2117 public static final int ACTION_SCROLL_BACKWARD = 0x00002000; 2118 2119 // Actions introduced in JellyBeanMr2 2120 2121 /** 2122 * Action to copy the current selection to the clipboard. 2123 */ 2124 public static final int ACTION_COPY = 0x00004000; 2125 2126 /** 2127 * Action to paste the current clipboard content. 2128 */ 2129 public static final int ACTION_PASTE = 0x00008000; 2130 2131 /** 2132 * Action to cut the current selection and place it to the clipboard. 2133 */ 2134 public static final int ACTION_CUT = 0x00010000; 2135 2136 /** 2137 * Action to set the selection. Performing this action with no arguments 2138 * clears the selection. 2139 * <p> 2140 * <strong>Arguments:</strong> {@link #ACTION_ARGUMENT_SELECTION_START_INT}, 2141 * {@link #ACTION_ARGUMENT_SELECTION_END_INT}<br> 2142 * <strong>Example:</strong> 2143 * <code><pre><p> 2144 * Bundle arguments = new Bundle(); 2145 * arguments.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_SELECTION_START_INT, 1); 2146 * arguments.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_SELECTION_END_INT, 2); 2147 * info.performAction(AccessibilityNodeInfo.ACTION_SET_SELECTION, arguments); 2148 * </code></pre></p> 2149 * </p> 2150 * 2151 * @see #ACTION_ARGUMENT_SELECTION_START_INT 2152 * @see #ACTION_ARGUMENT_SELECTION_END_INT 2153 */ 2154 public static final int ACTION_SET_SELECTION = 0x00020000; 2155 2156 /** 2157 * Action to expand an expandable node. 2158 */ 2159 public static final int ACTION_EXPAND = 0x00040000; 2160 2161 /** 2162 * Action to collapse an expandable node. 2163 */ 2164 public static final int ACTION_COLLAPSE = 0x00080000; 2165 2166 /** 2167 * Action to dismiss a dismissable node. 2168 */ 2169 public static final int ACTION_DISMISS = 0x00100000; 2170 2171 /** 2172 * Action that sets the text of the node. Performing the action without argument, using <code> 2173 * null</code> or empty {@link CharSequence} will clear the text. This action will also put the 2174 * cursor at the end of text. 2175 * <p> 2176 * <strong>Arguments:</strong> {@link #ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE}<br> 2177 * <strong>Example:</strong> 2178 * <code><pre><p> 2179 * Bundle arguments = new Bundle(); 2180 * arguments.putCharSequence(AccessibilityNodeInfo.ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE, 2181 * "android"); 2182 * info.performAction(AccessibilityNodeInfo.ACTION_SET_TEXT, arguments); 2183 * </code></pre></p> 2184 */ 2185 public static final int ACTION_SET_TEXT = 0x00200000; 2186 2187 // Action arguments 2188 2189 /** 2190 * Argument for which movement granularity to be used when traversing the node text. 2191 * <p> 2192 * <strong>Type:</strong> int<br> 2193 * <strong>Actions:</strong> {@link #ACTION_NEXT_AT_MOVEMENT_GRANULARITY}, 2194 * {@link #ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY} 2195 * </p> 2196 */ 2197 public static final String ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT = 2198 "ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT"; 2199 2200 /** 2201 * Argument for which HTML element to get moving to the next/previous HTML element. 2202 * <p> 2203 * <strong>Type:</strong> String<br> 2204 * <strong>Actions:</strong> {@link #ACTION_NEXT_HTML_ELEMENT}, 2205 * {@link #ACTION_PREVIOUS_HTML_ELEMENT} 2206 * </p> 2207 */ 2208 public static final String ACTION_ARGUMENT_HTML_ELEMENT_STRING = 2209 "ACTION_ARGUMENT_HTML_ELEMENT_STRING"; 2210 2211 /** 2212 * Argument for whether when moving at granularity to extend the selection 2213 * or to move it otherwise. 2214 * <p> 2215 * <strong>Type:</strong> boolean<br> 2216 * <strong>Actions:</strong> {@link #ACTION_NEXT_AT_MOVEMENT_GRANULARITY}, 2217 * {@link #ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY} 2218 * </p> 2219 * 2220 * @see #ACTION_NEXT_AT_MOVEMENT_GRANULARITY 2221 * @see #ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY 2222 */ 2223 public static final String ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN = 2224 "ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN"; 2225 2226 /** 2227 * Argument for specifying the selection start. 2228 * <p> 2229 * <strong>Type:</strong> int<br> 2230 * <strong>Actions:</strong> {@link #ACTION_SET_SELECTION} 2231 * </p> 2232 * 2233 * @see #ACTION_SET_SELECTION 2234 */ 2235 public static final String ACTION_ARGUMENT_SELECTION_START_INT = 2236 "ACTION_ARGUMENT_SELECTION_START_INT"; 2237 2238 /** 2239 * Argument for specifying the selection end. 2240 * <p> 2241 * <strong>Type:</strong> int<br> 2242 * <strong>Actions:</strong> {@link #ACTION_SET_SELECTION} 2243 * </p> 2244 * 2245 * @see #ACTION_SET_SELECTION 2246 */ 2247 public static final String ACTION_ARGUMENT_SELECTION_END_INT = 2248 "ACTION_ARGUMENT_SELECTION_END_INT"; 2249 2250 /** 2251 * Argument for specifying the text content to set 2252 * <p> 2253 * <strong>Type:</strong> CharSequence<br> 2254 * <strong>Actions:</strong> {@link #ACTION_SET_TEXT} 2255 * </p> 2256 * 2257 * @see #ACTION_SET_TEXT 2258 */ 2259 public static final String ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE = 2260 "ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE"; 2261 2262 // Focus types 2263 2264 /** 2265 * The input focus. 2266 */ 2267 public static final int FOCUS_INPUT = 1; 2268 2269 /** 2270 * The accessibility focus. 2271 */ 2272 public static final int FOCUS_ACCESSIBILITY = 2; 2273 2274 // Movement granularities 2275 2276 /** 2277 * Movement granularity bit for traversing the text of a node by character. 2278 */ 2279 public static final int MOVEMENT_GRANULARITY_CHARACTER = 0x00000001; 2280 2281 /** 2282 * Movement granularity bit for traversing the text of a node by word. 2283 */ 2284 public static final int MOVEMENT_GRANULARITY_WORD = 0x00000002; 2285 2286 /** 2287 * Movement granularity bit for traversing the text of a node by line. 2288 */ 2289 public static final int MOVEMENT_GRANULARITY_LINE = 0x00000004; 2290 2291 /** 2292 * Movement granularity bit for traversing the text of a node by paragraph. 2293 */ 2294 public static final int MOVEMENT_GRANULARITY_PARAGRAPH = 0x00000008; 2295 2296 /** 2297 * Movement granularity bit for traversing the text of a node by page. 2298 */ 2299 public static final int MOVEMENT_GRANULARITY_PAGE = 0x00000010; 2300 2301 /** 2302 * Creates a wrapper for info implementation. 2303 * 2304 * @param object The info to wrap. 2305 * @return A wrapper for if the object is not null, null otherwise. 2306 */ 2307 static AccessibilityNodeInfoCompat wrapNonNullInstance(Object object) { 2308 if (object != null) { 2309 return new AccessibilityNodeInfoCompat(object); 2310 } 2311 return null; 2312 } 2313 2314 /** 2315 * Creates a new instance wrapping an 2316 * {@link android.view.accessibility.AccessibilityNodeInfo}. 2317 * 2318 * @param info The info. 2319 */ 2320 public AccessibilityNodeInfoCompat(Object info) { 2321 mInfo = info; 2322 } 2323 2324 /** 2325 * @return The wrapped {@link android.view.accessibility.AccessibilityNodeInfo}. 2326 */ 2327 public Object getInfo() { 2328 return mInfo; 2329 } 2330 2331 /** 2332 * Returns a cached instance if such is available otherwise a new one and 2333 * sets the source. 2334 * 2335 * @return An instance. 2336 * @see #setSource(View) 2337 */ 2338 public static AccessibilityNodeInfoCompat obtain(View source) { 2339 return AccessibilityNodeInfoCompat.wrapNonNullInstance(IMPL.obtain(source)); 2340 } 2341 2342 /** 2343 * Returns a cached instance if such is available otherwise a new one 2344 * and sets the source. 2345 * 2346 * @param root The root of the virtual subtree. 2347 * @param virtualDescendantId The id of the virtual descendant. 2348 * @return An instance. 2349 * 2350 * @see #setSource(View, int) 2351 */ 2352 public static AccessibilityNodeInfoCompat obtain(View root, int virtualDescendantId) { 2353 return AccessibilityNodeInfoCompat.wrapNonNullInstance( 2354 IMPL.obtain(root, virtualDescendantId)); 2355 } 2356 2357 /** 2358 * Returns a cached instance if such is available otherwise a new one. 2359 * 2360 * @return An instance. 2361 */ 2362 public static AccessibilityNodeInfoCompat obtain() { 2363 return AccessibilityNodeInfoCompat.wrapNonNullInstance(IMPL.obtain()); 2364 } 2365 2366 /** 2367 * Returns a cached instance if such is available or a new one is create. 2368 * The returned instance is initialized from the given <code>info</code>. 2369 * 2370 * @param info The other info. 2371 * @return An instance. 2372 */ 2373 public static AccessibilityNodeInfoCompat obtain(AccessibilityNodeInfoCompat info) { 2374 return AccessibilityNodeInfoCompat.wrapNonNullInstance(IMPL.obtain(info.mInfo)); 2375 } 2376 2377 /** 2378 * Sets the source. 2379 * 2380 * @param source The info source. 2381 */ 2382 public void setSource(View source) { 2383 IMPL.setSource(mInfo, source); 2384 } 2385 2386 /** 2387 * Sets the source to be a virtual descendant of the given <code>root</code>. 2388 * If <code>virtualDescendantId</code> is {@link View#NO_ID} the root 2389 * is set as the source. 2390 * <p> 2391 * A virtual descendant is an imaginary View that is reported as a part of the view 2392 * hierarchy for accessibility purposes. This enables custom views that draw complex 2393 * content to report themselves as a tree of virtual views, thus conveying their 2394 * logical structure. 2395 * </p> 2396 * <p> 2397 * <strong>Note:</strong> Cannot be called from an 2398 * {@link android.accessibilityservice.AccessibilityService}. 2399 * This class is made immutable before being delivered to an AccessibilityService. 2400 * </p> 2401 * 2402 * @param root The root of the virtual subtree. 2403 * @param virtualDescendantId The id of the virtual descendant. 2404 */ 2405 public void setSource(View root, int virtualDescendantId) { 2406 IMPL.setSource(mInfo, root, virtualDescendantId); 2407 } 2408 2409 /** 2410 * Find the view that has the specified focus type. The search starts from 2411 * the view represented by this node info. 2412 * 2413 * @param focus The focus to find. One of {@link #FOCUS_INPUT} or 2414 * {@link #FOCUS_ACCESSIBILITY}. 2415 * @return The node info of the focused view or null. 2416 * 2417 * @see #FOCUS_INPUT 2418 * @see #FOCUS_ACCESSIBILITY 2419 */ 2420 public AccessibilityNodeInfoCompat findFocus(int focus) { 2421 return AccessibilityNodeInfoCompat.wrapNonNullInstance(IMPL.findFocus(mInfo, focus)); 2422 } 2423 2424 /** 2425 * Searches for the nearest view in the specified direction that can take 2426 * input focus. 2427 * 2428 * @param direction The direction. Can be one of: 2429 * {@link View#FOCUS_DOWN}, 2430 * {@link View#FOCUS_UP}, 2431 * {@link View#FOCUS_LEFT}, 2432 * {@link View#FOCUS_RIGHT}, 2433 * {@link View#FOCUS_FORWARD}, 2434 * {@link View#FOCUS_BACKWARD}. 2435 * 2436 * @return The node info for the view that can take accessibility focus. 2437 */ 2438 public AccessibilityNodeInfoCompat focusSearch(int direction) { 2439 return AccessibilityNodeInfoCompat.wrapNonNullInstance(IMPL.focusSearch(mInfo, direction)); 2440 } 2441 2442 /** 2443 * Gets the id of the window from which the info comes from. 2444 * 2445 * @return The window id. 2446 */ 2447 public int getWindowId() { 2448 return IMPL.getWindowId(mInfo); 2449 } 2450 2451 /** 2452 * Gets the number of children. 2453 * 2454 * @return The child count. 2455 */ 2456 public int getChildCount() { 2457 return IMPL.getChildCount(mInfo); 2458 } 2459 2460 /** 2461 * Get the child at given index. 2462 * <p> 2463 * <strong>Note:</strong> It is a client responsibility to recycle the 2464 * received info by calling {@link AccessibilityNodeInfoCompat#recycle()} to 2465 * avoid creating of multiple instances. 2466 * </p> 2467 * 2468 * @param index The child index. 2469 * @return The child node. 2470 * @throws IllegalStateException If called outside of an 2471 * AccessibilityService. 2472 */ 2473 public AccessibilityNodeInfoCompat getChild(int index) { 2474 return AccessibilityNodeInfoCompat.wrapNonNullInstance(IMPL.getChild(mInfo, index)); 2475 } 2476 2477 /** 2478 * Adds a child. 2479 * <p> 2480 * <strong>Note:</strong> Cannot be called from an 2481 * {@link android.accessibilityservice.AccessibilityService}. This class is 2482 * made immutable before being delivered to an AccessibilityService. 2483 * </p> 2484 * 2485 * @param child The child. 2486 * @throws IllegalStateException If called from an AccessibilityService. 2487 */ 2488 public void addChild(View child) { 2489 IMPL.addChild(mInfo, child); 2490 } 2491 2492 /** 2493 * Adds a virtual child which is a descendant of the given <code>root</code>. 2494 * If <code>virtualDescendantId</code> is {@link View#NO_ID} the root 2495 * is added as a child. 2496 * <p> 2497 * A virtual descendant is an imaginary View that is reported as a part of the view 2498 * hierarchy for accessibility purposes. This enables custom views that draw complex 2499 * content to report them selves as a tree of virtual views, thus conveying their 2500 * logical structure. 2501 * </p> 2502 * 2503 * @param root The root of the virtual subtree. 2504 * @param virtualDescendantId The id of the virtual child. 2505 */ 2506 public void addChild(View root, int virtualDescendantId) { 2507 IMPL.addChild(mInfo, root, virtualDescendantId); 2508 } 2509 2510 /** 2511 * Removes a child. If the child was not previously added to the node, 2512 * calling this method has no effect. 2513 * <p> 2514 * <strong>Note:</strong> Cannot be called from an 2515 * {@link android.accessibilityservice.AccessibilityService}. 2516 * This class is made immutable before being delivered to an AccessibilityService. 2517 * </p> 2518 * 2519 * @param child The child. 2520 * @return true if the child was present 2521 * 2522 * @throws IllegalStateException If called from an AccessibilityService. 2523 */ 2524 public boolean removeChild(View child) { 2525 return IMPL.removeChild(mInfo, child); 2526 } 2527 2528 /** 2529 * Removes a virtual child which is a descendant of the given 2530 * <code>root</code>. If the child was not previously added to the node, 2531 * calling this method has no effect. 2532 * 2533 * @param root The root of the virtual subtree. 2534 * @param virtualDescendantId The id of the virtual child. 2535 * @return true if the child was present 2536 * @see #addChild(View, int) 2537 */ 2538 public boolean removeChild(View root, int virtualDescendantId) { 2539 return IMPL.removeChild(mInfo, root, virtualDescendantId); 2540 } 2541 2542 /** 2543 * Gets the actions that can be performed on the node. 2544 * 2545 * @return The bit mask of with actions. 2546 * @see android.view.accessibility.AccessibilityNodeInfo#ACTION_FOCUS 2547 * @see android.view.accessibility.AccessibilityNodeInfo#ACTION_CLEAR_FOCUS 2548 * @see android.view.accessibility.AccessibilityNodeInfo#ACTION_SELECT 2549 * @see android.view.accessibility.AccessibilityNodeInfo#ACTION_CLEAR_SELECTION 2550 */ 2551 public int getActions() { 2552 return IMPL.getActions(mInfo); 2553 } 2554 2555 /** 2556 * Adds an action that can be performed on the node. 2557 * <p> 2558 * <strong>Note:</strong> Cannot be called from an 2559 * {@link android.accessibilityservice.AccessibilityService}. This class is 2560 * made immutable before being delivered to an AccessibilityService. 2561 * </p> 2562 * 2563 * @param action The action. 2564 * @throws IllegalStateException If called from an AccessibilityService. 2565 */ 2566 public void addAction(int action) { 2567 IMPL.addAction(mInfo, action); 2568 } 2569 2570 /** 2571 * Adds an action that can be performed on the node. 2572 * <p> 2573 * <strong>Note:</strong> Cannot be called from an 2574 * {@link android.accessibilityservice.AccessibilityService}. This class is 2575 * made immutable before being delivered to an AccessibilityService. 2576 * </p> 2577 * 2578 * @param action The action. 2579 * @throws IllegalStateException If called from an AccessibilityService. 2580 */ 2581 public void addAction(AccessibilityActionCompat action) { 2582 IMPL.addAction(mInfo, action.mAction); 2583 } 2584 2585 /** 2586 * Removes an action that can be performed on the node. If the action was 2587 * not already added to the node, calling this method has no effect. 2588 * <p> 2589 * <strong>Note:</strong> Cannot be called from an 2590 * {@link android.accessibilityservice.AccessibilityService}. 2591 * This class is made immutable before being delivered to an AccessibilityService. 2592 * </p> 2593 * 2594 * @param action The action to be removed. 2595 * @return The action removed from the list of actions. 2596 * 2597 * @throws IllegalStateException If called from an AccessibilityService. 2598 */ 2599 public boolean removeAction(AccessibilityActionCompat action) { 2600 return IMPL.removeAction(mInfo, action.mAction); 2601 } 2602 2603 /** 2604 * Performs an action on the node. 2605 * <p> 2606 * <strong>Note:</strong> An action can be performed only if the request is 2607 * made from an {@link android.accessibilityservice.AccessibilityService}. 2608 * </p> 2609 * 2610 * @param action The action to perform. 2611 * @return True if the action was performed. 2612 * @throws IllegalStateException If called outside of an 2613 * AccessibilityService. 2614 */ 2615 public boolean performAction(int action) { 2616 return IMPL.performAction(mInfo, action); 2617 } 2618 2619 /** 2620 * Performs an action on the node. 2621 * <p> 2622 * <strong>Note:</strong> An action can be performed only if the request is made 2623 * from an {@link android.accessibilityservice.AccessibilityService}. 2624 * </p> 2625 * 2626 * @param action The action to perform. 2627 * @param arguments A bundle with additional arguments. 2628 * @return True if the action was performed. 2629 * 2630 * @throws IllegalStateException If called outside of an AccessibilityService. 2631 */ 2632 public boolean performAction(int action, Bundle arguments) { 2633 return IMPL.performAction(mInfo, action, arguments); 2634 } 2635 2636 /** 2637 * Sets the movement granularities for traversing the text of this node. 2638 * <p> 2639 * <strong>Note:</strong> Cannot be called from an 2640 * {@link android.accessibilityservice.AccessibilityService}. 2641 * This class is made immutable before being delivered to an AccessibilityService. 2642 * </p> 2643 * 2644 * @param granularities The bit mask with granularities. 2645 * 2646 * @throws IllegalStateException If called from an AccessibilityService. 2647 */ 2648 public void setMovementGranularities(int granularities) { 2649 IMPL.setMovementGranularities(mInfo, granularities); 2650 } 2651 2652 /** 2653 * Gets the movement granularities for traversing the text of this node. 2654 * 2655 * @return The bit mask with granularities. 2656 */ 2657 public int getMovementGranularities() { 2658 return IMPL.getMovementGranularities(mInfo); 2659 } 2660 2661 /** 2662 * Finds {@link android.view.accessibility.AccessibilityNodeInfo}s by text. The match 2663 * is case insensitive containment. The search is relative to this info i.e. this 2664 * info is the root of the traversed tree. 2665 * <p> 2666 * <strong>Note:</strong> It is a client responsibility to recycle the 2667 * received info by calling {@link android.view.accessibility.AccessibilityNodeInfo#recycle()} 2668 * to avoid creating of multiple instances. 2669 * </p> 2670 * 2671 * @param text The searched text. 2672 * @return A list of node info. 2673 */ 2674 public List<AccessibilityNodeInfoCompat> findAccessibilityNodeInfosByText(String text) { 2675 List<AccessibilityNodeInfoCompat> result = new ArrayList<AccessibilityNodeInfoCompat>(); 2676 List<Object> infos = IMPL.findAccessibilityNodeInfosByText(mInfo, text); 2677 final int infoCount = infos.size(); 2678 for (int i = 0; i < infoCount; i++) { 2679 Object info = infos.get(i); 2680 result.add(new AccessibilityNodeInfoCompat(info)); 2681 } 2682 return result; 2683 } 2684 2685 /** 2686 * Gets the parent. 2687 * <p> 2688 * <strong>Note:</strong> It is a client responsibility to recycle the 2689 * received info by calling {@link android.view.accessibility.AccessibilityNodeInfo#recycle()} 2690 * to avoid creating of multiple instances. 2691 * </p> 2692 * 2693 * @return The parent. 2694 */ 2695 public AccessibilityNodeInfoCompat getParent() { 2696 return AccessibilityNodeInfoCompat.wrapNonNullInstance(IMPL.getParent(mInfo)); 2697 } 2698 2699 /** 2700 * Sets the parent. 2701 * <p> 2702 * <strong>Note:</strong> Cannot be called from an 2703 * {@link android.accessibilityservice.AccessibilityService}. This class is 2704 * made immutable before being delivered to an AccessibilityService. 2705 * </p> 2706 * 2707 * @param parent The parent. 2708 * @throws IllegalStateException If called from an AccessibilityService. 2709 */ 2710 public void setParent(View parent) { 2711 IMPL.setParent(mInfo, parent); 2712 } 2713 2714 /** 2715 * Sets the parent to be a virtual descendant of the given <code>root</code>. 2716 * If <code>virtualDescendantId</code> equals to {@link View#NO_ID} the root 2717 * is set as the parent. 2718 * <p> 2719 * A virtual descendant is an imaginary View that is reported as a part of the view 2720 * hierarchy for accessibility purposes. This enables custom views that draw complex 2721 * content to report them selves as a tree of virtual views, thus conveying their 2722 * logical structure. 2723 * </p> 2724 * <p> 2725 * <strong>Note:</strong> Cannot be called from an 2726 * {@link android.accessibilityservice.AccessibilityService}. 2727 * This class is made immutable before being delivered to an AccessibilityService. 2728 * </p> 2729 * 2730 * @param root The root of the virtual subtree. 2731 * @param virtualDescendantId The id of the virtual descendant. 2732 */ 2733 public void setParent(View root, int virtualDescendantId) { 2734 IMPL.setParent(mInfo, root, virtualDescendantId); 2735 } 2736 2737 /** 2738 * Gets the node bounds in parent coordinates. 2739 * 2740 * @param outBounds The output node bounds. 2741 */ 2742 public void getBoundsInParent(Rect outBounds) { 2743 IMPL.getBoundsInParent(mInfo, outBounds); 2744 } 2745 2746 /** 2747 * Sets the node bounds in parent coordinates. 2748 * <p> 2749 * <strong>Note:</strong> Cannot be called from an 2750 * {@link android.accessibilityservice.AccessibilityService}. This class is 2751 * made immutable before being delivered to an AccessibilityService. 2752 * </p> 2753 * 2754 * @param bounds The node bounds. 2755 *@throws IllegalStateException If called from an AccessibilityService. 2756 */ 2757 public void setBoundsInParent(Rect bounds) { 2758 IMPL.setBoundsInParent(mInfo, bounds); 2759 } 2760 2761 /** 2762 * Gets the node bounds in screen coordinates. 2763 * 2764 * @param outBounds The output node bounds. 2765 */ 2766 public void getBoundsInScreen(Rect outBounds) { 2767 IMPL.getBoundsInScreen(mInfo, outBounds); 2768 } 2769 2770 /** 2771 * Sets the node bounds in screen coordinates. 2772 * <p> 2773 * <strong>Note:</strong> Cannot be called from an 2774 * {@link android.accessibilityservice.AccessibilityService}. This class is 2775 * made immutable before being delivered to an AccessibilityService. 2776 * </p> 2777 * 2778 * @param bounds The node bounds. 2779 * @throws IllegalStateException If called from an AccessibilityService. 2780 */ 2781 public void setBoundsInScreen(Rect bounds) { 2782 IMPL.setBoundsInScreen(mInfo, bounds); 2783 } 2784 2785 /** 2786 * Gets whether this node is checkable. 2787 * 2788 * @return True if the node is checkable. 2789 */ 2790 public boolean isCheckable() { 2791 return IMPL.isCheckable(mInfo); 2792 } 2793 2794 /** 2795 * Sets whether this node is checkable. 2796 * <p> 2797 * <strong>Note:</strong> Cannot be called from an 2798 * {@link android.accessibilityservice.AccessibilityService}. This class is 2799 * made immutable before being delivered to an AccessibilityService. 2800 * </p> 2801 * 2802 * @param checkable True if the node is checkable. 2803 * @throws IllegalStateException If called from an AccessibilityService. 2804 */ 2805 public void setCheckable(boolean checkable) { 2806 IMPL.setCheckable(mInfo, checkable); 2807 } 2808 2809 /** 2810 * Gets whether this node is checked. 2811 * 2812 * @return True if the node is checked. 2813 */ 2814 public boolean isChecked() { 2815 return IMPL.isChecked(mInfo); 2816 } 2817 2818 /** 2819 * Sets whether this node is checked. 2820 * <p> 2821 * <strong>Note:</strong> Cannot be called from an 2822 * {@link android.accessibilityservice.AccessibilityService}. This class is 2823 * made immutable before being delivered to an AccessibilityService. 2824 * </p> 2825 * 2826 * @param checked True if the node is checked. 2827 * @throws IllegalStateException If called from an AccessibilityService. 2828 */ 2829 public void setChecked(boolean checked) { 2830 IMPL.setChecked(mInfo, checked); 2831 } 2832 2833 /** 2834 * Gets whether this node is focusable. 2835 * 2836 * @return True if the node is focusable. 2837 */ 2838 public boolean isFocusable() { 2839 return IMPL.isFocusable(mInfo); 2840 } 2841 2842 /** 2843 * Sets whether this node is focusable. 2844 * <p> 2845 * <strong>Note:</strong> Cannot be called from an 2846 * {@link android.accessibilityservice.AccessibilityService}. This class is 2847 * made immutable before being delivered to an AccessibilityService. 2848 * </p> 2849 * 2850 * @param focusable True if the node is focusable. 2851 * @throws IllegalStateException If called from an AccessibilityService. 2852 */ 2853 public void setFocusable(boolean focusable) { 2854 IMPL.setFocusable(mInfo, focusable); 2855 } 2856 2857 /** 2858 * Gets whether this node is focused. 2859 * 2860 * @return True if the node is focused. 2861 */ 2862 public boolean isFocused() { 2863 return IMPL.isFocused(mInfo); 2864 } 2865 2866 /** 2867 * Sets whether this node is focused. 2868 * <p> 2869 * <strong>Note:</strong> Cannot be called from an 2870 * {@link android.accessibilityservice.AccessibilityService}. This class is 2871 * made immutable before being delivered to an AccessibilityService. 2872 * </p> 2873 * 2874 * @param focused True if the node is focused. 2875 * @throws IllegalStateException If called from an AccessibilityService. 2876 */ 2877 public void setFocused(boolean focused) { 2878 IMPL.setFocused(mInfo, focused); 2879 } 2880 2881 /** 2882 * Sets whether this node is visible to the user. 2883 * 2884 * @return Whether the node is visible to the user. 2885 */ 2886 public boolean isVisibleToUser() { 2887 return IMPL.isVisibleToUser(mInfo); 2888 } 2889 2890 /** 2891 * Sets whether this node is visible to the user. 2892 * <p> 2893 * <strong>Note:</strong> Cannot be called from an 2894 * {@link android.accessibilityservice.AccessibilityService}. 2895 * This class is made immutable before being delivered to an AccessibilityService. 2896 * </p> 2897 * 2898 * @param visibleToUser Whether the node is visible to the user. 2899 * 2900 * @throws IllegalStateException If called from an AccessibilityService. 2901 */ 2902 public void setVisibleToUser(boolean visibleToUser) { 2903 IMPL.setVisibleToUser(mInfo, visibleToUser); 2904 } 2905 2906 /** 2907 * Gets whether this node is accessibility focused. 2908 * 2909 * @return True if the node is accessibility focused. 2910 */ 2911 public boolean isAccessibilityFocused() { 2912 return IMPL.isAccessibilityFocused(mInfo); 2913 } 2914 2915 /** 2916 * Sets whether this node is accessibility focused. 2917 * <p> 2918 * <strong>Note:</strong> Cannot be called from an 2919 * {@link android.accessibilityservice.AccessibilityService}. 2920 * This class is made immutable before being delivered to an AccessibilityService. 2921 * </p> 2922 * 2923 * @param focused True if the node is accessibility focused. 2924 * 2925 * @throws IllegalStateException If called from an AccessibilityService. 2926 */ 2927 public void setAccessibilityFocused(boolean focused) { 2928 IMPL.setAccessibilityFocused(mInfo, focused); 2929 } 2930 2931 /** 2932 * Gets whether this node is selected. 2933 * 2934 * @return True if the node is selected. 2935 */ 2936 public boolean isSelected() { 2937 return IMPL.isSelected(mInfo); 2938 } 2939 2940 /** 2941 * Sets whether this node is selected. 2942 * <p> 2943 * <strong>Note:</strong> Cannot be called from an 2944 * {@link android.accessibilityservice.AccessibilityService}. This class is 2945 * made immutable before being delivered to an AccessibilityService. 2946 * </p> 2947 * 2948 * @param selected True if the node is selected. 2949 * @throws IllegalStateException If called from an AccessibilityService. 2950 */ 2951 public void setSelected(boolean selected) { 2952 IMPL.setSelected(mInfo, selected); 2953 } 2954 2955 /** 2956 * Gets whether this node is clickable. 2957 * 2958 * @return True if the node is clickable. 2959 */ 2960 public boolean isClickable() { 2961 return IMPL.isClickable(mInfo); 2962 } 2963 2964 /** 2965 * Sets whether this node is clickable. 2966 * <p> 2967 * <strong>Note:</strong> Cannot be called from an 2968 * {@link android.accessibilityservice.AccessibilityService}. This class is 2969 * made immutable before being delivered to an AccessibilityService. 2970 * </p> 2971 * 2972 * @param clickable True if the node is clickable. 2973 * @throws IllegalStateException If called from an AccessibilityService. 2974 */ 2975 public void setClickable(boolean clickable) { 2976 IMPL.setClickable(mInfo, clickable); 2977 } 2978 2979 /** 2980 * Gets whether this node is long clickable. 2981 * 2982 * @return True if the node is long clickable. 2983 */ 2984 public boolean isLongClickable() { 2985 return IMPL.isLongClickable(mInfo); 2986 } 2987 2988 /** 2989 * Sets whether this node is long clickable. 2990 * <p> 2991 * <strong>Note:</strong> Cannot be called from an 2992 * {@link android.accessibilityservice.AccessibilityService}. This class is 2993 * made immutable before being delivered to an AccessibilityService. 2994 * </p> 2995 * 2996 * @param longClickable True if the node is long clickable. 2997 * @throws IllegalStateException If called from an AccessibilityService. 2998 */ 2999 public void setLongClickable(boolean longClickable) { 3000 IMPL.setLongClickable(mInfo, longClickable); 3001 } 3002 3003 /** 3004 * Gets whether this node is enabled. 3005 * 3006 * @return True if the node is enabled. 3007 */ 3008 public boolean isEnabled() { 3009 return IMPL.isEnabled(mInfo); 3010 } 3011 3012 /** 3013 * Sets whether this node is enabled. 3014 * <p> 3015 * <strong>Note:</strong> Cannot be called from an 3016 * {@link android.accessibilityservice.AccessibilityService}. This class is 3017 * made immutable before being delivered to an AccessibilityService. 3018 * </p> 3019 * 3020 * @param enabled True if the node is enabled. 3021 * @throws IllegalStateException If called from an AccessibilityService. 3022 */ 3023 public void setEnabled(boolean enabled) { 3024 IMPL.setEnabled(mInfo, enabled); 3025 } 3026 3027 /** 3028 * Gets whether this node is a password. 3029 * 3030 * @return True if the node is a password. 3031 */ 3032 public boolean isPassword() { 3033 return IMPL.isPassword(mInfo); 3034 } 3035 3036 /** 3037 * Sets whether this node is a password. 3038 * <p> 3039 * <strong>Note:</strong> Cannot be called from an 3040 * {@link android.accessibilityservice.AccessibilityService}. This class is 3041 * made immutable before being delivered to an AccessibilityService. 3042 * </p> 3043 * 3044 * @param password True if the node is a password. 3045 * @throws IllegalStateException If called from an AccessibilityService. 3046 */ 3047 public void setPassword(boolean password) { 3048 IMPL.setPassword(mInfo, password); 3049 } 3050 3051 /** 3052 * Gets if the node is scrollable. 3053 * 3054 * @return True if the node is scrollable, false otherwise. 3055 */ 3056 public boolean isScrollable() { 3057 return IMPL.isScrollable(mInfo); 3058 } 3059 3060 /** 3061 * Sets if the node is scrollable. 3062 * <p> 3063 * <strong>Note:</strong> Cannot be called from an 3064 * {@link android.accessibilityservice.AccessibilityService}. This class is 3065 * made immutable before being delivered to an AccessibilityService. 3066 * </p> 3067 * 3068 * @param scrollable True if the node is scrollable, false otherwise. 3069 * @throws IllegalStateException If called from an AccessibilityService. 3070 */ 3071 public void setScrollable(boolean scrollable) { 3072 IMPL.setScrollable(mInfo, scrollable); 3073 } 3074 3075 /** 3076 * Returns whether the node originates from a view considered important for accessibility. 3077 * 3078 * @return {@code true} if the node originates from a view considered important for 3079 * accessibility, {@code false} otherwise 3080 * 3081 * @see View#isImportantForAccessibility() 3082 */ 3083 public boolean isImportantForAccessibility() { 3084 return IMPL.isImportantForAccessibility(mInfo); 3085 } 3086 3087 /** 3088 * Sets whether the node is considered important for accessibility. 3089 * <p> 3090 * <strong>Note:</strong> Cannot be called from an 3091 * {@link android.accessibilityservice.AccessibilityService}. 3092 * This class is made immutable before being delivered to an AccessibilityService. 3093 * </p> 3094 * 3095 * @param important {@code true} if the node is considered important for accessibility, 3096 * {@code false} otherwise 3097 */ 3098 public void setImportantForAccessibility(boolean important) { 3099 IMPL.setImportantForAccessibility(mInfo, important); 3100 } 3101 3102 /** 3103 * Gets the package this node comes from. 3104 * 3105 * @return The package name. 3106 */ 3107 public CharSequence getPackageName() { 3108 return IMPL.getPackageName(mInfo); 3109 } 3110 3111 /** 3112 * Sets the package this node comes from. 3113 * <p> 3114 * <strong>Note:</strong> Cannot be called from an 3115 * {@link android.accessibilityservice.AccessibilityService}. This class is 3116 * made immutable before being delivered to an AccessibilityService. 3117 * </p> 3118 * 3119 * @param packageName The package name. 3120 * @throws IllegalStateException If called from an AccessibilityService. 3121 */ 3122 public void setPackageName(CharSequence packageName) { 3123 IMPL.setPackageName(mInfo, packageName); 3124 } 3125 3126 /** 3127 * Gets the class this node comes from. 3128 * 3129 * @return The class name. 3130 */ 3131 public CharSequence getClassName() { 3132 return IMPL.getClassName(mInfo); 3133 } 3134 3135 /** 3136 * Sets the class this node comes from. 3137 * <p> 3138 * <strong>Note:</strong> Cannot be called from an 3139 * {@link android.accessibilityservice.AccessibilityService}. This class is 3140 * made immutable before being delivered to an AccessibilityService. 3141 * </p> 3142 * 3143 * @param className The class name. 3144 * @throws IllegalStateException If called from an AccessibilityService. 3145 */ 3146 public void setClassName(CharSequence className) { 3147 IMPL.setClassName(mInfo, className); 3148 } 3149 3150 /** 3151 * Gets the text of this node. 3152 * 3153 * @return The text. 3154 */ 3155 public CharSequence getText() { 3156 return IMPL.getText(mInfo); 3157 } 3158 3159 /** 3160 * Sets the text of this node. 3161 * <p> 3162 * <strong>Note:</strong> Cannot be called from an 3163 * {@link android.accessibilityservice.AccessibilityService}. This class is 3164 * made immutable before being delivered to an AccessibilityService. 3165 * </p> 3166 * 3167 * @param text The text. 3168 * @throws IllegalStateException If called from an AccessibilityService. 3169 */ 3170 public void setText(CharSequence text) { 3171 IMPL.setText(mInfo, text); 3172 } 3173 3174 /** 3175 * Gets the content description of this node. 3176 * 3177 * @return The content description. 3178 */ 3179 public CharSequence getContentDescription() { 3180 return IMPL.getContentDescription(mInfo); 3181 } 3182 3183 /** 3184 * Sets the content description of this node. 3185 * <p> 3186 * <strong>Note:</strong> Cannot be called from an 3187 * {@link android.accessibilityservice.AccessibilityService}. This class is 3188 * made immutable before being delivered to an AccessibilityService. 3189 * </p> 3190 * 3191 * @param contentDescription The content description. 3192 * @throws IllegalStateException If called from an AccessibilityService. 3193 */ 3194 public void setContentDescription(CharSequence contentDescription) { 3195 IMPL.setContentDescription(mInfo, contentDescription); 3196 } 3197 3198 /** 3199 * Return an instance back to be reused. 3200 * <p> 3201 * <strong>Note:</strong> You must not touch the object after calling this function. 3202 * 3203 * @throws IllegalStateException If the info is already recycled. 3204 */ 3205 public void recycle() { 3206 IMPL.recycle(mInfo); 3207 } 3208 3209 /** 3210 * Sets the fully qualified resource name of the source view's id. 3211 * 3212 * <p> 3213 * <strong>Note:</strong> Cannot be called from an 3214 * {@link android.accessibilityservice.AccessibilityService}. 3215 * This class is made immutable before being delivered to an AccessibilityService. 3216 * </p> 3217 * 3218 * @param viewId The id resource name. 3219 */ 3220 public void setViewIdResourceName(String viewId) { 3221 IMPL.setViewIdResourceName(mInfo, viewId); 3222 } 3223 3224 /** 3225 * Gets the fully qualified resource name of the source view's id. 3226 * 3227 * <p> 3228 * <strong>Note:</strong> The primary usage of this API is for UI test automation 3229 * and in order to report the source view id of an {@link AccessibilityNodeInfoCompat} 3230 * the client has to set the {@link AccessibilityServiceInfoCompat#FLAG_REPORT_VIEW_IDS} 3231 * flag when configuring his {@link android.accessibilityservice.AccessibilityService}. 3232 * </p> 3233 * 3234 * @return The id resource name. 3235 */ 3236 public String getViewIdResourceName() { 3237 return IMPL.getViewIdResourceName(mInfo); 3238 } 3239 3240 /** 3241 * Gets the node's live region mode. 3242 * <p> 3243 * A live region is a node that contains information that is important for 3244 * the user and when it changes the user should be notified. For example, 3245 * in a login screen with a TextView that displays an "incorrect password" 3246 * notification, that view should be marked as a live region with mode 3247 * {@link ViewCompat#ACCESSIBILITY_LIVE_REGION_POLITE}. 3248 * <p> 3249 * It is the responsibility of the accessibility service to monitor 3250 * {@link AccessibilityEventCompat#TYPE_WINDOW_CONTENT_CHANGED} events 3251 * indicating changes to live region nodes and their children. 3252 * 3253 * @return The live region mode, or 3254 * {@link ViewCompat#ACCESSIBILITY_LIVE_REGION_NONE} if the view is 3255 * not a live region. 3256 * @see ViewCompat#getAccessibilityLiveRegion(View) 3257 */ 3258 public int getLiveRegion() { 3259 return IMPL.getLiveRegion(mInfo); 3260 } 3261 3262 /** 3263 * Sets the node's live region mode. 3264 * <p> 3265 * <strong>Note:</strong> Cannot be called from an 3266 * {@link android.accessibilityservice.AccessibilityService}. This class is 3267 * made immutable before being delivered to an AccessibilityService. 3268 * 3269 * @param mode The live region mode, or 3270 * {@link ViewCompat#ACCESSIBILITY_LIVE_REGION_NONE} if the view is 3271 * not a live region. 3272 * @see ViewCompat#setAccessibilityLiveRegion(View, int) 3273 */ 3274 public void setLiveRegion(int mode) { 3275 IMPL.setLiveRegion(mInfo, mode); 3276 } 3277 3278 /** 3279 * Get the drawing order of the view corresponding it this node. 3280 * <p> 3281 * Drawing order is determined only within the node's parent, so this index is only relative 3282 * to its siblings. 3283 * <p> 3284 * In some cases, the drawing order is essentially simultaneous, so it is possible for two 3285 * siblings to return the same value. It is also possible that values will be skipped. 3286 * 3287 * @return The drawing position of the view corresponding to this node relative to its siblings. 3288 */ 3289 public int getDrawingOrder() { 3290 return IMPL.getDrawingOrder(mInfo); 3291 } 3292 3293 /** 3294 * Set the drawing order of the view corresponding it this node. 3295 * 3296 * <p> 3297 * <strong>Note:</strong> Cannot be called from an 3298 * {@link android.accessibilityservice.AccessibilityService}. 3299 * This class is made immutable before being delivered to an AccessibilityService. 3300 * </p> 3301 * @param drawingOrderInParent 3302 * @throws IllegalStateException If called from an AccessibilityService. 3303 */ 3304 public void setDrawingOrder(int drawingOrderInParent) { 3305 IMPL.setDrawingOrder(mInfo, drawingOrderInParent); 3306 } 3307 3308 /** 3309 * Gets the collection info if the node is a collection. A collection 3310 * child is always a collection item. 3311 * 3312 * @return The collection info. 3313 */ 3314 public CollectionInfoCompat getCollectionInfo() { 3315 Object info = IMPL.getCollectionInfo(mInfo); 3316 if (info == null) return null; 3317 return new CollectionInfoCompat(info); 3318 } 3319 3320 public void setCollectionInfo(Object collectionInfo) { 3321 IMPL.setCollectionInfo(mInfo, ((CollectionInfoCompat) collectionInfo).mInfo); 3322 } 3323 3324 public void setCollectionItemInfo(Object collectionItemInfo) { 3325 IMPL.setCollectionItemInfo(mInfo, ((CollectionItemInfoCompat) collectionItemInfo).mInfo); 3326 } 3327 3328 /** 3329 * Gets the collection item info if the node is a collection item. A collection 3330 * item is always a child of a collection. 3331 * 3332 * @return The collection item info. 3333 */ 3334 public CollectionItemInfoCompat getCollectionItemInfo() { 3335 Object info = IMPL.getCollectionItemInfo(mInfo); 3336 if (info == null) return null; 3337 return new CollectionItemInfoCompat(info); 3338 } 3339 3340 /** 3341 * Gets the range info if this node is a range. 3342 * 3343 * @return The range. 3344 */ 3345 public RangeInfoCompat getRangeInfo() { 3346 Object info = IMPL.getRangeInfo(mInfo); 3347 if (info == null) return null; 3348 return new RangeInfoCompat(info); 3349 } 3350 3351 /** 3352 * Sets the range info if this node is a range. 3353 * <p> 3354 * <strong>Note:</strong> Cannot be called from an 3355 * {@link android.accessibilityservice.AccessibilityService}. 3356 * This class is made immutable before being delivered to an AccessibilityService. 3357 * </p> 3358 * 3359 * @param rangeInfo The range info. 3360 */ 3361 public void setRangeInfo(RangeInfoCompat rangeInfo) { 3362 IMPL.setRangeInfo(mInfo, rangeInfo.mInfo); 3363 } 3364 3365 /** 3366 * Gets the actions that can be performed on the node. 3367 * 3368 * @return A list of AccessibilityActions. 3369 */ 3370 public List<AccessibilityActionCompat> getActionList() { 3371 List<Object> actions = IMPL.getActionList(mInfo); 3372 if (actions != null) { 3373 List<AccessibilityActionCompat> result = new ArrayList<AccessibilityActionCompat>(); 3374 final int actionCount = actions.size(); 3375 for (int i = 0; i < actionCount; i++) { 3376 Object action = actions.get(i); 3377 result.add(new AccessibilityActionCompat(action)); 3378 } 3379 return result; 3380 } else { 3381 return Collections.<AccessibilityActionCompat>emptyList(); 3382 } 3383 } 3384 3385 /** 3386 * Sets if the content of this node is invalid. For example, 3387 * a date is not well-formed. 3388 * <p> 3389 * <strong>Note:</strong> Cannot be called from an 3390 * {@link android.accessibilityservice.AccessibilityService}. 3391 * This class is made immutable before being delivered to an AccessibilityService. 3392 * </p> 3393 * 3394 * @param contentInvalid If the node content is invalid. 3395 */ 3396 public void setContentInvalid(boolean contentInvalid) { 3397 IMPL.setContentInvalid(mInfo, contentInvalid); 3398 } 3399 3400 /** 3401 * Gets if the content of this node is invalid. For example, 3402 * a date is not well-formed. 3403 * 3404 * @return If the node content is invalid. 3405 */ 3406 public boolean isContentInvalid() { 3407 return IMPL.isContentInvalid(mInfo); 3408 } 3409 3410 /** 3411 * Sets the error text of this node. 3412 * <p> 3413 * <strong>Note:</strong> Cannot be called from an 3414 * {@link android.accessibilityservice.AccessibilityService}. 3415 * This class is made immutable before being delivered to an AccessibilityService. 3416 * </p> 3417 * 3418 * @param error The error text. 3419 * 3420 * @throws IllegalStateException If called from an AccessibilityService. 3421 */ 3422 public void setError(CharSequence error) { 3423 IMPL.setError(mInfo, error); 3424 } 3425 3426 /** 3427 * Gets the error text of this node. 3428 * 3429 * @return The error text. 3430 */ 3431 public CharSequence getError() { 3432 return IMPL.getError(mInfo); 3433 } 3434 3435 /** 3436 * Sets the view for which the view represented by this info serves as a 3437 * label for accessibility purposes. 3438 * 3439 * @param labeled The view for which this info serves as a label. 3440 */ 3441 public void setLabelFor(View labeled) { 3442 IMPL.setLabelFor(mInfo, labeled); 3443 } 3444 3445 /** 3446 * Sets the view for which the view represented by this info serves as a 3447 * label for accessibility purposes. If <code>virtualDescendantId</code> 3448 * is {@link View#NO_ID} the root is set as the labeled. 3449 * <p> 3450 * A virtual descendant is an imaginary View that is reported as a part of the view 3451 * hierarchy for accessibility purposes. This enables custom views that draw complex 3452 * content to report themselves as a tree of virtual views, thus conveying their 3453 * logical structure. 3454 * </p> 3455 * 3456 * @param root The root whose virtual descendant serves as a label. 3457 * @param virtualDescendantId The id of the virtual descendant. 3458 */ 3459 public void setLabelFor(View root, int virtualDescendantId) { 3460 IMPL.setLabelFor(mInfo, root, virtualDescendantId); 3461 } 3462 3463 /** 3464 * Gets the node info for which the view represented by this info serves as 3465 * a label for accessibility purposes. 3466 * <p> 3467 * <strong>Note:</strong> It is a client responsibility to recycle the 3468 * received info by calling {@link AccessibilityNodeInfoCompat#recycle()} 3469 * to avoid creating of multiple instances. 3470 * </p> 3471 * 3472 * @return The labeled info. 3473 */ 3474 public AccessibilityNodeInfoCompat getLabelFor() { 3475 return AccessibilityNodeInfoCompat.wrapNonNullInstance(IMPL.getLabelFor(mInfo)); 3476 } 3477 3478 /** 3479 * Sets the view which serves as the label of the view represented by 3480 * this info for accessibility purposes. 3481 * 3482 * @param label The view that labels this node's source. 3483 */ 3484 public void setLabeledBy(View label) { 3485 IMPL.setLabeledBy(mInfo, label); 3486 } 3487 3488 /** 3489 * Sets the view which serves as the label of the view represented by 3490 * this info for accessibility purposes. If <code>virtualDescendantId</code> 3491 * is {@link View#NO_ID} the root is set as the label. 3492 * <p> 3493 * A virtual descendant is an imaginary View that is reported as a part of the view 3494 * hierarchy for accessibility purposes. This enables custom views that draw complex 3495 * content to report themselves as a tree of virtual views, thus conveying their 3496 * logical structure. 3497 * </p> 3498 * <p> 3499 * <strong>Note:</strong> Cannot be called from an 3500 * {@link android.accessibilityservice.AccessibilityService}. 3501 * This class is made immutable before being delivered to an AccessibilityService. 3502 * </p> 3503 * 3504 * @param root The root whose virtual descendant labels this node's source. 3505 * @param virtualDescendantId The id of the virtual descendant. 3506 */ 3507 public void setLabeledBy(View root, int virtualDescendantId) { 3508 IMPL.setLabeledBy(mInfo, root, virtualDescendantId); 3509 } 3510 3511 /** 3512 * Gets the node info which serves as the label of the view represented by 3513 * this info for accessibility purposes. 3514 * <p> 3515 * <strong>Note:</strong> It is a client responsibility to recycle the 3516 * received info by calling {@link AccessibilityNodeInfoCompat#recycle()} 3517 * to avoid creating of multiple instances. 3518 * </p> 3519 * 3520 * @return The label. 3521 */ 3522 public AccessibilityNodeInfoCompat getLabeledBy() { 3523 return AccessibilityNodeInfoCompat.wrapNonNullInstance(IMPL.getLabeledBy(mInfo)); 3524 } 3525 3526 /** 3527 * Gets if this node opens a popup or a dialog. 3528 * 3529 * @return If the the node opens a popup. 3530 */ 3531 public boolean canOpenPopup() { 3532 return IMPL.canOpenPopup(mInfo); 3533 } 3534 3535 /** 3536 * Sets if this node opens a popup or a dialog. 3537 * <p> 3538 * <strong>Note:</strong> Cannot be called from an 3539 * {@link android.accessibilityservice.AccessibilityService}. 3540 * This class is made immutable before being delivered to an AccessibilityService. 3541 * </p> 3542 * 3543 * @param opensPopup If the the node opens a popup. 3544 */ 3545 public void setCanOpenPopup(boolean opensPopup) { 3546 IMPL.setCanOpenPopup(mInfo, opensPopup); 3547 } 3548 3549 /** 3550 * Finds {@link AccessibilityNodeInfoCompat}s by the fully qualified view id's resource 3551 * name where a fully qualified id is of the from "package:id/id_resource_name". 3552 * For example, if the target application's package is "foo.bar" and the id 3553 * resource name is "baz", the fully qualified resource id is "foo.bar:id/baz". 3554 * 3555 * <p> 3556 * <strong>Note:</strong> It is a client responsibility to recycle the 3557 * received info by calling {@link AccessibilityNodeInfoCompat#recycle()} 3558 * to avoid creating of multiple instances. 3559 * </p> 3560 * <p> 3561 * <strong>Note:</strong> The primary usage of this API is for UI test automation 3562 * and in order to report the fully qualified view id if an 3563 * {@link AccessibilityNodeInfoCompat} the client has to set the 3564 * {@link android.accessibilityservice.AccessibilityServiceInfo#FLAG_REPORT_VIEW_IDS} 3565 * flag when configuring his {@link android.accessibilityservice.AccessibilityService}. 3566 * </p> 3567 * 3568 * @param viewId The fully qualified resource name of the view id to find. 3569 * @return A list of node info. 3570 */ 3571 public List<AccessibilityNodeInfoCompat> findAccessibilityNodeInfosByViewId(String viewId) { 3572 List<Object> nodes = IMPL.findAccessibilityNodeInfosByViewId(mInfo, viewId); 3573 if (nodes != null) { 3574 List<AccessibilityNodeInfoCompat> result = new ArrayList<AccessibilityNodeInfoCompat>(); 3575 for (Object node : nodes) { 3576 result.add(new AccessibilityNodeInfoCompat(node)); 3577 } 3578 return result; 3579 } else { 3580 return Collections.emptyList(); 3581 } 3582 } 3583 3584 /** 3585 * Gets an optional bundle with extra data. The bundle 3586 * is lazily created and never <code>null</code>. 3587 * <p> 3588 * <strong>Note:</strong> It is recommended to use the package 3589 * name of your application as a prefix for the keys to avoid 3590 * collisions which may confuse an accessibility service if the 3591 * same key has different meaning when emitted from different 3592 * applications. 3593 * </p> 3594 * 3595 * @return The bundle. 3596 */ 3597 public Bundle getExtras() { 3598 return IMPL.getExtras(mInfo); 3599 } 3600 3601 /** 3602 * Gets the input type of the source as defined by {@link InputType}. 3603 * 3604 * @return The input type. 3605 */ 3606 public int getInputType() { 3607 return IMPL.getInputType(mInfo); 3608 } 3609 3610 /** 3611 * Sets the input type of the source as defined by {@link InputType}. 3612 * <p> 3613 * <strong>Note:</strong> Cannot be called from an 3614 * {@link android.accessibilityservice.AccessibilityService}. 3615 * This class is made immutable before being delivered to an 3616 * AccessibilityService. 3617 * </p> 3618 * 3619 * @param inputType The input type. 3620 * 3621 * @throws IllegalStateException If called from an AccessibilityService. 3622 */ 3623 public void setInputType(int inputType) { 3624 IMPL.setInputType(mInfo, inputType); 3625 } 3626 3627 /** 3628 * Sets the maximum text length, or -1 for no limit. 3629 * <p> 3630 * Typically used to indicate that an editable text field has a limit on 3631 * the number of characters entered. 3632 * <p> 3633 * <strong>Note:</strong> Cannot be called from an 3634 * {@link android.accessibilityservice.AccessibilityService}. 3635 * This class is made immutable before being delivered to an AccessibilityService. 3636 * 3637 * @param max The maximum text length. 3638 * @see #getMaxTextLength() 3639 * 3640 * @throws IllegalStateException If called from an AccessibilityService. 3641 */ 3642 public void setMaxTextLength(int max) { 3643 IMPL.setMaxTextLength(mInfo, max); 3644 } 3645 3646 /** 3647 * Returns the maximum text length for this node. 3648 * 3649 * @return The maximum text length, or -1 for no limit. 3650 * @see #setMaxTextLength(int) 3651 */ 3652 public int getMaxTextLength() { 3653 return IMPL.getMaxTextLength(mInfo); 3654 } 3655 3656 /** 3657 * Sets the text selection start and end. 3658 * <p> 3659 * <strong>Note:</strong> Cannot be called from an 3660 * {@link android.accessibilityservice.AccessibilityService}. 3661 * This class is made immutable before being delivered to an AccessibilityService. 3662 * </p> 3663 * 3664 * @param start The text selection start. 3665 * @param end The text selection end. 3666 * 3667 * @throws IllegalStateException If called from an AccessibilityService. 3668 */ 3669 public void setTextSelection(int start, int end) { 3670 IMPL.setTextSelection(mInfo, start, end); 3671 } 3672 3673 /** 3674 * Gets the text selection start. 3675 * 3676 * @return The text selection start if there is selection or -1. 3677 */ 3678 public int getTextSelectionStart() { 3679 return IMPL.getTextSelectionStart(mInfo); 3680 } 3681 3682 /** 3683 * Gets the text selection end. 3684 * 3685 * @return The text selection end if there is selection or -1. 3686 */ 3687 public int getTextSelectionEnd() { 3688 return IMPL.getTextSelectionEnd(mInfo); 3689 } 3690 3691 /** 3692 * Gets the node before which this one is visited during traversal. A screen-reader 3693 * must visit the content of this node before the content of the one it precedes. 3694 * 3695 * @return The succeeding node if such or <code>null</code>. 3696 * 3697 * @see #setTraversalBefore(android.view.View) 3698 * @see #setTraversalBefore(android.view.View, int) 3699 */ 3700 public AccessibilityNodeInfoCompat getTraversalBefore() { 3701 return AccessibilityNodeInfoCompat.wrapNonNullInstance(IMPL.getTraversalBefore(mInfo)); 3702 } 3703 3704 /** 3705 * Sets the view before whose node this one should be visited during traversal. A 3706 * screen-reader must visit the content of this node before the content of the one 3707 * it precedes. 3708 * <p> 3709 * <strong>Note:</strong> Cannot be called from an 3710 * {@link android.accessibilityservice.AccessibilityService}. 3711 * This class is made immutable before being delivered to an AccessibilityService. 3712 * </p> 3713 * 3714 * @param view The view providing the preceding node. 3715 * 3716 * @see #getTraversalBefore() 3717 */ 3718 public void setTraversalBefore(View view) { 3719 IMPL.setTraversalBefore(mInfo, view); 3720 } 3721 3722 /** 3723 * Sets the node before which this one is visited during traversal. A screen-reader 3724 * must visit the content of this node before the content of the one it precedes. 3725 * The successor is a virtual descendant of the given <code>root</code>. If 3726 * <code>virtualDescendantId</code> equals to {@link View#NO_ID} the root is set 3727 * as the successor. 3728 * <p> 3729 * A virtual descendant is an imaginary View that is reported as a part of the view 3730 * hierarchy for accessibility purposes. This enables custom views that draw complex 3731 * content to report them selves as a tree of virtual views, thus conveying their 3732 * logical structure. 3733 * </p> 3734 * <p> 3735 * <strong>Note:</strong> Cannot be called from an 3736 * {@link android.accessibilityservice.AccessibilityService}. 3737 * This class is made immutable before being delivered to an AccessibilityService. 3738 * </p> 3739 * 3740 * @param root The root of the virtual subtree. 3741 * @param virtualDescendantId The id of the virtual descendant. 3742 */ 3743 public void setTraversalBefore(View root, int virtualDescendantId) { 3744 IMPL.setTraversalBefore(mInfo, root, virtualDescendantId); 3745 } 3746 3747 /** 3748 * Gets the node after which this one is visited in accessibility traversal. 3749 * A screen-reader must visit the content of the other node before the content 3750 * of this one. 3751 * 3752 * @return The succeeding node if such or <code>null</code>. 3753 * 3754 * @see #setTraversalAfter(android.view.View) 3755 * @see #setTraversalAfter(android.view.View, int) 3756 */ 3757 public AccessibilityNodeInfoCompat getTraversalAfter() { 3758 return AccessibilityNodeInfoCompat.wrapNonNullInstance(IMPL.getTraversalAfter(mInfo)); 3759 } 3760 3761 /** 3762 * Sets the view whose node is visited after this one in accessibility traversal. 3763 * A screen-reader must visit the content of the other node before the content 3764 * of this one. 3765 * <p> 3766 * <strong>Note:</strong> Cannot be called from an 3767 * {@link android.accessibilityservice.AccessibilityService}. 3768 * This class is made immutable before being delivered to an AccessibilityService. 3769 * </p> 3770 * 3771 * @param view The previous view. 3772 * 3773 * @see #getTraversalAfter() 3774 */ 3775 public void setTraversalAfter(View view) { 3776 IMPL.setTraversalAfter(mInfo, view); 3777 } 3778 3779 /** 3780 * Sets the node after which this one is visited in accessibility traversal. 3781 * A screen-reader must visit the content of the other node before the content 3782 * of this one. If <code>virtualDescendantId</code> equals to {@link View#NO_ID} 3783 * the root is set as the predecessor. 3784 * <p> 3785 * A virtual descendant is an imaginary View that is reported as a part of the view 3786 * hierarchy for accessibility purposes. This enables custom views that draw complex 3787 * content to report them selves as a tree of virtual views, thus conveying their 3788 * logical structure. 3789 * </p> 3790 * <p> 3791 * <strong>Note:</strong> Cannot be called from an 3792 * {@link android.accessibilityservice.AccessibilityService}. 3793 * This class is made immutable before being delivered to an AccessibilityService. 3794 * </p> 3795 * 3796 * @param root The root of the virtual subtree. 3797 * @param virtualDescendantId The id of the virtual descendant. 3798 */ 3799 public void setTraversalAfter(View root, int virtualDescendantId) { 3800 IMPL.setTraversalAfter(mInfo, root, virtualDescendantId); 3801 } 3802 3803 /** 3804 * Gets the window to which this node belongs. 3805 * 3806 * @return The window. 3807 * 3808 * @see android.accessibilityservice.AccessibilityService#getWindows() 3809 */ 3810 public AccessibilityWindowInfoCompat getWindow() { 3811 return AccessibilityWindowInfoCompat.wrapNonNullInstance(IMPL.getWindow(mInfo)); 3812 } 3813 3814 /** 3815 * Gets if the node can be dismissed. 3816 * 3817 * @return If the node can be dismissed. 3818 */ 3819 public boolean isDismissable() { 3820 return IMPL.isDismissable(mInfo); 3821 } 3822 3823 /** 3824 * Sets if the node can be dismissed. 3825 * <p> 3826 * <strong>Note:</strong> Cannot be called from an 3827 * {@link android.accessibilityservice.AccessibilityService}. 3828 * This class is made immutable before being delivered to an AccessibilityService. 3829 * </p> 3830 * 3831 * @param dismissable If the node can be dismissed. 3832 */ 3833 public void setDismissable(boolean dismissable) { 3834 IMPL.setDismissable(mInfo, dismissable); 3835 } 3836 3837 /** 3838 * Gets if the node is editable. 3839 * 3840 * @return True if the node is editable, false otherwise. 3841 */ 3842 public boolean isEditable() { 3843 return IMPL.isEditable(mInfo); 3844 } 3845 3846 /** 3847 * Sets whether this node is editable. 3848 * <p> 3849 * <strong>Note:</strong> Cannot be called from an 3850 * {@link android.accessibilityservice.AccessibilityService}. 3851 * This class is made immutable before being delivered to an AccessibilityService. 3852 * </p> 3853 * 3854 * @param editable True if the node is editable. 3855 * 3856 * @throws IllegalStateException If called from an AccessibilityService. 3857 */ 3858 public void setEditable(boolean editable) { 3859 IMPL.setEditable(mInfo, editable); 3860 } 3861 3862 /** 3863 * Gets if the node is a multi line editable text. 3864 * 3865 * @return True if the node is multi line. 3866 */ 3867 public boolean isMultiLine() { 3868 return IMPL.isMultiLine(mInfo); 3869 } 3870 3871 /** 3872 * Sets if the node is a multi line editable text. 3873 * <p> 3874 * <strong>Note:</strong> Cannot be called from an 3875 * {@link android.accessibilityservice.AccessibilityService}. 3876 * This class is made immutable before being delivered to an AccessibilityService. 3877 * </p> 3878 * 3879 * @param multiLine True if the node is multi line. 3880 */ 3881 public void setMultiLine(boolean multiLine) { 3882 IMPL.setMultiLine(mInfo, multiLine); 3883 } 3884 3885 /** 3886 * Refreshes this info with the latest state of the view it represents. 3887 * <p> 3888 * <strong>Note:</strong> If this method returns false this info is obsolete 3889 * since it represents a view that is no longer in the view tree and should 3890 * be recycled. 3891 * </p> 3892 * @return Whether the refresh succeeded. 3893 */ 3894 public boolean refresh() { 3895 return IMPL.refresh(mInfo); 3896 } 3897 3898 /** 3899 * Gets the custom role description. 3900 * @return The role description. 3901 */ 3902 public @Nullable CharSequence getRoleDescription() { 3903 return IMPL.getRoleDescription(mInfo); 3904 } 3905 3906 /** 3907 * Sets the custom role description. 3908 * 3909 * <p> 3910 * The role description allows you to customize the name for the view's semantic 3911 * role. For example, if you create a custom subclass of {@link android.view.View} 3912 * to display a menu bar, you could assign it the role description of "menu bar". 3913 * </p> 3914 * <p> 3915 * <strong>Warning:</strong> For consistency with other applications, you should 3916 * not use the role description to force accessibility services to describe 3917 * standard views (such as buttons or checkboxes) using specific wording. For 3918 * example, you should not set a role description of "check box" or "tick box" for 3919 * a standard {@link android.widget.CheckBox}. Instead let accessibility services 3920 * decide what feedback to provide. 3921 * </p> 3922 * <p> 3923 * <strong>Note:</strong> Cannot be called from an 3924 * {@link android.accessibilityservice.AccessibilityService}. 3925 * This class is made immutable before being delivered to an AccessibilityService. 3926 * </p> 3927 * 3928 * @param roleDescription The role description. 3929 */ 3930 public void setRoleDescription(@Nullable CharSequence roleDescription) { 3931 IMPL.setRoleDescription(mInfo, roleDescription); 3932 } 3933 3934 @Override 3935 public int hashCode() { 3936 return (mInfo == null) ? 0 : mInfo.hashCode(); 3937 } 3938 3939 @Override 3940 public boolean equals(Object obj) { 3941 if (this == obj) { 3942 return true; 3943 } 3944 if (obj == null) { 3945 return false; 3946 } 3947 if (getClass() != obj.getClass()) { 3948 return false; 3949 } 3950 AccessibilityNodeInfoCompat other = (AccessibilityNodeInfoCompat) obj; 3951 if (mInfo == null) { 3952 if (other.mInfo != null) { 3953 return false; 3954 } 3955 } else if (!mInfo.equals(other.mInfo)) { 3956 return false; 3957 } 3958 return true; 3959 } 3960 3961 @Override 3962 public String toString() { 3963 StringBuilder builder = new StringBuilder(); 3964 builder.append(super.toString()); 3965 3966 Rect bounds = new Rect(); 3967 3968 getBoundsInParent(bounds); 3969 builder.append("; boundsInParent: " + bounds); 3970 3971 getBoundsInScreen(bounds); 3972 builder.append("; boundsInScreen: " + bounds); 3973 3974 builder.append("; packageName: ").append(getPackageName()); 3975 builder.append("; className: ").append(getClassName()); 3976 builder.append("; text: ").append(getText()); 3977 builder.append("; contentDescription: ").append(getContentDescription()); 3978 builder.append("; viewId: ").append(getViewIdResourceName()); 3979 3980 builder.append("; checkable: ").append(isCheckable()); 3981 builder.append("; checked: ").append(isChecked()); 3982 builder.append("; focusable: ").append(isFocusable()); 3983 builder.append("; focused: ").append(isFocused()); 3984 builder.append("; selected: ").append(isSelected()); 3985 builder.append("; clickable: ").append(isClickable()); 3986 builder.append("; longClickable: ").append(isLongClickable()); 3987 builder.append("; enabled: ").append(isEnabled()); 3988 builder.append("; password: ").append(isPassword()); 3989 builder.append("; scrollable: " + isScrollable()); 3990 3991 builder.append("; ["); 3992 for (int actionBits = getActions(); actionBits != 0;) { 3993 final int action = 1 << Integer.numberOfTrailingZeros(actionBits); 3994 actionBits &= ~action; 3995 builder.append(getActionSymbolicName(action)); 3996 if (actionBits != 0) { 3997 builder.append(", "); 3998 } 3999 } 4000 builder.append("]"); 4001 4002 return builder.toString(); 4003 } 4004 4005 private static String getActionSymbolicName(int action) { 4006 switch (action) { 4007 case ACTION_FOCUS: 4008 return "ACTION_FOCUS"; 4009 case ACTION_CLEAR_FOCUS: 4010 return "ACTION_CLEAR_FOCUS"; 4011 case ACTION_SELECT: 4012 return "ACTION_SELECT"; 4013 case ACTION_CLEAR_SELECTION: 4014 return "ACTION_CLEAR_SELECTION"; 4015 case ACTION_CLICK: 4016 return "ACTION_CLICK"; 4017 case ACTION_LONG_CLICK: 4018 return "ACTION_LONG_CLICK"; 4019 case ACTION_ACCESSIBILITY_FOCUS: 4020 return "ACTION_ACCESSIBILITY_FOCUS"; 4021 case ACTION_CLEAR_ACCESSIBILITY_FOCUS: 4022 return "ACTION_CLEAR_ACCESSIBILITY_FOCUS"; 4023 case ACTION_NEXT_AT_MOVEMENT_GRANULARITY: 4024 return "ACTION_NEXT_AT_MOVEMENT_GRANULARITY"; 4025 case ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY: 4026 return "ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY"; 4027 case ACTION_NEXT_HTML_ELEMENT: 4028 return "ACTION_NEXT_HTML_ELEMENT"; 4029 case ACTION_PREVIOUS_HTML_ELEMENT: 4030 return "ACTION_PREVIOUS_HTML_ELEMENT"; 4031 case ACTION_SCROLL_FORWARD: 4032 return "ACTION_SCROLL_FORWARD"; 4033 case ACTION_SCROLL_BACKWARD: 4034 return "ACTION_SCROLL_BACKWARD"; 4035 case ACTION_CUT: 4036 return "ACTION_CUT"; 4037 case ACTION_COPY: 4038 return "ACTION_COPY"; 4039 case ACTION_PASTE: 4040 return "ACTION_PASTE"; 4041 case ACTION_SET_SELECTION: 4042 return "ACTION_SET_SELECTION"; 4043 default: 4044 return"ACTION_UNKNOWN"; 4045 } 4046 } 4047} 4048