~emersion/goguma-dev

Enable users to upload images from their IME v1 APPLIED

delthas: 1
 Enable users to upload images from their IME

 1 files changed, 11 insertions(+), 0 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~emersion/goguma-dev/patches/49903/mbox | git am -3
Learn more about email & git

[PATCH] Enable users to upload images from their IME Export this patch

Tested on Gboard on Android.

See: https://developer.android.com/develop/ui/views/touch-and-input/image-keyboard
See: https://github.com/flutter/flutter/pull/110052
See: https://api.flutter.dev/flutter/material/TextField/contentInsertionConfiguration.html
---
 lib/widget/composer.dart | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/lib/widget/composer.dart b/lib/widget/composer.dart
index 4bab95e..0bb2455 100644
--- a/lib/widget/composer.dart
+++ b/lib/widget/composer.dart
@@ -513,6 +513,7 @@ class ComposerState extends State<Composer> {
	}

	Widget _buildTextField(BuildContext context, TextEditingController controller, FocusNode focusNode, VoidCallback onFieldSubmitted) {
		var client = context.read<Client>();
		var prefs = context.read<Prefs>();
		var sendTyping = prefs.typingIndicator;

@@ -548,6 +549,16 @@ class ComposerState extends State<Composer> {
			minLines: 1,
			maxLines: 5,
			keyboardType: TextInputType.text, // disallows newlines
			contentInsertionConfiguration: (client.isupport.filehost != null) ? ContentInsertionConfiguration(
				allowedMimeTypes: const <String>['image/jpeg', 'image/png', 'image/gif'],
				onContentInserted: (KeyboardInsertedContent data) async {
					if (data.hasData) {
						_runAddMenuTask(() async {
							await _uploadFile(XFile.fromData(data.data!, mimeType: data.mimeType, path: data.uri));
						});
					}
				},
			) : null,
		);
	}


base-commit: 2d16a7005d5ace641d69bf795c97c05244fa67cb
-- 
2.38.0
Pushed with a small edit to leave allowedMimeTypes null to allow all.
Thanks!