Fixed
Status Update
Comments
jo...@google.com <jo...@google.com> #2
Is that Error API available for other components as well? Should we add another bug to make the Error API available on Compose in general?
so...@google.com <so...@google.com> #3
Good point, please create a separate bug.
If I understand correctly, this error API was designed specifically for text fields, and I didn't see it's being used anywhere else. There is also a "contentInvalid" API in the accessibility services that could be used to mark something like invalid date.
We'll need to discuss whether we could unify the API or whether 2 APIs are necessary.
ap...@google.com <ap...@google.com> #4
Project: platform/frameworks/support
Branch: androidx-main
commit 72e2c2a4cddeaf9a80e664fd6fb8a12b9d962c48
Author: Anastasia Soboleva <soboleva@google.com>
Date: Tue Mar 23 15:34:44 2021
Add error API to mark node that contains invalid input
In accessibility services there're two APIs - setContentInvalid(Boolean) and setError(CharSequence).
And yet setting the error text requires the former to be set to true. At the same time, just setting contentInvalid to true will not result in anything.
Therefore having two APIs is not very beneficial and may only cause confusion. As such, in this CL I introduce a single API that takes an error description.
Name was not a clear choice, but decided to go with `error()` (as oppose to invalid or invalidContent) because
* this is what TextView uses, so developers should be familiar
* our material text fields have a 'isError' parameter for styling purpose. Therefore, it will be easier for developers to find the semantics if it has a very close name to something that is already treated as error.
In material text field we supply error semantics with default message in case developers forget to provide this semantics.
Relnote: "Added accessibility API `error` that allows to mark a node that contains invalid input"
Fixes: 180584804
Fixes: 182142737
Test: new tests in AndroidComposeViewAccessibilityDelegateCompatTest
Test: manually with Talkback on and alternative locale
Change-Id: I129977e3d3b5f03435de41de409fde9029c325b9
M compose/material/material/integration-tests/material-demos/src/main/java/androidx/compose/material/demos/MaterialTextField.kt
M compose/material/material/samples/src/main/java/androidx/compose/material/samples/TextFieldSamples.kt
M compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/textfield/OutlinedTextFieldTest.kt
M compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/textfield/TextFieldTest.kt
M compose/material/material/src/commonMain/kotlin/androidx/compose/material/Strings.kt
M compose/material/material/src/commonMain/kotlin/androidx/compose/material/TextFieldImpl.kt
M compose/ui/ui/api/1.0.0-beta06.txt
M compose/ui/ui/api/current.txt
M compose/ui/ui/api/public_plus_experimental_1.0.0-beta06.txt
M compose/ui/ui/api/public_plus_experimental_current.txt
M compose/ui/ui/api/restricted_1.0.0-beta06.txt
M compose/ui/ui/api/restricted_current.txt
M compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/AndroidAccessibilityTest.kt
M compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/AndroidComposeViewAccessibilityDelegateCompatTest.kt
M compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/platform/AndroidComposeViewAccessibilityDelegateCompat.android.kt
M compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/semantics/SemanticsProperties.kt
https://android-review.googlesource.com/1651127
Branch: androidx-main
commit 72e2c2a4cddeaf9a80e664fd6fb8a12b9d962c48
Author: Anastasia Soboleva <soboleva@google.com>
Date: Tue Mar 23 15:34:44 2021
Add error API to mark node that contains invalid input
In accessibility services there're two APIs - setContentInvalid(Boolean) and setError(CharSequence).
And yet setting the error text requires the former to be set to true. At the same time, just setting contentInvalid to true will not result in anything.
Therefore having two APIs is not very beneficial and may only cause confusion. As such, in this CL I introduce a single API that takes an error description.
Name was not a clear choice, but decided to go with `error()` (as oppose to invalid or invalidContent) because
* this is what TextView uses, so developers should be familiar
* our material text fields have a 'isError' parameter for styling purpose. Therefore, it will be easier for developers to find the semantics if it has a very close name to something that is already treated as error.
In material text field we supply error semantics with default message in case developers forget to provide this semantics.
Relnote: "Added accessibility API `error` that allows to mark a node that contains invalid input"
Fixes: 180584804
Fixes: 182142737
Test: new tests in AndroidComposeViewAccessibilityDelegateCompatTest
Test: manually with Talkback on and alternative locale
Change-Id: I129977e3d3b5f03435de41de409fde9029c325b9
M compose/material/material/integration-tests/material-demos/src/main/java/androidx/compose/material/demos/MaterialTextField.kt
M compose/material/material/samples/src/main/java/androidx/compose/material/samples/TextFieldSamples.kt
M compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/textfield/OutlinedTextFieldTest.kt
M compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/textfield/TextFieldTest.kt
M compose/material/material/src/commonMain/kotlin/androidx/compose/material/Strings.kt
M compose/material/material/src/commonMain/kotlin/androidx/compose/material/TextFieldImpl.kt
M compose/ui/ui/api/1.0.0-beta06.txt
M compose/ui/ui/api/current.txt
M compose/ui/ui/api/public_plus_experimental_1.0.0-beta06.txt
M compose/ui/ui/api/public_plus_experimental_current.txt
M compose/ui/ui/api/restricted_1.0.0-beta06.txt
M compose/ui/ui/api/restricted_current.txt
M compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/AndroidAccessibilityTest.kt
M compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/AndroidComposeViewAccessibilityDelegateCompatTest.kt
M compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/platform/AndroidComposeViewAccessibilityDelegateCompat.android.kt
M compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/semantics/SemanticsProperties.kt
Description
Use the Error API that a11y services are providing.