-
Notifications
You must be signed in to change notification settings - Fork 28.8k
Add support for language hints in TextFields (Android only) #165554
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
Conversation
d6214e6
to
08ef92e
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.
Thanks for taking this on @bleroux! It's always extra work to add engine+framework features like this.
Can you take a quick look at the iOS docs (if you haven't already) to see if they have a similar feature? I just want to make sure that what we're adding is more or less compatible if so. If you can reassure me there then LGTM.
@reidbaker Would you be able to back me up by reviewing the Android code in this PR?
I found https://developer.apple.com/documentation/uikit/uitextinputmode/primarylanguage which accepts one language tag instead of a list of locales. It looks like we would be able to provide this feature for iOS and macOS 🎉. The comment will reflect that only the first locale is used on iOS. @justinmc Do you think we should keep the name 'hintLocales' or used something agnostic such as 'preferredLocales'? |
08ef92e
to
da3401d
Compare
da3401d
to
3f9cbf6
Compare
@bleroux Let's say we keep the name hintLocales but add iOS support later. Are you thinking that iOS will take the first item in the list since it only supports one? Are the strings compatible like that? Overall I don't have a strong opinion about the name at the EditableText/TextField level. However at the TextInputConfiguration level I wonder if we can support both separately via different values in TextInputConfiguration? In order to give fine grained control to users that might want that. Maybe it's such a simple feature that fine grained control doesn't really matter in this case, but that's the approach I generally try to take for these kinds of cross platform APIs. |
Perfectly fine to me. 👍
Yes, It was my thinking. And yes the strings are compatible because the string expected by iOS is the result of
Great point! I will have to think about it and share my findings.
Very interesting, thank you for sharing this. |
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.
Android parts look solid to me!
Thanks @camsim99! 🙏 @justinmc Based on #165554 (comment) do you think we can proceed with this PR? Once merged I will work on the iOS support. |
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 respect to the future iOS support 👍 . So this PR supports only Android and uses the native Android name hintLocales. Native iOS calls it primaryLanguage, and that name is still available to us in case we find some reason to use both. Otherwise we can keep everything under hintLocales.
3f9cbf6
to
3b50a7b
Compare
flutter/flutter@aef4718...ecabb1a 2025-04-17 15619084+vashworth@users.noreply.github.com Hide error on mDNS registration failure and print warning in flutter attach (flutter/flutter#166782) 2025-04-17 bruno.leroux@gmail.com Add support for language hints in TextFields (Android only) (flutter/flutter#165554) 2025-04-17 engine-flutter-autoroll@skia.org Roll Skia from d8f13372549d to cc2b57434651 (1 revision) (flutter/flutter#167331) 2025-04-17 bruno.leroux@gmail.com Add DropdownMenu.restorationId (flutter/flutter#166684) 2025-04-17 engine-flutter-autoroll@skia.org Roll Skia from 3d6165b70199 to d8f13372549d (14 revisions) (flutter/flutter#167325) 2025-04-17 stanleycocoa@gmail.com fix(CircularProgressIndicator.adaptive): strokeWidth default value (flutter/flutter#165370) 2025-04-17 ahmedelsaayid@gmail.com Remove unnecessary builder (flutter/flutter#166623) 2025-04-17 34871572+gmackall@users.noreply.github.com Add a `gradle_errors.dart`entry for missing NDK source.properties file (flutter/flutter#167320) 2025-04-17 engine-flutter-autoroll@skia.org Roll Skia from 6627deb65939 to 3d6165b70199 (1 revision) (flutter/flutter#167255) 2025-04-17 engine-flutter-autoroll@skia.org Manual roll Dart SDK from 87965ab4864e to 992221a362ec (35 revisions) (flutter/flutter#167243) 2025-04-16 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from 7bWzHwIPBTyU6R9nO... to m8Aln7fTF_8zy1V9N... (flutter/flutter#167312) 2025-04-16 15619084+vashworth@users.noreply.github.com Don't throw on error for mDNS when searching for Dart VML url on core devices (flutter/flutter#167135) 2025-04-16 34465683+rkishan516@users.noreply.github.com Fix: Localization for non zero time in 24 hours format (flutter/flutter#164885) 2025-04-16 30870216+gaaclarke@users.noreply.github.com Updated docstrings for TextureContents (flutter/flutter#167221) 2025-04-16 30870216+gaaclarke@users.noreply.github.com Broke cyclical dependency with dlpath and typographer. (flutter/flutter#167293) 2025-04-16 34871572+gmackall@users.noreply.github.com Set an additional CMake arg in `forceNdkDownload` to make the task name align with the `BuildType` (flutter/flutter#167240) 2025-04-16 huy@nevercode.io Fix Carousel crashes when using PageStorageKey (flutter/flutter#166817) 2025-04-16 jason-simmons@users.noreply.github.com Revert "Removed superfluous copy in license checker (#167146)" (flutter/flutter#167246) 2025-04-16 dacoharkes@google.com [native assets] Roll dependencies (flutter/flutter#167287) 2025-04-16 fluttergithubbot@gmail.com Marks Linux_pixel_7pro static_path_stroke_tessellation_perf__timeline_summary to be unflaky (flutter/flutter#167259) 2025-04-16 34465683+rkishan516@users.noreply.github.com Feat: Add carousel view theme (flutter/flutter#164769) 2025-04-16 fluttergithubbot@gmail.com Marks Mac_ios dynamic_path_stroke_tessellation_perf_ios__timeline_summary to be unflaky (flutter/flutter#167261) 2025-04-16 jason-simmons@users.noreply.github.com When using --local-web-sdk, use a locally built Dart SDK if one is available (flutter/flutter#166732) 2025-04-16 30870216+gaaclarke@users.noreply.github.com Added emulator version to doctor (flutter/flutter#167236) 2025-04-16 fluttergithubbot@gmail.com Marks Mac_ios static_path_stroke_tessellation_perf_ios__timeline_summary to be unflaky (flutter/flutter#167260) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC stuartmorgan@google.com,tarrinneal@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Packages: 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
…165554) ## Description This PR adds support for language hints in TextFields. This is supported only on Android for the moment and the property name, aka `TextField.hintLocales`, is based on Android's `EditorInfo.hintLocales` property, see https://developer.android.com/reference/android/view/inputmethod/EditorInfo#hintLocales. ## Related Issue Fixes [Support for language hints in TextFields](flutter#163698) ## Tests Adds 4 tests. Updates several tests.
flutter/flutter@aef4718...ecabb1a 2025-04-17 15619084+vashworth@users.noreply.github.com Hide error on mDNS registration failure and print warning in flutter attach (flutter/flutter#166782) 2025-04-17 bruno.leroux@gmail.com Add support for language hints in TextFields (Android only) (flutter/flutter#165554) 2025-04-17 engine-flutter-autoroll@skia.org Roll Skia from d8f13372549d to cc2b57434651 (1 revision) (flutter/flutter#167331) 2025-04-17 bruno.leroux@gmail.com Add DropdownMenu.restorationId (flutter/flutter#166684) 2025-04-17 engine-flutter-autoroll@skia.org Roll Skia from 3d6165b70199 to d8f13372549d (14 revisions) (flutter/flutter#167325) 2025-04-17 stanleycocoa@gmail.com fix(CircularProgressIndicator.adaptive): strokeWidth default value (flutter/flutter#165370) 2025-04-17 ahmedelsaayid@gmail.com Remove unnecessary builder (flutter/flutter#166623) 2025-04-17 34871572+gmackall@users.noreply.github.com Add a `gradle_errors.dart`entry for missing NDK source.properties file (flutter/flutter#167320) 2025-04-17 engine-flutter-autoroll@skia.org Roll Skia from 6627deb65939 to 3d6165b70199 (1 revision) (flutter/flutter#167255) 2025-04-17 engine-flutter-autoroll@skia.org Manual roll Dart SDK from 87965ab4864e to 992221a362ec (35 revisions) (flutter/flutter#167243) 2025-04-16 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from 7bWzHwIPBTyU6R9nO... to m8Aln7fTF_8zy1V9N... (flutter/flutter#167312) 2025-04-16 15619084+vashworth@users.noreply.github.com Don't throw on error for mDNS when searching for Dart VML url on core devices (flutter/flutter#167135) 2025-04-16 34465683+rkishan516@users.noreply.github.com Fix: Localization for non zero time in 24 hours format (flutter/flutter#164885) 2025-04-16 30870216+gaaclarke@users.noreply.github.com Updated docstrings for TextureContents (flutter/flutter#167221) 2025-04-16 30870216+gaaclarke@users.noreply.github.com Broke cyclical dependency with dlpath and typographer. (flutter/flutter#167293) 2025-04-16 34871572+gmackall@users.noreply.github.com Set an additional CMake arg in `forceNdkDownload` to make the task name align with the `BuildType` (flutter/flutter#167240) 2025-04-16 huy@nevercode.io Fix Carousel crashes when using PageStorageKey (flutter/flutter#166817) 2025-04-16 jason-simmons@users.noreply.github.com Revert "Removed superfluous copy in license checker (#167146)" (flutter/flutter#167246) 2025-04-16 dacoharkes@google.com [native assets] Roll dependencies (flutter/flutter#167287) 2025-04-16 fluttergithubbot@gmail.com Marks Linux_pixel_7pro static_path_stroke_tessellation_perf__timeline_summary to be unflaky (flutter/flutter#167259) 2025-04-16 34465683+rkishan516@users.noreply.github.com Feat: Add carousel view theme (flutter/flutter#164769) 2025-04-16 fluttergithubbot@gmail.com Marks Mac_ios dynamic_path_stroke_tessellation_perf_ios__timeline_summary to be unflaky (flutter/flutter#167261) 2025-04-16 jason-simmons@users.noreply.github.com When using --local-web-sdk, use a locally built Dart SDK if one is available (flutter/flutter#166732) 2025-04-16 30870216+gaaclarke@users.noreply.github.com Added emulator version to doctor (flutter/flutter#167236) 2025-04-16 fluttergithubbot@gmail.com Marks Mac_ios static_path_stroke_tessellation_perf_ios__timeline_summary to be unflaky (flutter/flutter#167260) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC stuartmorgan@google.com,tarrinneal@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Packages: 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
…r#9104) flutter/flutter@aef4718...ecabb1a 2025-04-17 15619084+vashworth@users.noreply.github.com Hide error on mDNS registration failure and print warning in flutter attach (flutter/flutter#166782) 2025-04-17 bruno.leroux@gmail.com Add support for language hints in TextFields (Android only) (flutter/flutter#165554) 2025-04-17 engine-flutter-autoroll@skia.org Roll Skia from d8f13372549d to cc2b57434651 (1 revision) (flutter/flutter#167331) 2025-04-17 bruno.leroux@gmail.com Add DropdownMenu.restorationId (flutter/flutter#166684) 2025-04-17 engine-flutter-autoroll@skia.org Roll Skia from 3d6165b70199 to d8f13372549d (14 revisions) (flutter/flutter#167325) 2025-04-17 stanleycocoa@gmail.com fix(CircularProgressIndicator.adaptive): strokeWidth default value (flutter/flutter#165370) 2025-04-17 ahmedelsaayid@gmail.com Remove unnecessary builder (flutter/flutter#166623) 2025-04-17 34871572+gmackall@users.noreply.github.com Add a `gradle_errors.dart`entry for missing NDK source.properties file (flutter/flutter#167320) 2025-04-17 engine-flutter-autoroll@skia.org Roll Skia from 6627deb65939 to 3d6165b70199 (1 revision) (flutter/flutter#167255) 2025-04-17 engine-flutter-autoroll@skia.org Manual roll Dart SDK from 87965ab4864e to 992221a362ec (35 revisions) (flutter/flutter#167243) 2025-04-16 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from 7bWzHwIPBTyU6R9nO... to m8Aln7fTF_8zy1V9N... (flutter/flutter#167312) 2025-04-16 15619084+vashworth@users.noreply.github.com Don't throw on error for mDNS when searching for Dart VML url on core devices (flutter/flutter#167135) 2025-04-16 34465683+rkishan516@users.noreply.github.com Fix: Localization for non zero time in 24 hours format (flutter/flutter#164885) 2025-04-16 30870216+gaaclarke@users.noreply.github.com Updated docstrings for TextureContents (flutter/flutter#167221) 2025-04-16 30870216+gaaclarke@users.noreply.github.com Broke cyclical dependency with dlpath and typographer. (flutter/flutter#167293) 2025-04-16 34871572+gmackall@users.noreply.github.com Set an additional CMake arg in `forceNdkDownload` to make the task name align with the `BuildType` (flutter/flutter#167240) 2025-04-16 huy@nevercode.io Fix Carousel crashes when using PageStorageKey (flutter/flutter#166817) 2025-04-16 jason-simmons@users.noreply.github.com Revert "Removed superfluous copy in license checker (#167146)" (flutter/flutter#167246) 2025-04-16 dacoharkes@google.com [native assets] Roll dependencies (flutter/flutter#167287) 2025-04-16 fluttergithubbot@gmail.com Marks Linux_pixel_7pro static_path_stroke_tessellation_perf__timeline_summary to be unflaky (flutter/flutter#167259) 2025-04-16 34465683+rkishan516@users.noreply.github.com Feat: Add carousel view theme (flutter/flutter#164769) 2025-04-16 fluttergithubbot@gmail.com Marks Mac_ios dynamic_path_stroke_tessellation_perf_ios__timeline_summary to be unflaky (flutter/flutter#167261) 2025-04-16 jason-simmons@users.noreply.github.com When using --local-web-sdk, use a locally built Dart SDK if one is available (flutter/flutter#166732) 2025-04-16 30870216+gaaclarke@users.noreply.github.com Added emulator version to doctor (flutter/flutter#167236) 2025-04-16 fluttergithubbot@gmail.com Marks Mac_ios static_path_stroke_tessellation_perf_ios__timeline_summary to be unflaky (flutter/flutter#167260) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC stuartmorgan@google.com,tarrinneal@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Packages: 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
…r#9104) flutter/flutter@aef4718...ecabb1a 2025-04-17 15619084+vashworth@users.noreply.github.com Hide error on mDNS registration failure and print warning in flutter attach (flutter/flutter#166782) 2025-04-17 bruno.leroux@gmail.com Add support for language hints in TextFields (Android only) (flutter/flutter#165554) 2025-04-17 engine-flutter-autoroll@skia.org Roll Skia from d8f13372549d to cc2b57434651 (1 revision) (flutter/flutter#167331) 2025-04-17 bruno.leroux@gmail.com Add DropdownMenu.restorationId (flutter/flutter#166684) 2025-04-17 engine-flutter-autoroll@skia.org Roll Skia from 3d6165b70199 to d8f13372549d (14 revisions) (flutter/flutter#167325) 2025-04-17 stanleycocoa@gmail.com fix(CircularProgressIndicator.adaptive): strokeWidth default value (flutter/flutter#165370) 2025-04-17 ahmedelsaayid@gmail.com Remove unnecessary builder (flutter/flutter#166623) 2025-04-17 34871572+gmackall@users.noreply.github.com Add a `gradle_errors.dart`entry for missing NDK source.properties file (flutter/flutter#167320) 2025-04-17 engine-flutter-autoroll@skia.org Roll Skia from 6627deb65939 to 3d6165b70199 (1 revision) (flutter/flutter#167255) 2025-04-17 engine-flutter-autoroll@skia.org Manual roll Dart SDK from 87965ab4864e to 992221a362ec (35 revisions) (flutter/flutter#167243) 2025-04-16 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from 7bWzHwIPBTyU6R9nO... to m8Aln7fTF_8zy1V9N... (flutter/flutter#167312) 2025-04-16 15619084+vashworth@users.noreply.github.com Don't throw on error for mDNS when searching for Dart VML url on core devices (flutter/flutter#167135) 2025-04-16 34465683+rkishan516@users.noreply.github.com Fix: Localization for non zero time in 24 hours format (flutter/flutter#164885) 2025-04-16 30870216+gaaclarke@users.noreply.github.com Updated docstrings for TextureContents (flutter/flutter#167221) 2025-04-16 30870216+gaaclarke@users.noreply.github.com Broke cyclical dependency with dlpath and typographer. (flutter/flutter#167293) 2025-04-16 34871572+gmackall@users.noreply.github.com Set an additional CMake arg in `forceNdkDownload` to make the task name align with the `BuildType` (flutter/flutter#167240) 2025-04-16 huy@nevercode.io Fix Carousel crashes when using PageStorageKey (flutter/flutter#166817) 2025-04-16 jason-simmons@users.noreply.github.com Revert "Removed superfluous copy in license checker (#167146)" (flutter/flutter#167246) 2025-04-16 dacoharkes@google.com [native assets] Roll dependencies (flutter/flutter#167287) 2025-04-16 fluttergithubbot@gmail.com Marks Linux_pixel_7pro static_path_stroke_tessellation_perf__timeline_summary to be unflaky (flutter/flutter#167259) 2025-04-16 34465683+rkishan516@users.noreply.github.com Feat: Add carousel view theme (flutter/flutter#164769) 2025-04-16 fluttergithubbot@gmail.com Marks Mac_ios dynamic_path_stroke_tessellation_perf_ios__timeline_summary to be unflaky (flutter/flutter#167261) 2025-04-16 jason-simmons@users.noreply.github.com When using --local-web-sdk, use a locally built Dart SDK if one is available (flutter/flutter#166732) 2025-04-16 30870216+gaaclarke@users.noreply.github.com Added emulator version to doctor (flutter/flutter#167236) 2025-04-16 fluttergithubbot@gmail.com Marks Mac_ios static_path_stroke_tessellation_perf_ios__timeline_summary to be unflaky (flutter/flutter#167260) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC stuartmorgan@google.com,tarrinneal@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Packages: 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
Description
This PR adds support for language hints in TextFields.
This is supported only on Android for the moment and the property name, aka
TextField.hintLocales
, is based on Android'sEditorInfo.hintLocales
property, see https://developer.android.com/reference/android/view/inputmethod/EditorInfo#hintLocales.Related Issue
Fixes Support for language hints in TextFields
Tests
Adds 4 tests.
Updates several tests.