Java Code Examples for android.support.v4.view.accessibility.AccessibilityNodeInfoCompat#ACTION_NEXT_HTML_ELEMENT

The following examples show how to use android.support.v4.view.accessibility.AccessibilityNodeInfoCompat#ACTION_NEXT_HTML_ELEMENT . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AssetManager.java    From Android-SudoInstaller with MIT License 5 votes vote down vote up
private static void copyFile(InputStream in, OutputStream out) throws IOException {
    byte[] buffer = new byte[AccessibilityNodeInfoCompat.ACTION_NEXT_HTML_ELEMENT];
    while (true) {
        int read = in.read(buffer);
        if (read != -1) {
            out.write(buffer, 0, read);
        } else {
            return;
        }
    }
}
 
Example 2
Source File: AccessibilityNodeInfoWrapper.java    From stetho with MIT License 4 votes vote down vote up
@Nullable
public static String getActions(View view) {
  AccessibilityNodeInfoCompat node = createNodeInfoFromView(view);
  try {
    final StringBuilder actionLabels = new StringBuilder();
    final String separator = ", ";

    for (AccessibilityActionCompat action : node.getActionList()) {
      if (actionLabels.length() > 0) {
        actionLabels.append(separator);
      }
      switch (action.getId()) {
        case AccessibilityNodeInfoCompat.ACTION_FOCUS:
          actionLabels.append("focus");
          break;
        case AccessibilityNodeInfoCompat.ACTION_CLEAR_FOCUS:
          actionLabels.append("clear-focus");
          break;
        case AccessibilityNodeInfoCompat.ACTION_SELECT:
          actionLabels.append("select");
          break;
        case AccessibilityNodeInfoCompat.ACTION_CLEAR_SELECTION:
          actionLabels.append("clear-selection");
          break;
        case AccessibilityNodeInfoCompat.ACTION_CLICK:
          actionLabels.append("click");
          break;
        case AccessibilityNodeInfoCompat.ACTION_LONG_CLICK:
          actionLabels.append("long-click");
          break;
        case AccessibilityNodeInfoCompat.ACTION_ACCESSIBILITY_FOCUS:
          actionLabels.append("accessibility-focus");
          break;
        case AccessibilityNodeInfoCompat.ACTION_CLEAR_ACCESSIBILITY_FOCUS:
          actionLabels.append("clear-accessibility-focus");
          break;
        case AccessibilityNodeInfoCompat.ACTION_NEXT_AT_MOVEMENT_GRANULARITY:
          actionLabels.append("next-at-movement-granularity");
          break;
        case AccessibilityNodeInfoCompat.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY:
          actionLabels.append("previous-at-movement-granularity");
          break;
        case AccessibilityNodeInfoCompat.ACTION_NEXT_HTML_ELEMENT:
          actionLabels.append("next-html-element");
          break;
        case AccessibilityNodeInfoCompat.ACTION_PREVIOUS_HTML_ELEMENT:
          actionLabels.append("previous-html-element");
          break;
        case AccessibilityNodeInfoCompat.ACTION_SCROLL_FORWARD:
          actionLabels.append("scroll-forward");
          break;
        case AccessibilityNodeInfoCompat.ACTION_SCROLL_BACKWARD:
          actionLabels.append("scroll-backward");
          break;
        case AccessibilityNodeInfoCompat.ACTION_CUT:
          actionLabels.append("cut");
          break;
        case AccessibilityNodeInfoCompat.ACTION_COPY:
          actionLabels.append("copy");
          break;
        case AccessibilityNodeInfoCompat.ACTION_PASTE:
          actionLabels.append("paste");
          break;
        case AccessibilityNodeInfoCompat.ACTION_SET_SELECTION:
          actionLabels.append("set-selection");
          break;
        default:
          CharSequence label = action.getLabel();
          if (label != null) {
            actionLabels.append(label);
          } else {
            actionLabels.append("unknown");
          }
          break;
      }
    }

    return actionLabels.length() > 0 ? actionLabels.toString() : null;
  } finally {
    node.recycle();
  }
}
 
Example 3
Source File: WebInterfaceUtils.java    From brailleback with Apache License 2.0 3 votes vote down vote up
/**
 * Sends an instruction to ChromeVox to read the specified HTML element in
 * the given direction within a node.
 * <p>
 * WARNING: Calling this method with a source node of
 * {@link android.webkit.WebView} has the side effect of closing the IME
 * if currently displayed.
 *
 * @param node The node containing web content with ChromeVox to which the
 *            message should be sent
 * @param direction {@link #DIRECTION_FORWARD} or
 *            {@link #DIRECTION_BACKWARD}
 * @param htmlElement The HTML tag to send
 * @return {@code true} if the action was performed, {@code false}
 *         otherwise.
 */
public static boolean performNavigationToHtmlElementAction(
        AccessibilityNodeInfoCompat node, int direction, String htmlElement) {
    final int action = (direction == DIRECTION_FORWARD)
            ? AccessibilityNodeInfoCompat.ACTION_NEXT_HTML_ELEMENT
            : AccessibilityNodeInfoCompat.ACTION_PREVIOUS_HTML_ELEMENT;
    final Bundle args = new Bundle();
    args.putString(
            AccessibilityNodeInfoCompat.ACTION_ARGUMENT_HTML_ELEMENT_STRING, htmlElement);
    return node.performAction(action, args);
}
 
Example 4
Source File: WebInterfaceUtils.java    From brailleback with Apache License 2.0 3 votes vote down vote up
/**
 * Sends an instruction to ChromeVox to navigate by DOM object in
 * the given direction within a node.
 *
 * @param node The node containing web content with ChromeVox to which the
 *            message should be sent
 * @param direction {@link #DIRECTION_FORWARD} or
 *            {@link #DIRECTION_BACKWARD}
 * @return {@code true} if the action was performed, {@code false}
 *         otherwise.
 */
public static boolean performNavigationByDOMObject(
        AccessibilityNodeInfoCompat node, int direction) {
    final int action = (direction == DIRECTION_FORWARD)
            ? AccessibilityNodeInfoCompat.ACTION_NEXT_HTML_ELEMENT
            : AccessibilityNodeInfoCompat.ACTION_PREVIOUS_HTML_ELEMENT;
    return node.performAction(action);
}