190 Commits

Author SHA1 Message Date
pfthomas
b1bd580d7e [NavigationDrawer] Updated active text label to use a bold typeface.
PiperOrigin-RevId: 487600688
2022-11-18 16:53:12 -05:00
rightnao
cb384c5c2c [NavigationView] Disable drawing left and right insets if the nav bar is not edge to edge
resolves https://github.com/material-components/material-components-android/issues/3016

PiperOrigin-RevId: 484304490
2022-10-28 07:44:17 -07:00
leticiars
a85204eb75 [TextInputLayout] Updated expanded label color to take error color when on error.
Partially fixes https://github.com/material-components/material-components-android/issues/2719

PiperOrigin-RevId: 471799584
2022-09-02 12:54:09 -07:00
Material Design Team
44cc9b745c Add @CanIgnoreReturnValue to some APIs that return this.
PiperOrigin-RevId: 468721442
2022-08-22 15:22:27 -04:00
leticiars
00dfeaca53 [Internal] Merge DrawableUtils classes
PiperOrigin-RevId: 466426273
2022-08-10 13:14:53 +00:00
leticiars
079371fd10 [Checkbox] Fix pre-21 issue where a child of the layer drawable (the button and/or the icon drawables) may not have its constant state set up properly.
PiperOrigin-RevId: 464128801
2022-08-04 14:21:36 -04:00
leticiars
9ca8a80468 [Checkbox] Fixed issue where AppCompatCheckBox would not display its drawable when a Material theme was being used.
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
2022-07-28 17:41:12 -04:00
raajkumars
dfbbf609c5 [Internal] Added ExpandCollapseAnimationHelper and MultiViewUpdateListener.
PiperOrigin-RevId: 462451046
2022-07-22 15:23:37 +00:00
leticiars
8fae47a39e [Checkbox] Updated checkbox to M3 look.
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
2022-07-22 15:22:30 +00:00
raajkumars
07938f572f [Internal] Added utility methods to ViewUtils.
PiperOrigin-RevId: 462208023
2022-07-20 21:49:42 +00:00
raajkumars
2a58122252 [Internal] Move RectEvaluator to Material Android Library
PiperOrigin-RevId: 461973938
2022-07-20 21:47:03 +00:00
raajkumars
3a37288453 [Internal] Moved ReversableAnimatedValueInterpolator to Material Android Library.
PiperOrigin-RevId: 461963086
2022-07-20 21:45:58 +00:00
raajkumars
ec8e70babb [Internal] Moved TouchObserverFrameLayout to Material Android Library.
PiperOrigin-RevId: 461948017
2022-07-20 21:45:16 +00:00
raajkumars
f3d422fb99 [Internal] Moved FadeThroughDrawable to Material Android Library.
PiperOrigin-RevId: 461932441
2022-07-19 18:43:37 +00:00
raajkumars
c8878f1790 [Internal] Move ClippableRoundedCornerLayout to Material Android library.
PiperOrigin-RevId: 461898783
2022-07-19 18:43:09 +00:00
pubiqq
4dc3d93ac2 [NavigationView] Update foreground boundaries of menu items when setting a new foreground
Resolves https://github.com/material-components/material-components-android/pull/2737
Resolves https://github.com/material-components/material-components-android/issues/2735

GIT_ORIGIN_REV_ID=8632d22d414f592378b68a8d27f7fba73edc28f9
PiperOrigin-RevId: 458198734
2022-07-06 04:52:55 -07:00
dsn5ft
241aa5cd8b [CollapsingToolbarLayout] Added experimental API to allow generic customizations of the StaticLayout.Builder used for the title text
Example usage:

```
collapsingToolbarLayout.setStaticLayoutBuilderConfigurer(
    builder ->
        builder.setLineBreakConfig(
            new LineBreakConfig.Builder()
                .setLineBreakWordStyle(LineBreakConfig.LINE_BREAK_WORD_STYLE_PHRASE)
                .build()));
```

PiperOrigin-RevId: 455625977
2022-06-23 18:32:33 +00:00
conradchen
1a91e683a3 [BottomSheet] Fix bottom sheet dialog status bar color adjustment
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
2022-05-24 13:16:26 -04:00
conradchen
73cb1b6e78 [TextField] Fix hint is not displayed when expanding space is limited
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
2022-05-18 21:14:13 -04:00
dsn5ft
2ac796fdf4 [MaterialToolbar] Add null check for logo ConstantState check
Resolves https://github.com/material-components/material-components-android/issues/2708

PiperOrigin-RevId: 449305810
2022-05-17 22:16:43 -04:00
pubiqq
5d6678cc66 [MaterialDatePicker] Hide the keyboard when switching to calendar mode
Resolves https://github.com/material-components/material-components-android/pull/2688
Resolves https://github.com/material-components/material-components-android/issues/2687

GIT_ORIGIN_REV_ID=686526aa049eadb08ded72ca9eb0b60027358756
PiperOrigin-RevId: 447819486
2022-05-11 09:41:38 -04:00
conradchen
0c341c4e9b [TopAppBar] Fix collapsing title issue with different fonts
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
2022-05-05 15:15:16 -04:00
conradchen
526ce8c6c5 [TopAppBar] Fix margins not applied when collapsed and expanded text size and type face are the same
We missed to check if the available text width is changed when deciding if we should recreate the static text layout. Adds the check to fix the issue.

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

PiperOrigin-RevId: 445941276
2022-05-02 11:45:14 -04:00
Venugopal Rao Gubbala
7b043c3b68 [CollapsingToolbarLayout] Allow application to Set ellipsis to Title in CollapsingToolBar
Resolves https://github.com/material-components/material-components-android/pull/2636

GIT_ORIGIN_REV_ID=f6c2b07c1eb936ed2de47b7586688a5f6b322e48
PiperOrigin-RevId: 445200467
2022-04-28 16:26:58 -04:00
pfthomas
b1f7d5bebc [NavigationView][a11y] Announce number of items in drawer
Resolves https://github.com/material-components/material-components-android/issues/678

PiperOrigin-RevId: 445165922
2022-04-28 12:40:24 -04:00
pubiqq
3ca41be8f0 [General] Fix typos
Resolves https://github.com/material-components/material-components-android/pull/2654

GIT_ORIGIN_REV_ID=b8f6728979875629f2c813ef90d2f671cf56b4eb
PiperOrigin-RevId: 442852630
2022-04-19 14:48:55 -04:00
dsn5ft
f69e3a025b [MaterialToolbar] Fixed centering logic when title and subtitle are the same
Resolves https://github.com/material-components/material-components-android/issues/2303

PiperOrigin-RevId: 435348290
2022-03-17 11:41:23 -04:00
jeremymuhia
cfc307ed4e [NavigationView] fix navigation view item ripple
PiperOrigin-RevId: 434516655
2022-03-14 18:55:40 +00:00
conradchen
be6050a23c [DatePicker] Always go edge-to-edge in fullscreen mode
Resolves https://github.com/material-components/material-components-android/issues/1966

PiperOrigin-RevId: 432296692
2022-03-04 13:06:17 -05: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
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
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
jeremymuhia
2d90a7a508 [CollapsingTextHelper][TextAppearance] refactor how bold typefaces are created
PiperOrigin-RevId: 425988666
2022-02-02 18:17:01 -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
88eb089021 [TextField] Apply edit text's letter spacing to expanded hints
Resolves https://github.com/material-components/material-components-android/issues/2202

PiperOrigin-RevId: 417863400
2021-12-23 13:54:06 -05:00
Material Design Team
cfc00aa5a3 Update android core class definitions across material
PiperOrigin-RevId: 414839941
2021-12-08 14:56:25 +00:00
Dan Nizri
b7c7d18834
Revert "[Material Toolbar] Change logo scaleType and set logo adjustViewBounds" 2021-12-01 18:41:20 -05:00
Jose Figueroa
71a110fe89
Merge pull request #2406 from P1NG2WIN/master
[Material Toolbar] Change logo scaleType and set logo adjustViewBounds
2021-12-01 16:47:25 -05:00
Material Design Team
a487c89185 Internal change
PiperOrigin-RevId: 412135443
2021-11-29 17:35:39 +00:00
conradchen
89d80d080f [TopAppBar] Fix expanded title margin not applied
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
2021-11-29 16:58:15 +00:00
conradchen
1d50ed7846 [TopAppBar][TextField] Remove unneeded logic
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
2021-11-29 16:56:38 +00:00
jeremymuhia
65754bd152 [CollapsingToolbarLayout][a11y] collapsing toolbar layout not respecting system level bold
PiperOrigin-RevId: 410846065
2021-11-29 16:53:01 +00:00
serniebanders
185a0f9c92 [BottomSheetBehavior] Add margin flags to BottomSheetBehavior for system inset bars.
Updates bottom sheet styles to default to left and right margins, top and bottom padding.

Resolves: https://github.com/material-components/material-components-android/issues/2221
PiperOrigin-RevId: 410580245
2021-11-29 16:46:09 +00:00
serniebanders
d5729d5935 Automated g4 rollback of changelist 409212345
PiperOrigin-RevId: 409279906
2021-11-16 12:34:36 -05:00
serniebanders
022a05f526 [BottomSheetBehavior] Add margin flags to BottomSheetBehavior for system inset bars.
Updates bottom sheet styles to default to left and right margins, top and bottom padding.

Resolves: https://github.com/material-components/material-components-android/issues/2221
PiperOrigin-RevId: 409212345
2021-11-16 12:29:43 -05:00
conradchen
44d4c3ea3f [TopAppBar] Correctly set letter spacing when expanding titles
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
2021-11-10 16:54:12 -05:00
conradchen
34cce18d4a [TextField] Correctly calculate hint text offset
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
2021-11-10 16:52:14 -05:00
conradchen
e6db8a4d31 [TopAppBar] Fix text alignment of multi-line title in collapsing toolbar
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
2021-11-10 16:13:26 -05:00
conradchen
c80177d062 [CollapsingTextHelper] Small clean-up of CollapsingTextHelper
PiperOrigin-RevId: 408644009
2021-11-10 16:04:13 -05:00
dsn5ft
9ae56ceedd [Javadocs] Remove all broken attr links from Javadocs
PiperOrigin-RevId: 404246710
2021-10-20 19:06:18 +00:00