List of usage examples for android.view.accessibility AccessibilityNodeInfo getChildCount
public int getChildCount()
From source file:org.sufficientlysecure.keychain.gm.GmAccessibilityService.java
private void findPgpNodeInfo(AccessibilityNodeInfo parent, ArrayList<AccessibilityNodeInfo> pgpNodes) { for (int i = 0; i < parent.getChildCount(); i++) { AccessibilityNodeInfo currentChild = parent.getChild(i); /*/* www . j a v a2s. co m*/ WebView |- WebView |- View |- View |- View */ if (WEB_VIEW_CLASS_NAME.equals(parent.getClassName()) && VIEW_CLASS_NAME.equals(currentChild.getClassName()) && !TextUtils.isEmpty(currentChild.getContentDescription()) && currentChild.getContentDescription().toString().startsWith(BEGIN_PGP_MESSAGE)) { pgpNodes.add(currentChild); } else { // recursive traversal findPgpNodeInfo(currentChild, pgpNodes); currentChild.recycle(); } } }
From source file:com.googlecode.eyesfree.brailleback.TreeDebugNavigationMode.java
private AccessibilityNodeInfo getFirstChild(AccessibilityNodeInfo from) { if (from.getChildCount() < 1) { return null; }/*w w w. j a v a 2 s . c o m*/ return from.getChild(0); }
From source file:com.googlecode.eyesfree.brailleback.TreeDebugNavigationMode.java
private AccessibilityNodeInfo getLastChild(AccessibilityNodeInfo from) { if (from.getChildCount() < 1) { return null; }//from ww w . j ava 2 s . c o m return from.getChild(from.getChildCount() - 1); }
From source file:com.googlecode.eyesfree.brailleback.TreeDebugNavigationMode.java
private AccessibilityNodeInfo getNextSibling(AccessibilityNodeInfo from) { AccessibilityNodeInfo parent = from.getParent(); if (parent == null) { return null; }/*from ww w .ja va2 s.co m*/ AccessibilityNodeInfo cur = null; try { int childCount = parent.getChildCount(); for (int i = 0; i < childCount - 1; ++i) { cur = parent.getChild(i); if (cur == null) { return null; } if (cur.equals(from)) { return parent.getChild(i + 1); } if (cur != null) { cur.recycle(); cur = null; } } } finally { parent.recycle(); if (cur != null) { cur.recycle(); } } return null; }
From source file:com.googlecode.eyesfree.brailleback.TreeDebugNavigationMode.java
private AccessibilityNodeInfo getPreviousSibling(AccessibilityNodeInfo from) { AccessibilityNodeInfo ret = null;/* w w w. j a va 2 s.c o m*/ AccessibilityNodeInfo parent = from.getParent(); if (parent == null) { return null; } AccessibilityNodeInfo prev = null; AccessibilityNodeInfo cur = null; try { int childCount = parent.getChildCount(); for (int i = 0; i < childCount; ++i) { cur = parent.getChild(i); if (cur == null) { return null; } if (cur.equals(from)) { ret = prev; prev = null; return ret; } if (prev != null) { prev.recycle(); } prev = cur; cur = null; } } finally { parent.recycle(); if (prev != null) { prev.recycle(); } if (cur != null) { cur.recycle(); } } return ret; }
From source file:com.googlecode.eyesfree.brailleback.TreeDebugNavigationMode.java
private void printNodeTree(AccessibilityNodeInfo node, String indent, HashSet<AccessibilityNodeInfo> seen) { if (node == null) { return;/* w w w. j ava2 s.c o m*/ } if (!seen.add(node)) { LogUtils.log(this, Log.VERBOSE, "Cycle: %d", node.hashCode()); return; } // Include the hash code as a "poor man's" id, knowing that it // might not always be unique. LogUtils.log(this, Log.VERBOSE, "%s(%d)%s", indent, node.hashCode(), formatNode(node)); int childCount = node.getChildCount(); String childIndent = indent + " "; for (int i = 0; i < childCount; ++i) { AccessibilityNodeInfo child = node.getChild(i); if (child == null) { LogUtils.log(this, Log.VERBOSE, "%sCouldn't get child %d", indent, i); continue; } printNodeTree(child, childIndent, seen); } }
From source file:com.ucmap.dingdinghelper.services.DingDingHelperAccessibilityService.java
/** * AccessibilityNodeInfo ?webView /*from w w w .j a v a 2s . com*/ * * * @param target * @param accessibilityNodeInfo * @return */ private AccessibilityNodeInfo recurseFindByText(String target, AccessibilityNodeInfo accessibilityNodeInfo) { if (accessibilityNodeInfo != null && accessibilityNodeInfo.getChildCount() == 0) { if ((target.equals(accessibilityNodeInfo.getText()) || target.equals(accessibilityNodeInfo.getContentDescription()))) return accessibilityNodeInfo; else return null; } else { if (accessibilityNodeInfo == null) return null; for (int i = 0; i < accessibilityNodeInfo.getChildCount(); i++) { AccessibilityNodeInfo child = accessibilityNodeInfo.getChild(i); AccessibilityNodeInfo isTaget = recurseFindByText(target, child); if (isTaget == null) continue; else return isTaget; } return null; } }
From source file:com.ucmap.dingdinghelper.services.DingDingHelperAccessibilityService.java
/** * *//*from w w w . j a v a2 s . c om*/ public void recycle(AccessibilityNodeInfo info, String target, boolean isClickSelft) { int temp = 0; if (info != null && info.getChildCount() == 0) { if (info.getContentDescription() != null && info.getContentDescription().toString().equals(target) && isClickSelft) { String content = info.getContentDescription().toString(); info.performAction(AccessibilityNodeInfo.ACTION_CLICK); if (content.equals(AFTER_WORK)) handleIt(info); else if (content.equals(GO_TO_WORK)) handleGoToWork(info); return; } if (info.getText() != null) { if (target.equals(info.getText().toString())) { if (isClickSelft) { info.performAction(AccessibilityNodeInfo.ACTION_CLICK); return; } AccessibilityNodeInfo parent = info.getParent(); while (parent != null) { if (parent.isClickable()) { parent.performAction(AccessibilityNodeInfo.ACTION_CLICK); break; } parent = parent.getParent(); } } } } else { for (int i = 0; info != null && i < info.getChildCount(); i++) { if (info.getChild(i) != null) { temp = i; recycle(info.getChild(i), target, isClickSelft); } } } }
From source file:com.ucmap.dingdinghelper.services.DingDingHelperAccessibilityService.java
/** * AccessibilityNodeInfo ?webView // w w w . java 2 s . c o 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; } }