Java Code Examples for android.view.accessibility.AccessibilityNodeInfo#ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY
The following examples show how to use
android.view.accessibility.AccessibilityNodeInfo#ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ComponentHost.java From litho with Apache License 2.0 | 6 votes |
@Override public boolean performAccessibilityAction(int action, Bundle arguments) { // The view framework requires that a contentDescription be set for the // getIterableTextForAccessibility method to work. If one isn't set, all text granularity // actions will be ignored. if (action == AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY || action == AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY) { CharSequence contentDesc = null; if (!TextUtils.isEmpty(getContentDescription())) { contentDesc = getContentDescription(); } else if (!getContentDescriptions().isEmpty()) { contentDesc = TextUtils.join(", ", getContentDescriptions()); } else if (!getTextContent().getTextItems().isEmpty()) { contentDesc = TextUtils.join(", ", getTextContent().getTextItems()); } if (contentDesc == null) { return false; } mContentDescription = contentDesc; super.setContentDescription(mContentDescription); } return super.performAccessibilityAction(action, arguments); }
Example 2
Source File: JellyBeanAccessibilityInjector.java From android-chromium with BSD 2-Clause "Simplified" License | 5 votes |
@Override public boolean supportsAccessibilityAction(int action) { if (action == AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY || action == AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY || action == AccessibilityNodeInfo.ACTION_NEXT_HTML_ELEMENT || action == AccessibilityNodeInfo.ACTION_PREVIOUS_HTML_ELEMENT || action == AccessibilityNodeInfo.ACTION_CLICK) { return true; } return false; }
Example 3
Source File: JellyBeanAccessibilityInjector.java From android-chromium with BSD 2-Clause "Simplified" License | 5 votes |
@Override public boolean supportsAccessibilityAction(int action) { if (action == AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY || action == AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY || action == AccessibilityNodeInfo.ACTION_NEXT_HTML_ELEMENT || action == AccessibilityNodeInfo.ACTION_PREVIOUS_HTML_ELEMENT || action == AccessibilityNodeInfo.ACTION_CLICK) { return true; } return false; }
Example 4
Source File: SwitchAccessAction.java From talkback with Apache License 2.0 | 4 votes |
@Override public ActionResult execute(AccessibilityService service) { previousSelectionStart = Math.max(0, nodeCompat.getTextSelectionStart()); previousSelectionEnd = Math.max(0, nodeCompat.getTextSelectionEnd()); previousTextContent = TextEditingUtils.getNonDefaultTextForNode(nodeCompat); switch (getId()) { case TextEditingUtils.ACTION_DELETE_TEXT: // Delete text with granularity according to args. return new ActionResult(TextEditingUtils.deleteTextWithGranularity(nodeCompat, args)); case AccessibilityNodeInfo.ACTION_SET_SELECTION: // Select text with granularity according to args. return new ActionResult(TextEditingUtils.selectTextWithGranularity(nodeCompat, args)); case AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY: case AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY: if ((args.getInt(ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT) == TextEditingUtils.ACTION_GRANULARITY_SENTENCE)) { MovementDirection movementDirection = (getId() == AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY) ? TextEditingUtils.MovementDirection.DIRECTION_NEXT : TextEditingUtils.MovementDirection.DIRECTION_PREVIOUS; // Sentence granularity doesn't have built-in support, so move cursor by sentence // granularity. return new ActionResult( TextEditingUtils.moveCursorBySentenceGranularity(nodeCompat, movementDirection)); } else { // Perform the original granular movement return new ActionResult( PerformActionUtils.performAction(nodeCompat, getId(), args, null /* EventId */)); } case TextEditingUtils.ACTION_UNDO: // Undo the previous action on this node's timeline. return new ActionResult(TextEditingUtils.performUndo(service, nodeCompat)); case TextEditingUtils.ACTION_REDO: // Redo the next action on this node's timeline. return new ActionResult(TextEditingUtils.performRedo(service, nodeCompat)); case AccessibilityNodeInfo.ACTION_SET_TEXT: // Set the text and restore the cursor position. return new ActionResult(TextEditingUtils.setText(nodeCompat, args)); case AccessibilityNodeInfo.ACTION_COPY: case AccessibilityNodeInfo.ACTION_CUT: // For copy and cut actions, select all text as these actions only act on the currently // selected text. if ((args.getInt(ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT) == TextEditingUtils.ACTION_GRANULARITY_ALL) && !TextEditingUtils.selectTextWithGranularity(nodeCompat, args)) { return new ActionResult(false); } else { return new ActionResult( PerformActionUtils.performAction(nodeCompat, getId(), args, null /* EventId */)); } case AccessibilityNodeInfo.ACTION_CLICK: if (nodeCompat.isClickable() && attemptToClickUrl(service)) { return new ActionResult(true /* isSuccessful */); } // Fall-through if there were no clickable urls. default: // Perform the original user-visible action. return new ActionResult( PerformActionUtils.performAction(nodeCompat, getId(), args, null /* EventId */)); } }