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