List of usage examples for android.support.v4.view.accessibility AccessibilityNodeInfoCompat getParent
public AccessibilityNodeInfoCompat getParent()
From source file:Main.java
private static AccessibilityNodeInfoCompat refreshFromParent(AccessibilityNodeInfoCompat node) { AccessibilityNodeInfoCompat parent = node.getParent(); if (parent != null) { try {/* w w w. j a v a 2s . c o m*/ int childCount = parent.getChildCount(); for (int i = 0; i < childCount; ++i) { AccessibilityNodeInfoCompat child = parent.getChild(i); if (node.equals(child)) { return child; } recycleNodes(child); } } finally { parent.recycle(); } } return null; }
From source file:Main.java
/** * Returns the root node of the tree containing {@code node}. *///from w w w .j av a2s. com public static AccessibilityNodeInfoCompat getRoot(AccessibilityNodeInfoCompat node) { if (node == null) { return null; } AccessibilityNodeInfoCompat current = null; AccessibilityNodeInfoCompat parent = AccessibilityNodeInfoCompat.obtain(node); do { current = parent; parent = current.getParent(); } while (parent != null); return current; }
From source file:Main.java
private static AccessibilityNodeInfoCompat refreshFromChild(AccessibilityNodeInfoCompat node) { if (node.getChildCount() > 0) { AccessibilityNodeInfoCompat firstChild = node.getChild(0); if (firstChild != null) { AccessibilityNodeInfoCompat parent = firstChild.getParent(); firstChild.recycle();// w w w . j a v a2s. c om if (node.equals(parent)) { return parent; } else { recycleNodes(parent); } } } return null; }
From source file:com.android.utils.WebInterfaceUtils.java
/** * Determines whether or not the given node contains native web content (and not ChromeVox). * * @param node The node to evaluate/*ww w.j av a 2s . c om*/ * @return {@code true} if the node contains native web content, {@code false} otherwise */ public static boolean hasNativeWebContent(AccessibilityNodeInfoCompat node) { if (node == null) { return false; } if (!supportsWebActions(node)) { return false; } // ChromeVox does not have sub elements, so if the parent element also has web content // this cannot be ChromeVox. AccessibilityNodeInfoCompat parent = node.getParent(); if (supportsWebActions(parent)) { if (parent != null) { parent.recycle(); } return true; } if (parent != null) { parent.recycle(); } // ChromeVox never has child elements return node.getChildCount() > 0; }
From source file:com.example.accessibility.OverlayManager.java
public static AccessibilityNodeInfoCompat getRoot(AccessibilityNodeInfoCompat node) { if (node == null) { return null; }// w w w . j ava 2s . c o m AccessibilityNodeInfoCompat current = null; AccessibilityNodeInfoCompat parent = AccessibilityNodeInfoCompat.obtain(node); do { current = parent; parent = current.getParent(); } while (parent != null); return current; }
From source file:com.android.utils.WebInterfaceUtils.java
public static String[] getSupportedHtmlElements(AccessibilityNodeInfoCompat node) { HashSet<AccessibilityNodeInfoCompat> visitedNodes = new HashSet<AccessibilityNodeInfoCompat>(); while (node != null) { if (visitedNodes.contains(node)) { return null; }/*from ww w.j av a 2 s.co m*/ visitedNodes.add(node); Bundle bundle = node.getExtras(); CharSequence supportedHtmlElements = bundle.getCharSequence(ACTION_ARGUMENT_HTML_ELEMENT_STRING_VALUES); if (supportedHtmlElements != null) { return supportedHtmlElements.toString().split(","); } node = node.getParent(); } return null; }
From source file:com.android.talkback.speechrules.RulePagerPage.java
@Override public boolean accept(AccessibilityNodeInfoCompat node, AccessibilityEvent event) { if (node != null) { AccessibilityNodeInfoCompat parent = node.getParent(); if (parent != null) { try { int visibleChildren = 0; int totalChildren = parent.getChildCount(); for (int i = 0; i < totalChildren; ++i) { AccessibilityNodeInfoCompat child = parent.getChild(i); if (child != null) { if (child.isVisibleToUser()) { visibleChildren++; }//from w w w. j ava 2 s. c om child.recycle(); } } return Role.getRole(parent) == Role.ROLE_PAGER && visibleChildren == 1; } finally { parent.recycle(); } } } return false; }
From source file:com.google.android.marvin.utils.HighlightBoundsView.java
private boolean isValidNode(AccessibilityNodeInfoCompat node) { final AccessibilityNodeInfoCompat parent = node.getParent(); if (parent != null) { parent.recycle();/* www . j av a2s . com*/ return true; } final int childCount = node.getChildCount(); for (int i = 0; i < childCount; i++) { final AccessibilityNodeInfoCompat child = node.getChild(i); if (child != null) { child.recycle(); return true; } } return false; }
From source file:com.android.utils.WebInterfaceUtils.java
/** * Determines whether or not the given node contains ChromeVox content. * * @param node The node to evaluate//from w w w .j a v a 2 s. co m * @return {@code true} if the node contains ChromeVox content, {@code false} otherwise */ public static boolean hasLegacyWebContent(AccessibilityNodeInfoCompat node) { if (node == null) { return false; } // TODO: Need better checking for native versus legacy web content. // Right now Firefox is accidentally treated as legacy web content using the current // detection routines; the `isNodeFromFirefox` check blacklists any Firefox that supports // the native web actions from being treated as "legacy" content. // Once we have resolved this issue, remove the `isNodeFromFirefox` disjunct from the check. if (!supportsWebActions(node) || isNodeFromFirefox(node)) { return false; } // ChromeVox does not have sub elements, so if the parent element also has web content // this cannot be ChromeVox. AccessibilityNodeInfoCompat parent = node.getParent(); if (supportsWebActions(parent)) { if (parent != null) { parent.recycle(); } return false; } if (parent != null) { parent.recycle(); } // ChromeVox never has child elements return node.getChildCount() == 0; }
From source file:assistive.com.scanme.com.googlecode.eyesfree.utils.AccessibilityNodeInfoUtils.java
/** * Determines whether a node is a top-level item in a scrollable container. * * @param node The node to test.//from ww w . ja va 2 s .c om * @return {@code true} if {@code node} is a top-level item in a scrollable * container. */ public static boolean isTopLevelScrollItem(Context context, AccessibilityNodeInfoCompat node) { if (node == null) { return false; } AccessibilityNodeInfoCompat parent = null; try { parent = node.getParent(); if (parent == null) { // Not a child node of anything. return false; } if (isScrollable(node)) { return true; } // AdapterView, ScrollView, and HorizontalScrollView are focusable // containers, but Spinner is a special case. // TODO: Rename or break up this method, since it actually returns // whether the parent is scrollable OR is a focusable container that // should not block its children from receiving focus. if (nodeMatchesAnyClassByType(context, parent, android.widget.AdapterView.class, android.widget.ScrollView.class, android.widget.HorizontalScrollView.class, CLASS_TOUCHWIZ_TWADAPTERVIEW) && !nodeMatchesAnyClassByType(context, parent, android.widget.Spinner.class)) { return true; } return false; } finally { recycleNodes(parent); } }