Search in sources :

Example 1 with ExtractedTextRequest

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

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 2 with ExtractedTextRequest

use of android.view.inputmethod.ExtractedTextRequest in project Jota-Text-Editor-old by jiro-aqua.

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(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(TAG, "Reporting extracted start=" + ims.mTmpExtracted.partialStartOffset + " end=" + ims.mTmpExtracted.partialEndOffset + ": " + ims.mTmpExtracted.text);
                        imm.updateExtractedText(this, req.token, mInputMethodState.mTmpExtracted);
                        return true;
                    }
                }
            }
        }
    }
    return false;
}
Also used : ExtractedTextRequest(android.view.inputmethod.ExtractedTextRequest) InputMethodManager(android.view.inputmethod.InputMethodManager)

Example 3 with ExtractedTextRequest

use of android.view.inputmethod.ExtractedTextRequest in project platform_frameworks_base by android.

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 4 with ExtractedTextRequest

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

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 5 with ExtractedTextRequest

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

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)

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