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.DefaultNavigationMode.java
private boolean activateNode(AccessibilityNodeInfoCompat node, int position) { if (node == null) { return false; }// w w w.j ava2 s . c om AccessibilityNodeInfoRef current = AccessibilityNodeInfoRef.unOwned(node); try { do { LogUtils.log(this, Log.VERBOSE, "Considering to click: %s", current.get().getInfo()); int supportedActions = current.get().getActions(); int action = 0; // For edit texts, the click action doesn't currently focus // the view, so we special case it here. // TODO: Revise when that changes. if (AccessibilityNodeInfoUtils.nodeMatchesClassByType(mAccessibilityService, current.get(), EditText.class)) { if ((supportedActions & AccessibilityNodeInfo.ACTION_FOCUS) != 0) { action = AccessibilityNodeInfo.ACTION_FOCUS; } else { // Put accessibility focus on the field. If it is // already focused and the IME is selected, that will // activate the editing. action = AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS; } } else if (position >= 0 && isSelfBrailled(current.get()) && (supportedActions & AccessibilityNodeInfo.ACTION_CLICK) != 0) { // Generate a fake "action". For instance, a click at // position 33 maps to -275000033. // TODO: Remove this hack when a better way to pass this // information exists. int fakeAction = ACTION_BRAILLE_CLICK_MAX - position; if (fakeAction < ACTION_BRAILLE_CLICK_MIN) { LogUtils.log(this, Log.WARN, "underflow activating node %s at position %d", current.get(), position); fakeAction = ACTION_BRAILLE_CLICK_MIN; } else if (fakeAction > ACTION_BRAILLE_CLICK_MAX) { LogUtils.log(this, Log.WARN, "overflow activating node %s at position %d", current.get(), position); fakeAction = ACTION_BRAILLE_CLICK_MAX; } if (WebInterfaceUtils.performSpecialAction(current.get(), fakeAction)) { return true; } } else if ((supportedActions & AccessibilityNodeInfo.ACTION_CLICK) != 0) { action = AccessibilityNodeInfo.ACTION_CLICK; } if (action != 0 && current.get().performAction(action)) { return true; } else { LogUtils.log(this, Log.VERBOSE, "Action %d failed", action); } } while (current.parent()); } finally { current.recycle(); } LogUtils.log(this, Log.VERBOSE, "Click action failed"); return false; }
From source file:com.googlecode.eyesfree.brailleback.DefaultNavigationMode.java
/** * Attempts to navigate to the top-most focusable node in the tree. *//*from ww w .j a v a 2s . c om*/ private boolean attemptNavigateTop() { AccessibilityNodeInfoCompat root = AccessibilityServiceCompatUtils .getRootInActiveWindow(mAccessibilityService); AccessibilityNodeInfoCompat toFocus = null; if (AccessibilityNodeInfoUtils.shouldFocusNode(mAccessibilityService, root)) { toFocus = root; root = null; } else { toFocus = mFocusFinder.linear(root, FocusFinder.SEARCH_FORWARD); if (toFocus == null) { // Fall back on root as a last resort. toFocus = root; root = null; } } try { if (toFocus.isAccessibilityFocused()) { brailleFocusedNode(); return true; } return toFocus.performAction(AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS); } finally { AccessibilityNodeInfoUtils.recycleNodes(root, toFocus); } }
From source file:com.googlecode.eyesfree.brailleback.DefaultNavigationMode.java
/** * Attempts to navigate to the bottom-most focusable node in the tree. *///from w w w .j av a2 s.c o m private boolean attemptNavigateBottom() { AccessibilityNodeInfoCompat root = AccessibilityServiceCompatUtils .getRootInActiveWindow(mAccessibilityService); AccessibilityNodeInfoCompat toFocus = FocusFinder.findLastFocusableDescendant(root, mAccessibilityService); try { if (toFocus == null) { if (AccessibilityNodeInfoUtils.shouldFocusNode(mAccessibilityService, root)) { root = null; toFocus = root; } else { return false; } } if (toFocus.isAccessibilityFocused()) { brailleFocusedNode(); return true; } return toFocus.performAction(AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS); } finally { AccessibilityNodeInfoUtils.recycleNodes(root, toFocus); } }