98 Commits

Author SHA1 Message Date
kendricku
1501d08876 [Extended FAB][AppBar] Fix Extended FAB behavior demo to shrink and extend as expected.
Also:
- Library fix to the AppBarLayout calculations for extended FAB versus FAB visibility.
- Removed the M3 Expressive toolbar min heights in favor of actionBarSize.

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

PiperOrigin-RevId: 764380548
2025-05-28 22:50:57 +00:00
pekingme
1adc50110e [AppBarLayout] Fixed the bug that setBackground will reset the internal MaterialShapeDrawable for lift-on-scroll feature.
PiperOrigin-RevId: 760744509
2025-05-21 17:55:04 +00:00
rightnao
36b285c9e3 [SearchBar] Add a lift on scroll color to SearchBar when used with AppBarLayout
PiperOrigin-RevId: 740478154
2025-03-26 16:20:02 +00:00
Material Design Team
cfe822097b Automated g4 rollback of changelist 715031294
PiperOrigin-RevId: 717977309
2025-01-21 18:57:52 +00:00
pubiqq
bc2fdeadaf [Internal] Prefer platform methods to compat ones
Resolves https://github.com/material-components/material-components-android/pull/4532

GIT_ORIGIN_REV_ID=180dec736f2521579e483317a4d537629d8f247b
PiperOrigin-RevId: 715494344
2025-01-15 18:06:07 +00:00
pekingme
d4ac3d593e [TopAppBar] Fixed the toolbar not snap when switch to freeform windowing.
PiperOrigin-RevId: 715031294
2025-01-14 18:30:22 +00:00
pekingme
32633a6ff4 [TopAppBar] Applied formatting only.
PiperOrigin-RevId: 713744692
2025-01-10 15:26:13 +00:00
pubiqq
23aca03255 [Internal] Remove pre-Lollipop checks
Resolves https://github.com/material-components/material-components-android/pull/4266

GIT_ORIGIN_REV_ID=1de7808e66dd6666c893217c76c7499afe2df6a3
PiperOrigin-RevId: 669688797
2024-09-03 13:31:29 +00:00
dsn5ft
5371290913 [CollapsingToolbarLayout] Refactor multiline rotation fix to address related issue caused by keyboard
PiperOrigin-RevId: 645057096
2024-06-20 18:19:59 +00:00
pubiqq
510881a469 [Internal] Stop using deprecated androidx.core.view.* methods
Resolves https://github.com/material-components/material-components-android/pull/4117

GIT_ORIGIN_REV_ID=dd157e8360c2511810496693cec1616fce578655
PiperOrigin-RevId: 632284856
2024-05-13 17:37:38 +00:00
Ga\u00ebtan Muller
b3fe6a7f61 [Cleanup] Remove redundant version checks for api <= 19.
Resolves https://github.com/material-components/material-components-android/pull/3849

GIT_ORIGIN_REV_ID=47bb2fcc8031740e5a7d4f741f1ada2af025e126
PiperOrigin-RevId: 632154861
2024-05-09 18:46:02 +00:00
Material Design Team
3e866b8715 [AppBarLayout] Allow scrolling up when the app bar is lifted.
1. Suppose the view is large enough to scroll down
2. After scrolling down, you hide a child view, which reduces the height to a value which means it would have been unscrollable in step 1
3. Now you can’t scroll back up

PiperOrigin-RevId: 623883120
2024-04-11 20:08:04 +00:00
hunterstich
17855c116b [TopAppBar] Fixed compress effect when toolbar is set as a support action bar and hiddin/shown.
getSupportActionBar.show/hide uses visibility to show/hide the toolbar which conflicted with the compress effect's use of Visibility to remove the toolbar when completely masked. This updates the compress effect to use alpha instead of visibility.

PiperOrigin-RevId: 619253990
2024-03-26 21:39:03 +00:00
Material Design Team
8a71e7741a [AppBarLayout] Use an accessibility delegate to add and perform actions
This replaces the use of `ViewCompat#add/removeAccessibilityAction`

Both are valid strategies, but each call to `remove` or `add` triggers an accessibility event. Since this check is done in layout (originally to fix a11y scroll state) it's sending a high number of events that create noise for accessibility services.

To avoid this, we move this code to the delegate `onInitialize` and `performAction` methods. Instead of the view dynamically adding and removing actions to itself, the node is initialized with actions only when an a11y service sends a request with a new node (likely due to some UI change).

The flow here would look like:
1. UI is scrolled/page is loaded
2. TalkBack gets a scroll event/content change event
3. TalkBack requests new snapshot of the screen
4. ABL populates the node with the actions

For a simple scroll, this change reduces the events from ~40 to ~10.

We also add the Truth library for clearer assertions.

PiperOrigin-RevId: 605333170
2024-02-12 16:14:44 +00:00
hunterstich
2ac8c1cbf6 [TopAppBar] Fixed compress effect clipping on API 21-24
Partially resolves https://github.com/material-components/material-components-android/issues/3603

PiperOrigin-RevId: 576102714
2023-10-26 20:37:38 +00:00
pekingme
1e9f5f0730 [AppBarLayout] Simplified logics to animate the container color between lifted state and the default state.
PiperOrigin-RevId: 566754407
2023-09-20 12:30:16 +00:00
dsn5ft
c4ae01a5a5 [AppBarLayout] Fix dynamic status bar foreground lift on scroll color when using Tonal Surface Color on API Level 33
Resolves https://github.com/material-components/material-components-android/issues/3530
Resolves https://github.com/material-components/material-components-android/issues/3585

PiperOrigin-RevId: 566609767
2023-09-19 20:28:23 +00:00
dsn5ft
569ddac527 [AppBarLayout] Fix dynamic status bar foreground lift on scroll color when using Tonal Surface Color
Resolves https://github.com/material-components/material-components-android/issues/3530

PiperOrigin-RevId: 564364138
2023-09-12 10:47:09 -04:00
pekingme
43242f20de [TopAppBar] Fixed that liftOnScrollColor doesn't respect to setLifted when liftOnScroll is set to false.
Resolves https://github.com/material-components/material-components-android/issues/3523

PiperOrigin-RevId: 563829477
2023-09-08 16:10:50 -04:00
pubiqq
0663019f45 [Color] Add ColorStateListDrawable support
Resolves https://github.com/material-components/material-components-android/pull/3538

GIT_ORIGIN_REV_ID=1bf9e320dc148e1bc959e7577372d3a393f35574
PiperOrigin-RevId: 563258432
2023-09-07 12:37:54 +00:00
pekingme
c7a0adf8dd [AppBarLayout] Added getMaterialShapeBackground() to return a MaterialShapeDrawable object of the background (non-lifted layer).
PiperOrigin-RevId: 553531357
2023-08-04 01:04:40 +00:00
pekingme
2b476b3a96 [TopAppBar] Updated the handling of liftOnScrollColor not override android:background.
PiperOrigin-RevId: 547883467
2023-07-17 15:56:54 +00:00
rightnao
e3b255b3a0 [Docs] Crosslink github docs in javadocs
PiperOrigin-RevId: 546393704
2023-07-11 19:37:37 +00:00
pekingme
6980c40f12 [TopAppBar] Updated to take a CSL as the AppBarLayout background color.
PiperOrigin-RevId: 527090028
2023-04-26 16:18:09 -04:00
rightnao
fdaff78506 [TopAppBar] Removing keyboard scroll event workaround for AppBarLayout since CoordinatorLayout issue has been fixed in androidx.core:core:1.10.0
Resolves https://github.com/material-components/material-components-android/issues/2249

PiperOrigin-RevId: 525775019
2023-04-24 15:29:47 -04:00
pekingme
b3f7b6604e [AppBarLayout] Fixed dragging the app bar layout overshoots the status bar.
Resolves https://github.com/material-components/material-components-android/issues/3316

PiperOrigin-RevId: 520466126
2023-03-30 15:55:50 +00:00
pekingme
dfbf4d9c2c [Cleanup] Minor fix.
PiperOrigin-RevId: 519997026
2023-03-28 16:19:46 +00:00
rightnao
21a7aff545 [AppBarLayout] Fix bug in AppBarLayout that refreshes all its children's drawables instead of just its own
Resolves https://github.com/material-components/material-components-android/issues/3233

PiperOrigin-RevId: 512678371
2023-02-27 20:48:34 +00:00
pubiqq
80ec5ccdd5 [AppBarLayout] Add AbsListView to views that support nested scrolling
Resolves https://github.com/material-components/material-components-android/pull/3220

GIT_ORIGIN_REV_ID=14e89d9356190155a82f01414c2221118d8d1d02
PiperOrigin-RevId: 507880939
2023-02-07 22:14:29 +00:00
conradchen
7b8faef12b [TopAppBar] Fix input rectangle being modified in onRequestChildRectangleOnScreen()
Resolves https://github.com/material-components/material-components-android/issues/3054

PiperOrigin-RevId: 491440304
2022-11-28 17:17:40 -05:00
rightnao
c8108b1f8e [TopAppBar] Update motion specs
PiperOrigin-RevId: 480953621
2022-10-13 21:01:26 +00:00
rightnao
c587dd1259 [AppBarLayout] Adding new attribute liftOnScrollColor that disables elevation overlay and allows users to change the app bar color
PiperOrigin-RevId: 477794812
2022-10-03 16:57:13 +00:00
rightnao
9df6c9d072 [AppBarLayout] Fix issue with a physical keyboard scroll not collapsing toolbar
PiperOrigin-RevId: 471608866
2022-09-01 17:22:43 -07:00
rightnao
14415a1308 [AppBarLayout] Make a new setter for scroll effect and make SCROLL_EFFECT_COMPRESS public
resolves https://github.com/material-components/material-components-android/issues/2894

PiperOrigin-RevId: 471289613
2022-08-31 15:55:37 -07:00
conradchen
10ac255bb2 Automated g4 rollback of changelist 457744460
PiperOrigin-RevId: 459744654
2022-07-08 13:27:04 -07:00
conradchen
ca2da6c6a4 Automated g4 rollback of changelist 454163860
PiperOrigin-RevId: 457744460
2022-06-29 14:36:58 +00:00
conradchen
687e73590d [TopAppBar] Exclude gone views from scroll range calculation
Resolves https://github.com/material-components/material-components-android/issues/2709

PiperOrigin-RevId: 454163860
2022-06-10 16:38:51 -07:00
pubiqq
382ce9c792 [TopAppBar] Fix copy constructors
Resolves https://github.com/material-components/material-components-android/pull/2686

GIT_ORIGIN_REV_ID=7f62b56c7edf01046e85b474d1cf0f17c6153b68
PiperOrigin-RevId: 450440535
2022-05-23 11:20:15 -04:00
Material Design Team
4b81bb1d1a [AppBarLayout] Loosen check for scrollable child when adding a11y actions
Adding the a11y delegate and a11y actions was dependent on there being a CoordinatorLayout child that both inherits from certain scrolling classes (NestedScrollingChild, ListView, ScrollView) and has an AppBarLayout scrolling behavior. This was too restrictive and so we only check for a behavior.

Any scrolling child may add an a11y delegate or scroll action to the parent CoordinatorLayout.

PiperOrigin-RevId: 448335380
2022-05-12 17:24:36 -04:00
Material Design Team
72228f4f35 [AppBarLayout] Fix scrolling for a11y
Ensure the CoL can scroll to the bottommost elements of the scrolling child, which may not be visible due to the app bar.
Also, set the node info properties to expose the CoL to auto-scrolling.

PiperOrigin-RevId: 447596411
2022-05-10 09:48:55 -04:00
dsn5ft
d6c435461e [AppBarLayout] Add setLiftOnScrollTargetView() method
Resolves https://github.com/material-components/material-components-android/pull/2544

PiperOrigin-RevId: 442823082
2022-04-19 12:02:59 -04:00
conradchen
05be1b92c5 [TopAppBar] Fix app:expanded=false not working
When an AppBarLayout is loaded, it will load the attribute and set up a non-forcing pending action. However when it's measured, the current scroll state will be saved and restored, which will override the non-forcing pending action. This behavior is incorrect - if there's a pending action, we shouldn't restore the scrolling state because it's meant to be changed.

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

PiperOrigin-RevId: 440960254
2022-04-11 15:47:00 -04: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
Material Design Team
cfc00aa5a3 Update android core class definitions across material
PiperOrigin-RevId: 414839941
2021-12-08 14:56:25 +00:00
conradchen
acb7958c66 [TopAppBar] Fix top app bar snapping issue
Unlike other child views of AppBarLayout, CollapsingToolbarLayout will shift its top boundary to consume the window insets as well. Therefore we need to shift the top boundary back when calculating snapping positions to have a consistent logic with other views.

This CL also simplifies the calculation so the origin of the y-coordinate used in the calculation will always be the top of the AppBarLayout.

PiperOrigin-RevId: 413750156
2021-12-06 19:34:30 +00:00
Material Design Team
a487c89185 Internal change
PiperOrigin-RevId: 412135443
2021-11-29 17:35:39 +00:00
Khang NT
b935604e2c [AppBarLayout] Fix snap issue with transparent status bar
Resolves https://github.com/material-components/material-components-android/pull/2387

GIT_ORIGIN_REV_ID=47538c3b4cb10337c537d1ef532bd1d73b216ae3
PiperOrigin-RevId: 406835368
2021-11-01 19:53:05 +00:00
conradchen
7fc006c5e4 [TopAppBar] Fix the issue that top app bars not collapsed when top padding is set
In the snap logic we didn't take the AppBarLayout's top padding into account, therefore in certain cases the scrolling will be incorrectly snapped to the top of CollapsingToolbarLayout instead of the bottom of it, which cause the title not collapsed.

PiperOrigin-RevId: 400749401
2021-10-05 09:04:10 -04:00
conradchen
4bec3e2b13 [AppBar] Fix incorrect scroll position after orientation changes
An app bar remembers the visible percentage of its first visible child during recreation to restore its scroll position. However, if an app bar is "fully" scrolled (scrolled to its maximum range), gets recreated, and changes its size after recreation, it can become not fully scrolled even if it keeps the same visible percentage of its first visible child, due to the difference in its own size. This can result in unexpected "gaps" in the layout due to inconsistency between AppBar layout's scroll position and the content view's.

Fixes this by remembering the "fully scrolled" state and restore it during recreation.

PiperOrigin-RevId: 398013525
2021-09-23 19:18:08 +00:00
conradchen
a682ab0ee0 [AppBar] Make it possible to disable app bars' shadow
Originally we always set the outline provider of app bars to BOUND, even if the outline provider is set to none explicitly in the XML file.

Checks if the outline provider is set to BACKGROUND before we override it, to prevent unwanted overriding from happening.

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

PiperOrigin-RevId: 391339943
2021-08-18 10:01:27 -07:00