List of usage examples for android.view.accessibility AccessibilityNodeInfo findAccessibilityNodeInfosByText
public List<AccessibilityNodeInfo> findAccessibilityNodeInfosByText(String text)
From source file:Main.java
public static List<AccessibilityNodeInfo> findNodesByText(AccessibilityNodeInfo root, String text) { return root.findAccessibilityNodeInfosByText(text); }
From source file:Main.java
public static AccessibilityNodeInfo findNodeInfosByText(AccessibilityNodeInfo nodeInfo, String text) { List<AccessibilityNodeInfo> list = nodeInfo.findAccessibilityNodeInfosByText(text); if (list == null || list.isEmpty()) { return null; }//from w w w .ja va2s. c o m return list.get(0); }
From source file:Main.java
public static AccessibilityNodeInfo findNodeInfoByText(AccessibilityNodeInfo nodeInfo, String text) { List<AccessibilityNodeInfo> list = nodeInfo.findAccessibilityNodeInfosByText(text); if (list == null || list.isEmpty()) { return null; }/*w w w . j a va 2s . c o m*/ return list.get(0); }
From source file:Main.java
public static void findTextAndClick(AccessibilityService accessibilityService, String text) { AccessibilityNodeInfo accessibilityNodeInfo = accessibilityService.getRootInActiveWindow(); if (accessibilityNodeInfo == null) { return;/*from www . j a v a 2 s . co m*/ } List<AccessibilityNodeInfo> nodeInfoList = accessibilityNodeInfo.findAccessibilityNodeInfosByText(text); if (nodeInfoList != null && !nodeInfoList.isEmpty()) { for (AccessibilityNodeInfo nodeInfo : nodeInfoList) { if (nodeInfo != null && (text.equals(nodeInfo.getText()) || text.equals(nodeInfo.getContentDescription()))) { performClick(nodeInfo); break; } } } }
From source file:Main.java
@Nullable @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2) public static List<AccessibilityNodeInfo> getAccessibilityNodeInfos(AccessibilityEvent event, String[] ids, String[] texts) {/*from w w w.j a v a 2 s.co m*/ List<AccessibilityNodeInfo> result = null; AccessibilityNodeInfo source = event.getSource(); if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { if (ids != null && ids.length > 0) { for (String id : ids) { if (!TextUtils.isEmpty(id)) { result = source.findAccessibilityNodeInfosByViewId(id); if (result != null && result.size() > 0) { return result; } } } } } if (texts != null && texts.length > 0) { for (String text : texts) { if (!TextUtils.isEmpty(text)) { result = source.findAccessibilityNodeInfosByText(text); if (result != null && result.size() > 0) { return result; } } } } return result; }
From source file:com.googlecode.eyesfree.brailleback.IMEHelper.java
private void checkIMEPicker(AccessibilityEvent event) { if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED && "android".equals(event.getPackageName()) && "android.app.AlertDialog".equals(event.getClassName())) { AccessibilityNodeInfo node = event.getSource(); if (node == null) { return; }/* w w w . j a va2 s. com*/ String IMETitle = mContext.getString(R.string.braille_ime_name); List<AccessibilityNodeInfo> found = node.findAccessibilityNodeInfosByText(IMETitle); if (found.size() == 0) { return; } AccessibilityNodeInfo firstFound = found.get(0); AccessibilityNodeInfo toFocus = firstFound.getParent(); if (toFocus != null) { toFocus.performAction(AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS); } } }
From source file:com.linroid.pushapp.service.ApkAutoInstallService.java
/** * ?AccessibilityNodeInfo//from w ww. ja v a 2 s.co m * * @param event * @param text * @return */ private boolean hasAccessibilityNodeInfoByText(AccessibilityEvent event, String text) { List<AccessibilityNodeInfo> nodes = null; if (event != null && event.getSource() != null) { nodes = event.getSource().findAccessibilityNodeInfosByText(text); } else { AccessibilityNodeInfo info = getRootInActiveWindow(); if (info != null) { nodes = info.findAccessibilityNodeInfosByText(text); } } return !(nodes == null || nodes.size() <= 0); }
From source file:com.linroid.pushapp.service.ApkAutoInstallService.java
/** * ?AccessibilityNodeInfo // w w w .j av a 2s. c o m * * @param event * @param text * @return */ private AccessibilityNodeInfo getAccessibilityNodeInfoByText(AccessibilityEvent event, String text) { List<AccessibilityNodeInfo> nodes = null; // try-catch? event.getSource NullPointerException try { if (event != null && event.getSource() != null) { nodes = event.getSource().findAccessibilityNodeInfosByText(text); } } catch (Exception e) { } // ?else??? if (nodes == null || nodes.size() == 0) { AccessibilityNodeInfo info = getRootInActiveWindow(); if (info != null) { nodes = info.findAccessibilityNodeInfosByText(text); } } if (nodes != null && nodes.size() > 0) { for (AccessibilityNodeInfo nodeInfo : nodes) { String nodeText = nodeInfo.getText() == null ? BuildConfig.VERSION_NAME : nodeInfo.getText().toString(); //nodeInfo.getClassName().equals(className) && if (nodeText.equalsIgnoreCase(text)) { return nodeInfo; } nodeInfo.recycle(); } } return null; }
From source file:com.linroid.pushapp.service.ApkAutoInstallService.java
/** * ?/* ww w.j a v a 2 s .co m*/ * * @param info * @param text * @param isGlobalAction ? * @return ?? */ private boolean performEventAction(AccessibilityNodeInfo info, String text, boolean isGlobalAction) { if (info == null) { return false; } List<AccessibilityNodeInfo> nodes = info.findAccessibilityNodeInfosByText(text); if (nodes != null && nodes.size() > 0) { for (AccessibilityNodeInfo nodeInfo : nodes) { String nodeText = nodeInfo.getText() == null ? null : nodeInfo.getText().toString(); if (text.equalsIgnoreCase(nodeText)) { if (isGlobalAction) { // performGlobalAction(GLOBAL_ACTION_BACK); } else { performClick(nodeInfo); } return true; } nodeInfo.recycle(); } } return false; }
From source file:com.ucmap.dingdinghelper.services.DingDingHelperAccessibilityService.java
/** * AccessibilityNodeInfo,?// www .j a v a 2s.c o m * ? textAccessibilityNodeInfo * * @param text * @return */ private AccessibilityNodeInfo findByText(String text) { AccessibilityNodeInfo mAccessibilityNodeInfo = this.getRootInActiveWindow(); if (mAccessibilityNodeInfo == null) return null; List<AccessibilityNodeInfo> list = mAccessibilityNodeInfo.findAccessibilityNodeInfosByText(text); if (list == null || list.isEmpty()) return null; return list.get(0); }