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
[Android] Add support for text processing actions #44579
Conversation
0bab9c3
to
d9e1b29
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.
This approach LGTM. I think it's good to keep this separate in its own method channel.
CC @camsim99 in case you have any quick thoughts from the Android side of things.
infos = packageManager.queryIntentActivities(intent, PackageManager.ResolveInfoFlags.of(0)); | ||
} else { | ||
infos = packageManager.queryIntentActivities(intent, 0); |
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's the difference between the calls in these two versions? I'm just wondering if it's anything we should be documenting or anything like that.
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.
The previous version is deprecated, the new one allow using 'long' values instead of 'int' for the previous one.
I will probabl add a comment above the call to the old one to mention it is deprecated.
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.
The approach looks good to me! Just a question on some constructor logic.
this.processTextChannel = processTextChannel; | ||
this.packageManager = processTextChannel.packageManager; | ||
|
||
this.cacheResolveInfos(); |
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 wondering if we can do this elsewhere because this will happen immediately when a ProcessTextPlugin
is created, and that will happen regardless of whether or not this functionality is used. Would it make sense to be part of queryTextActions()
or processTextAction(...)
?
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.
Very good point, I will try lazy loading instead.
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.
Done
d9e1b29
to
baf8e4c
Compare
c8bb275
to
6a4274b
Compare
08753a2
to
641c524
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.
Looks good, just some nits!
@Override | ||
public Map<String, String> queryTextActions() { | ||
if (resolveInfosById == null) { | ||
resolveInfosById = new HashMap<String, ResolveInfo>(); |
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.
Nit: can this happen in cacheResolveInfos
versus 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.
Yes, great suggestion, and doing so we can remove the resolveInfosById.clear()
call your mention below.
infos = packageManager.queryIntentActivities(intent, 0); | ||
} | ||
|
||
resolveInfosById.clear(); |
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.
Is this ever called where resolveInfosById
wouldn't be an empty array? Wondering if we need this call.
641c524
to
554c18f
Compare
…136346) flutter/engine@cb0dabd...d93fe23 2023-10-11 leroux_bruno@yahoo.fr [Android] Add support for text processing actions (flutter/engine#44579) 2023-10-11 skia-flutter-autoroll@skia.org Roll Skia from 4935bed4260d to 11e41e0e2f9f (3 revisions) (flutter/engine#46759) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll Please CC jsimmons@google.com,rmistry@google.com,zra@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
)" This reverts commit d93fe23.
…46788) This reverts commit d93fe23. This change is causing integration tests to fail on attempts to roll the latest master version of flutter into the packages repo. See a sample failure here: https://logs.chromium.org/logs/flutter/buildbucket/cr-buildbucket/8767521956894285553/+/u/Run_package_tests/native_integration_tests/stdout The root cause seems to be that we are getting request codes in `onActivityResult` that we never added to the `requestsByCode` map, so the call to remove returns null (and we then call success getting a NPE). More info: 1. There is a [discussion in discord here](https://discord.com/channels/608014603317936148/1161718667566919761/1161721935927980052) 2. And the failure can be reproduced by running `dart run script/tool/bin/flutter_plugin_tools.dart native-test --android --packages file_selector` from the root of the packages repo (with a flutter checkout that contains these changes). cc @bleroux [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
## Description This is a reland of #44579 which was reverted in #46788. This reland adds a check into `onActivityResult` in order to return early if the result is related to an unknown request code (aka the result is related to a request sent by another plugin). It also adds one test that simulates receiving such an unknown request code. ## Related Issue Android engine side for flutter/flutter#107603 ## Tests Adds 4 tests.
## Description This Android related PR adds a channel buffer and a plugin to interact with Android 'process text' feature. It makes it possible to query text processing actions and to run those actions (for instance 'calling' Google translate). Text actions that outputs a processed text are supported. The implementation is based on the great sample provided by @gualse , see flutter/flutter#107603 (comment). In order to return a non empty list of text actions, the implementation will require adding a section to the Android manifest file (see flutter/flutter#107603 (comment)). Adding this section automatically to new or existing Flutter apps is not part of this PR but will be tackled in a future PR. ## Related Issue Android engine side for flutter/flutter#107603 ## Tests Adds 3 tests.
…46788) This reverts commit d93fe23. This change is causing integration tests to fail on attempts to roll the latest master version of flutter into the packages repo. See a sample failure here: https://logs.chromium.org/logs/flutter/buildbucket/cr-buildbucket/8767521956894285553/+/u/Run_package_tests/native_integration_tests/stdout The root cause seems to be that we are getting request codes in `onActivityResult` that we never added to the `requestsByCode` map, so the call to remove returns null (and we then call success getting a NPE). More info: 1. There is a [discussion in discord here](https://discord.com/channels/608014603317936148/1161718667566919761/1161721935927980052) 2. And the failure can be reproduced by running `dart run script/tool/bin/flutter_plugin_tools.dart native-test --android --packages file_selector` from the root of the packages repo (with a flutter checkout that contains these changes). cc @bleroux [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
## Description This is a reland of #44579 which was reverted in #46788. This reland adds a check into `onActivityResult` in order to return early if the result is related to an unknown request code (aka the result is related to a request sent by another plugin). It also adds one test that simulates receiving such an unknown request code. ## Related Issue Android engine side for flutter/flutter#107603 ## Tests Adds 4 tests.
## Description This PR adds `ProcessTextService` on the framework side to communicate with the engine to query and run text processing actions (on the engine side, only Android is supported currently, see flutter/engine#44579). ## Related Issue Non-UI framework side for #107603 ## Tests Adds 3 tests.
…7207) ## Description This PR adds a new section to the Android manifest file. This section is required for flutter/engine#44579 (because it uses `PackageManager.queryIntentActivities` API ), see: 1. https://developer.android.com/training/package-visibility?hl=en 2. https://developer.android.com/reference/android/content/Intent#ACTION_PROCESS_TEXT 3. https://developer.android.com/reference/android/content/pm/PackageManager?hl=en#queryIntentActivities(android.content.Intent,%20android.content.pm.PackageManager.ResolveInfoFlags) ## Related Issue Android manifest update for #107603 ## Tests This PR updates the integration tests and examples Android manifest files, this will help catch error or warning related to this change.
…tter#137207) ## Description This PR adds a new section to the Android manifest file. This section is required for flutter/engine#44579 (because it uses `PackageManager.queryIntentActivities` API ), see: 1. https://developer.android.com/training/package-visibility?hl=en 2. https://developer.android.com/reference/android/content/Intent#ACTION_PROCESS_TEXT 3. https://developer.android.com/reference/android/content/pm/PackageManager?hl=en#queryIntentActivities(android.content.Intent,%20android.content.pm.PackageManager.ResolveInfoFlags) ## Related Issue Android manifest update for flutter#107603 ## Tests This PR updates the integration tests and examples Android manifest files, this will help catch error or warning related to this change.
Используется, например, для обработки текста при выделении. Пока никакого эффекта, но заработает как только релизнут flutter со следующим PR: flutter/engine#44579
Description
This Android related PR adds a channel buffer and a plugin to interact with Android 'process text' feature. It makes it possible to query text processing actions and to run those actions (for instance 'calling' Google translate).
Text actions that outputs a processed text are supported.
The implementation is based on the great sample provided by @gualse , see flutter/flutter#107603 (comment).
In order to return a non empty list of text actions, the implementation will require adding a section to the Android manifest file (see flutter/flutter#107603 (comment)).
Adding this section automatically to new or existing Flutter apps is not part of this PR but will be tackled in a future PR.
Related Issue
Android engine side for flutter/flutter#139361
Tests
Adds 3 tests.