Example usage for android.view.accessibility AccessibilityNodeInfo ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN

List of usage examples for android.view.accessibility AccessibilityNodeInfo ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN

Introduction

In this page you can find the example usage for android.view.accessibility AccessibilityNodeInfo ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN.

Prototype

String ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN

To view the source code for android.view.accessibility AccessibilityNodeInfo ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN.

Click Source Link

Document

Argument for whether when moving at granularity to extend the selection or to move it otherwise.

Usage

From source file:com.ucmap.dingdinghelper.services.DingDingHelperAccessibilityService.java

/**
 * //  w  ww . ja v  a  2s .  com
 */
private void setTextToView(AccessibilityNodeInfo node, String text) {
    Bundle arguments = new Bundle();
    arguments.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT,
            AccessibilityNodeInfo.MOVEMENT_GRANULARITY_WORD);
    arguments.putBoolean(AccessibilityNodeInfo.ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN, true);
    node.performAction(AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY, arguments);
    /*?*/
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Bundle args = new Bundle();
        args.putCharSequence(AccessibilityNodeInfo.ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE, text);
        node.performAction(AccessibilityNodeInfo.ACTION_SET_TEXT, args);
    } else {
        ClipData data = ClipData.newPlainText("reply", text);
        ClipboardManager clipboardManager = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
        clipboardManager.setPrimaryClip(data);
        node.performAction(AccessibilityNodeInfo.ACTION_FOCUS); // ?
        node.performAction(AccessibilityNodeInfo.ACTION_PASTE); // 
    }

}