-
Notifications
You must be signed in to change notification settings - Fork 233
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
compose: Support images from keyboard for Android #1203
base: main
Are you sure you want to change the base?
Conversation
89446ec
to
af8c5b3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exciting! Small question from a quick skim; I know this is still a draft.
lib/widgets/compose_box.dart
Outdated
// The data can be empty when the URL is associated with an empty | ||
// resource. See Flutter engine implementation that provides this data: | ||
// https://github.com/flutter/flutter/blob/0ffc4ce00ea7bb912e379adf39354644eab2c17e/engine/src/flutter/shell/platform/android/io/flutter/plugin/editing/InputConnectionAdaptor.java#L497-L548 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is specifically about the case where data
ends up being present as an empty array, right? In the code you linked to, I assume that specifically means readStreamFully
came up empty in line 531:
final byte[] data = this.readStreamFully(is, 64 * 1024);
(Right?)
How about a different case: what could cause data
to be null as opposed to present-but-empty? I noticed KeyboardInsertedContent.data
is optional. This would be helpful to document upstream there. 🙂
Also, looking around the whole commitContent
function you linked to, it looks like there are various unhappy paths there, where the function can't do something desirable and returns false
. Like if the Android version is too old. What's the user-facing behavior in those unhappy paths?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having swept through the Java code, I couldn't find other places where data
is null
and gets passed via a textInputChannel.commitContent
call. The link points to the only current non-test call site. The Dart code constructor doesn't have code paths where data
is explicitly null
either.
data
can be empty if (a) the file is empty or (b) there was an IOException
during the read. So data
should probably be null
if there is an error reading it, so that we can handle it properly.
When returning false
, no textInputChannel.commitContent
call is made and our handler does not get called at all. But the return value is probably read by some part of the Android SDK code: https://developer.android.com/reference/android/view/inputmethod/BaseInputConnection
Default implementation which invokes View.performReceiveContent on the target view if the view allows content insertion; otherwise returns false without any side effects.
true if this request is accepted by the application, whether the request is already handled or still being handled in background, false otherwise.
I assume the behavior is akin to when we do not provide ContentInsertionConfiguration
at all. That also results in this method returning false
because the allowedMimeTypes
default to an empty list. This gives you an OS-specific error message:
Signed-off-by: Zixuan James Li <[email protected]>
So the test is more realistic. A side effect of this is that the content input text field is focused afterwards. Signed-off-by: Zixuan James Li <[email protected]>
Fixes: zulip#419 Fixes: zulip#1173 Signed-off-by: Zixuan James Li <[email protected]>
Preview error message
Fixes: #419
Fixes: #1173