78 Commits

Author SHA1 Message Date
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
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
pekingme
9de9319b1e [Resources] Added styles in res-public.
PiperOrigin-RevId: 403451624
2021-10-18 15:31:13 -04:00
conradchen
764cd05b9d [M3][Snackbar] Update snackbar dev doc with M3 themes/styles
Also adds missed text appearance attribute.

PiperOrigin-RevId: 395951691
2021-09-15 12:45:45 -07:00
conradchen
41219f05ac [M3][Snackbar] Create snack bar styles
PiperOrigin-RevId: 394314511
2021-09-02 13:01:09 -04: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
Gabriele Mariotti
391d1f8ac5 [Snackbar] Changed dimens according to spec
Resolves https://github.com/material-components/material-components-android/pull/1711
Resolves https://github.com/material-components/material-components-android/issues/1721

GIT_ORIGIN_REV_ID=c039075b65833724b59ecdfde1ba70ed8ae5b8eb
Co-authored-by: pekingme <pekingme@gmail.com>
PiperOrigin-RevId: 333292492
2020-09-23 12:08:37 -07:00
marianomartin
049ad022a6 Delete components build.gradle files
PiperOrigin-RevId: 320944144
2020-07-15 09:38:31 -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
marianomartin
934c407d7d Add a setter for maxInlineActionWidth
PiperOrigin-RevId: 295033109
2020-02-14 11:30:12 -05: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
dniz
1882fa96b5 Remove ThemeOverlay.AppCompat.Dark from Snackbar mtrl layouts
The theme overlay should no longer be needed now that we explicitly set colors on the Snackbar's message text and action button

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

PiperOrigin-RevId: 281067788
2019-11-19 10:21:00 -08: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
dniz
b99709200e Add support for Snackbar message text styling via snackbarTextViewStyle attr
PiperOrigin-RevId: 272198481
2019-10-01 12:35:27 -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
dniz
72cfef981b Rename prefix mtrl_ to material_ in public resources
PiperOrigin-RevId: 265729121
2019-08-29 12:16:13 -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
52ebd29fa6 Add setBackgroundTintList to Snackbar
PiperOrigin-RevId: 259812607
2019-07-25 13:11:25 -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
dniz
0512f776c5 Remove sub-package AndroidManifest.xml files from lib directory
PiperOrigin-RevId: 258390736
2019-07-16 13:18:32 -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
marianomartin
0a5d66ffc0 Internal cleanup
PiperOrigin-RevId: 257802841
2019-07-15 19:07:26 -04:00
dniz
68ddfee0ed Remove Material's legacy androidx core_ui and core_utils dependencies in favor of more granular dependencies (coordinatorlayout, graphics, interpolator, customview)
PiperOrigin-RevId: 257452569
2019-07-10 15:17:12 -04:00
marianomartin
152f05adbc Internal cleanup
PiperOrigin-RevId: 256180803
2019-07-03 14:09:17 -04:00
marianomartin
c695592f90 Remove redeclaration of @Duration annotation from Snackbar in favor
of inheriting it and the constant values from BaseTransientBottomBar.

PiperOrigin-RevId: 255629856
2019-07-03 14:04:20 -04:00
marianomartin
164bf0fabd Internal cleanup
PiperOrigin-RevId: 255609320
2019-07-03 14:02:53 -04:00
marianomartin
469c12636d Change snackbar duration timeout for a11y
PiperOrigin-RevId: 255456517
2019-07-03 14:00:16 -04:00
marianomartin
367b295624 Internal cleanup
PiperOrigin-RevId: 254414602
2019-06-24 17:12:42 -04:00