2306 Commits

Author SHA1 Message Date
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
hunterstich
c66633b385 [NavigationRail] Added support for opting in/out of the NavigationRail automatically adding system top and bottom window insets.
PiperOrigin-RevId: 424424554
2022-01-27 09:51:41 -08:00
conradchen
0c8fc4144e [M3][Color] Add missing M3 color attributes to public
Resolves https://github.com/material-components/material-components-android/issues/2538

PiperOrigin-RevId: 424403413
2022-01-27 09:50:52 -08:00
conradchen
1c5c054b70 [Dialog] Fix crashes when colorControlHighlight is a CSL
We set ?attr/colorControlHighlight as scroll indicators' background attribute. However, on older platforms this will crash the app due to Android expects a drawable or a plain color for the background attribute.

Changes the view to TextView so it will be rendered as MaterialTextView, which supports app:backgroundTint with CSLs. Also changes the base background color to #1F000000 and the tint color to ?attr/colorForeground, which are aligned with what framework's alert dialog implementation is doing.

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

PiperOrigin-RevId: 423917985
2022-01-25 14:48:33 -05:00
dsn5ft
96fa85e216 [MaterialButtonToggleGroup] Removed getAccessibilityClassName() override since TalkBack doesn't recognize the class name, in favor of getting identified as a generic list container
PiperOrigin-RevId: 423814546
2022-01-24 15:47:55 -05:00
pfthomas
7d46b95e9e [TextInputLayout] Add support for minEms and maxEms
Resolves https://github.com/material-components/material-components-android/issues/2269

PiperOrigin-RevId: 423118234
2022-01-24 14:48:13 -05:00
Material Design Team
285fa9de30 Automated g4 rollback of changelist 422930284
PiperOrigin-RevId: 422949121
2022-01-20 10:24:30 -05:00
Material Design Team
c52b95d4d5 Automated g4 rollback of changelist 420096508
PiperOrigin-RevId: 422930284
2022-01-19 19:34:23 -05:00
dsn5ft
b84f35f121 [Color] Update DynamicColors util to use activity.getTheme().applyStyle() instead of activity.setTheme() to workaround Force Dark issue
Resolves https://github.com/material-components/material-components-android/issues/2521

PiperOrigin-RevId: 422816956
2022-01-19 11:15:01 -05:00
pekingme
d0e0d9404d [Tokens] Downgraded token resources to v0.71.
PiperOrigin-RevId: 421954490
2022-01-18 12:04:57 -05:00
conradchen
3cf0647da0 [Slider] Fix lint error caused by hidden super interface
Overriding the inherited methods from a hidden super interface to fix lint errors caused by those methods being hidden.

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

PiperOrigin-RevId: 421909180
2022-01-18 12:03:14 -05:00
conradchen
6c41f070e8 [Button] Support icon gravity with text alignments other than centered
Resolves https://github.com/material-components/material-components-android/issues/1371

PiperOrigin-RevId: 421605261
2022-01-18 12:02:02 -05:00
conradchen
8342f9025e [M3][Dialog] Add date and time picker themes to M3 dialog themes
Also moves all theme overlays to separate files for internal building purpose.

PiperOrigin-RevId: 421385265
2022-01-13 12:18:05 -05:00
conradchen
698cf9b45e [AppBarLayout] Save and restore scroll state during scroll range recalculation
When scroll range changes, the current scroll position may not make sense anymore. Therefore we need to save the scroll state and restore it after the scroll range is invalidated. This change reuses and refactors the existing saving instance state logic to support this need. Also adds a flag to denote "fully expanded" state to avoid improper scroll position calculation when views are still being initialized.

PiperOrigin-RevId: 421348135
2022-01-13 12:15:17 -05:00
dsn5ft
8f4837e059 [MaterialCheckBox] Horizontally center the checkbox button drawable if there is no text
PiperOrigin-RevId: 421304994
2022-01-12 11:30:33 -05:00
jeremymuhia
90787bf0e0 [TextAppearance] fix drawables not applying system level bold
PiperOrigin-RevId: 421066050
2022-01-12 11:21:15 -05:00
conradchen
a74675177f [Badge] Internal change
PiperOrigin-RevId: 420376250
2022-01-12 11:20:32 -05:00
dsn5ft
48741b4e16 [Color] Avoid Short#compare usage in ColorResourcesTableCreator.java since it requires API level 19
PiperOrigin-RevId: 420358384
2022-01-12 11:19:45 -05:00
pekingme
4527272319 [Tokens] Upgraded token resources to v0.73.
PiperOrigin-RevId: 420329292
2022-01-12 11:18:41 -05:00
pekingme
4de8565634 [Tokens] Upgrade M3 token resources to v0.71
PiperOrigin-RevId: 420319663
2022-01-12 11:16:06 -05:00
conradchen
bbbeacd64e [Badge] Refactor Badge state managing logic
This CL fixes a couple of badge state related issues. First, it prevents the badges created before restoring instance states from being overwritten by the old instance states. Second, it makes badges reload their default style settings everytime when its being recreated so if the environment has been changed, the default values will reflect the environment change.

This CL also fixes that several attributes were not correctly saved/restored or their default values were not correctly loaded.

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

PiperOrigin-RevId: 420096508
2022-01-06 15:51:50 -05:00
conradchen
3db25be3b6 [ButtonGroup] Simplify MaterialButtonToggleGroup's checking logic
1. Consolidates single selected ID and multiple selected IDs to a single selected
   ID set.
2. Separates View states and internal checked states so we can focus and enforce
   policies much easier on only internal states.

PiperOrigin-RevId: 420087718
2022-01-06 15:44:19 -05:00
conradchen
ff97a6805c [SnackBar] Enforce vertical layout when action text is too long
The snack bar content layout is by default horizontal, and we only change it to vertical when the action view is too wide and ellipsizes the message text. Therefore if the layout orientation is already vertical, we should just keep the layout and no need to check if the message text is multi-line again.

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

PiperOrigin-RevId: 419885582
2022-01-05 23:26:51 -05:00
conradchen
a43d7d993c [M3][Theme] Internal change
PiperOrigin-RevId: 419602208
2022-01-04 18:01:05 -05:00
pfthomas
8bc64201d4 [AlertDialog][a11y] Make dialog icon not important for accessibility
Resolves https://github.com/material-components/material-components-android/issues/1400

PiperOrigin-RevId: 419600919
2022-01-04 18:00:22 -05:00
Material Design Team
bc811d231b Automated g4 rollback of changelist 418911641
PiperOrigin-RevId: 418915787
2022-01-04 17:59:36 -05:00
pfthomas
bd15f071e1 [AlertDialog][a11y] Make dialog icon not important for accessibility
Resolves https://github.com/material-components/material-components-android/issues/1400

PiperOrigin-RevId: 418911641
2022-01-04 17:58:32 -05:00
conradchen
246b3400ec [M3][Dialog] Fix dialog icon color tint
Only tints dialog icons when it's an SVG with colorControlNormal, which is the common default color used by vector icons.

PiperOrigin-RevId: 418666657
2021-12-29 13:56:43 -05:00
conradchen
a17af6ee04 Automated g4 rollback of changelist 418054400
PiperOrigin-RevId: 418062580
2021-12-28 11:44:12 -05:00
conradchen
747bcf25ff [ButtonGroup] Simplify MaterialButtonTogglerGroup's checking logic
1. Consolidates single selected ID and multiple selected IDs to a single selected
   ID set.
2. Separates View states and internal checked states so we can focus and enforce
   policies much easier on only internal states.

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

PiperOrigin-RevId: 418054400
2021-12-28 08:55:31 -05:00