Android framework Canvas.clipRect() has a bug with Region.Op.DIFFERENCE when handling bounds.left on APIs lower than 18, which causes text field outlines are still drawn over the label on lower APIs, despite the label area is supposed to be cut out.
Fixes this by bringing back the old solution we were using - "painting out" the label area after the stroke is drawn. Since the implementation is quite complicated, this CL also splits the CutoutDrawable to two inner impl classes to have a better code structure.
Resolves https://github.com/material-components/material-components-android/issues/2811#issuecomment-1196016169
PiperOrigin-RevId: 482013070
Saving/restoring themeable fields will cause problems when the view is recreated, because those fields will be restored to the value resolved from the context before the recreation, instead of the current context. For example, when the device locale changes, those fields will still be restored to the previous locale instead of the new one.
It's a general practice in Android framework and AndroidX not to save/restore themeable fields. If clients need this, they should implement their own logic.
Resolves https://github.com/material-components/material-components-android/issues/2075
PiperOrigin-RevId: 454708278
In CollapsingTextHelper we are checking both the expanded bound and the collapsed bound to be larger than 0 to decide if we are going to draw the collapsing text. However this can result in a situation that when there's no space to display expanded hint, the collapsed hint won't be drawn either, even if the hint is not expandable at all.
This CL fixes the issue in a more generic way - whenever draw() is called, we check if the current bound (should be calculated whenever the collapsing fraction is changed) is larger than 0 to decide if we need to draw the collapsing text.
This CL also adds the logic to ensure the cutout bound will never be larger than the collapsed bound.
Resolves https://github.com/material-components/material-components-android/issues/2573
PiperOrigin-RevId: 449597658
This CL also cleans up and fixes the edit text background setting logic - when the edit text is an autocomplete text view and provides its own background, we won't override the background by trying to add ripples to it.
Later they should be split again from the main class with other box-background-relevant logic.
Resolves https://github.com/material-components/material-components-android/issues/1431
PiperOrigin-RevId: 445486075
We already had class documentation that explains that TextInputEditText should be instantiated with the parent TextInputLayout's context for proper theming, but this information is important enough to the basic usage of TextInputLayout and TextInputEditText that it's best to have it the class documentation, as well.
Added the guidance in both TextInputLayout and TextInputEditText because it's relevant to both classes.
PiperOrigin-RevId: 432244388
Add an expanding animation for the focused underline that's triggered when the edit text gains focus. The line mask animation is built to calculate its bounds based on the hint CollapsingTextHelper's expansion fraction, so it seamlessly follows that animation.
PiperOrigin-RevId: 424703815
Changes are mostly to keep start/end layouts and icon views hidden (visibility = gone) when they are not needed.
Resolves https://github.com/material-components/material-components-android/pull/2326
GIT_ORIGIN_REV_ID=0393ac65d562bc87d340ec7bb260ebba99a1ac3b
Co-authored-by: leticiarossi <9288695+leticiarossi@users.noreply.github.com>
PiperOrigin-RevId: 418038435
The setLabelFor calls were made in the call to populate the accessibility node but they were made after calling super (one of them was actually nested inside of a getter!), this is too late, the accessibility node is populated with the label for by the super class
PiperOrigin-RevId: 407178334
Before, when swiping with TalkBack on, the placeholder text would be mistakenly announced. This change makes it so it's only announced when it appears, for API >= 16. It's still announced as part of the description announcement when the text field is selected, as before, so it's still accessible for APIs < 16.
PiperOrigin-RevId: 405668594
Before, when swiping with TalkBack on, the placeholder text would be mistakenly announced. This change makes it so it's only announced when it appears, for API >= 16. It's still announced as part of the description announcement when the text field is selected, as before, so it's still accessible for APIs < 16.
PiperOrigin-RevId: 404871534
The box background of text fields are applied to EditTexts instead of the TextInputLayout. So when there are paddings in TextInputLayout, we will need to adjust cutout bounds, which is calculated based on TextInputLayout's coordinates, according to the paddings.
PiperOrigin-RevId: 404281248
Before, when swiping with TalkBack on, the placeholder text would be mistakenly announced. This change makes it so it's only announced when it appears, for API >= 16. It's still announced as part of the description announcement when the text field is selected, as before, so it's still accessible for APIs < 16.
PiperOrigin-RevId: 404266249
When a collapsed label is showing, we cutout part of the border of an outlined text input box according to the exact stroke width. However when using rounded corners, there can be slight offsets from where the border is really drawn. Also, if the corner size is large, the part of border we need to cutout might not just be a straight line but contains part of the corner.
However, with the existing cutout logic, we cannot just cutout the whole label area, which will cause the area inside the border also gets cutout, if it has color. This CL changes the cutout drawing logic to only apply the cutout on stroke drawing to fix the issue.
This CL also fixes the bug that when the label is too long, we didn't take the ellipsized text length into account. Creates a variable to store the calculated collapsed text width to fix the issue.
Resolves https://github.com/material-components/material-components-android/issues/2145
PiperOrigin-RevId: 402316057