Example usage for android.view.accessibility AccessibilityNodeInfo ACTION_ARGUMENT_HTML_ELEMENT_STRING

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

Introduction

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

Prototype

String ACTION_ARGUMENT_HTML_ELEMENT_STRING

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

Click Source Link

Document

Argument for which HTML element to get moving to the next/previous HTML element.

Usage

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 . jav  a  2  s.  c om
 * @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

/**
 * Packs an accessibility action into a JSON object and sends it to AndroidVox.
 *
 * @param action The action identifier./*from   w  w w.java  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);
}