androidx.core.view.inputmethod.InputConnectionCompat Java Examples
The following examples show how to use
androidx.core.view.inputmethod.InputConnectionCompat.
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 check out the related API usage on the sidebar.
Example #1
Source File: ComposeText.java From mollyim-android with GNU General Public License v3.0 | 6 votes |
@Override public boolean onCommitContent(InputContentInfoCompat inputContentInfo, int flags, Bundle opts) { if (BuildCompat.isAtLeastNMR1() && (flags & InputConnectionCompat.INPUT_CONTENT_GRANT_READ_URI_PERMISSION) != 0) { try { inputContentInfo.requestPermission(); } catch (Exception e) { Log.w(TAG, e); return false; } } if (inputContentInfo.getDescription().getMimeTypeCount() > 0) { mediaListener.onMediaSelected(inputContentInfo.getContentUri(), inputContentInfo.getDescription().getMimeType(0)); return true; } return false; }
Example #2
Source File: QiscusEditText.java From qiscus-sdk-android with Apache License 2.0 | 6 votes |
@Override public InputConnection onCreateInputConnection(final EditorInfo info) { final InputConnection ic = super.onCreateInputConnection(info); EditorInfoCompat.setContentMimeTypes(info, new String[]{"image/gif"}); final InputConnectionCompat.OnCommitContentListener callback = (info1, flags, opts) -> { if (BuildVersionUtil.isAtLeastNMR1() && (flags & InputConnectionCompat.INPUT_CONTENT_GRANT_READ_URI_PERMISSION) != 0) { try { info1.requestPermission(); } catch (Exception e) { return false; } } if (commitListener != null) { commitListener.onCommitContent(info1); } return true; }; return InputConnectionCompat.createWrapper(ic, info, callback); }
Example #3
Source File: ComposeText.java From deltachat-android with GNU General Public License v3.0 | 6 votes |
@Override public boolean onCommitContent(InputContentInfoCompat inputContentInfo, int flags, Bundle opts) { if (BuildCompat.isAtLeastNMR1() && (flags & InputConnectionCompat.INPUT_CONTENT_GRANT_READ_URI_PERMISSION) != 0) { try { inputContentInfo.requestPermission(); } catch (Exception e) { Log.w(TAG, e); return false; } } if (inputContentInfo.getDescription().getMimeTypeCount() > 0) { mediaListener.onMediaSelected(inputContentInfo.getContentUri(), inputContentInfo.getDescription().getMimeType(0)); return true; } return false; }
Example #4
Source File: ConversationFragment.java From Pix-Art-Messenger with GNU General Public License v3.0 | 6 votes |
@Override public boolean onCommitContent(InputContentInfoCompat inputContentInfo, int flags, Bundle opts, String[] contentMimeTypes) { // try to get permission to read the image, if applicable if ((flags & InputConnectionCompat.INPUT_CONTENT_GRANT_READ_URI_PERMISSION) != 0) { try { inputContentInfo.requestPermission(); } catch (Exception e) { Log.e(Config.LOGTAG, "InputContentInfoCompat#requestPermission() failed.", e); ToastCompat.makeText(getActivity(), activity.getString(R.string.no_permission_to_access_x, inputContentInfo.getDescription()), Toast.LENGTH_LONG ).show(); return false; } } if (hasPermissions(REQUEST_ADD_EDITOR_CONTENT, Manifest.permission.WRITE_EXTERNAL_STORAGE) && hasPermissions(REQUEST_ADD_EDITOR_CONTENT, Manifest.permission.READ_EXTERNAL_STORAGE)) { attachEditorContentToConversation(inputContentInfo.getContentUri()); } else { mPendingEditorContent = inputContentInfo.getContentUri(); } return true; }
Example #5
Source File: RichEditText.java From linphone-android with GNU General Public License v3.0 | 6 votes |
@Override public InputConnection onCreateInputConnection(EditorInfo editorInfo) { final InputConnection ic = super.onCreateInputConnection(editorInfo); EditorInfoCompat.setContentMimeTypes(editorInfo, mSupportedMimeTypes); final InputConnectionCompat.OnCommitContentListener callback = new InputConnectionCompat.OnCommitContentListener() { @Override public boolean onCommitContent( InputContentInfoCompat inputContentInfo, int flags, Bundle opts) { if (mListener != null) { return mListener.onCommitContent( inputContentInfo, flags, opts, mSupportedMimeTypes); } return false; } }; if (ic != null) { return InputConnectionCompat.createWrapper(ic, editorInfo, callback); } return null; }
Example #6
Source File: ChatMessagesFragment.java From linphone-android with GNU General Public License v3.0 | 6 votes |
private boolean onCommitContentInternal(InputContentInfoCompat inputContentInfo, int flags) { if ((flags & InputConnectionCompat.INPUT_CONTENT_GRANT_READ_URI_PERMISSION) != 0) { try { inputContentInfo.requestPermission(); } catch (Exception e) { Log.e("[Chat Messages Fragment] requestPermission failed : ", e); return false; } } if (inputContentInfo.getContentUri() != null) { String contentUri = FileUtils.getFilePath(mContext, inputContentInfo.getContentUri()); addImageToPendingList(contentUri); } mCurrentInputContentInfo = inputContentInfo; return true; }
Example #7
Source File: ComposeText.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
@Override public InputConnection onCreateInputConnection(EditorInfo editorInfo) { InputConnection inputConnection = super.onCreateInputConnection(editorInfo); if(TextSecurePreferences.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; EditorInfoCompat.setContentMimeTypes(editorInfo, new String[] {"image/jpeg", "image/png", "image/gif"}); return InputConnectionCompat.createWrapper(inputConnection, editorInfo, new CommitContentListener(mediaListener)); }
Example #8
Source File: EditTextCompose.java From FairEmail with GNU General Public License v3.0 | 5 votes |
@Override public InputConnection onCreateInputConnection(EditorInfo editorInfo) { //https://developer.android.com/guide/topics/text/image-keyboard InputConnection ic = super.onCreateInputConnection(editorInfo); if (ic == null) return null; EditorInfoCompat.setContentMimeTypes(editorInfo, new String[]{"image/*"}); return InputConnectionCompat.createWrapper(ic, editorInfo, new InputConnectionCompat.OnCommitContentListener() { @Override public boolean onCommitContent(InputContentInfoCompat info, int flags, Bundle opts) { Log.i("Uri=" + info.getContentUri()); try { if (inputContentListener == null) throw new IllegalArgumentException("InputContent listener not set"); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1 && (flags & InputConnectionCompat.INPUT_CONTENT_GRANT_READ_URI_PERMISSION) != 0) info.requestPermission(); inputContentListener.onInputContent(info.getContentUri()); return true; } catch (Throwable ex) { Log.w(ex); return false; } } }); }
Example #9
Source File: ComposeText.java From deltachat-android with GNU General Public License v3.0 | 5 votes |
@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; EditorInfoCompat.setContentMimeTypes(editorInfo, new String[] {"image/jpeg", "image/png", "image/gif"}); return InputConnectionCompat.createWrapper(inputConnection, editorInfo, new CommitContentListener(mediaListener)); }
Example #10
Source File: EditMessage.java From Pix-Art-Messenger with GNU General Public License v3.0 | 5 votes |
@Override public InputConnection onCreateInputConnection(EditorInfo editorInfo) { final InputConnection ic = super.onCreateInputConnection(editorInfo); if (mimeTypes != null && mCommitContentListener != null && ic != null) { EditorInfoCompat.setContentMimeTypes(editorInfo, mimeTypes); return InputConnectionCompat.createWrapper(ic, editorInfo, (inputContentInfo, flags, opts) -> EditMessage.this.mCommitContentListener.onCommitContent(inputContentInfo, flags, opts, mimeTypes)); } else { return ic; } }