Merge "Constraint Snackbar's width to 504dp" into sc-v2-dev am: 3013c7ecf5

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/16388221

Change-Id: I7067c281f20b405f47253a486275189f63b6b5d9
This commit is contained in:
TreeHugger Robot
2021-12-03 19:37:51 +00:00
committed by Automerger Merge Worker
2 changed files with 8 additions and 2 deletions

View File

@@ -300,6 +300,7 @@
<dimen name="snackbar_elevation">3dp</dimen>
<dimen name="snackbar_min_text_size">12sp</dimen>
<dimen name="snackbar_max_text_size">14sp</dimen>
<dimen name="snackbar_max_width">504dp</dimen>
<!-- Developer Options -->
<dimen name="developer_options_filter_margins">10dp</dimen>

View File

@@ -88,9 +88,14 @@ public class Snackbar extends AbstractFloatingView {
int maxMarginLeftRight = res.getDimensionPixelSize(R.dimen.snackbar_max_margin_left_right);
int minMarginLeftRight = res.getDimensionPixelSize(R.dimen.snackbar_min_margin_left_right);
int marginBottom = res.getDimensionPixelSize(R.dimen.snackbar_margin_bottom);
int absoluteMaxWidth = res.getDimensionPixelSize(R.dimen.snackbar_max_width);
Rect insets = activity.getDeviceProfile().getInsets();
int maxWidth = dragLayer.getWidth() - minMarginLeftRight * 2 - insets.left - insets.right;
int minWidth = dragLayer.getWidth() - maxMarginLeftRight * 2 - insets.left - insets.right;
int maxWidth = Math.min(
dragLayer.getWidth() - minMarginLeftRight * 2 - insets.left - insets.right,
absoluteMaxWidth);
int minWidth = Math.min(
dragLayer.getWidth() - maxMarginLeftRight * 2 - insets.left - insets.right,
absoluteMaxWidth);
params.width = minWidth;
params.setMargins(0, 0, 0, marginBottom + insets.bottom);