Search in sources :

Example 16 with ExtractedTextRequest

use of android.view.inputmethod.ExtractedTextRequest in project android_frameworks_base by AOSPA.

the class Editor method reportExtractedText.

boolean reportExtractedText() {
    final Editor.InputMethodState ims = mInputMethodState;
    if (ims != null) {
        final boolean contentChanged = ims.mContentChanged;
        if (contentChanged || ims.mSelectionModeChanged) {
            ims.mContentChanged = false;
            ims.mSelectionModeChanged = false;
            final ExtractedTextRequest req = ims.mExtractedTextRequest;
            if (req != null) {
                InputMethodManager imm = InputMethodManager.peekInstance();
                if (imm != null) {
                    if (TextView.DEBUG_EXTRACT)
                        Log.v(TextView.LOG_TAG, "Retrieving extracted start=" + ims.mChangedStart + " end=" + ims.mChangedEnd + " delta=" + ims.mChangedDelta);
                    if (ims.mChangedStart < 0 && !contentChanged) {
                        ims.mChangedStart = EXTRACT_NOTHING;
                    }
                    if (extractTextInternal(req, ims.mChangedStart, ims.mChangedEnd, ims.mChangedDelta, ims.mExtractedText)) {
                        if (TextView.DEBUG_EXTRACT)
                            Log.v(TextView.LOG_TAG, "Reporting extracted start=" + ims.mExtractedText.partialStartOffset + " end=" + ims.mExtractedText.partialEndOffset + ": " + ims.mExtractedText.text);
                        imm.updateExtractedText(mTextView, req.token, ims.mExtractedText);
                        ims.mChangedStart = EXTRACT_UNKNOWN;
                        ims.mChangedEnd = EXTRACT_UNKNOWN;
                        ims.mChangedDelta = 0;
                        ims.mContentChanged = false;
                        return true;
                    }
                }
            }
        }
    }
    return false;
}
Also used : ExtractedTextRequest(android.view.inputmethod.ExtractedTextRequest) InputMethodManager(android.view.inputmethod.InputMethodManager)

Example 17 with ExtractedTextRequest

use of android.view.inputmethod.ExtractedTextRequest in project XobotOS by xamarin.

the class TextView method reportExtractedText.

boolean reportExtractedText() {
    final InputMethodState ims = mInputMethodState;
    if (ims != null) {
        final boolean contentChanged = ims.mContentChanged;
        if (contentChanged || ims.mSelectionModeChanged) {
            ims.mContentChanged = false;
            ims.mSelectionModeChanged = false;
            final ExtractedTextRequest req = mInputMethodState.mExtracting;
            if (req != null) {
                InputMethodManager imm = InputMethodManager.peekInstance();
                if (imm != null) {
                    if (DEBUG_EXTRACT)
                        Log.v(LOG_TAG, "Retrieving extracted start=" + ims.mChangedStart + " end=" + ims.mChangedEnd + " delta=" + ims.mChangedDelta);
                    if (ims.mChangedStart < 0 && !contentChanged) {
                        ims.mChangedStart = EXTRACT_NOTHING;
                    }
                    if (extractTextInternal(req, ims.mChangedStart, ims.mChangedEnd, ims.mChangedDelta, ims.mTmpExtracted)) {
                        if (DEBUG_EXTRACT)
                            Log.v(LOG_TAG, "Reporting extracted start=" + ims.mTmpExtracted.partialStartOffset + " end=" + ims.mTmpExtracted.partialEndOffset + ": " + ims.mTmpExtracted.text);
                        imm.updateExtractedText(this, req.token, mInputMethodState.mTmpExtracted);
                        ims.mChangedStart = EXTRACT_UNKNOWN;
                        ims.mChangedEnd = EXTRACT_UNKNOWN;
                        ims.mChangedDelta = 0;
                        ims.mContentChanged = false;
                        return true;
                    }
                }
            }
        }
    }
    return false;
}
Also used : ExtractedTextRequest(android.view.inputmethod.ExtractedTextRequest) InputMethodManager(android.view.inputmethod.InputMethodManager)

Example 18 with ExtractedTextRequest

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

the class InputMethodService method startExtractingText.

void startExtractingText(boolean inputChanged) {
    final ExtractEditText eet = mExtractEditText;
    if (eet != null && getCurrentInputStarted() && isFullscreenMode()) {
        mExtractedToken++;
        ExtractedTextRequest req = new ExtractedTextRequest();
        req.token = mExtractedToken;
        req.flags = InputConnection.GET_TEXT_WITH_STYLES;
        req.hintMaxLines = 10;
        req.hintMaxChars = 10000;
        InputConnection ic = getCurrentInputConnection();
        mExtractedText = ic == null ? null : ic.getExtractedText(req, InputConnection.GET_EXTRACTED_TEXT_MONITOR);
        if (mExtractedText == null || ic == null) {
            Log.e(TAG, "Unexpected null in startExtractingText : mExtractedText = " + mExtractedText + ", input connection = " + ic);
        }
        final EditorInfo ei = getCurrentInputEditorInfo();
        try {
            eet.startInternalChanges();
            onUpdateExtractingVisibility(ei);
            onUpdateExtractingViews(ei);
            int inputType = ei.inputType;
            if ((inputType & EditorInfo.TYPE_MASK_CLASS) == EditorInfo.TYPE_CLASS_TEXT) {
                if ((inputType & EditorInfo.TYPE_TEXT_FLAG_IME_MULTI_LINE) != 0) {
                    inputType |= EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE;
                }
            }
            eet.setInputType(inputType);
            eet.setHint(ei.hintText);
            if (mExtractedText != null) {
                eet.setEnabled(true);
                eet.setExtractedText(mExtractedText);
            } else {
                eet.setEnabled(false);
                eet.setText("");
            }
        } finally {
            eet.finishInternalChanges();
        }
        if (inputChanged) {
            onExtractingInputChanged(ei);
        }
    }
}
Also used : InputConnection(android.view.inputmethod.InputConnection) EditorInfo(android.view.inputmethod.EditorInfo) ExtractedTextRequest(android.view.inputmethod.ExtractedTextRequest)

Example 19 with ExtractedTextRequest

use of android.view.inputmethod.ExtractedTextRequest in project android_frameworks_base by crdroidandroid.

the class InputMethodService method startExtractingText.

void startExtractingText(boolean inputChanged) {
    final ExtractEditText eet = mExtractEditText;
    if (eet != null && getCurrentInputStarted() && isFullscreenMode()) {
        mExtractedToken++;
        ExtractedTextRequest req = new ExtractedTextRequest();
        req.token = mExtractedToken;
        req.flags = InputConnection.GET_TEXT_WITH_STYLES;
        req.hintMaxLines = 10;
        req.hintMaxChars = 10000;
        InputConnection ic = getCurrentInputConnection();
        mExtractedText = ic == null ? null : ic.getExtractedText(req, InputConnection.GET_EXTRACTED_TEXT_MONITOR);
        if (mExtractedText == null || ic == null) {
            Log.e(TAG, "Unexpected null in startExtractingText : mExtractedText = " + mExtractedText + ", input connection = " + ic);
        }
        final EditorInfo ei = getCurrentInputEditorInfo();
        try {
            eet.startInternalChanges();
            onUpdateExtractingVisibility(ei);
            onUpdateExtractingViews(ei);
            int inputType = ei.inputType;
            if ((inputType & EditorInfo.TYPE_MASK_CLASS) == EditorInfo.TYPE_CLASS_TEXT) {
                if ((inputType & EditorInfo.TYPE_TEXT_FLAG_IME_MULTI_LINE) != 0) {
                    inputType |= EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE;
                }
            }
            eet.setInputType(inputType);
            eet.setHint(ei.hintText);
            if (mExtractedText != null) {
                eet.setEnabled(true);
                eet.setExtractedText(mExtractedText);
            } else {
                eet.setEnabled(false);
                eet.setText("");
            }
        } finally {
            eet.finishInternalChanges();
        }
        if (inputChanged) {
            onExtractingInputChanged(ei);
        }
    }
}
Also used : InputConnection(android.view.inputmethod.InputConnection) EditorInfo(android.view.inputmethod.EditorInfo) ExtractedTextRequest(android.view.inputmethod.ExtractedTextRequest)

Aggregations

ExtractedTextRequest (android.view.inputmethod.ExtractedTextRequest)19 InputConnection (android.view.inputmethod.InputConnection)9 EditorInfo (android.view.inputmethod.EditorInfo)8 InputMethodManager (android.view.inputmethod.InputMethodManager)8 KeyEvent (android.view.KeyEvent)2 ExtractedText (android.view.inputmethod.ExtractedText)2 Paint (android.graphics.Paint)1 Bundle (android.os.Bundle)1 Pair (android.support.v4.util.Pair)1 SpannableStringBuilder (android.text.SpannableStringBuilder)1 BaseInputConnection (android.view.inputmethod.BaseInputConnection)1 CompletionInfo (android.view.inputmethod.CompletionInfo)1 CorrectionInfo (android.view.inputmethod.CorrectionInfo)1 IOException (java.io.IOException)1