From 8ff3ecb4d437021a052aeb82d0aaf3037bb395cf Mon Sep 17 00:00:00 2001 From: David Hewitt Date: Sun, 30 Oct 2022 14:56:47 +0000 Subject: [PATCH] Fix receiving images from keyboards The call to `super.onCreateInputConnection` was overwriting the mimes in the `outAttrs`, so we can call that first and then modify the mimes. This fixes the ability to insert GIFs with the default GBoard GIF menu for me. --- .../org/joinmastodon/android/ui/views/ComposeEditText.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/views/ComposeEditText.java b/mastodon/src/main/java/org/joinmastodon/android/ui/views/ComposeEditText.java index f3ff13b0..f15bee3b 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/views/ComposeEditText.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/views/ComposeEditText.java @@ -54,12 +54,13 @@ public class ComposeEditText extends EditText{ // Support receiving images from keyboards @Override public InputConnection onCreateInputConnection(EditorInfo outAttrs){ + final var ic = super.onCreateInputConnection(outAttrs); if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.N_MR1){ outAttrs.contentMimeTypes=selectionListener.onGetAllowedMediaMimeTypes(); - inputConnectionWrapper.setTarget(super.onCreateInputConnection(outAttrs)); + inputConnectionWrapper.setTarget(ic); return inputConnectionWrapper; } - return super.onCreateInputConnection(outAttrs); + return ic; } // Support pasting images