List of usage examples for android.view.accessibility AccessibilityNodeInfo ACTION_CLEAR_ACCESSIBILITY_FOCUS
int ACTION_CLEAR_ACCESSIBILITY_FOCUS
To view the source code for android.view.accessibility AccessibilityNodeInfo ACTION_CLEAR_ACCESSIBILITY_FOCUS.
Click Source Link
From source file:com.googlecode.eyesfree.brailleback.TreeDebugNavigationMode.java
private CharSequence formatNode(AccessibilityNodeInfo node) { StringBuilder sb = new StringBuilder(); sb.append(node.getWindowId());/*w ww . j ava2s . c om*/ 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.android.screenspeak.controller.CursorControllerApp.java
@Override public void clearCursor(AccessibilityNodeInfoCompat currentNode) { if (currentNode == null) { return;// ww w. java 2s.co m } PerformActionUtils.performAction(currentNode, AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS); }
From source file:com.google.android.marvin.mytalkback.CursorController.java
/** * Clears the current cursor position./* ww w. j av a 2 s.c o m*/ */ public void clearCursor() { final AccessibilityNodeInfo root = mService.getRootInActiveWindow(); if (root == null) { return; } final AccessibilityNodeInfo focused = root.findFocus(AccessibilityNodeInfo.FOCUS_ACCESSIBILITY); if (focused == null) { return; } focused.performAction(AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS); }
From source file:com.google.android.marvin.mytalkback.ProcessorFocusAndSingleTap.java
/** * Attempts to place focus within a new window. *//*ww w .jav a 2s. c o m*/ private boolean ensureFocusConsistency(boolean shouldPlaceFocus) { AccessibilityNodeInfoCompat root = null; AccessibilityNodeInfoCompat focused = null; AccessibilityNodeInfoCompat inputFocused = null; AccessibilityNodeInfoCompat firstFocus = null; try { root = AccessibilityServiceCompatUtils.getRootInActiveWindow(mService); if (root == null) { return false; } // First, see if we've already placed accessibility focus. focused = root.findFocus(AccessibilityNodeInfo.FOCUS_ACCESSIBILITY); if (focused != null) { if (AccessibilityNodeInfoUtils.shouldFocusNode(mService, focused)) { return true; } LogUtils.log(Log.VERBOSE, "Clearing focus from invalid node"); focused.performAction(AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS); } // If not, should we attempt to place focus? if (!shouldPlaceFocus) { return false; } // Next, see if the system has placed input focus. inputFocused = root.findFocus(AccessibilityNodeInfo.FOCUS_INPUT); if (tryFocusing(inputFocused)) { return true; } // Finally, just try to focus the first focusable item. firstFocus = AccessibilityNodeInfoUtils.searchFromInOrderTraversal(mService, root, AccessibilityNodeInfoUtils.FILTER_SHOULD_FOCUS, NodeFocusFinder.SEARCH_FORWARD); if (tryFocusing(firstFocus)) { return true; } LogUtils.log(Log.ERROR, "Failed to place focus from new window"); return false; } finally { AccessibilityNodeInfoUtils.recycleNodes(root, focused, inputFocused, firstFocus); } }
From source file:com.google.android.marvin.mytalkback.ProcessorFocusAndSingleTap.java
private boolean attemptRefocusNode(AccessibilityNodeInfoCompat node) { if (!mMaybeRefocus || mSpeechController.isSpeaking()) { return false; }/*www. ja v a2 s .c o m*/ // Never refocus web content, it will just read the title again. if (WebInterfaceUtils.hasWebContent(node)) { return false; } if (!node.performAction(AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS)) { return false; } return tryFocusing(node); }
From source file:com.google.android.marvin.mytalkback.ProcessorFocusAndSingleTap.java
private boolean followScrollEvent(AccessibilityNodeInfoCompat source, boolean isMovingForward, boolean wasScrollAction) { AccessibilityNodeInfoCompat root = null; AccessibilityNodeInfoCompat focused = null; try {/* w w w . j a v a2 s . c om*/ // First, see if we've already placed accessibility focus. root = AccessibilityServiceCompatUtils.getRootInActiveWindow(mService); if (root == null) { return false; } focused = root.findFocus(AccessibilityNodeInfo.FOCUS_ACCESSIBILITY); if (focused != null) { // If a node already has focus, ensure it should still have // focus. Return immediately if it's correctly focused and this // event is not the result a scroll action OR we successfully // refocus the node. if (AccessibilityNodeInfoUtils.shouldFocusNode(mService, focused) && (!wasScrollAction || mCursorController.refocus())) { return true; } LogUtils.log(this, Log.DEBUG, "Clear focus from %s", focused); focused.performAction(AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS); } // Try focusing the appropriate child node. if (tryFocusingChild(source, isMovingForward)) { return true; } // Finally, try focusing the scrollable node itself. if (tryFocusing(source)) { return true; } return false; } finally { AccessibilityNodeInfoUtils.recycleNodes(root, focused); } }
From source file:com.android.screenspeak.eventprocessor.ProcessorFocusAndSingleTap.java
/** * Attempts to place focus within a new window. *//*from w w w .jav a2s . c om*/ private boolean ensureFocusConsistency() { AccessibilityNodeInfoCompat root = null; AccessibilityNodeInfoCompat focused = null; try { root = AccessibilityServiceCompatUtils.getRootInAccessibilityFocusedWindow(mService); if (root == null) { return false; } // First, see if we've already placed accessibility focus. focused = root.findFocus(AccessibilityNodeInfo.FOCUS_ACCESSIBILITY); if (focused != null) { if (AccessibilityNodeInfoUtils.shouldFocusNode(focused)) { return true; } LogUtils.log(Log.VERBOSE, "Clearing focus from invalid node"); PerformActionUtils.performAction(focused, AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS); } return false; } finally { AccessibilityNodeInfoUtils.recycleNodes(root, focused); } }
From source file:com.android.screenspeak.eventprocessor.ProcessorFocusAndSingleTap.java
private boolean attemptRefocusNode(AccessibilityNodeInfoCompat node) { if (!mMaybeRefocus || mSpeechController.isSpeaking()) { return false; }// w ww . j av a 2 s .com // Never refocus web content, it will just read the title again. return !WebInterfaceUtils.supportsWebActions(node) && PerformActionUtils.performAction(node, AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS) && tryFocusing(node); }
From source file:com.android.talkback.eventprocessor.ProcessorFocusAndSingleTap.java
private boolean attemptRefocusNode(AccessibilityNodeInfoCompat node) { if (!mMaybeRefocus || mSpeechController.isSpeaking()) { return false; }//from w w w .ja va 2s .com // Never refocus legacy web content, it will just read the title again. if (WebInterfaceUtils.hasLegacyWebContent(node)) { return false; } mLastRefocusStartTime = SystemClock.uptimeMillis(); if (mLastRefocusedNode != null) { mLastRefocusedNode.recycle(); } mLastRefocusedNode = AccessibilityNodeInfoCompat.obtain(node); boolean result = PerformActionUtils.performAction(node, AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS) && tryFocusing(node, true /* force */); mLastRefocusEndTime = SystemClock.uptimeMillis(); return result; }