Java Code Examples for android.support.v4.view.accessibility.AccessibilityNodeInfoCompat#getActionList()
The following examples show how to use
android.support.v4.view.accessibility.AccessibilityNodeInfoCompat#getActionList() .
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: AccessibilityUtil.java From stetho with MIT License | 6 votes |
/** * Returns whether a node is actionable. That is, the node supports one of * {@link AccessibilityNodeInfoCompat#isClickable()}, * {@link AccessibilityNodeInfoCompat#isFocusable()}, or * {@link AccessibilityNodeInfoCompat#isLongClickable()}. * * @param node The {@link AccessibilityNodeInfoCompat} to evaluate * @return {@code true} if node is actionable. */ public static boolean isActionableForAccessibility(@Nullable AccessibilityNodeInfoCompat node) { if (node == null) { return false; } if (node.isClickable() || node.isLongClickable() || node.isFocusable()) { return true; } List actionList = node.getActionList(); return actionList.contains(AccessibilityNodeInfoCompat.ACTION_CLICK) || actionList.contains(AccessibilityNodeInfoCompat.ACTION_LONG_CLICK) || actionList.contains(AccessibilityNodeInfoCompat.ACTION_FOCUS); }
Example 2
Source File: AccessibilityUtil.java From stetho with MIT License | 5 votes |
/** * Determines whether the provided {@link View} and {@link AccessibilityNodeInfoCompat} is a * top-level item in a scrollable container. * * @param view The {@link View} to evaluate * @param node The {@link AccessibilityNodeInfoCompat} to evaluate * @return {@code true} if it is a top-level item in a scrollable container. */ public static boolean isTopLevelScrollItem( @Nullable AccessibilityNodeInfoCompat node, @Nullable View view) { if (node == null || view == null) { return false; } View parent = (View) ViewCompat.getParentForAccessibility(view); if (parent == null) { return false; } if (node.isScrollable()) { return true; } List actionList = node.getActionList(); if (actionList.contains(AccessibilityNodeInfoCompat.ACTION_SCROLL_FORWARD) || actionList.contains(AccessibilityNodeInfoCompat.ACTION_SCROLL_BACKWARD)) { return true; } // AdapterView, ScrollView, and HorizontalScrollView are focusable // containers, but Spinner is a special case. if (parent instanceof Spinner) { return false; } return parent instanceof AdapterView || parent instanceof ScrollView || parent instanceof HorizontalScrollView; }
Example 3
Source File: AccessibilityNodeInfoWrapper.java From stetho with MIT License | 4 votes |
@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(); } }