List of usage examples for android.support.v4.view.accessibility AccessibilityNodeInfoCompat getActions
public int getActions()
From source file:Main.java
/** * Returns {@code true} if the node supports at least one of the specified * actions. To check whether a node supports multiple actions, combine them * using the {@code |} (logical OR) operator. * * @param node The node to check.//from w ww . j a v a 2 s . c om * @param actions The actions to check. * @return {@code true} if at least one action is supported. */ public static boolean supportsAnyAction(AccessibilityNodeInfoCompat node, int... actions) { if (node != null) { final int supportedActions = node.getActions(); for (int action : actions) { if ((supportedActions & action) == action) { return true; } } } return false; }
From source file:com.googlecode.eyesfree.utils.TreeDebug.java
/** * Gets a description of the properties of a node. *///from ww w .j a va 2s.c o m public static CharSequence nodeDebugDescription(AccessibilityNodeInfoCompat node) { StringBuilder sb = new StringBuilder(); sb.append(node.getWindowId()); if (node.getClassName() != null) { appendSimpleName(sb, node.getClassName()); } else { sb.append("??"); } if (!node.isVisibleToUser()) { sb.append(":invisible"); } if (node.getText() != null) { sb.append(":"); sb.append(node.getText().toString().trim()); } if (node.getContentDescription() != null) { sb.append(":"); sb.append(node.getContentDescription().toString().trim()); } int actions = node.getActions(); if (actions != 0) { sb.append(":"); if ((actions & AccessibilityNodeInfoCompat.ACTION_FOCUS) != 0) { sb.append("F"); } if ((actions & AccessibilityNodeInfoCompat.ACTION_ACCESSIBILITY_FOCUS) != 0) { sb.append("A"); } if ((actions & AccessibilityNodeInfoCompat.ACTION_CLEAR_ACCESSIBILITY_FOCUS) != 0) { sb.append("a"); } if ((actions & AccessibilityNodeInfoCompat.ACTION_SCROLL_BACKWARD) != 0) { sb.append("-"); } if ((actions & AccessibilityNodeInfoCompat.ACTION_SCROLL_FORWARD) != 0) { sb.append("+"); } } if (node.isCheckable()) { sb.append(":"); if (node.isChecked()) { sb.append("(X)"); } else { sb.append("( )"); } } if (node.isFocusable()) { sb.append(":focusable"); } if (node.isFocused()) { sb.append(":focused"); } if (node.isSelected()) { sb.append(":selected"); } if (node.isClickable()) { sb.append(":clickable"); } if (node.isLongClickable()) { sb.append(":longClickable"); } if (node.isAccessibilityFocused()) { sb.append(":accessibilityFocused"); } if (!node.isEnabled()) { sb.append(":disabled"); } return sb.toString(); }
From source file:com.android.utils.TreeDebug.java
/** * Gets a description of the properties of a node. *///from www . j av a2 s. c o m private static CharSequence nodeDebugDescription(AccessibilityNodeInfoCompat node) { StringBuilder sb = new StringBuilder(); sb.append(node.getWindowId()); if (node.getClassName() != null) { appendSimpleName(sb, node.getClassName()); } else { sb.append("??"); } if (!node.isVisibleToUser()) { sb.append(":invisible"); } Rect rect = new Rect(); node.getBoundsInScreen(rect); sb.append(":"); sb.append("(").append(rect.left).append(", ").append(rect.top).append(" - ").append(rect.right).append(", ") .append(rect.bottom).append(")"); if (node.getText() != null) { sb.append(":"); sb.append(node.getText().toString().trim()); } if (node.getContentDescription() != null) { sb.append(":"); sb.append(node.getContentDescription().toString().trim()); } int actions = node.getActions(); if (actions != 0) { sb.append(":"); if ((actions & AccessibilityNodeInfoCompat.ACTION_FOCUS) != 0) { sb.append("F"); } if ((actions & AccessibilityNodeInfoCompat.ACTION_ACCESSIBILITY_FOCUS) != 0) { sb.append("A"); } if ((actions & AccessibilityNodeInfoCompat.ACTION_CLEAR_ACCESSIBILITY_FOCUS) != 0) { sb.append("a"); } if ((actions & AccessibilityNodeInfoCompat.ACTION_SCROLL_BACKWARD) != 0) { sb.append("-"); } if ((actions & AccessibilityNodeInfoCompat.ACTION_CLICK) != 0) { sb.append("C"); } if ((actions & AccessibilityNodeInfoCompat.ACTION_LONG_CLICK) != 0) { sb.append("L"); } if ((actions & AccessibilityNodeInfoCompat.ACTION_SCROLL_FORWARD) != 0) { sb.append("+"); } if ((actions & AccessibilityNodeInfoCompat.ACTION_EXPAND) != 0) { sb.append("e"); } if ((actions & AccessibilityNodeInfoCompat.ACTION_COLLAPSE) != 0) { sb.append("c"); } } if (node.isCheckable()) { sb.append(":"); if (node.isChecked()) { sb.append("(X)"); } else { sb.append("( )"); } } if (node.isFocusable()) { sb.append(":focusable"); } if (node.isFocused()) { sb.append(":focused"); } if (node.isSelected()) { sb.append(":selected"); } if (node.isClickable()) { sb.append(":clickable"); } if (node.isLongClickable()) { sb.append(":longClickable"); } if (node.isAccessibilityFocused()) { sb.append(":accessibilityFocused"); } if (!node.isEnabled()) { sb.append(":disabled"); } if (node.getCollectionInfo() != null) { sb.append(":collection"); sb.append("#R"); sb.append(node.getCollectionInfo().getRowCount()); sb.append("C"); sb.append(node.getCollectionInfo().getColumnCount()); } if (node.getCollectionItemInfo() != null) { if (node.getCollectionItemInfo().isHeading()) { sb.append(":heading"); } else { sb.append(":item"); } sb.append("#r"); sb.append(node.getCollectionItemInfo().getRowIndex()); sb.append("c"); sb.append(node.getCollectionItemInfo().getColumnIndex()); } return sb.toString(); }
From source file:com.google.android.marvin.mytalkback.speechrules.RuleDefault.java
@Override public CharSequence getHintText(Context context, AccessibilityNodeInfoCompat node) { // Disabled actionable items don't have any hint text. if (AccessibilityNodeInfoUtils.isActionableForAccessibility(node) && !node.isEnabled()) { return context.getString(R.string.value_disabled); }// ww w. j a v a 2s .co m final SpannableStringBuilder builder = new SpannableStringBuilder(); final int actions = node.getActions(); // Don't read both the checkable AND clickable hints! if (node.isCheckable()) { StringBuilderUtils.appendWithSeparator(builder, NodeHintHelper.getHintString(context, R.string.template_hint_checkable)); } else if (AccessibilityNodeInfoUtils.isClickable(node)) { StringBuilderUtils.appendWithSeparator(builder, NodeHintHelper.getHintString(context, R.string.template_hint_clickable)); } // Long clickable is long. if (AccessibilityNodeInfoUtils.isLongClickable(node)) { StringBuilderUtils.appendWithSeparator(builder, NodeHintHelper.getHintString(context, R.string.template_hint_long_clickable)); } return builder; }
From source file:com.android.utils.AccessibilityNodeInfoUtils.java
/** * Returns {@code true} if the node supports the specified action. This method supports actions * introduced in API level 21 and later. However, it does not support bitmasks. * */// ww w . j a va2 s. c o m public static boolean supportsAction(AccessibilityNodeInfoCompat node, int action) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { // New actions in >= API 21 won't appear in getActions() but in getActionList(). // On Lollipop+ devices, pre-API 21 actions will also appear in getActionList(). List<AccessibilityActionCompat> actions = node.getActionList(); int size = actions.size(); for (int i = 0; i < size; ++i) { AccessibilityActionCompat actionCompat = actions.get(i); if (actionCompat.getId() == action) { return true; } } return false; } else { // On < API 21, actions aren't guaranteed to appear in getActionsList(), so we need to // check getActions() instead. return (node.getActions() & action) == action; } }