List of usage examples for android.view.accessibility AccessibilityNodeInfo isVisibleToUser
public boolean isVisibleToUser()
From source file:com.android.utils.FocusFinder.java
public static AccessibilityNodeInfoCompat getFocusedNode(AccessibilityService service, boolean fallbackOnRoot) { AccessibilityNodeInfo root = service.getRootInActiveWindow(); AccessibilityNodeInfo focused = null; try {//from www . j a v a 2 s .co m AccessibilityNodeInfo ret = null; if (root != null) { focused = root.findFocus(AccessibilityNodeInfo.FOCUS_ACCESSIBILITY); if (focused != null && focused.isVisibleToUser()) { ret = focused; focused = null; } else if (fallbackOnRoot) { ret = root; root = null; } } else { LogUtils.log(service, Log.ERROR, "No current window root"); } if (ret != null) { return new AccessibilityNodeInfoCompat(ret); } } finally { if (root != null) { root.recycle(); } if (focused != null) { focused.recycle(); } } return null; }
From source file:com.googlecode.eyesfree.brailleback.FocusFinder.java
public static AccessibilityNodeInfoCompat getFocusedNode(AccessibilityService service, boolean fallbackOnRoot) { AccessibilityNodeInfo root = service.getRootInActiveWindow(); AccessibilityNodeInfo focused = null; try {/*from ww w . j a v a 2 s . c o m*/ AccessibilityNodeInfo ret = null; if (root != null) { focused = root.findFocus(AccessibilityNodeInfo.FOCUS_ACCESSIBILITY); if (focused != null && focused.isVisibleToUser()) { ret = focused; focused = null; } else if (fallbackOnRoot) { ret = root; root = null; } } else { LogUtils.log(service, Log.ERROR, "No current window root"); } if (ret != null) { return new AccessibilityNodeInfoCompat(ret); } } finally { if (root != null) { root.recycle(); } if (focused != null) { focused.recycle(); } } return null; }
From source file:com.android.screenspeak.eventprocessor.ProcessorScrollPosition.java
/** * Given an {@link AccessibilityEvent}, speaks a scroll position. * * @param event The source event./*from w ww.ja v a 2 s . co m*/ */ private void handleScrollFeedback(AccessibilityEvent event) { final CharSequence text = getDescriptionForScrollEvent(event); if (TextUtils.isEmpty(text)) { return; } // don't pronounce non-visible nodes AccessibilityNodeInfo node = event.getSource(); if (node != null && !node.isVisibleToUser()) { return; } // Use QUEUE mode so that we don't interrupt more important messages. mSpeechController.speak(text, SpeechController.QUEUE_MODE_QUEUE, 0, mSpeechParams); }
From source file:com.android.talkback.eventprocessor.ProcessorScrollPosition.java
/** * Given an {@link AccessibilityEvent}, speaks a scroll position. * * @param event The source event./*from w w w. j av a 2 s .c o m*/ */ private void handleScrollFeedback(AccessibilityEvent event) { final CharSequence text; AccessibilityNodeInfo source = event.getSource(); if (Role.getRole(source) == Role.ROLE_PAGER) { text = getDescriptionForPageEvent(event, source); } else { text = getDescriptionForScrollEvent(event); } if (source != null) { source.recycle(); } if (TextUtils.isEmpty(text)) { return; } // don't pronounce non-visible nodes AccessibilityNodeInfo node = event.getSource(); if (node != null && !node.isVisibleToUser()) { return; } // Use QUEUE mode so that we don't interrupt more important messages. mSpeechController.speak(text, SpeechController.QUEUE_MODE_QUEUE, 0, mSpeechParams); }
From source file:com.googlecode.eyesfree.brailleback.TreeDebugNavigationMode.java
private CharSequence formatNode(AccessibilityNodeInfo node) { StringBuilder sb = new StringBuilder(); sb.append(node.getWindowId());//from w ww.j a va 2 s. co m if (node.getClassName() != null) { appendSimpleName(sb, node.getClassName()); } else { sb.append("??"); } if (!node.isVisibleToUser()) { sb.append(":invisible"); } if (node.getText() != null) { sb.append(":"); sb.append(node.getText()); } if (node.getContentDescription() != null) { sb.append(":"); sb.append(node.getContentDescription()); } int actions = node.getActions(); if (actions != 0) { sb.append(":"); if ((actions & AccessibilityNodeInfo.ACTION_FOCUS) != 0) { sb.append("F"); } if ((actions & AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS) != 0) { sb.append("A"); } if ((actions & AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS) != 0) { sb.append("a"); } if ((actions & AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD) != 0) { sb.append("-"); } if ((actions & AccessibilityNodeInfo.ACTION_SCROLL_FORWARD) != 0) { sb.append("+"); } } if (node.isCheckable()) { sb.append(":"); if (node.isChecked()) { sb.append("(X)"); } else { sb.append("( )"); } } if (node.isFocusable()) { sb.append(":focusable"); } if (node.isFocused()) { sb.append(":focused"); } if (node.isSelected()) { sb.append(":selected"); } if (node.isClickable()) { sb.append(":clickable"); } if (node.isLongClickable()) { sb.append(":longClickable"); } if (node.isAccessibilityFocused()) { sb.append(":accessibilityFocused"); } if (!node.isEnabled()) { sb.append(":disabled"); } return sb.toString(); }
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(); }