Java Code Examples for android.view.inputmethod.ExtractedTextRequest

The following examples show how to use android.view.inputmethod.ExtractedTextRequest. These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: FirefoxReality   Source File: KeyboardWidget.java    License: Mozilla Public License 2.0 6 votes vote down vote up
private void displayComposingText(String aText, ComposingAction aAction) {
    if (mInputConnection == null) {
        return;
    }
    boolean succeeded = mInputConnection.setComposingText(aText, 1);
    if (!succeeded) {
        // Fix for InlineAutocompleteEditText failed setComposingText() calls
        String fullText = mInputConnection.getExtractedText(new ExtractedTextRequest(),0).text.toString();
        String beforeText = mInputConnection.getTextBeforeCursor(fullText.length(),0).toString();
        if (beforeText.endsWith(mComposingDisplayText)) {
            mInternalDeleteHint = true;
            mInputConnection.deleteSurroundingText(mComposingDisplayText.length(), 0);
        }
        mInputConnection.setComposingText(aText, 1);
    }
    mComposingDisplayText = aText;
    if (aAction == ComposingAction.FINISH) {
        mInputConnection.finishComposingText();
        mComposingText = "";
    }
}
 
Example 2
@Override
public boolean replace(String str1, String str2) {
    boolean success = false;
    mInputConnection.beginBatchEdit();
    ExtractedText extractedText = mInputConnection.getExtractedText(new ExtractedTextRequest(), 0);
    if (extractedText != null) {
        CharSequence beforeCursor = extractedText.text;
        //CharSequence beforeCursor = mInputConnection.getTextBeforeCursor(MAX_SELECTABLE_CONTEXT, 0);
        Log.i("replace: " + beforeCursor);
        int index = beforeCursor.toString().lastIndexOf(str1);
        Log.i("replace: " + index);
        if (index > 0) {
            mInputConnection.setSelection(index, index);
            mInputConnection.deleteSurroundingText(0, str1.length());
            if (!str2.isEmpty()) {
                mInputConnection.commitText(str2, 0);
            }
            success = true;
        }
        mInputConnection.endBatchEdit();
    }
    return success;
}
 
Example 3
Source Project: remotekeyboard   Source File: CtrlInputAction.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Try to replace the current word with its substitution.
 */
private void replaceText(InputConnection con) {
	ExtractedText txt = con.getExtractedText(new ExtractedTextRequest(), 0);
	if (txt != null) {
		int end = txt.text.toString().indexOf(" ", txt.selectionEnd);
		if (end == -1) {
			end = txt.text.length();
		}
		int start = txt.text.toString().lastIndexOf(" ", txt.selectionEnd - 1);
		start++;
		String sel = txt.text.subSequence(start, end).toString();
		String rep = myService.replacements.get(sel);
		if (rep != null) {
			con.setComposingRegion(start, end);
			con.setComposingText(rep, 1);
			con.finishComposingText();
		}
		else {
			String err = myService.getResources().getString(
					R.string.err_no_replacement, sel);
			Toast.makeText(myService, err, Toast.LENGTH_SHORT).show();
		}
	}
}
 
Example 4
private void checkConsistencyForDebug() {
    final ExtractedTextRequest r = new ExtractedTextRequest();
    r.hintMaxChars = 0;
    r.hintMaxLines = 0;
    r.token = 1;
    r.flags = 0;
    final ExtractedText et = mIC.getExtractedText(r, 0);
    final CharSequence beforeCursor = getTextBeforeCursor(Constants.EDITOR_CONTENTS_CACHE_SIZE,
            0);
    final StringBuilder internal = new StringBuilder(mCommittedTextBeforeComposingText)
            .append(mComposingText);
    if (null == et || null == beforeCursor) return;
    final int actualLength = Math.min(beforeCursor.length(), internal.length());
    if (internal.length() > actualLength) {
        internal.delete(0, internal.length() - actualLength);
    }
    final String reference = (beforeCursor.length() <= actualLength) ? beforeCursor.toString()
            : beforeCursor.subSequence(beforeCursor.length() - actualLength,
                    beforeCursor.length()).toString();
    if (et.selectionStart != mExpectedSelStart
            || !(reference.equals(internal.toString()))) {
        final String context = "Expected selection start = " + mExpectedSelStart
                + "\nActual selection start = " + et.selectionStart
                + "\nExpected text = " + internal.length() + " " + internal
                + "\nActual text = " + reference.length() + " " + reference;
        ((LatinIME)mParent).debugDumpStateAndCrashWithException(context);
    } else {
        Log.e(TAG, DebugLogUtils.getStackTrace(2));
        Log.e(TAG, "Exp <> Actual : " + mExpectedSelStart + " <> " + et.selectionStart);
    }
}
 
Example 5
private void checkConsistencyForDebug() {
    final ExtractedTextRequest r = new ExtractedTextRequest();
    r.hintMaxChars = 0;
    r.hintMaxLines = 0;
    r.token = 1;
    r.flags = 0;
    final ExtractedText et = mIC.getExtractedText(r, 0);
    final CharSequence beforeCursor = getTextBeforeCursor(Constants.EDITOR_CONTENTS_CACHE_SIZE,
            0);
    final StringBuilder internal = new StringBuilder(mCommittedTextBeforeComposingText)
            .append(mComposingText);
    if (null == et || null == beforeCursor) return;
    final int actualLength = Math.min(beforeCursor.length(), internal.length());
    if (internal.length() > actualLength) {
        internal.delete(0, internal.length() - actualLength);
    }
    final String reference = (beforeCursor.length() <= actualLength) ? beforeCursor.toString()
            : beforeCursor.subSequence(beforeCursor.length() - actualLength,
                    beforeCursor.length()).toString();
    if (et.selectionStart != mExpectedSelStart
            || !(reference.equals(internal.toString()))) {
        final String context = "Expected selection start = " + mExpectedSelStart
                + "\nActual selection start = " + et.selectionStart
                + "\nExpected text = " + internal.length() + " " + internal
                + "\nActual text = " + reference.length() + " " + reference;
        ((LatinIME)mParent).debugDumpStateAndCrashWithException(context);
    } else {
        Log.e(TAG, DebugLogUtils.getStackTrace(2));
        Log.e(TAG, "Exp <> Actual : " + mExpectedSelStart + " <> " + et.selectionStart);
    }
}
 
Example 6
public ExtractedText getExtractedText(ExtractedTextRequest request, int flags) {
    if (mTextView != null) {
        ExtractedText et = new ExtractedText();
        if (mTextView.extractText(request, et)) {
            if ((flags&GET_EXTRACTED_TEXT_MONITOR) != 0) {
                mTextView.setExtracting(request);
            }
            return et;
        }
    }
    return null;
}
 
Example 7
Source Project: FirefoxReality   Source File: Session.java    License: Mozilla Public License 2.0 5 votes vote down vote up
@Override
public void updateExtractedText(@NonNull GeckoSession aSession, @NonNull ExtractedTextRequest request, @NonNull ExtractedText text) {
    if (mState.mSession == aSession) {
        for (GeckoSession.TextInputDelegate listener : mTextInputListeners) {
            listener.updateExtractedText(aSession, request, text);
        }
    }
}
 
Example 8
Source Project: FirefoxReality   Source File: KeyboardWidget.java    License: Mozilla Public License 2.0 5 votes vote down vote up
private String getTextBeforeCursor(InputConnection aConnection) {
    if (aConnection == null) {
        return "";
    }

    ExtractedText extracted = aConnection.getExtractedText(new ExtractedTextRequest(),0);
    if ((extracted == null) || extracted.text == null) {
        return "";
    }

    String fullText = extracted.text.toString();
    return aConnection.getTextBeforeCursor(fullText.length(),0).toString();
}
 
Example 9
Source Project: mongol-library   Source File: MetInputConnection.java    License: MIT License 5 votes vote down vote up
@Override
public ExtractedText getExtractedText(ExtractedTextRequest request, int flags) {
    if (request == null)
        return null;

    Editable editable = getEditable();
    if (editable == null) {
        return null;
    }
    int selStart = Selection.getSelectionStart(editable);
    int selEnd = Selection.getSelectionEnd(editable);

    ExtractedText extract = new ExtractedText();
    extract.flags = 0;
    extract.partialStartOffset = -1;
    extract.partialEndOffset = -1;
    extract.selectionStart = selStart;
    extract.selectionEnd = selEnd;
    extract.startOffset = 0;
    if ((request.flags & GET_TEXT_WITH_STYLES) != 0) {
        extract.text = new SpannableString(editable);
    } else {
        extract.text = editable.toString();
    }
    mMongolEditText.setExtractedTextToken(request.token);
    return extract;
}
 
Example 10
Source Project: mongol-library   Source File: ImeContainer.java    License: MIT License 5 votes vote down vote up
@Override
public void moveCursorEnd() {
    InputConnection ic = getInputConnection();
    if (ic == null) return;
    ExtractedText extractedText = ic.getExtractedText(new ExtractedTextRequest(), 0);
    if (extractedText == null || extractedText.text == null) return;
    int length = extractedText.text.length();
    ic.setSelection(length, length);
}
 
Example 11
Source Project: mongol-library   Source File: ImeContainer.java    License: MIT License 5 votes vote down vote up
@Override
public void selectWordBack() {
    InputConnection ic = getInputConnection();
    if (ic == null) return;
    ExtractedText extractedText = ic.getExtractedText(new ExtractedTextRequest(), 0);
    int previousWordBoundary = getPreviousWordBoundary(extractedText.text, extractedText.selectionStart);
    int start = extractedText.startOffset + previousWordBoundary;
    int end = extractedText.startOffset + extractedText.selectionEnd;
    ic.setSelection(start, end);
}
 
Example 12
Source Project: mongol-library   Source File: ImeContainer.java    License: MIT License 5 votes vote down vote up
@Override
public void selectWordForward() {
    InputConnection ic = getInputConnection();
    if (ic == null) return;
    ExtractedText extractedText = ic.getExtractedText(new ExtractedTextRequest(), 0);
    int nextWordBoundary = getNextWordBoundary(extractedText.text, extractedText.selectionEnd);
    int start = extractedText.startOffset + extractedText.selectionStart;
    int end = extractedText.startOffset + nextWordBoundary;
    ic.setSelection(start, end);
}
 
Example 13
Source Project: simple-keyboard   Source File: RichInputConnection.java    License: Apache License 2.0 5 votes vote down vote up
private void checkConsistencyForDebug() {
    final ExtractedTextRequest r = new ExtractedTextRequest();
    r.hintMaxChars = 0;
    r.hintMaxLines = 0;
    r.token = 1;
    r.flags = 0;
    final ExtractedText et = mIC.getExtractedText(r, 0);
    final CharSequence beforeCursor = getTextBeforeCursor(Constants.EDITOR_CONTENTS_CACHE_SIZE,
            0);
    final StringBuilder internal = new StringBuilder(mCommittedTextBeforeComposingText)
            .append(mComposingText);
    if (null == et || null == beforeCursor) return;
    final int actualLength = Math.min(beforeCursor.length(), internal.length());
    if (internal.length() > actualLength) {
        internal.delete(0, internal.length() - actualLength);
    }
    final String reference = (beforeCursor.length() <= actualLength) ? beforeCursor.toString()
            : beforeCursor.subSequence(beforeCursor.length() - actualLength,
                    beforeCursor.length()).toString();
    if (et.selectionStart != mExpectedSelStart
            || !(reference.equals(internal.toString()))) {
        final String context = "Expected selection start = " + mExpectedSelStart
                + "\nActual selection start = " + et.selectionStart
                + "\nExpected text = " + internal.length() + " " + internal
                + "\nActual text = " + reference.length() + " " + reference;
        ((LatinIME)mParent).debugDumpStateAndCrashWithException(context);
    } else {
        Log.e(TAG, DebugLogUtils.getStackTrace(2));
        Log.e(TAG, "Exp <> Actual : " + mExpectedSelStart + " <> " + et.selectionStart);
    }
}
 
Example 14
Source Project: AOSP-Kayboard-7.1.2   Source File: RichInputConnection.java    License: Apache License 2.0 5 votes vote down vote up
private void checkConsistencyForDebug() {
    final ExtractedTextRequest r = new ExtractedTextRequest();
    r.hintMaxChars = 0;
    r.hintMaxLines = 0;
    r.token = 1;
    r.flags = 0;
    final ExtractedText et = mIC.getExtractedText(r, 0);
    final CharSequence beforeCursor = getTextBeforeCursor(Constants.EDITOR_CONTENTS_CACHE_SIZE,
            0);
    final StringBuilder internal = new StringBuilder(mCommittedTextBeforeComposingText)
            .append(mComposingText);
    if (null == et || null == beforeCursor) return;
    final int actualLength = Math.min(beforeCursor.length(), internal.length());
    if (internal.length() > actualLength) {
        internal.delete(0, internal.length() - actualLength);
    }
    final String reference = (beforeCursor.length() <= actualLength) ? beforeCursor.toString()
            : beforeCursor.subSequence(beforeCursor.length() - actualLength,
                    beforeCursor.length()).toString();
    if (et.selectionStart != mExpectedSelStart
            || !(reference.equals(internal.toString()))) {
        final String context = "Expected selection start = " + mExpectedSelStart
                + "\nActual selection start = " + et.selectionStart
                + "\nExpected text = " + internal.length() + " " + internal
                + "\nActual text = " + reference.length() + " " + reference;
        ((LatinIME)mParent).debugDumpStateAndCrashWithException(context);
    } else {
        Log.e(TAG, DebugLogUtils.getStackTrace(2));
        Log.e(TAG, "Exp <> Actual : " + mExpectedSelStart + " <> " + et.selectionStart);
    }
}
 
Example 15
Source Project: brailleback   Source File: BrailleIME.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onStartInput(EditorInfo attribute, boolean restarting) {
    super.onStartInput(attribute, restarting);
    LogUtils.log(this, Log.VERBOSE,
            "onStartInput: inputType: %x, imeOption: %x, " +
            ", label: %s, hint: %s, package: %s, ",
            attribute.inputType, attribute.imeOptions, attribute.label,
            attribute.hintText, attribute.packageName);
    InputConnection ic = getCurrentInputConnection();
    if (ic != null) {
        ExtractedTextRequest req = new ExtractedTextRequest();
        req.token = ++mExtractedTextToken;
        req.hintMaxChars = MAX_REQUEST_CHARS;
        mExtractedText = getCurrentInputConnection().getExtractedText(req,
                InputConnection.GET_EXTRACTED_TEXT_MONITOR);
    } else {
        mExtractedText = null;
    }
    updateCurrentText();
    updateDisplay();
    mComposingBraille.clear();

    Host host = getHost();
    if (host != null) {
        host.onStartInput(attribute, restarting);
    }
}
 
Example 16
Source Project: kboard   Source File: KCommands.java    License: GNU General Public License v3.0 5 votes vote down vote up
private int getCursorPosition() {
    ExtractedText extracted = inputConnection.getExtractedText(
            new ExtractedTextRequest(), 0);
    if (extracted == null) {
        return -1;
    }
    return extracted.startOffset + extracted.selectionStart;
}
 
Example 17
@Override
public boolean select(String str) {
    boolean success = false;
    mInputConnection.beginBatchEdit();
    ExtractedText extractedText = mInputConnection.getExtractedText(new ExtractedTextRequest(), 0);
    CharSequence beforeCursor = extractedText.text;
    int index = beforeCursor.toString().lastIndexOf(str);
    if (index > 0) {
        mInputConnection.setSelection(index, index + str.length());
        success = true;
    }
    mInputConnection.endBatchEdit();
    return success;
}
 
Example 18
Source Project: 920-text-editor-v2   Source File: InputConnectionHacker.java    License: Apache License 2.0 5 votes vote down vote up
@Override
    public ExtractedText getExtractedText(ExtractedTextRequest request, int flags) {
//        return ic.getExtractedText(request, flags);
        String text = editAreaView.getSelectedText();
        if (text == null) text = "";
        ExtractedText et = new ExtractedText();
        et.text = text;
        et.partialEndOffset = text.length();
        et.selectionStart = 0;
        et.selectionEnd = text.length();
        et.flags = 0;
        return et;
    }
 
Example 19
Source Project: hackerskeyboard   Source File: LatinIME.java    License: Apache License 2.0 5 votes vote down vote up
private void checkReCorrectionOnStart() {
    if (mReCorrectionEnabled && isPredictionOn()) {
        // First get the cursor position. This is required by
        // setOldSuggestions(), so that
        // it can pass the correct range to setComposingRegion(). At this
        // point, we don't
        // have valid values for mLastSelectionStart/Stop because
        // onUpdateSelection() has
        // not been called yet.
        InputConnection ic = getCurrentInputConnection();
        if (ic == null)
            return;
        ExtractedTextRequest etr = new ExtractedTextRequest();
        etr.token = 0; // anything is fine here
        ExtractedText et = ic.getExtractedText(etr, 0);
        if (et == null)
            return;

        mLastSelectionStart = et.startOffset + et.selectionStart;
        mLastSelectionEnd = et.startOffset + et.selectionEnd;

        // Then look for possible corrections in a delayed fashion
        if (!TextUtils.isEmpty(et.text) && isCursorTouchingWord()) {
            postUpdateOldSuggestions();
        }
    }
}
 
Example 20
Source Project: hackerskeyboard   Source File: EditingUtil.java    License: Apache License 2.0 5 votes vote down vote up
private static int getCursorPosition(InputConnection connection) {
    ExtractedText extracted = connection.getExtractedText(
        new ExtractedTextRequest(), 0);
    if (extracted == null) {
      return -1;
    }
    return extracted.startOffset + extracted.selectionStart;
}
 
Example 21
Source Project: 365browser   Source File: ThreadedInputConnection.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * @see InputConnection#getExtractedText(android.view.inputmethod.ExtractedTextRequest, int)
 */
@Override
public ExtractedText getExtractedText(ExtractedTextRequest request, int flags) {
    if (DEBUG_LOGS) Log.i(TAG, "getExtractedText");
    assertOnImeThread();
    mShouldUpdateExtractedText = (flags & GET_EXTRACTED_TEXT_MONITOR) > 0;
    if (mShouldUpdateExtractedText) {
        mCurrentExtractedTextRequestToken = request != null ? request.token : 0;
    }
    TextInputState textInputState = requestAndWaitForTextInputState();
    return convertToExtractedText(textInputState);
}
 
Example 22
Source Project: kboard   Source File: KCommands.java    License: GNU General Public License v3.0 5 votes vote down vote up
private int getCursorPosition() {
    ExtractedText extracted = inputConnection.getExtractedText(
            new ExtractedTextRequest(), 0);
    if (extracted == null) {
        return -1;
    }
    return extracted.startOffset + extracted.selectionStart;
}
 
Example 23
Source Project: JotaTextEditor   Source File: EditableInputConnection.java    License: Apache License 2.0 5 votes vote down vote up
public ExtractedText getExtractedText(ExtractedTextRequest request, int flags) {
    if (mTextView != null) {
        ExtractedText et = new ExtractedText();
        if (mTextView.extractText(request, et)) {
            if ((flags&GET_EXTRACTED_TEXT_MONITOR) != 0) {
                mTextView.setExtracting(request);
            }
            return et;
        }
    }
    return null;
}
 
Example 24
@Override
public ExtractedText getExtractedText(ExtractedTextRequest request, int flags) {
    if (Display.isInitialized() && Display.getInstance().getCurrent() != null) {
        this.request = request;
        ExtractedText et = new ExtractedText();
        if (extractText(request, et)) {
            return et;
        }
    }
    return null;
}
 
Example 25
boolean extractTextInternal(ExtractedTextRequest request, ExtractedText outText) {

        Component txtCmp = Display.getInstance().getCurrent().getFocused();
        if (txtCmp != null && txtCmp instanceof TextField) {
            String txt = ((TextField) txtCmp).getText();
            int partialStartOffset = -1;
            int partialEndOffset = -1;
            final CharSequence content = txt;
            if (content != null) {
                final int N = content.length();
                outText.partialStartOffset = outText.partialEndOffset = -1;
                partialStartOffset = 0;
                partialEndOffset = N;

                if ((request.flags & InputConnection.GET_TEXT_WITH_STYLES) != 0) {
                    outText.text = content.subSequence(partialStartOffset,
                            partialEndOffset);
                } else {
                    outText.text = TextUtils.substring(content, partialStartOffset,
                            partialEndOffset);
                }

                outText.flags = 0;
                outText.flags |= ExtractedText.FLAG_SINGLE_LINE;
                outText.startOffset = 0;
                outText.selectionStart = Selection.getSelectionStart(content);
                outText.selectionEnd = Selection.getSelectionEnd(content);
                return true;
            }

        }
        return false;
    }
 
Example 26
Source Project: Indic-Keyboard   Source File: RichInputConnection.java    License: Apache License 2.0 5 votes vote down vote up
private void checkConsistencyForDebug() {
    final ExtractedTextRequest r = new ExtractedTextRequest();
    r.hintMaxChars = 0;
    r.hintMaxLines = 0;
    r.token = 1;
    r.flags = 0;
    final ExtractedText et = mIC.getExtractedText(r, 0);
    final CharSequence beforeCursor = getTextBeforeCursor(Constants.EDITOR_CONTENTS_CACHE_SIZE,
            0);
    final StringBuilder internal = new StringBuilder(mCommittedTextBeforeComposingText)
            .append(mComposingText);
    if (null == et || null == beforeCursor) return;
    final int actualLength = Math.min(beforeCursor.length(), internal.length());
    if (internal.length() > actualLength) {
        internal.delete(0, internal.length() - actualLength);
    }
    final String reference = (beforeCursor.length() <= actualLength) ? beforeCursor.toString()
            : beforeCursor.subSequence(beforeCursor.length() - actualLength,
                    beforeCursor.length()).toString();
    if (et.selectionStart != mExpectedSelStart
            || !(reference.equals(internal.toString()))) {
        final String context = "Expected selection start = " + mExpectedSelStart
                + "\nActual selection start = " + et.selectionStart
                + "\nExpected text = " + internal.length() + " " + internal
                + "\nActual text = " + reference.length() + " " + reference;
        ((LatinIME)mParent).debugDumpStateAndCrashWithException(context);
    } else {
        Log.e(TAG, DebugLogUtils.getStackTrace(2));
        Log.e(TAG, "Exp <> Actual : " + mExpectedSelStart + " <> " + et.selectionStart);
    }
}
 
Example 27
Source Project: TokenAutoComplete   Source File: TokenCompleteTextView.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public boolean extractText(@NonNull ExtractedTextRequest request, @NonNull ExtractedText outText) {
    try {
        return super.extractText(request, outText);
    } catch (IndexOutOfBoundsException ex) {
        Log.d(TAG, "extractText hit IndexOutOfBoundsException. This may be normal.", ex);
        return false;
    }
}
 
Example 28
/**
 * @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;
}
 
Example 29
/**
 * @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;
}
 
Example 30
Source Project: remotekeyboard   Source File: CtrlInputAction.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Place the cursor on the next occurance of a symbol
 * 
 * @param con
 *          driver
 * @param symbol
 *          the symbol to jump to
 */
private void jumpForward(InputConnection con, int symbol) {
	ExtractedText txt = con.getExtractedText(new ExtractedTextRequest(), 0);
	if (txt != null) {
		int pos = txt.text.toString().indexOf(symbol, txt.selectionEnd + 1);
		if (pos == -1) {
			pos = txt.text.length();
		}
		con.setSelection(pos, pos);
	}
}