Instead of nulling android:button and buttonCompat in the Material style, we now check if the legacy drawable is being used, and override that if so.
PiperOrigin-RevId: 463643386
The checkbox is now composed of an `app:buttonCompat` button drawable (the squared
icon) and an `app:buttonIcon` icon drawable (the checkmark icon) layered on top
of it. The animation has also been updated.
PiperOrigin-RevId: 462244130
This CL fixes two issues regarding bottom sheet dialog status color adjustment in edge-to-edge mode:
1. Uses WindowInsetsControllerCompat to set status bar color to replace the deprecated way of setting flags, which cannot override the light/dark setting set by WindowInsetsControllerCompat.
2. Tracks Window change so the original status bar color can be updated when the dialog is re-shown. (The day/night mode can be changed when the dialog is hidden.)
Resolves https://github.com/material-components/material-components-android/issues/2168
PiperOrigin-RevId: 450463570
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
When the collapsing title is fully expanded, the current logic won't update the linear text setting correctly to false, which may result in the issue that the type face is not updated correctly. Fixes this by always updating linear text settings when the available text width is not 0.
Also refactors the typeface relevant logic so we will decide if we should recreate the static text layout in a consistent way.
Resolves https://github.com/material-components/material-components-android/issues/2463
PiperOrigin-RevId: 446735260
Includes two main fixes:
1. Applied a workaround for alpha issue of shadow layer in Paint for API 31(+).
- Issue: For API 31 and plus, Paint doesn't apply the correct alpha value to the shadow layer. When the shadow color is opaque (alpha=255), the alpha of shadow should use the alpha of the Paint. But it seems the inverse alpha (255-alpha) is applied to the shadow layer.
- Solution: Added a workaround to set shadow color with a real-time alpha value, Paint still respects to the shadow color's alpha when it's not opaque.
2. Fixed rounding issue when blending shadow color for API 30(-).
- Issue: The rounding of alpha value in removed blendColors() function is casting (round down). This causes the shadow color occasionally becomes non-opaque. Then Paint stops to apply the alpha value to it.
- Solution: When blending colors, round values with Math.round() (round to nearest).
Note: Fix (1) covers fix (2). But fix (2) is still worth to keep, if issue (1) is fixed in the framework in future and workaround is removed.
Resolves: https://github.com/material-components/material-components-android/issues/2545
PiperOrigin-RevId: 427812326
This CL pulls out the checkable group logic to a standalone class, which can be shared by different UX components. It also makes chip groups support multiple selection better with introducing a new listener based on the multiple selection and deprecates the old listener which only supports single selection.
PiperOrigin-RevId: 427204476
In the original logic we compares interpolated text size to decide if the available width should be the collapsed one or the expanded one. This logic wouldn't work if the collapsed text size and the expanded text size are the same. Refactors the logic to make the decision by interpolating fraction directly.
Resolves https://github.com/material-components/material-components-android/issues/2459
PiperOrigin-RevId: 410901171
After letter spacing is correctly set in CollapsingTextHelper.calculateUsingTextSize(), we no longer need to set letter spacing separately for collapsed and expanded titles. Also this enhances the logic by using textPaint consistently in CollapsingTextHelper.calculateBaseOffsets(), which was not the case before the change. (We got text height from textPaint and text width from tmpPaint.)
PiperOrigin-RevId: 410888232
We recreated title text layout when expanding from the collapsed state but didn't correctly set the letter spacing to the expanded one. The letter spacing being used will be a interpolated value between collapsed and expanded letter spacing (close to the collapsed one due to the implementation). This will cause the text layout incorrectly calculate the line count from the wrong letter spacing and result in a broken layout.
Correctly sets the letter spacing to fix the issue.
Resolves https://github.com/material-components/material-components-android/issues/2463
PiperOrigin-RevId: 408910555
We changes letter spacing during expanding/collapsing animations, which causes us use letter spacing during animation while calculating final expanded/collapsed offset instead of final letter spacing. This in turn causes hints be drawn at the wrong positions. Uses final letter spacing during calculating offset instead to fix the problem.
Resolves https://github.com/material-components/material-components-android/issues/2277
PiperOrigin-RevId: 408904991
In single line mode, we implement the expanded title alignment by calculating the expected x-coordinate of expanded title and translate the canvas so the title will be aligned. However, when maxLines > 1, the static layout will always occupy the full available width, therefore the text alignment need to be done by the static layout instead.
Provides text alignment other than NORMAL when it's in multi-line mode to solve the issue.
Resolves https://github.com/material-components/material-components-android/issues/1276
PiperOrigin-RevId: 408895140