Java Code Examples for androidx.core.view.accessibility.AccessibilityNodeInfoCompat#getExtras()

The following examples show how to use androidx.core.view.accessibility.AccessibilityNodeInfoCompat#getExtras() . 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: WebInterfaceUtils.java    From talkback with Apache License 2.0 6 votes vote down vote up
public static String @Nullable [] getSupportedHtmlElements(AccessibilityNodeInfoCompat node) {
  HashSet<AccessibilityNodeInfoCompat> visitedNodes = new HashSet<AccessibilityNodeInfoCompat>();

  while (node != null) {
    if (visitedNodes.contains(node)) {
      return null;
    }

    visitedNodes.add(node);

    Bundle bundle = node.getExtras();
    CharSequence supportedHtmlElements =
        bundle.getCharSequence(ACTION_ARGUMENT_HTML_ELEMENT_STRING_VALUES);

    if (supportedHtmlElements != null) {
      return supportedHtmlElements.toString().split(",");
    }

    node = node.getParent();
  }

  return null;
}
 
Example 2
Source File: AccessibilityNodeInfoUtils.java    From talkback with Apache License 2.0 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.O)
public static CharSequence getHintText(AccessibilityNodeInfoCompat node) {
  CharSequence hintText = node.getHintText();
  if (TextUtils.isEmpty(hintText)) {
    Bundle bundle = node.getExtras();
    if (bundle != null) {
      // Hint text for WebView.
      hintText = bundle.getCharSequence(HINT_TEXT_KEY);
    }
  }

  return hintText;
}
 
Example 3
Source File: AccessibilityNodeInfoUtils.java    From talkback with Apache License 2.0 5 votes vote down vote up
/**
 * @param node The node being checked.
 * @param property the property sets in {@code node}
 * @return true if set it successfully.
 */
private static boolean getBooleanProperty(AccessibilityNodeInfoCompat node, int property) {
  Bundle extras = node.getExtras();
  if (extras == null) {
    return false;
  } else {
    return (extras.getInt(BOOLEAN_PROPERTY_KEY, 0) & property) == property;
  }
}
 
Example 4
Source File: AccessibilityNodeInfoUtils.java    From talkback with Apache License 2.0 5 votes vote down vote up
private static void setBooleanProperty(
    AccessibilityNodeInfoCompat node, int property, boolean value) {
  Bundle extras = node.getExtras();
  if (extras != null) {
    int booleanProperties = extras.getInt(BOOLEAN_PROPERTY_KEY, 0);
    booleanProperties &= ~property;
    booleanProperties |= value ? property : 0;
    extras.putInt(BOOLEAN_PROPERTY_KEY, booleanProperties);
  }
}
 
Example 5
Source File: WebInterfaceUtils.java    From talkback with Apache License 2.0 5 votes vote down vote up
/** Returns {@code true} if the {@code node} or its descendant contains image. */
public static boolean containsImage(AccessibilityNodeInfoCompat node) {
  if (node == null) {
    return false;
  }
  Bundle extras = node.getExtras();
  return (extras != null) && VALUE_HAS_WEB_IMAGE.equals(extras.getString(KEY_WEB_IMAGE));
}