Search in sources :

Example 11 with ExtractedText

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

the class WiFiInputMethod method wordLeft.

private void wordLeft(InputConnection conn) {
    boolean shift = pressedKeys.contains(KeyEvent.KEYCODE_SHIFT_LEFT);
    ExtractedText text = conn.getExtractedText(req, 0);
    if (text == null)
        return;
    int end = text.selectionEnd - 1;
    String str = text.text.toString();
    for (; end >= 0; end--) {
        if (!Character.isSpace(str.charAt(end)))
            break;
    }
    for (; end >= 0; end--) {
        if (Character.isSpace(str.charAt(end)))
            break;
    }
    end++;
    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 12 with ExtractedText

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

the class WiFiInputMethod method wordRight.

private void wordRight(InputConnection conn) {
    boolean shift = pressedKeys.contains(KeyEvent.KEYCODE_SHIFT_LEFT);
    ExtractedText text = conn.getExtractedText(req, 0);
    if (text == null)
        return;
    int end = text.selectionEnd;
    String str = text.text.toString();
    int len = str.length();
    for (; end < len; end++) {
        if (!Character.isSpace(str.charAt(end)))
            break;
    }
    for (; end < len; end++) {
        if (Character.isSpace(str.charAt(end)))
            break;
    }
    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 13 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 14 with ExtractedText

use of android.view.inputmethod.ExtractedText in project chromeview by pwnall.

the class AdapterInputConnection method getExtractedText.

/**
     * @see BaseInputConnection#getExtractedText(android.view.inputmethod.ExtractedTextRequest,
     *                                           int)
     */
@Override
public ExtractedText getExtractedText(ExtractedTextRequest request, int flags) {
    if (DEBUG)
        Log.w(TAG, "getExtractedText");
    ExtractedText et = new ExtractedText();
    Editable editable = getEditable();
    et.text = editable.toString();
    et.partialEndOffset = editable.length();
    et.selectionStart = Selection.getSelectionStart(editable);
    et.selectionEnd = Selection.getSelectionEnd(editable);
    et.flags = mSingleLine ? ExtractedText.FLAG_SINGLE_LINE : 0;
    return et;
}
Also used : Editable(android.text.Editable) ExtractedText(android.view.inputmethod.ExtractedText)

Example 15 with ExtractedText

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

the class WiFiInputMethod method keyHome.

private void keyHome(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 = 0;
    } else {
        end = text.text.toString().lastIndexOf('\n', text.selectionEnd - 1);
        end++;
    }
    int start = shift ? text.selectionStart : end;
    Log.d("wifikeyboard", "start = " + start + " end = " + end);
    conn.setSelection(start, end);
}
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