Example usage for android.view.accessibility AccessibilityNodeInfo ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE

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

Introduction

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

Prototype

String ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE

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

Click Source Link

Document

Argument for specifying the text content to set.

Usage

From source file:com.fenlisproject.elf.core.widget.ExtendedEditText.java

@Override
public boolean performAccessibilityAction(int action, Bundle arguments) {
    switch (action) {
    case AccessibilityNodeInfo.ACTION_SET_TEXT: {
        CharSequence text = (arguments != null)
                ? arguments.getCharSequence(AccessibilityNodeInfo.ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE)
                : null;/*from   ww  w .  j av  a2s  . c o  m*/
        setText(text);
        if (text != null && text.length() > 0) {
            setSelection(text.length());
        }
        return true;
    }
    default: {
        return super.performAccessibilityAction(action, arguments);
    }
    }
}

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

/**
 * //w  w  w  .  j  a  v a 2s.co  m
 */
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); // 
    }

}