130 lines
4.0 KiB
Java
130 lines
4.0 KiB
Java
package androidx.appcompat.app;
|
|
|
|
import android.content.Context;
|
|
import android.content.DialogInterface;
|
|
import android.graphics.drawable.Drawable;
|
|
import android.os.Bundle;
|
|
import android.util.TypedValue;
|
|
import android.view.ContextThemeWrapper;
|
|
import android.view.KeyEvent;
|
|
import android.view.View;
|
|
import android.widget.ListAdapter;
|
|
import androidx.appcompat.R$attr;
|
|
import androidx.appcompat.app.AlertController;
|
|
|
|
/* loaded from: classes.dex */
|
|
public class AlertDialog extends AppCompatDialog implements DialogInterface {
|
|
final AlertController c;
|
|
|
|
public static class Builder {
|
|
private final AlertController.AlertParams a;
|
|
private final int b;
|
|
|
|
public Builder(Context context) {
|
|
this(context, AlertDialog.a(context, 0));
|
|
}
|
|
|
|
public Builder a(CharSequence charSequence) {
|
|
this.a.f = charSequence;
|
|
return this;
|
|
}
|
|
|
|
public Context b() {
|
|
return this.a.a;
|
|
}
|
|
|
|
public Builder(Context context, int i) {
|
|
this.a = new AlertController.AlertParams(new ContextThemeWrapper(context, AlertDialog.a(context, i)));
|
|
this.b = i;
|
|
}
|
|
|
|
public Builder a(View view) {
|
|
this.a.g = view;
|
|
return this;
|
|
}
|
|
|
|
public Builder b(View view) {
|
|
AlertController.AlertParams alertParams = this.a;
|
|
alertParams.z = view;
|
|
alertParams.y = 0;
|
|
alertParams.E = false;
|
|
return this;
|
|
}
|
|
|
|
public Builder a(Drawable drawable) {
|
|
this.a.d = drawable;
|
|
return this;
|
|
}
|
|
|
|
public Builder a(DialogInterface.OnKeyListener onKeyListener) {
|
|
this.a.u = onKeyListener;
|
|
return this;
|
|
}
|
|
|
|
public Builder a(ListAdapter listAdapter, DialogInterface.OnClickListener onClickListener) {
|
|
AlertController.AlertParams alertParams = this.a;
|
|
alertParams.w = listAdapter;
|
|
alertParams.x = onClickListener;
|
|
return this;
|
|
}
|
|
|
|
public AlertDialog a() {
|
|
AlertDialog alertDialog = new AlertDialog(this.a.a, this.b);
|
|
this.a.a(alertDialog.c);
|
|
alertDialog.setCancelable(this.a.r);
|
|
if (this.a.r) {
|
|
alertDialog.setCanceledOnTouchOutside(true);
|
|
}
|
|
alertDialog.setOnCancelListener(this.a.s);
|
|
alertDialog.setOnDismissListener(this.a.t);
|
|
DialogInterface.OnKeyListener onKeyListener = this.a.u;
|
|
if (onKeyListener != null) {
|
|
alertDialog.setOnKeyListener(onKeyListener);
|
|
}
|
|
return alertDialog;
|
|
}
|
|
}
|
|
|
|
protected AlertDialog(Context context, int i) {
|
|
super(context, a(context, i));
|
|
this.c = new AlertController(getContext(), this, getWindow());
|
|
}
|
|
|
|
static int a(Context context, int i) {
|
|
if (((i >>> 24) & 255) >= 1) {
|
|
return i;
|
|
}
|
|
TypedValue typedValue = new TypedValue();
|
|
context.getTheme().resolveAttribute(R$attr.alertDialogTheme, typedValue, true);
|
|
return typedValue.resourceId;
|
|
}
|
|
|
|
@Override // androidx.appcompat.app.AppCompatDialog, android.app.Dialog
|
|
protected void onCreate(Bundle bundle) {
|
|
super.onCreate(bundle);
|
|
this.c.a();
|
|
}
|
|
|
|
@Override // android.app.Dialog, android.view.KeyEvent.Callback
|
|
public boolean onKeyDown(int i, KeyEvent keyEvent) {
|
|
if (this.c.a(i, keyEvent)) {
|
|
return true;
|
|
}
|
|
return super.onKeyDown(i, keyEvent);
|
|
}
|
|
|
|
@Override // android.app.Dialog, android.view.KeyEvent.Callback
|
|
public boolean onKeyUp(int i, KeyEvent keyEvent) {
|
|
if (this.c.b(i, keyEvent)) {
|
|
return true;
|
|
}
|
|
return super.onKeyUp(i, keyEvent);
|
|
}
|
|
|
|
@Override // androidx.appcompat.app.AppCompatDialog, android.app.Dialog
|
|
public void setTitle(CharSequence charSequence) {
|
|
super.setTitle(charSequence);
|
|
this.c.b(charSequence);
|
|
}
|
|
}
|