Removed the Context/Application/Activity in the Builders class.
Updated docs accordingly and added examples explaining how harmonizing color attributes with theme overlay works.
PiperOrigin-RevId: 433769484
Reduces and restructures the calling chain when a state is set to improve readability and robustness.
This CL also introduces the following fixes:
1. Limit the possible input values of setState() and throws IllegalArgumentException if invalid values are provided.
2. Block the state to be set as HIDDEN when hideable is false.
3. Fix the bug that SettleRunnable could be posted multiple times due to isPosted flag being incorrectly set to false when the settling is still going on.
4. Fix the bug that dragging the bottom sheet when settling would result the bottom sheet in an incorrect state (the target state of settling instead of DRAGGING).
PiperOrigin-RevId: 432963533
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
The activity leak can happen in a corner case: setting bottom sheet state when the bottom sheet is dismissed and the host activity is closed. In this situation SettleRunnable will be posted to ViewRootImpl since the bottom sheet is not attached, which leaves references of the dismissed bottom sheet (and thus the destroyed activity) in ViewRootImpl and causes activity leak.
Fixes this by using weak reference in SettleRunnable instead of the strong reference, which is the standard practice of the BottomSheetBehavior class.
Resolves https://github.com/material-components/material-components-android/issues/1417
PiperOrigin-RevId: 430709002
Since adding bottom sheet behavior callbacks won't trigger any callbacks to be called, the bottom sheet paddings won't be updated right away. This causes the issue that top paddings are not correctly applied when the bottom sheet is initially expanded. Besides that, due to some unknown reason, bottom sheet's getTop() method will only return a non-zero value that is the offset to the container top when calling from bottom sheet behavior callbacks. It seems related to how ViewCompat.offsetTopAndBottom() is working. Not 100% sure.
Therefore this CL add a internal callback to BottomSheetCallback class so when bottom sheet is being laid out (and getting offset), we can update paddings right away.
Resolves https://github.com/material-components/material-components-android/issues/2165
PiperOrigin-RevId: 429071367
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
We always use the original margins saved when the snackbar is created to update snackbar's actual margins. Therefore the newly set margins will always be overridden. Fixes this by updating original margins when layout params are set.
Resolves https://github.com/material-components/material-components-android/issues/1076
PiperOrigin-RevId: 427795853