Skip to content

Commit 0a4e419

Browse files
Material Design Teamdrchen
authored andcommitted
Automated g4 rollback of changelist 522443049
PiperOrigin-RevId: 523143316
1 parent 9c4b73d commit 0a4e419

File tree

5 files changed

+7
-14
lines changed

5 files changed

+7
-14
lines changed

docs/components/Dialog.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ particular type), a background scrim, and, optionally, title and buttons.
120120

121121
Element | **Attribute** | **Related methods** | **Default value**
122122
----------------------------------- | -------------------------------------------------------- | ------------------------------------------------------ | -----------------
123-
**Color** | `app:backgroundTint` | N/A | `?attr/colorSurface`
123+
**Color** | N/A | N/A | `?attr/colorSurface`
124124
**Shape** | `app:shapeAppearance`<br/>`app:shapeAppearanceOverlay` | N/A | `?attr/shapeAppearanceMediumComponent` with a corner size of `28dp`
125125
**Background inset start and end** | `app:backgroundInsetStart`<br/>`app:backgroundInsetEnd` | `setBackgroundInsetStart`<br/>`setBackgroundInsetEnd` | `24dp`
126126
**Background inset top and bottom** | `app:backgroundInsetTop`<br/>`app:backgroundInsetBottom` | `setBackgroundInsetTop`<br/>`setBackgroundInsetBottom` | `80dp`

lib/java/com/google/android/material/dialog/MaterialAlertDialogBuilder.java

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import android.content.DialogInterface.OnMultiChoiceClickListener;
2929
import android.content.res.ColorStateList;
3030
import android.content.res.Resources.Theme;
31-
import android.content.res.TypedArray;
3231
import android.database.Cursor;
3332
import android.graphics.Rect;
3433
import android.graphics.drawable.Drawable;
@@ -42,6 +41,7 @@
4241
import android.widget.ListAdapter;
4342
import androidx.annotation.ArrayRes;
4443
import androidx.annotation.AttrRes;
44+
import androidx.annotation.Dimension;
4545
import androidx.annotation.DrawableRes;
4646
import androidx.annotation.NonNull;
4747
import androidx.annotation.Nullable;
@@ -50,6 +50,7 @@
5050
import androidx.annotation.StyleRes;
5151
import androidx.appcompat.view.ContextThemeWrapper;
5252
import androidx.core.view.ViewCompat;
53+
import com.google.android.material.color.MaterialColors;
5354
import com.google.android.material.resources.MaterialAttributes;
5455
import com.google.android.material.shape.MaterialShapeDrawable;
5556
import com.google.errorprone.annotations.CanIgnoreReturnValue;
@@ -73,7 +74,7 @@ public class MaterialAlertDialogBuilder extends AlertDialog.Builder {
7374
private static final int MATERIAL_ALERT_DIALOG_THEME_OVERLAY = R.attr.materialAlertDialogTheme;
7475

7576
@Nullable private Drawable background;
76-
@NonNull private final Rect backgroundInsets;
77+
@NonNull @Dimension private final Rect backgroundInsets;
7778

7879
private static int getMaterialAlertDialogThemeOverlay(@NonNull Context context) {
7980
TypedValue materialAlertDialogThemeOverlay =
@@ -116,16 +117,12 @@ public MaterialAlertDialogBuilder(@NonNull Context context, int overrideThemeRes
116117
backgroundInsets =
117118
MaterialDialogs.getDialogBackgroundInsets(context, DEF_STYLE_ATTR, DEF_STYLE_RES);
118119

119-
TypedArray a =
120-
context.obtainStyledAttributes(
121-
/* set= */ null, R.styleable.MaterialAlertDialog, DEF_STYLE_ATTR, DEF_STYLE_RES);
122-
int backgroundColor = a.getColor(R.styleable.MaterialAlertDialog_backgroundTint, 0);
123-
a.recycle();
124-
120+
int surfaceColor =
121+
MaterialColors.getColor(context, R.attr.colorSurface, getClass().getCanonicalName());
125122
MaterialShapeDrawable materialShapeDrawable =
126123
new MaterialShapeDrawable(context, null, DEF_STYLE_ATTR, DEF_STYLE_RES);
127124
materialShapeDrawable.initializeElevationOverlay(context);
128-
materialShapeDrawable.setFillColor(ColorStateList.valueOf(backgroundColor));
125+
materialShapeDrawable.setFillColor(ColorStateList.valueOf(surfaceColor));
129126

130127
// dialogCornerRadius first appeared in Android Pie
131128
if (Build.VERSION.SDK_INT >= VERSION_CODES.P) {

lib/java/com/google/android/material/dialog/res/values/attrs.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
</declare-styleable>
3030

3131
<declare-styleable name="MaterialAlertDialog">
32-
<attr name="backgroundTint"/>
3332
<attr name="backgroundInsetStart" format="dimension"/>
3433
<attr name="backgroundInsetTop" format="dimension"/>
3534
<attr name="backgroundInsetEnd" format="dimension"/>

lib/java/com/google/android/material/dialog/res/values/styles.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
</style>
2828

2929
<style name="MaterialAlertDialog.MaterialComponents" parent="AlertDialog.AppCompat">
30-
<item name="backgroundTint">?attr/colorSurface</item>
3130
<item name="android:layout">@layout/mtrl_alert_dialog</item>
3231
<item name="listItemLayout">@layout/mtrl_alert_select_dialog_item</item>
3332
<item name="multiChoiceItemLayout">@layout/mtrl_alert_select_dialog_multichoice</item>
@@ -112,7 +111,6 @@
112111
</style>
113112

114113
<style name="MaterialAlertDialog.Material3" parent="MaterialAlertDialog.MaterialComponents">
115-
<item name="backgroundTint">@macro/m3_comp_dialog_container_color</item>
116114
<item name="enforceMaterialTheme">true</item>
117115
<item name="android:layout">@layout/m3_alert_dialog</item>
118116
<item name="shapeAppearance">@macro/m3_comp_dialog_container_shape</item>

lib/java/com/google/android/material/dialog/res/values/tokens.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
<!-- Generated from token set (md.comp.dialog) in context (platform=android, audience=3p). -->
2323
<!-- Enabled - Container -->
24-
<macro name="m3_comp_dialog_container_color">?attr/colorSurface</macro>
2524
<macro name="m3_comp_dialog_container_shape">?attr/shapeAppearanceCornerExtraLarge</macro>
2625
<!-- Enabled - Headline -->
2726
<macro name="m3_comp_dialog_headline_type">?attr/textAppearanceHeadlineSmall</macro>

0 commit comments

Comments
 (0)