List of usage examples for android.view.accessibility AccessibilityNodeInfo ACTION_ACCESSIBILITY_FOCUS
int ACTION_ACCESSIBILITY_FOCUS
To view the source code for android.view.accessibility AccessibilityNodeInfo ACTION_ACCESSIBILITY_FOCUS.
Click Source Link
From source file:com.googlecode.eyesfree.brailleback.SearchNavigationMode.java
@Override public void onActivate() { mActive = true;/* w ww. j ava 2 s . c om*/ // In case the initial node is no longer focused (such as exiting the // tutorial), we want to try to focus it here. if (!AccessibilityNodeInfoRef.isNull(mInitialNode)) { // Intentionally ignoring return value. mInitialNode.get().performAction(AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS); } // Save the currently focused node. mSearchStateListener.onSearchStarted(); // Update display. brailleMatchedOrFocusedNode(); mSearchOverlay.show(); }
From source file:com.googlecode.eyesfree.brailleback.IMEHelper.java
private void checkIMEPicker(AccessibilityEvent event) { if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED && "android".equals(event.getPackageName()) && "android.app.AlertDialog".equals(event.getClassName())) { AccessibilityNodeInfo node = event.getSource(); if (node == null) { return; }/*w w w . java2 s .com*/ String IMETitle = mContext.getString(R.string.braille_ime_name); List<AccessibilityNodeInfo> found = node.findAccessibilityNodeInfosByText(IMETitle); if (found.size() == 0) { return; } AccessibilityNodeInfo firstFound = found.get(0); AccessibilityNodeInfo toFocus = firstFound.getParent(); if (toFocus != null) { toFocus.performAction(AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS); } } }
From source file:com.googlecode.eyesfree.brailleback.DefaultNavigationMode.java
private boolean onPanRightOverflowInternal(DisplayManager.Content content) { AccessibilityNodeInfoCompat currentNode = getFocusedNode(true); try {/* w w w .j a va 2s .co m*/ if (currentNode != null && WebInterfaceUtils.hasWebContent(currentNode) && WebInterfaceUtils.performNavigationAtGranularityAction(currentNode, DIRECTION_FORWARD, AccessibilityNodeInfoCompat.MOVEMENT_GRANULARITY_LINE)) { return true; } // Check if we need to scroll. if (autoScrollItem(currentNode, AccessibilityNodeInfo.ACTION_SCROLL_FORWARD)) { return true; } } finally { AccessibilityNodeInfoUtils.recycleNodes(currentNode); } AccessibilityNodeInfoRef target = findNodeForPanRight(content); if (AccessibilityNodeInfoRef.isNull(target)) { return false; } try { return target.get().performAction(AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS); } finally { target.recycle(); } }
From source file:com.googlecode.eyesfree.brailleback.TreeDebugNavigationMode.java
private CharSequence formatNode(AccessibilityNodeInfo node) { StringBuilder sb = new StringBuilder(); sb.append(node.getWindowId());//from w w w . jav a 2 s .co m 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()); } if (node.getContentDescription() != null) { sb.append(":"); sb.append(node.getContentDescription()); } int actions = node.getActions(); if (actions != 0) { sb.append(":"); if ((actions & AccessibilityNodeInfo.ACTION_FOCUS) != 0) { sb.append("F"); } if ((actions & AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS) != 0) { sb.append("A"); } if ((actions & AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS) != 0) { sb.append("a"); } if ((actions & AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD) != 0) { sb.append("-"); } if ((actions & AccessibilityNodeInfo.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.googlecode.eyesfree.brailleback.SearchNavigationMode.java
/** * Syncs accessibility focus back to the node focused when search mode * first activated.//from w ww . j av a2 s . c o m */ private void syncBackToInitial() { AccessibilityNodeInfoCompat focused = FocusFinder.getFocusedNode(mAccessibilityService, false); if (focused == null) { return; } try { mInitialNode.reset(AccessibilityNodeInfoUtils.refreshNode(mInitialNode.get())); if (!AccessibilityNodeInfoRef.isNull(mInitialNode)) { if (mInitialNode.get().isAccessibilityFocused()) { return; } mFeedbackManager.emitOnFailure( mInitialNode.get().performAction(AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS), FeedbackManager.TYPE_COMMAND_FAILED); } else { mFeedbackManager.emitOnFailure( focused.performAction(AccessibilityNodeInfoCompat.ACTION_CLEAR_ACCESSIBILITY_FOCUS), FeedbackManager.TYPE_COMMAND_FAILED); } } finally { focused.recycle(); } }
From source file:com.android.utils.NodeSearch.java
/** * Searches for the next result matching the current search query in the specified direction. * Ordering of results taken from linear navigation. * * @param direction The direction in which to search, {@link NodeFocusFinder#SEARCH_FORWARD} or * {@link NodeFocusFinder#SEARCH_BACKWARD}. * @return {@code true} if a match was found, or {@code false} otherwise. *///from w ww . j a v a2 s . co m public boolean nextResult(int direction) { AccessibilityNodeInfoRef next = new AccessibilityNodeInfoRef(); next.reset(NodeFocusFinder.focusSearch(getCurrentNode(), direction)); AccessibilityNodeInfoCompat focusableNext = null; try { while (next.get() != null) { if (nodeMatchesQuery(next.get())) { // Even if the text matches, we need to make sure the node should be focused or // has a parent that should be focused. focusableNext = AccessibilityNodeInfoUtils.findFocusFromHover(next.get()); // Only count this as a match if it doesn't lead to the same parent. if (focusableNext != null && !focusableNext.isAccessibilityFocused()) { break; } } next.reset(NodeFocusFinder.focusSearch(next.get(), direction)); if (focusableNext != null) { focusableNext.recycle(); focusableNext = null; } } if (focusableNext == null) { return false; } mMatchedNode.reset(next); return PerformActionUtils.performAction(focusableNext, AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS); } finally { if (focusableNext != null) { focusableNext.recycle(); } next.recycle(); } }
From source file:com.googlecode.eyesfree.brailleback.SearchNavigationMode.java
/** * Searches for the next result matching the current search query in the * specified direction. Ordering of results taken from linear navigation. * Returns whether there is another result in that direction. *///from ww w.ja v a2s . c o m private boolean nextResult(int direction) { AccessibilityNodeInfoRef next = new AccessibilityNodeInfoRef(); next.reset(NodeFocusFinder.focusSearch(getCurrentNode(), direction)); AccessibilityNodeInfoCompat focusableNext = null; try { while (next.get() != null) { if (nodeMatchesQuery(next.get())) { // Even if the text matches, we need to make sure the node // should be focused or has a parent that should be focused. focusableNext = AccessibilityNodeInfoUtils.findFocusFromHover(mAccessibilityService, next.get()); // Only count this as a match if it doesn't lead to the same // parent. if (focusableNext != null && !focusableNext.isAccessibilityFocused()) { break; } } next.reset(NodeFocusFinder.focusSearch(next.get(), direction)); } if (focusableNext == null) { return false; } mMatchedNode.reset(next); return focusableNext.performAction(AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS); } finally { AccessibilityNodeInfoUtils.recycleNodes(focusableNext); next.recycle(); } }
From source file:com.android.screenspeak.KeyboardSearchManager.java
/** * Cancel the current search. Return accessibility focus to the initial node. *///from w ww .ja va 2 s . c o m private void cancelSearch() { mHandler.removeCallbacks(mHint); mNodeSearch.stopSearch(); mSpeechController.speak(mContext.getString(R.string.search_mode_cancel), SpeechController.QUEUE_MODE_UNINTERRUPTIBLE, FeedbackItem.FLAG_NO_HISTORY, null); AccessibilityNodeInfoCompat focused = FocusFinder.getFocusedNode(mContext, false); if (focused == null) { return; } try { mInitialNode.reset(AccessibilityNodeInfoUtils.refreshNode(mInitialNode.get())); if (!AccessibilityNodeInfoRef.isNull(mInitialNode)) { if (mInitialNode.get().isAccessibilityFocused()) { return; } PerformActionUtils.performAction(mInitialNode.get(), AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS); } else { PerformActionUtils.performAction(focused, AccessibilityNodeInfoCompat.ACTION_CLEAR_ACCESSIBILITY_FOCUS); } } finally { focused.recycle(); } }
From source file:com.googlecode.eyesfree.brailleback.DefaultNavigationMode.java
/** * Moves accessibility focus to the first focusable node of the previous * 'line'./*w ww .ja v a 2s. c o m*/ */ private boolean linePreviousInternal(DisplayManager.Content content) { AccessibilityNodeInfoRef left = new AccessibilityNodeInfoRef(); AccessibilityNodeInfoRef right = new AccessibilityNodeInfoRef(); AccessibilityNodeInfoCompat target = null; AccessibilityNodeInfoCompat currentNode = getFocusedNode(true); try { if (currentNode != null && WebInterfaceUtils.hasWebContent(currentNode) && WebInterfaceUtils.performNavigationAtGranularityAction(currentNode, DIRECTION_BACKWARD, AccessibilityNodeInfoCompat.MOVEMENT_GRANULARITY_LINE)) { return true; } // Check if we need to scroll. if (autoScrollItem(currentNode, AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD)) { return true; } AccessibilityNodeInfoRef firstNode = AccessibilityNodeInfoRef.unOwned(content.getFirstNode()); // If the content doesn't have a first node, fall back on the // currently focused node. if (AccessibilityNodeInfoRef.isNull(firstNode)) { firstNode = AccessibilityNodeInfoRef.owned(currentNode); currentNode = null; } if (AccessibilityNodeInfoRef.isNull(firstNode)) { return false; } // Move backwards one step from the first node that is currently // displayed. target = mFocusFinder.linear(firstNode.get(), FocusFinder.SEARCH_BACKWARD); firstNode.recycle(); if (target == null) { return false; } // Find what would be covered by the display if target // would have accessibility focus. mNodeBrailler.findDisplayExtentFromNode(target, left, right); // Find the first focusable nodes moving forward from left, // i fleft is not focusable itself. if (!AccessibilityNodeInfoUtils.shouldFocusNode(mAccessibilityService, left.get())) { left.reset(mFocusFinder.linear(left.get(), FocusFinder.SEARCH_FORWARD)); } // If we didn't find a focusable node at the beginning of the // line we are trying to move to, just move to target as // a fallback. if (AccessibilityNodeInfoRef.isNull(left)) { left.reset(target); target = null; } return left.get().performAction(AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS); } finally { AccessibilityNodeInfoUtils.recycleNodes(target, currentNode); left.recycle(); right.recycle(); } }
From source file:com.googlecode.eyesfree.brailleback.DefaultNavigationMode.java
private boolean moveFocus(AccessibilityNodeInfoCompat from, int direction) { int searchDirection = (direction == DIRECTION_BACKWARD) ? FocusFinder.SEARCH_BACKWARD : FocusFinder.SEARCH_FORWARD; AccessibilityNodeInfoCompat next = null; next = mFocusFinder.linear(from, searchDirection); try {/* w w w .ja v a 2 s . c o m*/ if (next != null) { return next.performAction(AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS); } } finally { AccessibilityNodeInfoUtils.recycleNodes(next); } return false; }