-
Notifications
You must be signed in to change notification settings - Fork 6k
Add support for image insertion on Android #35619
Conversation
I'm also lost on how I can make this test pass. The error isn't helping me much to be honest:
|
cc @stuartmorgan for finding a reviewer for this. |
@GaryQian Could you take a look at this? @gspencergoog or @dkwingsmt should probably look as well given recent changes to the keyboard system. |
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.
Just a few small comments here. I just reviewed the framework PR and this engine one seems fine, though I'm still trying to get it running locally so I can try it out.
Bump @GaryQian @gspencergoog @dkwingsmt for a secondary review.
shell/platform/android/io/flutter/embedding/engine/systemchannels/TextInputChannel.java
Outdated
Show resolved
Hide resolved
return false; | ||
} | ||
} else { | ||
return false; |
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.
What will this end up looking like in the framework if this isn't supported by the device for some reason? Ideally an app developer would be able to gracefully handle this situation.
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.
There's a toast message displayed that "<app>
doesn't support image insertion here". It will display this toast any time this function returns false. To my knowledge, it cannot be customized and is an Android framework thing.
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.
Ok sounds like that's the same as native so that should be fine 👍
final Map<String, Object> obj = new HashMap<>(); | ||
obj.put("mimeType", mimeType); | ||
obj.put("data", data); | ||
obj.put("uri", uri.toString()); |
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.
Are all 3 of these parameters guaranteed to be valid at this point, or should there be any checking and error handling here?
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.
Not sure to be honest. This is why we made the CommittedContent
class parameters nullable, just in case something doesn't work correctly.
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.
So I guess it will be up to the framework to handle an invalid CommittedContent.
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.
Correct, or the developer themselves. They can choose what they want to do if a parameter they need happens to be null.
|
||
// Commit the content to the text input channel and release the permission. | ||
textInputChannel.commitContent(mClient, obj); | ||
inputContentInfo.releasePermission(); |
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.
Do you have to release permission when is
is null? You request it in line 508 but only release when successful here.
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.
Fixed. Good catch :)
And JIT release builds are failing on what look to be related errors. |
Think I fixed the JIT builds by merging upstream |
@@ -171,6 +174,44 @@ public void testPerformContextMenuAction_paste() { | |||
assertTrue(editable.toString().startsWith(textToBePasted)); | |||
} | |||
|
|||
@Test | |||
public void testCommitContent() throws JSONException { |
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.
Heads up that this test appears to be failing
io.flutter.plugin.editing.InputConnectionAdaptorTest > testCommitContent FAILED
Wanted but not invoked:
dartExecutor.send(
<Capturing argument>,
<Capturing argument>,
isNull()
);
-> at io.flutter.embedding.engine.dart.DartExecutor.send(DartExecutor.java:223)
However, there was exactly 1 interaction with this mock:
dartExecutor.setMessageHandler(
"flutter/textinput",
io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler@18698c6a
);
-> at io.flutter.plugin.common.MethodChannel.setMethodCallHandler(MethodChannel.java:146)
at io.flutter.embedding.engine.dart.DartExecutor.send(DartExecutor.java:223)
at io.flutter.plugin.editing.InputConnectionAdaptorTest.testCommitContent(InputConnectionAdaptorTest.java:203)
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.
I'm aware of this, the error hasn't really helped me to figure out why its failing. No idea what needs to change to get it to work.
I tried to look into this but locally I'm always getting a bunch of failures in the java tests, even on main. Maybe something with my setup... |
From PR review triage: It looks like the next step on this PR is for @tneotia to fix the presubmit test failures, which do appear related to this change. |
Closing this as stale. Please re-open once progress can be made to patch the presubmit failures. |
I really wish this wouldn't be closed ... I just need a little help getting this test to run. I have no experience writing tests and only have a windows system so I don't even have a great way to run these. So close to getting this merged yet so far away |
I really want to see this merged too. I'm going to be out for a week but when I get back I'll try to take a look at the test again if I have time. Not sure what's going on with my engine setup. |
@chinmaygarde @gspencergoog @dkwingsmt @justinmc @tneotia I'm sure this will come across as a rant, but it is meant more of a general observation. There are several flutter projects (including the engine itself) that are backed by google where PRs for fixes or enhancements are at least encouraged in the documentation. When suggestions or questions are asked in advance, maintainers (especially google staff) tend to remain somewhat silent or request that a PR just be submitted. When in fact one or more outside contributors attempt to create and submit a PR, if any issues come up (such as with unit tests), there is little-to-no assistance to be found from google maintainers. While I know myself, and I suspect most others appreciate the hard work that the flutter team (including google) puts in to everything, I think providing some minimal dedicated time to assisting free contributions would go a long way to both helping improve the platform and the general flutter community. I would bet a little bit of help would encourage those contributing to learn the specifics of why a PR failed to past tests, and/or how code could better align with the coding style of a particular project and most importantly, encourage contributors to make additional submissions. Instead, even basic functionality included in other native apps are missing, often for months/years, such as this PR. When the public community attempts to fill in the gaps they are met with a (unintended?) wall of resistance both technically and from the maintainers. I can state that this sentiment is shared with several other OS contributors I've communicated with. If there is a better way for contributors to request assistance, or if in reality the maintainers do not feel these contributions to be beneficial, I think it would at least be fair to mention this honestly in the documentation so that contributors can reduce wasting time on these efforts, and instead provide submissions to other open source projects. Thanks for your time, and I hope also that this PR gets re-opened. |
I second this 100%. I know Tanay has worked really hard to get this PR into a state where it can move forward. But he's stuck and any assistance would be greatly appreciated; for a feature that a lot of people are asking for. This isn't a framework that we created or are super well versed in. So it's already an intimidating codebase and an uphill battle to get it all working between the framework & engine. ANY guidance on ways to implement things or fix unit tests would go a long way... With just a little effort from the maintainers side |
@mrorabau The #hackers channel on the Flutter Discord would be a much better place for a general discussion about code review practice than a specific PR. (I'd be happy to weigh in there, but not here, as I don't want to drive the discussion here further off of the topic of the PR itself. And others who would certainly have relevant things to say aren't even on this PR.) |
I'm going to try to push a new commit that fixes the test. |
@tneotia I don't have permission to push a commit to your branch, but my fix is here: e5ef030 Feel free to make the changes yourself. Or maybe you can allow me to push my commit by checking "Allow edits and access to secrets by maintainers" at the bottom of the right bar of this PR? I'm not sure how that works exactly. I also merged main in locally, I'm not sure if you'll need to do that or not. I tested this locally with its corresponding framework PR (flutter/flutter#110052) too, and everything worked great. Super excited for this feature. |
I don't see that button unfortunately, but I will apply your changes in an hour or so. Thank you so, so, SO much for your help on this. Can't wait to get this in a stable flutter release :) |
Sounds good, thank you for your work and persistence! |
|
@chinmaygarde @zanderso test failures are fixed and everything seems ready to go here :) |
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.
LGTM 👍. I'm glad the test fix worked!
As mentioned elsewhere, I was able to get this code running with the associated framework PR and its example, and it worked great.
This needs one more approval and then we can merge.
shell/platform/android/io/flutter/plugin/editing/InputConnectionAdaptor.java
Outdated
Show resolved
Hide resolved
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.
LGTM, with a small comment ^^^.
This PR adds support for image keyboard support on Android, utilizing the
commitContent
function.Partially addresses flutter/flutter#20796. Associated Flutter PR: flutter/flutter#110052.
This is a re-PR of #27763 to clean up the commits.
cc @justinmc and @zlshames
Pre-launch Checklist
///
).