73 Commits

Author SHA1 Message Date
hunterstich
71f014fa41 [Snackbar] Added optional close icon
PiperOrigin-RevId: 845256053
2025-12-17 14:23:55 +00:00
dsn5ft
5853d725fa [Snackbar] Ignore bottom gesture inset if anchor view is specified to avoid infinite loop flicker
Resolves https://github.com/material-components/material-components-android/issues/3462

PiperOrigin-RevId: 775698551
2025-06-27 16:15:56 +00:00
hunterstich
580e8d56d6 [Build] Updated build to use Dackka for documentation generation
PiperOrigin-RevId: 730522331
2025-02-25 19:33:33 +00:00
Material Design Team
7f8f3e762b Automated g4 rollback of changelist 655638807
PiperOrigin-RevId: 730472222
2025-02-25 19:31:01 +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
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
Material Design Team
31f80151a9 [Snackbar] Set the accessibility pane title right before the Snackbar's appearance to resolve an event stream issue
PiperOrigin-RevId: 664967701
2024-08-20 17:36:35 +00:00
Material Design Team
d7645ae5e1 [Snackbar] Add an accessibility pane title of "Alert"
PiperOrigin-RevId: 655638807
2024-07-25 19:04:11 +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
57b26639d8 [Bugfix] Consistently use window coordinates to calculate Snackbar offsets. In one place screen and window coordinates are mixed, which leads to bad behavior in split screen apps.
PiperOrigin-RevId: 546057340
2023-07-07 17:55:24 +00:00
pubiqq
abd1d1c802 [Snackbar] Fix the snackbar position when the anchor view layout listener is enabled
Resolves https://github.com/material-components/material-components-android/pull/3211
Resolves: https://github.com/material-components/material-components-android/issues/3194

GIT_ORIGIN_REV_ID=ef12e5c4f6c6ec49287a472ba1243c20cc2ac979
PiperOrigin-RevId: 509892239
2023-02-17 04:51:00 -08:00
pubiqq
e06a11982b [Internal] Add compat method to get the screen size
Resolves https://github.com/material-components/material-components-android/pull/3221

GIT_ORIGIN_REV_ID=9323e23689386561d38b0c8c73114e0db7a30557
PiperOrigin-RevId: 509548792
2023-02-15 10:25:53 -08:00
rightnao
3d3edce956 [Snackbar] Update motion specs
PiperOrigin-RevId: 470790457
2022-08-30 11:21:45 -04:00
conradchen
fd5ee4a989 [Snackbar] Avoid update layout if bottom margins for anchor view does not change
Whenever the anchor view is being relaid out, we will try to update the bottom margin of the snack bar, which may cause the anchor view be relaid out again, thus an infinite loop. Avoids updating margins if the bottom margin for anchor view doesn't change to fix the issue.

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

PiperOrigin-RevId: 454885847
2022-06-14 10:19:33 -07:00
conradchen
46fa8cc45b [SnackBar] Fix margins are added multiple times when show() is called
When a snack bar is hidden and its show() method is called, it will be added to the target parent, and at this moment the parent view will set the layout params to the snack bar, with the same existing margins if any. Therefore if the margins are already updated with extra margins, the original margins will be incorrectly updated. This CL introduces a flag to tells this situation from other "real" scenarios in which clients want to update their custom margins.

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

PiperOrigin-RevId: 445159923
2022-04-28 12:37:45 -04:00
dsn5ft
a71781355e [Snackbar] Add shape theming support and update M3 style to use new shapeAppearanceCornerExtraSmall
PiperOrigin-RevId: 444883546
2022-04-27 12:37:04 -04: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
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
Material Design Team
cfc00aa5a3 Update android core class definitions across material
PiperOrigin-RevId: 414839941
2021-12-08 14:56:25 +00:00
conradchen
35d9da8f67 [SnackBar] Fix NPE on Android 8 & 9
It seems like on Android 8 & 9 framework's View implementation has a bug that under certain scenarios if we set a view's visibility when view.getParent() is null, it can cause NPE crash.

Fixes this by switching the order of addView and setVisibility() call.

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

PiperOrigin-RevId: 413978332
2021-12-06 19:46:57 +00:00
conradchen
6a3ea94ae0 [Snackbar] Fix maxWidth is not applied on Snackbar
During a previous refactoring, the maxWidth enforcement logic was incorrectly moved to the inner layout of snackbar. Moves the logic back to the outer layout so it can be properly applied.

PiperOrigin-RevId: 413938993
2021-12-06 19:43:13 +00:00
Material Design Team
a487c89185 Internal change
PiperOrigin-RevId: 412135443
2021-11-29 17:35:39 +00:00
conradchen
8729d8ab57 [SnackBar] Fix maxWidth and maxInlineActionWidth are not applied
We load maxWidth and maxInlineActionWidth style attributes in SnackbarContentLayout, but the snackbar styles are only applied to SnackbarLayout. We need to pass the values to SnackbarContentLayout, as we did for actionTextColorAlpha.

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

PiperOrigin-RevId: 404320339
2021-10-20 19:18:47 +00:00
conradchen
58ceeab63c [SnackBar] Handle anchor view properly so no memory leak will happen
The anchor view can be detached even when the snack bar (or any
transient bottom bar) is showing. If this situation happens the
global layout listener it registers with the anchor view will
become not removable due to a bug/intended behavior of Android View's
implementation.

We need to remove the listener when the anchor view is detached to
fix the issue.

This CL also refactors the whole implementation of anchor view and consolidates
the anchoring/unanchoring logic to improve readability and robustness of it.

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

PiperOrigin-RevId: 382603130
2021-07-02 08:15:03 -04:00
conradchen
b0558dc006 [Snackbar] Fix memory leak caused by not resetting anchor views
PiperOrigin-RevId: 379830572
2021-06-17 14:51:36 -04:00
Valentin Slawicek
d15d435093 Automated g4 rollback of changelist 350755495
PiperOrigin-RevId: 351144304
2021-01-11 21:10:54 -05:00
Valentin Slawicek
a3b8be845a [Snackbar] Fix last remaining NPE from #917
Resolves https://github.com/material-components/material-components-android/pull/1938

GIT_ORIGIN_REV_ID=2b71fd49e19c577ef2caf17ca5a92c3f069b1fe0
PiperOrigin-RevId: 350755495
2021-01-08 10:28:18 -05:00
Valentin Slawicek
ebd3223147 [Snackbar] Fixes remaining NPEs from #917
Resolves https://github.com/material-components/material-components-android/pull/1887

GIT_ORIGIN_REV_ID=331d064eb02cb4ff1a2b84f274b8d2c98848e9d4
PiperOrigin-RevId: 345283901
2020-12-03 14:45:59 -05:00
Mattia Pagini
2b95793ea6 [BaseTransientBottomBar] Check for nullable AccessibilityService
Resolves https://github.com/material-components/material-components-android/issues/1885
Resolves https://github.com/material-components/material-components-android/pull/1888

GIT_ORIGIN_REV_ID=35572a920b4bdd66e416d428c55416df7c498db6
PiperOrigin-RevId: 343873267
2020-11-23 14:41:28 -05:00
Material Design Team
9659a536b9 [Snackbar] Add support for passing a Context to Snackbar.make()
Currently Snackbar.make() will use the context of the parent view (typically CoordinatorLayout or decor content view) to inflate the Snackbar view. This is not desirable for cases where there may be a ContextThemeWrapper below that parent view, e.g. for a Fragment that uses material theme.

The behavior of existing methods without Context argument remain unchanged.

PiperOrigin-RevId: 340286851
2020-11-03 11:12:55 -05:00
dniz
89a1bf883f [Snackbar] Added ability to have Snackbar position respond to anchor view layout changes
Disabled by default to avoid changes in behavior and breakages in tests

PiperOrigin-RevId: 333299318
2020-09-23 12:10:02 -07:00
marianomartin
555356b03f Internal cleanup
PiperOrigin-RevId: 318134343
2020-06-26 14:06:52 -04:00
isabellekim
c30abe9d7a Update javadocs for Snackbar.
PiperOrigin-RevId: 300406441
2020-03-13 10:46:58 -04:00
connieshi
bd7de3d412 Add null check in #animateViewIn to guard against the post runnable executing after the view has been destroyed.
Resolves https://github.com/material-components/material-components-android/issues/917

PiperOrigin-RevId: 290300667
2020-01-17 13:57:49 -05:00
dniz
86b2ec3243 Update Snackbar gesture inset calculation to factor in translationY
Fixes issue of compounding margins for legacy Snackbar which uses a slide animation that affects it's position on the screen

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

PiperOrigin-RevId: 285246645
2019-12-12 16:10:26 -05:00
marianomartin
115313c0c0 Expose a class for themeoverlay in style
This moves functionality from ThemeEnforcement into a stand alone class.

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

PiperOrigin-RevId: 275481343
2019-10-21 10:24:19 -04:00
dniz
0c8c6f6249 Update Snackbar to respect left/right system window insets
PiperOrigin-RevId: 272667571
2019-10-03 11:45:22 -04:00
dniz
4974f31a8b Update Snackbar#setGestureInsetBottomIgnored to return Snackbar
PiperOrigin-RevId: 272522128
2019-10-03 11:43:28 -04:00
isabellekim
2f740c73e3 Update Snackbar's application of backgroundTint so that it applies a tint on a colored background to keep the shadow.
PiperOrigin-RevId: 270970055
2019-09-26 17:53:38 -04:00
isabellekim
95af724ca4 Updates snackbar to support app:backgroundTint and app:backgroundTintMode.
Also adds ability to setBackgroundTintMode programmatically.

PiperOrigin-RevId: 270337384
2019-09-24 12:20:17 -04:00
dniz
03b5cffbb7 Update naming of Snackbar gesture inset ignore flag
PiperOrigin-RevId: 268914646
2019-09-18 14:06:07 -04:00
cketcham
4211a8a794 Add @NonNull and @Nullable annotations
PiperOrigin-RevId: 265057036
2019-08-29 10:25:19 -04:00
dniz
c1098453fc Update Snackbars to respect bottom system gesture inset on Android Q
Ensures that the Snackbar swipe to dismiss gesture doesn't conflict with the Quick Switch gesture

PiperOrigin-RevId: 264836552
2019-08-26 11:34:02 -04:00
dniz
bfcaf43715 Hide BaseTransientBottomBar IntDef annotations
PiperOrigin-RevId: 260144023
2019-07-29 16:38:30 -04:00
dniz
949e64475e Update Snackbar#setAnchorView(int) javadoc to explain how anchor view is found
PiperOrigin-RevId: 259991025
2019-07-29 16:31:45 -04:00
dniz
cc73c2a630 Update TODOs
PiperOrigin-RevId: 259535844
2019-07-23 11:21:39 -04:00
marianomartin
11e6dd134e Cleanup BaseTransientBottomBar and write test making sure touch events are handled properly
PiperOrigin-RevId: 259260862
2019-07-22 12:22:46 -04:00
isabellekim
a628bf516b Revert the library to compile with Java 7: revert lambdas, add necessary casts, and make some variables final.
Continue compile shrine demo, catalog, and tests with Java 8.

PiperOrigin-RevId: 257874888
2019-07-15 19:19:23 -04:00
marianomartin
b5ec7135c5 Rollback accidental changes to snackbar
PiperOrigin-RevId: 257821452
2019-07-15 19:13:06 -04:00