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 android.widget.ListView;
import androidx.appcompat.app.AlertController;

/* JADX INFO: compiled from: AlertDialog.java */
/* JADX INFO: loaded from: classes.dex */
public class b extends h {

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    final AlertController f164i;

    /* JADX INFO: compiled from: AlertDialog.java */
    public static class a {

        /* JADX INFO: renamed from: a, reason: collision with root package name */
        private final AlertController.f f165a;

        /* JADX INFO: renamed from: b, reason: collision with root package name */
        private final int f166b;

        public a(Context context) {
            this(context, b.o(context, 0));
        }

        public b a() {
            b bVar = new b(this.f165a.f124a, this.f166b);
            this.f165a.a(bVar.f164i);
            bVar.setCancelable(this.f165a.f141r);
            if (this.f165a.f141r) {
                bVar.setCanceledOnTouchOutside(true);
            }
            bVar.setOnCancelListener(this.f165a.f142s);
            bVar.setOnDismissListener(this.f165a.f143t);
            DialogInterface.OnKeyListener onKeyListener = this.f165a.f144u;
            if (onKeyListener != null) {
                bVar.setOnKeyListener(onKeyListener);
            }
            return bVar;
        }

        public Context b() {
            return this.f165a.f124a;
        }

        public a c(ListAdapter listAdapter, DialogInterface.OnClickListener onClickListener) {
            AlertController.f fVar = this.f165a;
            fVar.f146w = listAdapter;
            fVar.f147x = onClickListener;
            return this;
        }

        public a d(View view) {
            this.f165a.f130g = view;
            return this;
        }

        public a e(Drawable drawable) {
            this.f165a.f127d = drawable;
            return this;
        }

        public a f(DialogInterface.OnKeyListener onKeyListener) {
            this.f165a.f144u = onKeyListener;
            return this;
        }

        public a g(ListAdapter listAdapter, int i3, DialogInterface.OnClickListener onClickListener) {
            AlertController.f fVar = this.f165a;
            fVar.f146w = listAdapter;
            fVar.f147x = onClickListener;
            fVar.I = i3;
            fVar.H = true;
            return this;
        }

        public a h(CharSequence charSequence) {
            this.f165a.f129f = charSequence;
            return this;
        }

        public a(Context context, int i3) {
            this.f165a = new AlertController.f(new ContextThemeWrapper(context, b.o(context, i3)));
            this.f166b = i3;
        }
    }

    protected b(Context context, int i3) {
        super(context, o(context, i3));
        this.f164i = new AlertController(getContext(), this, getWindow());
    }

    static int o(Context context, int i3) {
        if (((i3 >>> 24) & 255) >= 1) {
            return i3;
        }
        TypedValue typedValue = new TypedValue();
        context.getTheme().resolveAttribute(c.a.f3164o, typedValue, true);
        return typedValue.resourceId;
    }

    public ListView n() {
        return this.f164i.d();
    }

    @Override // androidx.appcompat.app.h, androidx.activity.f, android.app.Dialog
    protected void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        this.f164i.e();
    }

    @Override // android.app.Dialog, android.view.KeyEvent.Callback
    public boolean onKeyDown(int i3, KeyEvent keyEvent) {
        if (this.f164i.g(i3, keyEvent)) {
            return true;
        }
        return super.onKeyDown(i3, keyEvent);
    }

    @Override // android.app.Dialog, android.view.KeyEvent.Callback
    public boolean onKeyUp(int i3, KeyEvent keyEvent) {
        if (this.f164i.h(i3, keyEvent)) {
            return true;
        }
        return super.onKeyUp(i3, keyEvent);
    }

    @Override // androidx.appcompat.app.h, android.app.Dialog
    public void setTitle(CharSequence charSequence) {
        super.setTitle(charSequence);
        this.f164i.q(charSequence);
    }
}
