Example usage for android.view.accessibility AccessibilityNodeInfo findAccessibilityNodeInfosByViewId

List of usage examples for android.view.accessibility AccessibilityNodeInfo findAccessibilityNodeInfosByViewId

Introduction

In this page you can find the example usage for android.view.accessibility AccessibilityNodeInfo findAccessibilityNodeInfosByViewId.

Prototype

public List<AccessibilityNodeInfo> findAccessibilityNodeInfosByViewId(String viewId) 

Source Link

Document

Finds AccessibilityNodeInfo s by the fully qualified view id's resource name where a fully qualified id is of the from "package:id/id_resource_name".

Usage

From source file:Main.java

public static AccessibilityNodeInfo findNodeInfoById(AccessibilityNodeInfo nodeInfo, String Id) {
    List<AccessibilityNodeInfo> nodeInfos = nodeInfo.findAccessibilityNodeInfosByViewId(Id);
    if (nodeInfos.size() == 0) {
        return null;
    }//from  www  .j av  a  2 s .  c o  m
    return nodeInfo.findAccessibilityNodeInfosByViewId(Id).get(0);
}

From source file:Main.java

public static AccessibilityNodeInfo findNodeInfosById(AccessibilityNodeInfo nodeInfo, String resId) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
        List<AccessibilityNodeInfo> list = nodeInfo.findAccessibilityNodeInfosByViewId(resId);
        if (list != null && !list.isEmpty()) {
            return list.get(0);
        }//from   ww w.  ja  v a 2s . com
    }
    return null;
}

From source file:Main.java

public static void findViewIdAndClick(AccessibilityService accessibilityService, String id) {

    AccessibilityNodeInfo accessibilityNodeInfo = accessibilityService.getRootInActiveWindow();
    if (accessibilityNodeInfo == null) {
        return;/*w w w .j a  v  a2  s.c om*/
    }

    List<AccessibilityNodeInfo> nodeInfoList = accessibilityNodeInfo.findAccessibilityNodeInfosByViewId(id);
    if (nodeInfoList != null && !nodeInfoList.isEmpty()) {
        for (AccessibilityNodeInfo nodeInfo : nodeInfoList) {
            if (nodeInfo != null) {
                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  ww  .  ja va  2  s .  c  o 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.ucmap.dingdinghelper.services.DingDingHelperAccessibilityService.java

/**
 * ID?//from  ww  w.j a va 2  s  .  co m
 *
 * @param clickId
 */
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
private void inputClick(String clickId) {
    AccessibilityNodeInfo nodeInfo = getRootInActiveWindow();
    if (nodeInfo != null) {
        List<AccessibilityNodeInfo> list = nodeInfo.findAccessibilityNodeInfosByViewId(clickId);
        for (AccessibilityNodeInfo item : list) {
            item.performAction(AccessibilityNodeInfo.ACTION_CLICK);
        }
    }
}

From source file:com.ucmap.dingdinghelper.services.DingDingHelperAccessibilityService.java

private void setCurrentPagerId() {

    List<AccessibilityNodeInfo> listMine = null;
    AccessibilityNodeInfo mAccessibilityNodeInfo = getRootInActiveWindow();
    if (mAccessibilityNodeInfo == null)
        return;/*from w  w  w . j  a  v a  2s . co  m*/
    listMine = mAccessibilityNodeInfo.findAccessibilityNodeInfosByViewId(HEADER_MINE_ID);
    if (listMine != null && !listMine.isEmpty()) {
        CURRENT_PAGER = MINE_PAGER;
        return;
    }

    List<AccessibilityNodeInfo> listConstact = mAccessibilityNodeInfo
            .findAccessibilityNodeInfosByViewId(HEADER_CONTACT_ID);
    if (listConstact != null && !listConstact.isEmpty()) {
        CURRENT_PAGER = CONTACT_PAGER;
        return;
    }

    List<AccessibilityNodeInfo> listCompany = mAccessibilityNodeInfo
            .findAccessibilityNodeInfosByViewId(TAB_COMPANY_INDEX_ID);
    if (listCompany != null && !listCompany.isEmpty()) {
        CURRENT_PAGER = TCN_PAGER;
        return;
    }
    List<AccessibilityNodeInfo> listDing = mAccessibilityNodeInfo
            .findAccessibilityNodeInfosByViewId(HEADER_DING);
    if (listDing != null && !listDing.isEmpty()) {
        CURRENT_PAGER = DING_PAGER;
        return;
    }
    List<AccessibilityNodeInfo> listMessage = mAccessibilityNodeInfo
            .findAccessibilityNodeInfosByViewId(HEADER_MESSAGE);
    if (listMessage != null && !listMessage.isEmpty()) {
        CURRENT_PAGER = MESSAGE_PAGER;
        return;
    }

}

From source file:com.ucmap.dingdinghelper.services.DingDingHelperAccessibilityService.java

private AccessibilityNodeInfo findById(String id) {
    AccessibilityNodeInfo mAccessibilityNodeInfo = this.getRootInActiveWindow();
    if (mAccessibilityNodeInfo == null)
        return null;
    List<AccessibilityNodeInfo> mNodeInfos = mAccessibilityNodeInfo.findAccessibilityNodeInfosByViewId(id);
    if (mNodeInfos == null || mNodeInfos.isEmpty())
        return null;
    return mNodeInfos.get(0);
}

From source file:com.ucmap.dingdinghelper.services.DingDingHelperAccessibilityService.java

private void performWaitCheckIn() {

    AccessibilityNodeInfo mAccessibilityNodeInfo = this.getRootInActiveWindow();
    if (mAccessibilityNodeInfo == null)
        return;//from   ww  w  .  j a va  2  s.c  o  m
    List<AccessibilityNodeInfo> mNodeInfos = mAccessibilityNodeInfo
            .findAccessibilityNodeInfosByViewId(HOME_BOTTOM_WORK_ID);
    if (mNodeInfos == null || mNodeInfos.isEmpty())
        return;
    /*?Bottom*/
    AccessibilityNodeInfo mNodeInfoBottomWork = mNodeInfos.get(0);
    if (mNodeInfoBottomWork.isClickable()) {
        mNodeInfoBottomWork.performAction(AccessibilityNodeInfo.ACTION_CLICK);
        CURRENT_PAGER = TCN_PAGER;
    }

}

From source file:com.ucmap.dingdinghelper.services.DingDingHelperAccessibilityService.java

private void toSignIn() {
    AccessibilityNodeInfo mAccessibilityNodeInfo = this.getRootInActiveWindow();
    if (mAccessibilityNodeInfo == null)
        return;/*from   w w w .  jav a  2 s.  co m*/
    List<AccessibilityNodeInfo> mEdPhoneNodes = mAccessibilityNodeInfo
            .findAccessibilityNodeInfosByViewId(PHONE_ID);
    if (mEdPhoneNodes == null || mEdPhoneNodes.isEmpty())
        return;
    isChecking = true;
    AccessibilityNodeInfo mEdPhoneNode = mEdPhoneNodes.get(0);
    CharSequence mCharSequence = mEdPhoneNode.getText();

    if (mCharSequence != null && !mCharSequence.toString().equals(targetCheckInAcount.getAccount())) {
        mEdPhoneNode.performAction(AccessibilityNodeInfo.ACTION_FOCUS);//?
        Rect mRect = new Rect();
        mEdPhoneNode.getBoundsInScreen(mRect);
        doShellCmdInputTap(mRect.right - 10, mRect.centerY());
        setTextToView(mEdPhoneNode, "");
        setTextToView(mEdPhoneNode, targetCheckInAcount.getAccount());
    }

    List<AccessibilityNodeInfo> mEdPasswordNodes = mAccessibilityNodeInfo
            .findAccessibilityNodeInfosByViewId(PASSWORD_ID);
    if (mEdPasswordNodes == null)
        return;
    AccessibilityNodeInfo mEdPasswordNode = mEdPasswordNodes.get(0);
    CharSequence mCharSequencePassword = mEdPasswordNode.getText();
    setTextToView(mEdPasswordNode, "");
    setTextToView(mEdPasswordNode, targetCheckInAcount.getPassword());

    /*?*/
    inputClick(BUTTON_ID);
}