use of android.view.inputmethod.InputConnection 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);
}
}
}
use of android.view.inputmethod.InputConnection in project android_frameworks_base by ParanoidAndroid.
the class InputMethodService method updateFullscreenMode.
/**
* Re-evaluate whether the input method should be running in fullscreen
* mode, and update its UI if this has changed since the last time it
* was evaluated. This will call {@link #onEvaluateFullscreenMode()} to
* determine whether it should currently run in fullscreen mode. You
* can use {@link #isFullscreenMode()} to determine if the input method
* is currently running in fullscreen mode.
*/
public void updateFullscreenMode() {
boolean fullScreenOverride = Settings.System.getInt(getContentResolver(), Settings.System.DISABLE_FULLSCREEN_KEYBOARD, 0) != 0;
boolean isFullscreen;
if (fullScreenOverride) {
isFullscreen = false;
} else {
isFullscreen = mShowInputRequested && onEvaluateFullscreenMode();
}
boolean changed = mLastShowInputRequested != mShowInputRequested;
if (mIsFullscreen != isFullscreen || !mFullscreenApplied) {
changed = true;
mIsFullscreen = isFullscreen;
InputConnection ic = getCurrentInputConnection();
if (ic != null)
ic.reportFullscreenMode(isFullscreen);
mFullscreenApplied = true;
initialize();
LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) mFullscreenArea.getLayoutParams();
if (isFullscreen) {
mFullscreenArea.setBackgroundDrawable(mThemeAttrs.getDrawable(com.android.internal.R.styleable.InputMethodService_imeFullscreenBackground));
lp.height = 0;
lp.weight = 1;
} else {
mFullscreenArea.setBackgroundDrawable(null);
lp.height = LinearLayout.LayoutParams.WRAP_CONTENT;
lp.weight = 0;
}
((ViewGroup) mFullscreenArea.getParent()).updateViewLayout(mFullscreenArea, lp);
if (isFullscreen) {
if (mExtractView == null) {
View v = onCreateExtractTextView();
if (v != null) {
setExtractView(v);
}
}
startExtractingText(false);
}
updateExtractFrameVisibility();
}
if (changed) {
onConfigureWindow(mWindow.getWindow(), isFullscreen, !mShowInputRequested);
mLastShowInputRequested = mShowInputRequested;
}
}
use of android.view.inputmethod.InputConnection in project android_frameworks_base by ParanoidAndroid.
the class InputMethodService method sendDownUpKeyEvents.
/**
* Send the given key event code (as defined by {@link KeyEvent}) to the
* current input connection is a key down + key up event pair. The sent
* events have {@link KeyEvent#FLAG_SOFT_KEYBOARD KeyEvent.FLAG_SOFT_KEYBOARD}
* set, so that the recipient can identify them as coming from a software
* input method, and
* {@link KeyEvent#FLAG_KEEP_TOUCH_MODE KeyEvent.FLAG_KEEP_TOUCH_MODE}, so
* that they don't impact the current touch mode of the UI.
*
* <p>Note that it's discouraged to send such key events in normal operation;
* this is mainly for use with {@link android.text.InputType#TYPE_NULL} type
* text fields, or for non-rich input methods. A reasonably capable software
* input method should use the
* {@link android.view.inputmethod.InputConnection#commitText} family of methods
* to send text to an application, rather than sending key events.</p>
*
* @param keyEventCode The raw key code to send, as defined by
* {@link KeyEvent}.
*/
public void sendDownUpKeyEvents(int keyEventCode) {
InputConnection ic = getCurrentInputConnection();
if (ic == null)
return;
long eventTime = SystemClock.uptimeMillis();
ic.sendKeyEvent(new KeyEvent(eventTime, eventTime, KeyEvent.ACTION_DOWN, keyEventCode, 0, 0, KeyCharacterMap.VIRTUAL_KEYBOARD, 0, KeyEvent.FLAG_SOFT_KEYBOARD | KeyEvent.FLAG_KEEP_TOUCH_MODE));
ic.sendKeyEvent(new KeyEvent(eventTime, SystemClock.uptimeMillis(), KeyEvent.ACTION_UP, keyEventCode, 0, 0, KeyCharacterMap.VIRTUAL_KEYBOARD, 0, KeyEvent.FLAG_SOFT_KEYBOARD | KeyEvent.FLAG_KEEP_TOUCH_MODE));
}
use of android.view.inputmethod.InputConnection in project android_frameworks_base by ParanoidAndroid.
the class IInputMethodWrapper method bindInput.
@Override
public void bindInput(InputBinding binding) {
InputConnection ic = new InputConnectionWrapper(IInputContext.Stub.asInterface(binding.getConnectionToken()));
InputBinding nu = new InputBinding(ic, binding);
mCaller.executeOrSendMessage(mCaller.obtainMessageO(DO_SET_INPUT_CONTEXT, nu));
}
use of android.view.inputmethod.InputConnection in project android_frameworks_base by ResurrectionRemix.
the class TextView method onCreateInputConnection.
@Override
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
if (onCheckIsTextEditor() && isEnabled()) {
mEditor.createInputMethodStateIfNeeded();
outAttrs.inputType = getInputType();
if (mEditor.mInputContentType != null) {
outAttrs.imeOptions = mEditor.mInputContentType.imeOptions;
outAttrs.privateImeOptions = mEditor.mInputContentType.privateImeOptions;
outAttrs.actionLabel = mEditor.mInputContentType.imeActionLabel;
outAttrs.actionId = mEditor.mInputContentType.imeActionId;
outAttrs.extras = mEditor.mInputContentType.extras;
outAttrs.hintLocales = mEditor.mInputContentType.imeHintLocales;
} else {
outAttrs.imeOptions = EditorInfo.IME_NULL;
outAttrs.hintLocales = null;
}
if (focusSearch(FOCUS_DOWN) != null) {
outAttrs.imeOptions |= EditorInfo.IME_FLAG_NAVIGATE_NEXT;
}
if (focusSearch(FOCUS_UP) != null) {
outAttrs.imeOptions |= EditorInfo.IME_FLAG_NAVIGATE_PREVIOUS;
}
if ((outAttrs.imeOptions & EditorInfo.IME_MASK_ACTION) == EditorInfo.IME_ACTION_UNSPECIFIED) {
if ((outAttrs.imeOptions & EditorInfo.IME_FLAG_NAVIGATE_NEXT) != 0) {
// An action has not been set, but the enter key will move to
// the next focus, so set the action to that.
outAttrs.imeOptions |= EditorInfo.IME_ACTION_NEXT;
} else {
// An action has not been set, and there is no focus to move
// to, so let's just supply a "done" action.
outAttrs.imeOptions |= EditorInfo.IME_ACTION_DONE;
}
if (!shouldAdvanceFocusOnEnter()) {
outAttrs.imeOptions |= EditorInfo.IME_FLAG_NO_ENTER_ACTION;
}
}
if (isMultilineInputType(outAttrs.inputType)) {
// Multi-line text editors should always show an enter key.
outAttrs.imeOptions |= EditorInfo.IME_FLAG_NO_ENTER_ACTION;
}
outAttrs.hintText = mHint;
if (mText instanceof Editable) {
InputConnection ic = new EditableInputConnection(this);
outAttrs.initialSelStart = getSelectionStart();
outAttrs.initialSelEnd = getSelectionEnd();
outAttrs.initialCapsMode = ic.getCursorCapsMode(getInputType());
return ic;
}
}
return null;
}
Aggregations