Search in sources :

Example 16 with ExtractedText

use of android.view.inputmethod.ExtractedText in project wifikeyboard by IvanVolosyuk.

the class WiFiInputMethod method keyEnd.

private void keyEnd(InputConnection conn) {
    boolean control = pressedKeys.contains(KEY_CONTROL);
    boolean shift = pressedKeys.contains(KeyEvent.KEYCODE_SHIFT_LEFT);
    ExtractedText text = conn.getExtractedText(req, 0);
    if (text == null)
        return;
    int end;
    if (control) {
        end = text.text.length();
    } else {
        end = text.text.toString().indexOf('\n', text.selectionEnd);
        if (end == -1)
            end = text.text.length();
    }
    int start = shift ? text.selectionStart : end;
    Log.d("wifikeyboard", "start = " + start + " end = " + end);
    conn.setSelection(start, end);
}
Also used : ExtractedText(android.view.inputmethod.ExtractedText)

Example 17 with ExtractedText

use of android.view.inputmethod.ExtractedText in project android_frameworks_base by ParanoidAndroid.

the class InputConnectionWrapper method getExtractedText.

public ExtractedText getExtractedText(ExtractedTextRequest request, int flags) {
    ExtractedText value = null;
    try {
        InputContextCallback callback = InputContextCallback.getInstance();
        mIInputContext.getExtractedText(request, flags, callback.mSeq, callback);
        synchronized (callback) {
            callback.waitForResultLocked();
            if (callback.mHaveValue) {
                value = callback.mExtractedText;
            }
        }
        callback.dispose();
    } catch (RemoteException e) {
        return null;
    }
    return value;
}
Also used : RemoteException(android.os.RemoteException) ExtractedText(android.view.inputmethod.ExtractedText)

Example 18 with ExtractedText

use of android.view.inputmethod.ExtractedText in project android_frameworks_base by DirtyUnicorns.

the class InputConnectionWrapper method getExtractedText.

public ExtractedText getExtractedText(ExtractedTextRequest request, int flags) {
    ExtractedText value = null;
    try {
        InputContextCallback callback = InputContextCallback.getInstance();
        mIInputContext.getExtractedText(request, flags, callback.mSeq, callback);
        synchronized (callback) {
            callback.waitForResultLocked();
            if (callback.mHaveValue) {
                value = callback.mExtractedText;
            }
        }
        callback.dispose();
    } catch (RemoteException e) {
        return null;
    }
    return value;
}
Also used : RemoteException(android.os.RemoteException) ExtractedText(android.view.inputmethod.ExtractedText)

Example 19 with ExtractedText

use of android.view.inputmethod.ExtractedText in project speechutils by Kaljurand.

the class InputConnectionCommandEditor method selectAll.

/**
     * mInputConnection.performContextMenuAction(android.R.id.selectAll) does not create a selection
     */
@Override
public Op selectAll() {
    return new Op("selectAll") {

        @Override
        public Op run() {
            Op undo = null;
            mInputConnection.beginBatchEdit();
            final ExtractedText et = getExtractedText();
            if (et != null) {
                undo = getOpSetSelection(0, et.text.length(), et.selectionStart, et.selectionEnd).run();
            }
            mInputConnection.endBatchEdit();
            return undo;
        }
    };
}
Also used : ExtractedText(android.view.inputmethod.ExtractedText)

Example 20 with ExtractedText

use of android.view.inputmethod.ExtractedText in project speechutils by Kaljurand.

the class InputConnectionCommandEditor method moveRel.

public Op moveRel(final int numberOfChars) {
    return new Op("moveRel") {

        @Override
        public Op run() {
            Op undo = null;
            mInputConnection.beginBatchEdit();
            ExtractedText extractedText = getExtractedText();
            if (extractedText != null) {
                int pos;
                if (numberOfChars < 0) {
                    pos = extractedText.selectionStart;
                } else {
                    pos = extractedText.selectionEnd;
                }
                int newPos = pos + numberOfChars;
                undo = getOpSetSelection(newPos, newPos, extractedText.selectionStart, extractedText.selectionEnd).run();
            }
            mInputConnection.endBatchEdit();
            return undo;
        }
    };
}
Also used : ExtractedText(android.view.inputmethod.ExtractedText)

Aggregations

ExtractedText (android.view.inputmethod.ExtractedText)27 RemoteException (android.os.RemoteException)7 ExtractedTextRequest (android.view.inputmethod.ExtractedTextRequest)2 Pair (android.support.v4.util.Pair)1 Editable (android.text.Editable)1 SpannableString (android.text.SpannableString)1 SpannableStringBuilder (android.text.SpannableStringBuilder)1 KeyEvent (android.view.KeyEvent)1 EditorInfo (android.view.inputmethod.EditorInfo)1 InputConnection (android.view.inputmethod.InputConnection)1 SpacingAndPunctuations (com.android.inputmethod.latin.settings.SpacingAndPunctuations)1 TextRange (com.android.inputmethod.latin.utils.TextRange)1