feat(clipboard): add image pasting#2312
Conversation
When the user copies an image and presses the clipboard paste key, commit it to the target app using Android's commitContent API. Shows a toast if the editor doesn't support the MIME type. Text pasting continues to work as before. Signed-off-by: slonka <slonka@users.noreply.github.com>
Signed-off-by: slonka <slonka@users.noreply.github.com>
d3b60d1 to
3a4edca
Compare
Signed-off-by: slonka <slonka@users.noreply.github.com>
|
@Helium314 can I get a review of this? |
|
@slonka, get in line 🙂 |
|
@slonka my main issue is lack of time for all the things that should be done, that's why I put "Due to maintainer availability, your PR may take quite some time to be addressed" in the PR template. I certainly intend to review, and I know that review soon after PR is done is much better than waiting for months first. But each one of PRs, gesture typing project, issues, or discussions / help is enough to completely fill my available time on its own. So sorry, but you will likely need to wait for a few more weeks. |
|
So, finally... sorry for the wait This looks really good, only some minor things (will comment in code). |
| } | ||
|
|
||
| @JvmStatic | ||
| fun isMimeTypeSupportedByEditor(editorInfo: EditorInfo?, mimeType: String): Boolean { |
There was a problem hiding this comment.
This appears to be useful, but is not used at all. (I assume the unused toast_msg_unsupported_uri is related)
| * | ||
| */ | ||
| private void handleClipboardPaste() { | ||
| final android.net.Uri clipUri = mLatinIME.getClipboardHistoryManager().retrieveClipboardUri(); |
There was a problem hiding this comment.
Why android.net.Uri instead of importing?
It's not really relevant, but I'd prefer imports unless you have a good reason for the current state (similar in other places).
| binding.clipboardSuggestionText.isGone = true | ||
| val imageView = binding.clipboardSuggestionImage | ||
| imageView.visibility = View.VISIBLE |
There was a problem hiding this comment.
I'd prefer use of the extensions (isGone, isVisible), or at least consistent use of one of visibility or extenstions over mixing.
| mKeyboardSwitcher.onEvent(event, getCurrentAutoCapsState(), getCurrentRecapitalizeState()); | ||
| } | ||
|
|
||
| public void onUriInput(final Uri uri) { |
There was a problem hiding this comment.
Why is the handling done in LatinIME instead of just keeping it in InputLogic? Do you have plans to extend image clipboard or URI functionality?
Also, onUriInput seems to be specific to content URIs, with a fallback made for clipboard URIs. This should be clarified in the name. Or if it will stay for clipboard pasting only, it could be moved into InputLogic.handleClipboardPaste.
| final InputContentInfoCompat contentInfo = new InputContentInfoCompat(uri, | ||
| new android.content.ClipDescription("clipboard image", new String[]{mimeType}), | ||
| null); | ||
| return InputConnectionCompat.commitContent(mIC, editorInfo, contentInfo, |
There was a problem hiding this comment.
Why a return value when it's not used? Is this related to the unused toast message?
Adds support for pasting images from the system clipboard via
commitContent.InputConnectionCompat.commitContentPart of #490 (second part will be history)