Add support for language hints in TextFields (Android only) - #165554
Conversation
d6214e6 to
08ef92e
Compare
justinmc
left a comment
There was a problem hiding this comment.
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. |
camsim99
left a comment
There was a problem hiding this comment.
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. |
justinmc
left a comment
There was a problem hiding this comment.
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
|
Is there an issue tracking the iOS implementation for this? |
I filed #172620 to track the iOS implementation. |
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.hintLocalesproperty, 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.