Example usage for android.view.accessibility AccessibilityNodeInfo ACTION_CLICK

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

Introduction

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

Prototype

int ACTION_CLICK

To view the source code for android.view.accessibility AccessibilityNodeInfo ACTION_CLICK.

Click Source Link

Document

Action that clicks on the node info.

Usage

From source file:Main.java

public static void performClick(AccessibilityNodeInfo nodeInfo) {
    if (nodeInfo == null) {
        return;//ww w.  ja va  2 s . c o  m
    }
    if (nodeInfo.isClickable()) {
        nodeInfo.performAction(AccessibilityNodeInfo.ACTION_CLICK);
    } else {
        performClick(nodeInfo.getParent());
    }
}

From source file:org.chromium.content.browser.accessibility.JellyBeanAccessibilityInjector.java

@Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
    info.setMovementGranularities(AccessibilityNodeInfo.MOVEMENT_GRANULARITY_CHARACTER
            | AccessibilityNodeInfo.MOVEMENT_GRANULARITY_WORD | AccessibilityNodeInfo.MOVEMENT_GRANULARITY_LINE
            | AccessibilityNodeInfo.MOVEMENT_GRANULARITY_PARAGRAPH
            | AccessibilityNodeInfo.MOVEMENT_GRANULARITY_PAGE);
    info.addAction(AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY);
    info.addAction(AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY);
    info.addAction(AccessibilityNodeInfo.ACTION_NEXT_HTML_ELEMENT);
    info.addAction(AccessibilityNodeInfo.ACTION_PREVIOUS_HTML_ELEMENT);
    info.addAction(AccessibilityNodeInfo.ACTION_CLICK);
    info.setClickable(true);/*w w w  . j  a  va 2  s.  co m*/
}

From source file:org.chromium.content.browser.accessibility.JellyBeanAccessibilityInjector.java

@Override
public boolean supportsAccessibilityAction(int action) {
    if (action == AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY
            || action == AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY
            || action == AccessibilityNodeInfo.ACTION_NEXT_HTML_ELEMENT
            || action == AccessibilityNodeInfo.ACTION_PREVIOUS_HTML_ELEMENT
            || action == AccessibilityNodeInfo.ACTION_CLICK) {
        return true;
    }// www  .  j  av a 2s . c  o  m

    return false;
}

From source file:android.webkit.AccessibilityInjector.java

/**
 * Initializes an {@link AccessibilityNodeInfo} with the actions and
 * movement granularity levels supported by this
 * {@link AccessibilityInjector}./*  www.  ja va  2 s .  c om*/
 * <p>
 * If an action identifier is added in this method, this
 * {@link AccessibilityInjector} should also return {@code true} from
 * {@link #supportsAccessibilityAction(int)}.
 * </p>
 *
 * @param info The info to initialize.
 * @see View#onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo)
 */
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
    info.setMovementGranularities(AccessibilityNodeInfo.MOVEMENT_GRANULARITY_CHARACTER
            | AccessibilityNodeInfo.MOVEMENT_GRANULARITY_WORD | AccessibilityNodeInfo.MOVEMENT_GRANULARITY_LINE
            | AccessibilityNodeInfo.MOVEMENT_GRANULARITY_PARAGRAPH
            | AccessibilityNodeInfo.MOVEMENT_GRANULARITY_PAGE);
    info.addAction(AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY);
    info.addAction(AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY);
    info.addAction(AccessibilityNodeInfo.ACTION_NEXT_HTML_ELEMENT);
    info.addAction(AccessibilityNodeInfo.ACTION_PREVIOUS_HTML_ELEMENT);
    info.addAction(AccessibilityNodeInfo.ACTION_CLICK);
    info.setClickable(true);
}

From source file:android.webkit.AccessibilityInjector.java

/**
 * Returns {@code true} if this {@link AccessibilityInjector} should handle
 * the specified action.//from   w  w  w  .j  a  v  a  2  s . co  m
 *
 * @param action An accessibility action identifier.
 * @return {@code true} if this {@link AccessibilityInjector} should handle
 *         the specified action.
 */
public boolean supportsAccessibilityAction(int action) {
    switch (action) {
    case AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY:
    case AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY:
    case AccessibilityNodeInfo.ACTION_NEXT_HTML_ELEMENT:
    case AccessibilityNodeInfo.ACTION_PREVIOUS_HTML_ELEMENT:
    case AccessibilityNodeInfo.ACTION_CLICK:
        return true;
    default:
        return false;
    }
}

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;/* w  w w  .j  ava 2 s.  c o  m*/
        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 switchMine() {
    if (STATE != STATE_CHECKED_IN)
        return;/* w w w  .  j  a  v a  2 s  . 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.googlecode.eyesfree.brailleback.DefaultNavigationMode.java

private boolean activateNode(AccessibilityNodeInfoCompat node, int position) {
    if (node == null) {
        return false;
    }//from   w ww .  j  a  v a  2s.  com
    AccessibilityNodeInfoRef current = AccessibilityNodeInfoRef.unOwned(node);
    try {
        do {
            LogUtils.log(this, Log.VERBOSE, "Considering to click: %s", current.get().getInfo());
            int supportedActions = current.get().getActions();
            int action = 0;
            // For edit texts, the click action doesn't currently focus
            // the view, so we special case it here.
            // TODO: Revise when that changes.
            if (AccessibilityNodeInfoUtils.nodeMatchesClassByType(mAccessibilityService, current.get(),
                    EditText.class)) {
                if ((supportedActions & AccessibilityNodeInfo.ACTION_FOCUS) != 0) {
                    action = AccessibilityNodeInfo.ACTION_FOCUS;
                } else {
                    // Put accessibility focus on the field.  If it is
                    // already focused and the IME is selected, that will
                    // activate the editing.
                    action = AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS;
                }
            } else if (position >= 0 && isSelfBrailled(current.get())
                    && (supportedActions & AccessibilityNodeInfo.ACTION_CLICK) != 0) {
                // Generate a fake "action". For instance, a click at
                // position 33 maps to -275000033.
                // TODO: Remove this hack when a better way to pass this
                // information exists.
                int fakeAction = ACTION_BRAILLE_CLICK_MAX - position;
                if (fakeAction < ACTION_BRAILLE_CLICK_MIN) {
                    LogUtils.log(this, Log.WARN, "underflow activating node %s at position %d", current.get(),
                            position);
                    fakeAction = ACTION_BRAILLE_CLICK_MIN;
                } else if (fakeAction > ACTION_BRAILLE_CLICK_MAX) {
                    LogUtils.log(this, Log.WARN, "overflow activating node %s at position %d", current.get(),
                            position);
                    fakeAction = ACTION_BRAILLE_CLICK_MAX;
                }
                if (WebInterfaceUtils.performSpecialAction(current.get(), fakeAction)) {
                    return true;
                }
            } else if ((supportedActions & AccessibilityNodeInfo.ACTION_CLICK) != 0) {
                action = AccessibilityNodeInfo.ACTION_CLICK;
            }
            if (action != 0 && current.get().performAction(action)) {
                return true;
            } else {
                LogUtils.log(this, Log.VERBOSE, "Action %d failed", action);
            }
        } while (current.parent());
    } finally {
        current.recycle();
    }
    LogUtils.log(this, Log.VERBOSE, "Click action failed");
    return false;
}

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  va2  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.linroid.pushapp.service.ApkAutoInstallService.java

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