use of android.view.inputmethod.InputConnection in project deltachat-android by deltachat.
the class ComposeText method onCreateInputConnection.
@Override
public InputConnection onCreateInputConnection(EditorInfo editorInfo) {
InputConnection inputConnection = super.onCreateInputConnection(editorInfo);
if (Prefs.isEnterSendsEnabled(getContext())) {
editorInfo.imeOptions &= ~EditorInfo.IME_FLAG_NO_ENTER_ACTION;
}
if (Build.VERSION.SDK_INT < 21)
return inputConnection;
if (mediaListener == null)
return inputConnection;
if (inputConnection == null)
return null;
// media with mime-types defined by setContentMimeTypes() may be selected in the system keyboard
// and are passed to onCommitContent() then;
// from there we use them as stickers.
EditorInfoCompat.setContentMimeTypes(editorInfo, new String[] { "image/jpeg", "image/png", "image/gif", "image/webp" });
return InputConnectionCompat.createWrapper(inputConnection, editorInfo, new CommitContentListener(mediaListener));
}
use of android.view.inputmethod.InputConnection in project android-java-chat-push-notification-app by cometchat-pro.
the class CometChatEditText method onCreateInputConnection.
@Override
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
final InputConnection ic = super.onCreateInputConnection(outAttrs);
EditorInfoCompat.setContentMimeTypes(outAttrs, new String[] { "image/png", "image/gif" });
final InputConnectionCompat.OnCommitContentListener callback = new InputConnectionCompat.OnCommitContentListener() {
@Override
public boolean onCommitContent(InputContentInfoCompat inputContentInfo, int flags, Bundle opts) {
// read and display inputContentInfo asynchronously
if (BuildCompat.isAtLeastNMR1() && (flags & InputConnectionCompat.INPUT_CONTENT_GRANT_READ_URI_PERMISSION) != 0) {
try {
inputContentInfo.requestPermission();
} catch (Exception e) {
// return false if failed
return false;
}
}
ContentResolver cr = getContext().getContentResolver();
String mimeType = cr.getType(inputContentInfo.getLinkUri());
Log.e(TAG, "onCommitContent: " + inputContentInfo.getLinkUri().getPath() + "\n" + inputContentInfo.getContentUri() + "\n" + mimeType);
onEditTextMediaListener.OnMediaSelected(inputContentInfo);
// return true if succeeded
return true;
}
};
return InputConnectionCompat.createWrapper(ic, outAttrs, callback);
}
use of android.view.inputmethod.InputConnection in project K6nele by Kaljurand.
the class SpeechInputMethodService method onStartInputView.
/**
* Note that when editing a HTML page, then switching between form fields might fail to call
* this method with restarting=false, we thus always update the editor info (incl. inputType).
*/
@Override
public void onStartInputView(EditorInfo editorInfo, boolean restarting) {
super.onStartInputView(editorInfo, restarting);
Log.i("onStartInputView: " + editorInfo.inputType + "/" + editorInfo.imeOptions + "/" + restarting);
InputConnection ic = getCurrentInputConnection();
// TODO: review, e.g. move to after restarting-check
if (ic == null) {
toast(R.string.errorFailedGetCurrentInputConnection);
// switchToLastIme();
return;
}
((InputConnectionCommandEditor) mCommandEditor).setInputConnection(ic);
// TODO: quick hack to add app to the matcher, not sure if we can access the class name of the app
// TODO: use getPackageName() or editorInfo.packageName, but not both
String packageName = editorInfo.packageName;
ComponentName app = new ComponentName(packageName, packageName);
mInputView.init(R.array.keysIme, new CallerInfo(makeExtras(), editorInfo, getPackageName()), true, app);
// TODO: update this less often (in onStart)
closeSession();
if (restarting) {
return;
}
mInputView.setListener(getSpeechInputViewListener(getMyWindow(), app, mRuleManager), editorInfo);
mShowPartialResults = PreferenceUtils.getPrefBoolean(mPrefs, mRes, R.string.keyImeShowPartialResults, R.bool.defaultImeShowPartialResults);
// Launch recognition immediately (if set so)
if (PreferenceUtils.getPrefBoolean(mPrefs, mRes, R.string.keyImeAutoStart, R.bool.defaultImeAutoStart)) {
Log.i("Auto-starting");
mInputView.start();
}
}
use of android.view.inputmethod.InputConnection in project wire-android by wireapp.
the class CursorEditText method onCreateInputConnection.
@Override
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
InputConnection conn = super.onCreateInputConnection(outAttrs);
outAttrs.imeOptions &= ~EditorInfo.IME_FLAG_NO_ENTER_ACTION;
return new CursorInputConnection(conn, true);
}
use of android.view.inputmethod.InputConnection in project syncthing-android by syncthing.
the class EnhancedEditText method onCreateInputConnection.
@Override
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
InputConnection conn = super.onCreateInputConnection(outAttrs);
outAttrs.imeOptions &= ~IME_FLAG_NO_ENTER_ACTION;
return conn;
}
Aggregations