Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds support for pasting URIs (images, videos, and other media types) copied to the primary clipboard, provided that the current input field editor supports the MIME type of the URI (currently, due to the lack of notification permission, there would be no indication if the URI could not be pasted).
Many instant messengers and some rich text editors (such as Samsung Notes/Google Keep) nowadays can paste images from the clipboard.
If clipboard history is enabled in settings, copied images will be stored in the app internal storage.
They will be available in the clipboard history view, and you will be able to paste them from there:
Unpinned images will be deleted from the storage when the clipboard history first initializes, at retention time, and when pressing "Clear history" toolbar key.
Individual images manually removed from the history view by swiping will also be removed from the storage.
To paste a URI copied to the primary clipboard even if it is not an image, you can short press the clipboard key if history is disabled, otherwise you will need to pin the clipboard key and long press it.
When my other PR #647 will be finally merged, it should also be possible to show a suggestion of a clipboard image (only if the current editor supports that) which would make it even easier to paste clipboard images.
No database is used, may lead to performance issues if there are many clipboard images in the history. If someone could add one that would be really great (sadly I don't know yet how to create one myself).
I am also not sure if the current implementation of file operations is bound to concurrency issuess, please let me know if it does and what can be done to mitigate them.
I've tested the feature in multiple apps in Android 14, if others could test it too, preferably in older versions, that could really help make this feature a release candidate. If you tried it out and could not paste an image in some app, please check if a different keyboard that does support clipboard images like GBoard/Florisboard is able paste the copied content.
Thanks for reading!
P.S. GIFs are not animated in the history view currently as that would likely require adding a new dependency