Example usage for android.view.accessibility AccessibilityNodeInfo performAction

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

Introduction

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

Prototype

public boolean performAction(int action) 

Source Link

Document

Performs an action on the node.

Usage

From source file:Main.java

public static void performClick(AccessibilityNodeInfo nodeInfo) {
    if (nodeInfo == null) {
        return;//from  w ww.  j a  va  2 s  .  com
    }
    if (nodeInfo.isClickable()) {
        nodeInfo.performAction(AccessibilityNodeInfo.ACTION_CLICK);
    } else {
        performClick(nodeInfo.getParent());
    }
}

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  av  a2s .c  o m*/
        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.android.switchaccess.test.ShadowAccessibilityNodeInfoCompat.java

@Implementation
public boolean performAction(int action) {
    final AccessibilityNodeInfo info = (AccessibilityNodeInfo) mRealObject.getInfo();
    return info.performAction(action);
}

From source file:com.google.android.marvin.mytalkback.CursorController.java

/**
 * Clears the current cursor position./*  ww  w.j a  v a  2 s .  c o  m*/
 */
public void clearCursor() {
    final AccessibilityNodeInfo root = mService.getRootInActiveWindow();
    if (root == null) {
        return;
    }

    final AccessibilityNodeInfo focused = root.findFocus(AccessibilityNodeInfo.FOCUS_ACCESSIBILITY);
    if (focused == null) {
        return;
    }

    focused.performAction(AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS);
}

From source file:com.linroid.pushapp.service.ApkAutoInstallService.java

/**
 * ?//ww w.  j a v a 2 s  .c  om
 *
 * @param node
 * @return ??
 */
private boolean performClick(AccessibilityNodeInfo node) {
    return node != null && node.isEnabled() && node.isClickable()
            && node.performAction(AccessibilityNodeInfo.ACTION_CLICK);
}

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

/**
 * ID?/*from   w  w w. j  a  v a2 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 performWaitCheckIn() {

    AccessibilityNodeInfo mAccessibilityNodeInfo = this.getRootInActiveWindow();
    if (mAccessibilityNodeInfo == null)
        return;//from ww w .  j  a v a2  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 switchMine() {
    if (STATE != STATE_CHECKED_IN)
        return;/*w ww . j a  v  a  2s .  c om*/
    AccessibilityNodeInfo mAccessibilityNodeInfo = findById(HOME_MINE_ID);
    if (mAccessibilityNodeInfo == null)
        return;
    mAccessibilityNodeInfo.performAction(AccessibilityNodeInfo.ACTION_CLICK);
    CURRENT_PAGER = MINE_PAGER;
}

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

private void doQuit() {
    AccessibilityNodeInfo mAccessibilityNodeInfo = findById(CONFIRM_QUIT_ID);
    if (mAccessibilityNodeInfo != null && mAccessibilityNodeInfo.isClickable()) {
        STATE = STATE_RELEASE;/*from   w  w w .ja  va 2s.c om*/
        mAccessibilityNodeInfo.performAction(AccessibilityNodeInfo.ACTION_CLICK);
        isChecking = false;
        if (mAccountEntities == null)
            return;
        if (index >= mAccountEntities.size()) {
            String[] hm = DateUtils.getHourAndMin(System.currentTimeMillis()).split(":");
            if (Integer.parseInt(hm[0]) > TIME_LIMIT) {
                index = 0;
                targetCheckInAcount = mAccountEntities.get(index++);
            }
            closeHelperService();
            return;
        }

        doScript();

        if (STATE == STATE_UNCHECKED_IN) {
            toSignIn();
        }

    }
}

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

private void toSignIn() {
    AccessibilityNodeInfo mAccessibilityNodeInfo = this.getRootInActiveWindow();
    if (mAccessibilityNodeInfo == null)
        return;//  w w w .j a va2s . c om
    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);
}