Example usage for android.view.accessibility AccessibilityNodeInfo ACTION_PREVIOUS_HTML_ELEMENT

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

Introduction

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

Prototype

int ACTION_PREVIOUS_HTML_ELEMENT

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

Click Source Link

Document

Action to move to the previous HTML element of a given type.

Usage

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);/*from w  w  w  .ja  v  a2s  . c  o 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;
    }/*from  ww w.j  a v  a2s .  co  m*/

    return false;
}

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

/**
 * Packs an accessibility action into a JSON object and sends it to AndroidVox.
 *
 * @param action The action identifier./*from ww  w.  j a va2s . co  m*/
 * @param arguments The action arguments, if applicable.
 * @return The result of the action.
 */
private boolean sendActionToAndroidVox(int action, Bundle arguments) {
    if (mCallback == null)
        return false;
    if (mAccessibilityJSONObject == null) {
        mAccessibilityJSONObject = new JSONObject();
    } else {
        // Remove all keys from the object.
        final Iterator<?> keys = mAccessibilityJSONObject.keys();
        while (keys.hasNext()) {
            keys.next();
            keys.remove();
        }
    }

    try {
        mAccessibilityJSONObject.accumulate("action", action);
        if (arguments != null) {
            if (action == AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY
                    || action == AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY) {
                final int granularity = arguments
                        .getInt(AccessibilityNodeInfo.ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT);
                mAccessibilityJSONObject.accumulate("granularity", granularity);
            } else if (action == AccessibilityNodeInfo.ACTION_NEXT_HTML_ELEMENT
                    || action == AccessibilityNodeInfo.ACTION_PREVIOUS_HTML_ELEMENT) {
                final String element = arguments
                        .getString(AccessibilityNodeInfo.ACTION_ARGUMENT_HTML_ELEMENT_STRING);
                mAccessibilityJSONObject.accumulate("element", element);
            }
        }
    } catch (JSONException ex) {
        return false;
    }

    final String jsonString = mAccessibilityJSONObject.toString();
    final String jsCode = String.format(ACCESSIBILITY_ANDROIDVOX_TEMPLATE, jsonString);
    return mCallback.performAction(mContentViewCore, jsCode);
}

From source file:android.webkit.AccessibilityInjector.java

/**
 * Initializes an {@link AccessibilityNodeInfo} with the actions and
 * movement granularity levels supported by this
 * {@link AccessibilityInjector}./*  w ww . j a v a2  s .  c o  m*/
 * <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   www . j a  v  a 2 s.c om
 *
 * @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:android.webkit.AccessibilityInjector.java

/**
 * Packs an accessibility action into a JSON object and sends it to AndroidVox.
 *
 * @param action The action identifier.//  w  w  w . j a v  a  2 s.c o m
 * @param arguments The action arguments, if applicable.
 * @return The result of the action.
 */
private boolean sendActionToAndroidVox(int action, Bundle arguments) {
    if (mAccessibilityJSONObject == null) {
        mAccessibilityJSONObject = new JSONObject();
    } else {
        // Remove all keys from the object.
        final Iterator<?> keys = mAccessibilityJSONObject.keys();
        while (keys.hasNext()) {
            keys.next();
            keys.remove();
        }
    }

    try {
        mAccessibilityJSONObject.accumulate("action", action);

        switch (action) {
        case AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY:
        case AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY:
            if (arguments != null) {
                final int granularity = arguments
                        .getInt(AccessibilityNodeInfo.ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT);
                mAccessibilityJSONObject.accumulate("granularity", granularity);
            }
            break;
        case AccessibilityNodeInfo.ACTION_NEXT_HTML_ELEMENT:
        case AccessibilityNodeInfo.ACTION_PREVIOUS_HTML_ELEMENT:
            if (arguments != null) {
                final String element = arguments
                        .getString(AccessibilityNodeInfo.ACTION_ARGUMENT_HTML_ELEMENT_STRING);
                mAccessibilityJSONObject.accumulate("element", element);
            }
            break;
        }
    } catch (JSONException e) {
        return false;
    }

    final String jsonString = mAccessibilityJSONObject.toString();
    final String jsCode = String.format(ACCESSIBILITY_ANDROIDVOX_TEMPLATE, jsonString);
    return mCallback.performAction(mWebView, jsCode);
}