ADD week 5
This commit is contained in:
		| @@ -0,0 +1,46 @@ | ||||
| package com.google.android.material.dialog; | ||||
|  | ||||
| import android.R; | ||||
| import android.app.Dialog; | ||||
| import android.graphics.Rect; | ||||
| import android.graphics.RectF; | ||||
| import android.os.Build; | ||||
| import android.view.MotionEvent; | ||||
| import android.view.View; | ||||
| import android.view.ViewConfiguration; | ||||
|  | ||||
| /* loaded from: classes.dex */ | ||||
| public class InsetDialogOnTouchListener implements View.OnTouchListener { | ||||
|     private final Dialog dialog; | ||||
|     private final int leftInset; | ||||
|     private final int prePieSlop; | ||||
|     private final int topInset; | ||||
|  | ||||
|     public InsetDialogOnTouchListener(Dialog dialog, Rect rect) { | ||||
|         this.dialog = dialog; | ||||
|         this.leftInset = rect.left; | ||||
|         this.topInset = rect.top; | ||||
|         this.prePieSlop = ViewConfiguration.get(dialog.getContext()).getScaledWindowTouchSlop(); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.View.OnTouchListener | ||||
|     public boolean onTouch(View view, MotionEvent motionEvent) { | ||||
|         View findViewById = view.findViewById(R.id.content); | ||||
|         int left = this.leftInset + findViewById.getLeft(); | ||||
|         int width = findViewById.getWidth() + left; | ||||
|         if (new RectF(left, this.topInset + findViewById.getTop(), width, findViewById.getHeight() + r3).contains(motionEvent.getX(), motionEvent.getY())) { | ||||
|             return false; | ||||
|         } | ||||
|         MotionEvent obtain = MotionEvent.obtain(motionEvent); | ||||
|         if (motionEvent.getAction() == 1) { | ||||
|             obtain.setAction(4); | ||||
|         } | ||||
|         if (Build.VERSION.SDK_INT < 28) { | ||||
|             obtain.setAction(0); | ||||
|             int i = this.prePieSlop; | ||||
|             obtain.setLocation((-i) - 1, (-i) - 1); | ||||
|         } | ||||
|         view.performClick(); | ||||
|         return this.dialog.onTouchEvent(obtain); | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,306 @@ | ||||
| package com.google.android.material.dialog; | ||||
|  | ||||
| import android.content.Context; | ||||
| import android.content.DialogInterface; | ||||
| import android.content.res.ColorStateList; | ||||
| import android.content.res.Resources; | ||||
| import android.content.res.TypedArray; | ||||
| import android.database.Cursor; | ||||
| import android.graphics.Rect; | ||||
| import android.graphics.drawable.Drawable; | ||||
| import android.os.Build; | ||||
| import android.util.TypedValue; | ||||
| import android.view.View; | ||||
| import android.view.Window; | ||||
| import android.widget.AdapterView; | ||||
| import android.widget.ListAdapter; | ||||
| import androidx.appcompat.app.AlertDialog; | ||||
| import androidx.appcompat.view.ContextThemeWrapper; | ||||
| import androidx.core.view.ViewCompat; | ||||
| import com.google.android.material.R; | ||||
| import com.google.android.material.color.MaterialColors; | ||||
| import com.google.android.material.resources.MaterialAttributes; | ||||
| import com.google.android.material.shape.MaterialShapeDrawable; | ||||
| import com.google.android.material.theme.overlay.MaterialThemeOverlay; | ||||
|  | ||||
| /* loaded from: classes.dex */ | ||||
| public class MaterialAlertDialogBuilder extends AlertDialog.Builder { | ||||
|     private static final int DEF_STYLE_ATTR = R.attr.alertDialogStyle; | ||||
|     private static final int DEF_STYLE_RES = R.style.MaterialAlertDialog_MaterialComponents; | ||||
|     private static final int MATERIAL_ALERT_DIALOG_THEME_OVERLAY = R.attr.materialAlertDialogTheme; | ||||
|     private Drawable background; | ||||
|     private final Rect backgroundInsets; | ||||
|  | ||||
|     public Drawable getBackground() { | ||||
|         return this.background; | ||||
|     } | ||||
|  | ||||
|     public MaterialAlertDialogBuilder setBackground(Drawable drawable) { | ||||
|         this.background = drawable; | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     private static int getMaterialAlertDialogThemeOverlay(Context context) { | ||||
|         TypedValue resolve = MaterialAttributes.resolve(context, MATERIAL_ALERT_DIALOG_THEME_OVERLAY); | ||||
|         if (resolve == null) { | ||||
|             return 0; | ||||
|         } | ||||
|         return resolve.data; | ||||
|     } | ||||
|  | ||||
|     private static Context createMaterialAlertDialogThemedContext(Context context) { | ||||
|         int materialAlertDialogThemeOverlay = getMaterialAlertDialogThemeOverlay(context); | ||||
|         Context wrap = MaterialThemeOverlay.wrap(context, null, DEF_STYLE_ATTR, DEF_STYLE_RES); | ||||
|         return materialAlertDialogThemeOverlay == 0 ? wrap : new ContextThemeWrapper(wrap, materialAlertDialogThemeOverlay); | ||||
|     } | ||||
|  | ||||
|     private static int getOverridingThemeResId(Context context, int i) { | ||||
|         return i == 0 ? getMaterialAlertDialogThemeOverlay(context) : i; | ||||
|     } | ||||
|  | ||||
|     public MaterialAlertDialogBuilder(Context context) { | ||||
|         this(context, 0); | ||||
|     } | ||||
|  | ||||
|     public MaterialAlertDialogBuilder(Context context, int i) { | ||||
|         super(createMaterialAlertDialogThemedContext(context), getOverridingThemeResId(context, i)); | ||||
|         Context context2 = getContext(); | ||||
|         Resources.Theme theme = context2.getTheme(); | ||||
|         int i2 = DEF_STYLE_ATTR; | ||||
|         int i3 = DEF_STYLE_RES; | ||||
|         this.backgroundInsets = MaterialDialogs.getDialogBackgroundInsets(context2, i2, i3); | ||||
|         int color = MaterialColors.getColor(context2, R.attr.colorSurface, getClass().getCanonicalName()); | ||||
|         TypedArray obtainStyledAttributes = context2.obtainStyledAttributes(null, R.styleable.MaterialAlertDialog, i2, i3); | ||||
|         int color2 = obtainStyledAttributes.getColor(R.styleable.MaterialAlertDialog_backgroundTint, color); | ||||
|         obtainStyledAttributes.recycle(); | ||||
|         MaterialShapeDrawable materialShapeDrawable = new MaterialShapeDrawable(context2, null, i2, i3); | ||||
|         materialShapeDrawable.initializeElevationOverlay(context2); | ||||
|         materialShapeDrawable.setFillColor(ColorStateList.valueOf(color2)); | ||||
|         if (Build.VERSION.SDK_INT >= 28) { | ||||
|             TypedValue typedValue = new TypedValue(); | ||||
|             theme.resolveAttribute(android.R.attr.dialogCornerRadius, typedValue, true); | ||||
|             float dimension = typedValue.getDimension(getContext().getResources().getDisplayMetrics()); | ||||
|             if (typedValue.type == 5 && dimension >= 0.0f) { | ||||
|                 materialShapeDrawable.setCornerSize(dimension); | ||||
|             } | ||||
|         } | ||||
|         this.background = materialShapeDrawable; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.app.AlertDialog.Builder | ||||
|     public AlertDialog create() { | ||||
|         AlertDialog create = super.create(); | ||||
|         Window window = create.getWindow(); | ||||
|         View decorView = window.getDecorView(); | ||||
|         Drawable drawable = this.background; | ||||
|         if (drawable instanceof MaterialShapeDrawable) { | ||||
|             ((MaterialShapeDrawable) drawable).setElevation(ViewCompat.getElevation(decorView)); | ||||
|         } | ||||
|         window.setBackgroundDrawable(MaterialDialogs.insetDrawable(this.background, this.backgroundInsets)); | ||||
|         decorView.setOnTouchListener(new InsetDialogOnTouchListener(create, this.backgroundInsets)); | ||||
|         return create; | ||||
|     } | ||||
|  | ||||
|     public MaterialAlertDialogBuilder setBackgroundInsetStart(int i) { | ||||
|         if (getContext().getResources().getConfiguration().getLayoutDirection() == 1) { | ||||
|             this.backgroundInsets.right = i; | ||||
|         } else { | ||||
|             this.backgroundInsets.left = i; | ||||
|         } | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     public MaterialAlertDialogBuilder setBackgroundInsetTop(int i) { | ||||
|         this.backgroundInsets.top = i; | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     public MaterialAlertDialogBuilder setBackgroundInsetEnd(int i) { | ||||
|         if (getContext().getResources().getConfiguration().getLayoutDirection() == 1) { | ||||
|             this.backgroundInsets.left = i; | ||||
|         } else { | ||||
|             this.backgroundInsets.right = i; | ||||
|         } | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     public MaterialAlertDialogBuilder setBackgroundInsetBottom(int i) { | ||||
|         this.backgroundInsets.bottom = i; | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.app.AlertDialog.Builder | ||||
|     public MaterialAlertDialogBuilder setTitle(int i) { | ||||
|         return (MaterialAlertDialogBuilder) super.setTitle(i); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.app.AlertDialog.Builder | ||||
|     public MaterialAlertDialogBuilder setTitle(CharSequence charSequence) { | ||||
|         return (MaterialAlertDialogBuilder) super.setTitle(charSequence); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.app.AlertDialog.Builder | ||||
|     public MaterialAlertDialogBuilder setCustomTitle(View view) { | ||||
|         return (MaterialAlertDialogBuilder) super.setCustomTitle(view); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.app.AlertDialog.Builder | ||||
|     public MaterialAlertDialogBuilder setMessage(int i) { | ||||
|         return (MaterialAlertDialogBuilder) super.setMessage(i); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.app.AlertDialog.Builder | ||||
|     public MaterialAlertDialogBuilder setMessage(CharSequence charSequence) { | ||||
|         return (MaterialAlertDialogBuilder) super.setMessage(charSequence); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.app.AlertDialog.Builder | ||||
|     public MaterialAlertDialogBuilder setIcon(int i) { | ||||
|         return (MaterialAlertDialogBuilder) super.setIcon(i); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.app.AlertDialog.Builder | ||||
|     public MaterialAlertDialogBuilder setIcon(Drawable drawable) { | ||||
|         return (MaterialAlertDialogBuilder) super.setIcon(drawable); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.app.AlertDialog.Builder | ||||
|     public MaterialAlertDialogBuilder setIconAttribute(int i) { | ||||
|         return (MaterialAlertDialogBuilder) super.setIconAttribute(i); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.app.AlertDialog.Builder | ||||
|     public MaterialAlertDialogBuilder setPositiveButton(int i, DialogInterface.OnClickListener onClickListener) { | ||||
|         return (MaterialAlertDialogBuilder) super.setPositiveButton(i, onClickListener); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.app.AlertDialog.Builder | ||||
|     public MaterialAlertDialogBuilder setPositiveButton(CharSequence charSequence, DialogInterface.OnClickListener onClickListener) { | ||||
|         return (MaterialAlertDialogBuilder) super.setPositiveButton(charSequence, onClickListener); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.app.AlertDialog.Builder | ||||
|     public MaterialAlertDialogBuilder setPositiveButtonIcon(Drawable drawable) { | ||||
|         return (MaterialAlertDialogBuilder) super.setPositiveButtonIcon(drawable); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.app.AlertDialog.Builder | ||||
|     public MaterialAlertDialogBuilder setNegativeButton(int i, DialogInterface.OnClickListener onClickListener) { | ||||
|         return (MaterialAlertDialogBuilder) super.setNegativeButton(i, onClickListener); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.app.AlertDialog.Builder | ||||
|     public MaterialAlertDialogBuilder setNegativeButton(CharSequence charSequence, DialogInterface.OnClickListener onClickListener) { | ||||
|         return (MaterialAlertDialogBuilder) super.setNegativeButton(charSequence, onClickListener); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.app.AlertDialog.Builder | ||||
|     public MaterialAlertDialogBuilder setNegativeButtonIcon(Drawable drawable) { | ||||
|         return (MaterialAlertDialogBuilder) super.setNegativeButtonIcon(drawable); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.app.AlertDialog.Builder | ||||
|     public MaterialAlertDialogBuilder setNeutralButton(int i, DialogInterface.OnClickListener onClickListener) { | ||||
|         return (MaterialAlertDialogBuilder) super.setNeutralButton(i, onClickListener); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.app.AlertDialog.Builder | ||||
|     public MaterialAlertDialogBuilder setNeutralButton(CharSequence charSequence, DialogInterface.OnClickListener onClickListener) { | ||||
|         return (MaterialAlertDialogBuilder) super.setNeutralButton(charSequence, onClickListener); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.app.AlertDialog.Builder | ||||
|     public MaterialAlertDialogBuilder setNeutralButtonIcon(Drawable drawable) { | ||||
|         return (MaterialAlertDialogBuilder) super.setNeutralButtonIcon(drawable); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.app.AlertDialog.Builder | ||||
|     public MaterialAlertDialogBuilder setCancelable(boolean z) { | ||||
|         return (MaterialAlertDialogBuilder) super.setCancelable(z); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.app.AlertDialog.Builder | ||||
|     public MaterialAlertDialogBuilder setOnCancelListener(DialogInterface.OnCancelListener onCancelListener) { | ||||
|         return (MaterialAlertDialogBuilder) super.setOnCancelListener(onCancelListener); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.app.AlertDialog.Builder | ||||
|     public MaterialAlertDialogBuilder setOnDismissListener(DialogInterface.OnDismissListener onDismissListener) { | ||||
|         return (MaterialAlertDialogBuilder) super.setOnDismissListener(onDismissListener); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.app.AlertDialog.Builder | ||||
|     public MaterialAlertDialogBuilder setOnKeyListener(DialogInterface.OnKeyListener onKeyListener) { | ||||
|         return (MaterialAlertDialogBuilder) super.setOnKeyListener(onKeyListener); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.app.AlertDialog.Builder | ||||
|     public MaterialAlertDialogBuilder setItems(int i, DialogInterface.OnClickListener onClickListener) { | ||||
|         return (MaterialAlertDialogBuilder) super.setItems(i, onClickListener); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.app.AlertDialog.Builder | ||||
|     public MaterialAlertDialogBuilder setItems(CharSequence[] charSequenceArr, DialogInterface.OnClickListener onClickListener) { | ||||
|         return (MaterialAlertDialogBuilder) super.setItems(charSequenceArr, onClickListener); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.app.AlertDialog.Builder | ||||
|     public MaterialAlertDialogBuilder setAdapter(ListAdapter listAdapter, DialogInterface.OnClickListener onClickListener) { | ||||
|         return (MaterialAlertDialogBuilder) super.setAdapter(listAdapter, onClickListener); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.app.AlertDialog.Builder | ||||
|     public MaterialAlertDialogBuilder setCursor(Cursor cursor, DialogInterface.OnClickListener onClickListener, String str) { | ||||
|         return (MaterialAlertDialogBuilder) super.setCursor(cursor, onClickListener, str); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.app.AlertDialog.Builder | ||||
|     public MaterialAlertDialogBuilder setMultiChoiceItems(int i, boolean[] zArr, DialogInterface.OnMultiChoiceClickListener onMultiChoiceClickListener) { | ||||
|         return (MaterialAlertDialogBuilder) super.setMultiChoiceItems(i, zArr, onMultiChoiceClickListener); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.app.AlertDialog.Builder | ||||
|     public MaterialAlertDialogBuilder setMultiChoiceItems(CharSequence[] charSequenceArr, boolean[] zArr, DialogInterface.OnMultiChoiceClickListener onMultiChoiceClickListener) { | ||||
|         return (MaterialAlertDialogBuilder) super.setMultiChoiceItems(charSequenceArr, zArr, onMultiChoiceClickListener); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.app.AlertDialog.Builder | ||||
|     public MaterialAlertDialogBuilder setMultiChoiceItems(Cursor cursor, String str, String str2, DialogInterface.OnMultiChoiceClickListener onMultiChoiceClickListener) { | ||||
|         return (MaterialAlertDialogBuilder) super.setMultiChoiceItems(cursor, str, str2, onMultiChoiceClickListener); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.app.AlertDialog.Builder | ||||
|     public MaterialAlertDialogBuilder setSingleChoiceItems(int i, int i2, DialogInterface.OnClickListener onClickListener) { | ||||
|         return (MaterialAlertDialogBuilder) super.setSingleChoiceItems(i, i2, onClickListener); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.app.AlertDialog.Builder | ||||
|     public MaterialAlertDialogBuilder setSingleChoiceItems(Cursor cursor, int i, String str, DialogInterface.OnClickListener onClickListener) { | ||||
|         return (MaterialAlertDialogBuilder) super.setSingleChoiceItems(cursor, i, str, onClickListener); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.app.AlertDialog.Builder | ||||
|     public MaterialAlertDialogBuilder setSingleChoiceItems(CharSequence[] charSequenceArr, int i, DialogInterface.OnClickListener onClickListener) { | ||||
|         return (MaterialAlertDialogBuilder) super.setSingleChoiceItems(charSequenceArr, i, onClickListener); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.app.AlertDialog.Builder | ||||
|     public MaterialAlertDialogBuilder setSingleChoiceItems(ListAdapter listAdapter, int i, DialogInterface.OnClickListener onClickListener) { | ||||
|         return (MaterialAlertDialogBuilder) super.setSingleChoiceItems(listAdapter, i, onClickListener); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.app.AlertDialog.Builder | ||||
|     public MaterialAlertDialogBuilder setOnItemSelectedListener(AdapterView.OnItemSelectedListener onItemSelectedListener) { | ||||
|         return (MaterialAlertDialogBuilder) super.setOnItemSelectedListener(onItemSelectedListener); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.app.AlertDialog.Builder | ||||
|     public MaterialAlertDialogBuilder setView(int i) { | ||||
|         return (MaterialAlertDialogBuilder) super.setView(i); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.appcompat.app.AlertDialog.Builder | ||||
|     public MaterialAlertDialogBuilder setView(View view) { | ||||
|         return (MaterialAlertDialogBuilder) super.setView(view); | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,33 @@ | ||||
| package com.google.android.material.dialog; | ||||
|  | ||||
| import android.content.Context; | ||||
| import android.content.res.TypedArray; | ||||
| import android.graphics.Rect; | ||||
| import android.graphics.drawable.Drawable; | ||||
| import android.graphics.drawable.InsetDrawable; | ||||
| import com.google.android.material.R; | ||||
| import com.google.android.material.internal.ThemeEnforcement; | ||||
|  | ||||
| /* loaded from: classes.dex */ | ||||
| public class MaterialDialogs { | ||||
|     private MaterialDialogs() { | ||||
|     } | ||||
|  | ||||
|     public static InsetDrawable insetDrawable(Drawable drawable, Rect rect) { | ||||
|         return new InsetDrawable(drawable, rect.left, rect.top, rect.right, rect.bottom); | ||||
|     } | ||||
|  | ||||
|     public static Rect getDialogBackgroundInsets(Context context, int i, int i2) { | ||||
|         TypedArray obtainStyledAttributes = ThemeEnforcement.obtainStyledAttributes(context, null, R.styleable.MaterialAlertDialog, i, i2, new int[0]); | ||||
|         int dimensionPixelSize = obtainStyledAttributes.getDimensionPixelSize(R.styleable.MaterialAlertDialog_backgroundInsetStart, context.getResources().getDimensionPixelSize(R.dimen.mtrl_alert_dialog_background_inset_start)); | ||||
|         int dimensionPixelSize2 = obtainStyledAttributes.getDimensionPixelSize(R.styleable.MaterialAlertDialog_backgroundInsetTop, context.getResources().getDimensionPixelSize(R.dimen.mtrl_alert_dialog_background_inset_top)); | ||||
|         int dimensionPixelSize3 = obtainStyledAttributes.getDimensionPixelSize(R.styleable.MaterialAlertDialog_backgroundInsetEnd, context.getResources().getDimensionPixelSize(R.dimen.mtrl_alert_dialog_background_inset_end)); | ||||
|         int dimensionPixelSize4 = obtainStyledAttributes.getDimensionPixelSize(R.styleable.MaterialAlertDialog_backgroundInsetBottom, context.getResources().getDimensionPixelSize(R.dimen.mtrl_alert_dialog_background_inset_bottom)); | ||||
|         obtainStyledAttributes.recycle(); | ||||
|         if (context.getResources().getConfiguration().getLayoutDirection() == 1) { | ||||
|             dimensionPixelSize3 = dimensionPixelSize; | ||||
|             dimensionPixelSize = dimensionPixelSize3; | ||||
|         } | ||||
|         return new Rect(dimensionPixelSize, dimensionPixelSize2, dimensionPixelSize3, dimensionPixelSize4); | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user