Skip to content

feat(clipboard): add image pasting#2312

Open
slonka wants to merge 3 commits intoHeliBorg:mainfrom
slonka:clip-img-paste
Open

feat(clipboard): add image pasting#2312
slonka wants to merge 3 commits intoHeliBorg:mainfrom
slonka:clip-img-paste

Conversation

@slonka
Copy link
Copy Markdown

@slonka slonka commented Feb 22, 2026

Adds support for pasting images from the system clipboard via commitContent.

  • When an app supports image input (e.g. messaging apps), the paste toolbar key now sends clipboard images using InputConnectionCompat.commitContent
  • The clipboard suggestion strip shows an image thumbnail when an image is on the clipboard, instead of only handling text
  • Tapping the thumbnail pastes the image; tapping X dismisses it
  • If the target app doesn't support the image MIME type, a toast is shown

Part of #490 (second part will be history)

image

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>
@slonka slonka marked this pull request as draft February 22, 2026 19:42
Signed-off-by: slonka <slonka@users.noreply.github.com>
@slonka slonka marked this pull request as ready for review February 22, 2026 19:53
@slonka slonka marked this pull request as draft February 23, 2026 11:06
Signed-off-by: slonka <slonka@users.noreply.github.com>
@slonka slonka marked this pull request as ready for review February 23, 2026 11:19
@slonka
Copy link
Copy Markdown
Author

slonka commented Mar 16, 2026

@Helium314 can I get a review of this?

@eranl
Copy link
Copy Markdown
Contributor

eranl commented Mar 16, 2026

@slonka, get in line 🙂

@Helium314
Copy link
Copy Markdown
Collaborator

@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.
Currently I'm mostly focusing on the gesture typing project because it has a deadline (squeezing in small features in between), and the sooner I'm done with passive data gathering the better for eclexic (who is working on the actually relevant stuff).

So sorry, but you will likely need to wait for a few more weeks.

@Helium314
Copy link
Copy Markdown
Collaborator

So, finally... sorry for the wait

This looks really good, only some minor things (will comment in code).
On your screenshot the preview image fits perfectly with into the clip view, but on my phone it's taller (almost suggestion strip height). Is this due to later changes, or does it depend on Android version?

}

@JvmStatic
fun isMimeTypeSupportedByEditor(editorInfo: EditorInfo?, mimeType: String): Boolean {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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();
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Comment on lines +170 to +172
binding.clipboardSuggestionText.isGone = true
val imageView = binding.clipboardSuggestionImage
imageView.visibility = View.VISIBLE
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why a return value when it's not used? Is this related to the unused toast message?

@Helium314 Helium314 added the waiting for info more information is requested label Apr 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

waiting for info more information is requested

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants