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
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
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
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
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
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
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
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