-
-
Save hitherejoe/b6b759bbbde9f6c41e7f16a1727a1a4a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override fun onCreateInputConnection(editorInfo: EditorInfo): InputConnection { | |
val inputConnection = super.onCreateInputConnection(editorInfo) | |
EditorInfoCompat.setContentMimeTypes(editorInfo, arrayOf("image/gif", "image/png")) | |
val callback = InputConnectionCompat.OnCommitContentListener { inputContentInfo, flags, _ -> | |
if (ApiLevelHelper.isAtLeast(25) && flags and InputConnectionCompat.INPUT_CONTENT_GRANT_READ_URI_PERMISSION != 0) { | |
try { | |
inputContentInfo.requestPermission() | |
} catch (e: Exception) { | |
return@OnCommitContentListener false | |
} | |
mediaSelectionListener?.onMediaSelected(inputContentInfo.contentUri) | |
} | |
true | |
} | |
return InputConnectionCompat.createWrapper(inputConnection, editorInfo, callback) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi! What is a mediaSelectionListener? Is that your custom interface?