List of usage examples for android.view.accessibility AccessibilityNodeInfo getContentDescription
public CharSequence getContentDescription()
From source file:com.ucmap.dingdinghelper.services.DingDingHelperAccessibilityService.java
/** * AccessibilityNodeInfo ?webView /*from www. j ava2s .co m*/ * List * ? ???target?? * * @param target * @param accessibilityNodeInfo * @return */ private void recurseFindByTextToList(String target, AccessibilityNodeInfo accessibilityNodeInfo, @NonNull List<AccessibilityNodeInfo> mInfos) { if (accessibilityNodeInfo != null && accessibilityNodeInfo.getChildCount() == 0) { if (((accessibilityNodeInfo.getText() != null && accessibilityNodeInfo.getText().toString().contains(target)) || (accessibilityNodeInfo.getContentDescription() != null && accessibilityNodeInfo.getContentDescription().toString().contains(target)))) { mInfos.add(accessibilityNodeInfo); return; } else return; } else { if (accessibilityNodeInfo == null) return; for (int i = 0; i < accessibilityNodeInfo.getChildCount(); i++) { AccessibilityNodeInfo child = accessibilityNodeInfo.getChild(i); recurseFindByTextToList(target, child, mInfos); } return; } }
From source file:com.google.android.apps.common.testing.accessibility.framework.uielement.ViewHierarchyElement.java
ViewHierarchyElement(int id, @Nullable ViewHierarchyElement parent, AccessibilityNodeInfo fromInfo) { // Bookkeeping this.id = id; this.parentId = (parent != null) ? parent.getId() : null; // API 18+ properties this.resourceName = AT_18 ? fromInfo.getViewIdResourceName() : null; this.editable = AT_18 ? fromInfo.isEditable() : null; // API 16+ properties this.visibleToUser = AT_16 ? fromInfo.isVisibleToUser() : null; // Base properties this.className = fromInfo.getClassName(); this.packageName = fromInfo.getPackageName(); this.accessibilityClassName = fromInfo.getClassName(); this.contentDescription = SpannableString.valueOf(fromInfo.getContentDescription()); this.text = SpannableString.valueOf(fromInfo.getText()); this.importantForAccessibility = true; this.clickable = fromInfo.isClickable(); this.longClickable = fromInfo.isLongClickable(); this.focusable = fromInfo.isFocusable(); this.scrollable = fromInfo.isScrollable(); this.canScrollForward = ((fromInfo.getActions() & AccessibilityNodeInfo.ACTION_SCROLL_FORWARD) != 0); this.canScrollBackward = ((fromInfo.getActions() & AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD) != 0); this.checkable = fromInfo.isCheckable(); this.checked = fromInfo.isChecked(); this.hasTouchDelegate = false; /* Touch delegates are not considered by AccessibilityServices */ android.graphics.Rect tempRect = new android.graphics.Rect(); fromInfo.getBoundsInScreen(tempRect); this.boundsInScreen = new Rect(tempRect); this.nonclippedHeight = null; /* AccessibilityServices cannot discover nonclipped dimensions */ this.nonclippedWidth = null; /* AccessibilityServices cannot discover nonclipped dimensions */ this.textSize = null; this.textColor = null; this.backgroundDrawableColor = null; this.typefaceStyle = null; this.enabled = fromInfo.isEnabled(); }