2492 Commits

Author SHA1 Message Date
Material Design Team
bfb6086e24 [M3][Color] Update getters/setters naming in the HarmonizedColorsOptions
PiperOrigin-RevId: 431700407
2022-03-02 14:16:44 -08:00
pekingme
2ae676c5d9 [Tokens][Motion] Added fundamental resources for pathinterpolator.
PiperOrigin-RevId: 431554031
2022-03-01 08:59:29 -08:00
pekingme
51821176a8 [Tokens] Internal cleanup.
PiperOrigin-RevId: 431547939
2022-03-01 08:58:31 -08:00
conradchen
9789f2e286 [CleanUp][TextField] Split icon tinting logic to a helper class
PiperOrigin-RevId: 431477762
2022-03-01 08:55:44 -08:00
hunterstich
f3d7ca4014 [Tokens] Ignore NewApi lint check for typography fontFamily.
PiperOrigin-RevId: 430978528
2022-02-25 10:36:06 -08:00
Material Design Team
869d943067 [M3][Color] Add support for color resources harmonization in XML
PiperOrigin-RevId: 430757816
2022-02-25 03:54:09 -08:00
conradchen
43114c4f7c [BottomSheet] Fix activity leak when setting states on destroying activities
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
2022-02-25 03:53:30 -08:00
pekingme
37fcd242bd [Tokens][Cleanup] Better ordering in the output.
PiperOrigin-RevId: 430479085
2022-02-23 11:23:09 -08:00
afohrman
1222268437 [BottomNavigationView] Added supported NavigationBarView#LabelVisibilityMode alternative to deprecated BottomNavigationView#LabelVisibilityMode.
PiperOrigin-RevId: 430230181
2022-02-23 11:21:14 -08:00
leticiars
b6901275d9 [TextInputLayout][a11y] Fixed prefix/suffix not being properly announced when the text field is focused and they show up. Also improved their screen reader focus order to align with the visual order of the elements: navigating to the left will focus on the prefix and navigating to the right will focus on the suffix.
Resolves https://github.com/material-components/material-components-android/issues/2497

PiperOrigin-RevId: 430208388
2022-02-23 11:13:30 -08:00
dsn5ft
45841c97fe [Color] Remove constructor comments from DynamicColorsOptions.Builder
PiperOrigin-RevId: 430202113
2022-02-23 11:11:21 -08:00
conradchen
17da000a29 [Slider] Add support for custom thumb drawables
Resolves https://github.com/material-components/material-components-android/issues/1522

PiperOrigin-RevId: 429607888
2022-02-23 11:10:12 -08:00
Material Design Team
bdbf052aaf [M3][Color] Refactor DynamicColors overloading methods and added DynamicColorsOptions class to support color harmonization.
PiperOrigin-RevId: 429324480
2022-02-18 15:43:45 +00:00
pekingme
878ea36a79 [Tokens] Generated TextAppearance styles instead of atomic typography resources.
PiperOrigin-RevId: 429161102
2022-02-18 15:42:24 +00:00
conradchen
19af0ac9d9 [BottomSheet] Update edge-to-edge paddings when bottom sheet is laid out
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
2022-02-18 15:41:23 +00:00
dsn5ft
b49284ec75 [M3][Toolbar] Hide shadows on all M3 Toolbar styles, not just Surface style
Resolves https://github.com/material-components/material-components-android/issues/2552

PiperOrigin-RevId: 429059800
2022-02-18 15:40:35 +00:00
raajkumars
18554d9cb5 [BottomNavigationView] Fix for IllegalArgumentException in preview mode.
Resolves https://github.com/material-components/material-components-android/issues/2489

PiperOrigin-RevId: 428861308
2022-02-15 21:29:32 +00:00
pekingme
1304522beb [BottomSheet] Fixed IME bottom padding is ignored in edge-to-edge case. Reverted to use deprecated getSystemWindowInsetBottom() for bottom inset to align with behaviors in 1.5.0.
Resolves: https://github.com/material-components/material-components-android/issues/2543
PiperOrigin-RevId: 428856163
2022-02-15 21:28:33 +00:00
P1NG2WIN
b01051b8bc [MaterialToolbar] Support scaleType and adjustViewBounds for logo
Resolves https://github.com/material-components/material-components-android/pull/2562

GIT_ORIGIN_REV_ID=c675c6a12e2fc242d2e9e019913df650b87eea2b
PiperOrigin-RevId: 428837808
2022-02-15 19:52:03 +00:00
conradchen
85ed9938d7 [TextField] Provide set simple items API with default item layout for MaterialAutoCompleteTextView
Resolves https://github.com/material-components/material-components-android/issues/692

PiperOrigin-RevId: 428832331
2022-02-15 19:33:49 +00:00
conradchen
13dbc9f906 [BottomSheet] Support background tint without shape appearance set
Resolves https://github.com/material-components/material-components-android/issues/2200

PiperOrigin-RevId: 428781539
2022-02-15 19:26:40 +00:00
pfthomas
85a44054f3 [MaterialTimePicker] Add setters for hour and minute
Resolves https://github.com/material-components/material-components-android/issues/2515

PiperOrigin-RevId: 428563049
2022-02-15 19:24:16 +00:00
pekingme
6bf92e1c07 Automated g4 rollback of changelist 426304311
PiperOrigin-RevId: 428054428
2022-02-11 20:27:52 -08:00
dsn5ft
56ed07008b [Color] Update DynamicColors to use peekDecorView() instead of getDecorView() when applying dynamic color theme overlay
Resolves https://github.com/material-components/material-components-android/issues/2558

PiperOrigin-RevId: 428033173
2022-02-11 20:27:06 -08:00
pekingme
64c6d047a9 [Tokens] Updated copyright year.
PiperOrigin-RevId: 427833895
2022-02-11 15:47:03 +00:00
pekingme
86e8b00ecd [CollapsingToolbarLayout] Fixed shadow issues when transition between expanded and collapsed states.
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
2022-02-11 15:45:15 +00:00
conradchen
d5856fd036 [Snackbar] Fix the issue that setting margins programmatically does not work
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
2022-02-11 15:43:45 +00:00
leticiars
1b7e92d99c [TextInputLayout] Updated documentation to clarify end icon mode's expected usage and behaviors relating to the icon's drawable.
Resolves https://github.com/material-components/material-components-android/issues/2528

PiperOrigin-RevId: 427506995
2022-02-11 15:41:02 +00:00
conradchen
4c7be52775 [Snackbar] Support setting max lines programmatically
Resolves https://github.com/material-components/material-components-android/issues/2018

PiperOrigin-RevId: 427305265
2022-02-09 15:59:34 +00:00
leticiars
ae16efd5da [TextInputLayout] Fixed icons behaving unexpectedly when switching modes + bug of wrong icon tint state when setting an icon programmatically.
Resolves https://github.com/material-components/material-components-android/issues/503
Resolves https://github.com/material-components/material-components-android/issues/1849

PiperOrigin-RevId: 427268349
2022-02-09 15:58:45 +00:00
conradchen
b0f37007aa [Button] Fix icon position not being updated when size is not changed
If a button has a WRAP_CONTENT width and after its text is updated but its size does not change, the icon position won't be updated because at the moment when onTextChanged() is called, getLayout() will return null and a new layout to display text will only be recreated in the next onMeasure() call.

To fix this issue, the change moves updateIconPosition() from onSizeChanged() to onLayout(), which will always be called after onMeasure() or onSizeChanged() is called, and thus covers both of the cases after the text is updated (the button changes its size or not.)

Note: we still need to keep the updateIconPosition() call in onTextChanged(), to cover the case that the button has a fixed width, in which updating text won't trigger remeasuring of the button.

Resolves https://github.com/material-components/material-components-android/issues/2553

PiperOrigin-RevId: 427215840
2022-02-09 15:56:11 +00:00
conradchen
f3c6430f94 [ChipGroup] Refactor chip group selection logic to a standalone class
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
2022-02-09 15:55:24 +00:00
pekingme
0de6ad4764 [Tokens] Updated motion token resources.
PiperOrigin-RevId: 427070157
2022-02-09 15:53:43 +00:00
pekingme
e721c468c2 [Tokens] Updated atomic shape resources to ShapeAppearance styles.
PiperOrigin-RevId: 426466909
2022-02-04 13:48:13 -08:00
dsn5ft
f6c8fa5aef [Color] Update DynamicColors util to applyStyle() on window decorView theme as well to fix potential ContextMenu issue
PiperOrigin-RevId: 426416360
2022-02-04 13:46:41 -08:00
pfthomas
94cd532bd1 [DatePicker] Start align edit icon in landscape
PiperOrigin-RevId: 426402283
2022-02-04 13:43:51 -08:00
pekingme
6454b8709a [BottomSheet] Fixed IME bottom padding is ignored in edge-to-edge case.
The regression on BottomSheet was introduced in 1.6.0-alpha01. Before this version, the bottom padding in edge-to-edge mode is calculated by getSystemWindowInsetBottom().

https://developer.android.com/reference/android/view/WindowInsets#getSystemWindowInsetBottom()

This is deprecated in newer APIs. According to deprecation message, the replacement is to use getInsets(int) with Type#systemBars(). But this is not completely true, because it doesn't contain IME insets.

https://developer.android.com/reference/android/view/WindowInsets.Type#systemBars()

Resolves: https://github.com/material-components/material-components-android/issues/2543
PiperOrigin-RevId: 426304311
2022-02-03 21:52:22 -08:00
hunterstich
d66676fd6b [NavigationBar][NavigationRail] Removed font scaling from NavigationBarView item labels.
PiperOrigin-RevId: 426264069
2022-02-03 20:20:31 -08:00
conradchen
b4cab87015 [Card] Fix crash on Pre-Q devices when checked icon is null
LayerDrawable has this bug that if any of the provided drawables are null during creation, it crashes. The fix is only available on Q+. Fixes this by providing a dummy drawable when we find checked icon is null.

Resolves https://github.com/material-components/material-components-android/issues/2532

PiperOrigin-RevId: 426179927
2022-02-03 20:19:40 -08:00
jeremymuhia
810541e7c0 [TypefaceUtils] clean up code smell
PiperOrigin-RevId: 426161045
2022-02-03 20:18:37 -08:00
jeremymuhia
2d90a7a508 [CollapsingTextHelper][TextAppearance] refactor how bold typefaces are created
PiperOrigin-RevId: 425988666
2022-02-02 18:17:01 -08:00
pfthomas
0f2b5378f7 [Top App Bar][ActionMode] Make title and subtitle match ActionBar's
Resolves https://github.com/material-components/material-components-android/issues/2189

PiperOrigin-RevId: 425712147
2022-02-01 22:00:53 -08:00
pfthomas
f9914da4e9 [TimePicker][a11y] Fix Switch Access can't reach clock items
PiperOrigin-RevId: 425684600
2022-02-01 13:56:37 -08:00
Material Design Team
dff1e4edf1 [TextAppearance] Clamp typeface weight when adjusting it
PiperOrigin-RevId: 425440606
2022-01-31 18:15:11 -08:00
Material Design Team
5dce006a5c [CollapsingToolbarLayout] Constrain adjusted font weight to acceptable values
PiperOrigin-RevId: 425438646
2022-01-31 18:13:57 -08:00
conradchen
b3db1cc028 [Badge] Prevent multiple badges being attached to a menu item at the same time
Fixes the logic in NavigationBarMenuView.restoreBadgeDrawables(), which may override the newly created badges with the restored drawables incorrectly. Also adds a safe guard that removes the previously attached badges if any, before attaching a new badge.

PiperOrigin-RevId: 424923078
2022-01-31 18:12:50 -08:00
conradchen
3cf23e4bf1 [Snackbar] Solve lint error caused by @IntDef
It seems like lint won't take both @IntDef and @IntRange into consideration at the same time. Just uses @IntRange to cover all possible values.

Resolves https://github.com/material-components/material-components-android/issues/1767

PiperOrigin-RevId: 424918785
2022-01-28 11:56:33 -08:00
afohrman
2463946d24 [TextInputLayout] Add line mask expansion animation to filled box underline.
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
2022-01-28 11:55:08 -08:00
pekingme
53863287d6 [Tokens] Re-upgraded to v0.73.
PiperOrigin-RevId: 424635556
2022-01-27 09:54:21 -08:00
pubiqq
10edcd11d5 [ChipDrawable] Support setting text color programmatically.
Resolves https://github.com/material-components/material-components-android/pull/2526

GIT_ORIGIN_REV_ID=d1f47b5aa0b823ae0915d4c7ae85417e7d0eddd5
PiperOrigin-RevId: 424632069
2022-01-27 09:53:18 -08:00