List of usage examples for android.support.v4.view.accessibility AccessibilityNodeInfoCompat ACTION_FOCUS
int ACTION_FOCUS
To view the source code for android.support.v4.view.accessibility AccessibilityNodeInfoCompat ACTION_FOCUS.
Click Source Link
From source file:Main.java
/** * Returns whether a node is actionable. That is, the node supports one of * the following actions:/*from w w w . j a v a 2 s .c o m*/ * <ul> * <li>{@link AccessibilityNodeInfoCompat#isClickable()} * <li>{@link AccessibilityNodeInfoCompat#isFocusable()} * <li>{@link AccessibilityNodeInfoCompat#isLongClickable()} * </ul> * This parities the system method View#isActionableForAccessibility(), which * was added in JellyBean. * * @param node The node to examine. * @return {@code true} if node is actionable. */ public static boolean isActionableForAccessibility(AccessibilityNodeInfoCompat node) { if (node == null) { return false; } // Nodes that are clickable are always actionable. if (isClickable(node) || isLongClickable(node)) { return true; } if (node.isFocusable()) { return true; } return supportsAnyAction(node, AccessibilityNodeInfoCompat.ACTION_FOCUS, AccessibilityNodeInfoCompat.ACTION_NEXT_HTML_ELEMENT, AccessibilityNodeInfoCompat.ACTION_PREVIOUS_HTML_ELEMENT); }
From source file:com.googlecode.eyesfree.utils.TreeDebug.java
/** * Gets a description of the properties of a node. *///from w w w . j a v a 2 s. 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 w w w. ja va2s. co 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:Main.java
/** * 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. *//*from w ww . ja v a 2 s.c om*/ 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); }
From source file:com.facebook.stetho.inspector.elements.android.AccessibilityNodeInfoWrapper.java
@Nullable public static String getActions(AccessibilityNodeInfoCompat node) { final StringBuilder actionLabels = new StringBuilder(); final String separator = ", "; for (AccessibilityActionCompat action : node.getActionList()) { if (actionLabels.length() > 0) { actionLabels.append(separator); }//from w w w . j ava 2 s .c o m 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; }
From source file:com.android.talkback.controller.CursorControllerApp.java
@Override public boolean setCursor(AccessibilityNodeInfoCompat node) { // Accessibility focus follows input focus; on TVs we want to set both simultaneously, // so we change the input focus if possible and let the ProcessorFocusAndSingleTap // handle changing the accessibility focus. if (mControlInputFocus && node.isFocusable() && !node.isFocused()) { if (setCursor(node, AccessibilityNodeInfoCompat.ACTION_FOCUS)) { return true; }//w ww . j a va 2 s .c o m } // Set accessibility focus otherwise (or as a fallback if setting input focus failed). return setCursor(node, AccessibilityNodeInfoCompat.ACTION_ACCESSIBILITY_FOCUS); }
From source file:com.android.utils.AccessibilityNodeInfoUtils.java
/** * Returns whether a node is actionable. That is, the node supports one of * the following actions:/*from w w w . j a v a 2 s. c o m*/ * <ul> * <li>{@link AccessibilityNodeInfoCompat#isClickable()} * <li>{@link AccessibilityNodeInfoCompat#isFocusable()} * <li>{@link AccessibilityNodeInfoCompat#isLongClickable()} * </ul> * This parities the system method View#isActionableForAccessibility(), which * was added in JellyBean. * * @param node The node to examine. * @return {@code true} if node is actionable. */ public static boolean isActionableForAccessibility(AccessibilityNodeInfoCompat node) { if (node == null) { return false; } // Nodes that are clickable are always actionable. if (isClickable(node) || isLongClickable(node)) { return true; } if (node.isFocusable()) { return true; } if (WebInterfaceUtils.hasNativeWebContent(node)) { return supportsAnyAction(node, AccessibilityNodeInfoCompat.ACTION_FOCUS); } return supportsAnyAction(node, AccessibilityNodeInfoCompat.ACTION_FOCUS, AccessibilityNodeInfoCompat.ACTION_NEXT_HTML_ELEMENT, AccessibilityNodeInfoCompat.ACTION_PREVIOUS_HTML_ELEMENT); }
From source file:com.google.android.marvin.mytalkback.ProcessorFocusAndSingleTap.java
private void performClick(AccessibilityNodeInfoCompat node) { // Performing a click on an EditText does not show the IME, so we need // to place input focus on it. If the IME was already connected and is // hidden, there is nothing we can do. if (AccessibilityNodeInfoUtils.nodeMatchesAnyClassByType(mService, node, android.widget.EditText.class)) { node.performAction(AccessibilityNodeInfoCompat.ACTION_FOCUS); return;//from w ww.jav a 2 s . c o m } // If a user quickly touch explores in web content (event stream < // TAP_TIMEOUT), we'll send an unintentional ACTION_CLICK. Switch // off clicking on web content for now. if (WebInterfaceUtils.hasWebContent(node)) { return; } node.performAction(AccessibilityNodeInfoCompat.ACTION_CLICK); }
From source file:com.android.screenspeak.eventprocessor.ProcessorFocusAndSingleTap.java
private void performClick(AccessibilityNodeInfoCompat node) { // Performing a click on an EditText does not show the IME, so we need // to place input focus on it. If the IME was already connected and is // hidden, there is nothing we can do. if (AccessibilityNodeInfoUtils.nodeMatchesClassByType(node, EditText.class)) { PerformActionUtils.performAction(node, AccessibilityNodeInfoCompat.ACTION_FOCUS); return;/*from w w w . j av a2 s . co m*/ } // If a user quickly touch explores in web content (event stream < // TAP_TIMEOUT), we'll send an unintentional ACTION_CLICK. Switch // off clicking on web content for now. if (WebInterfaceUtils.supportsWebActions(node)) { return; } PerformActionUtils.performAction(node, AccessibilityNodeInfoCompat.ACTION_CLICK); }
From source file:com.android.talkback.eventprocessor.ProcessorFocusAndSingleTap.java
private void performClick(AccessibilityNodeInfoCompat node) { // Performing a click on an EditText does not show the IME, so we need // to place input focus on it. If the IME was already connected and is // hidden, there is nothing we can do. if (Role.getRole(node) == Role.ROLE_EDIT_TEXT) { PerformActionUtils.performAction(node, AccessibilityNodeInfoCompat.ACTION_FOCUS); return;//from w w w.j a v a 2 s. c o m } // If a user quickly touch explores in web content (event stream < // TAP_TIMEOUT), we'll send an unintentional ACTION_CLICK. Switch // off clicking on web content for now. if (WebInterfaceUtils.supportsWebActions(node)) { return; } PerformActionUtils.performAction(node, AccessibilityNodeInfoCompat.ACTION_CLICK); }