package com.google.android.material.datepicker; import android.R; import android.app.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.graphics.Rect; import android.graphics.drawable.Drawable; import android.graphics.drawable.InsetDrawable; import android.graphics.drawable.StateListDrawable; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.Window; import android.widget.Button; import android.widget.LinearLayout; import android.widget.TextView; import androidx.core.view.n0; import com.google.android.material.datepicker.a; import com.google.android.material.internal.CheckableImageButton; import java.util.Iterator; import java.util.LinkedHashSet; /* loaded from: classes2.dex */ public final class j extends androidx.fragment.app.d { /* renamed from: p, reason: collision with root package name */ static final Object f4526p = "CONFIRM_BUTTON_TAG"; /* renamed from: q, reason: collision with root package name */ static final Object f4527q = "CANCEL_BUTTON_TAG"; /* renamed from: r, reason: collision with root package name */ static final Object f4528r = "TOGGLE_BUTTON_TAG"; /* renamed from: a, reason: collision with root package name */ private final LinkedHashSet f4529a = new LinkedHashSet(); /* renamed from: b, reason: collision with root package name */ private final LinkedHashSet f4530b = new LinkedHashSet(); /* renamed from: c, reason: collision with root package name */ private final LinkedHashSet f4531c = new LinkedHashSet(); /* renamed from: d, reason: collision with root package name */ private final LinkedHashSet f4532d = new LinkedHashSet(); /* renamed from: e, reason: collision with root package name */ private int f4533e; /* renamed from: f, reason: collision with root package name */ private p f4534f; /* renamed from: g, reason: collision with root package name */ private com.google.android.material.datepicker.a f4535g; /* renamed from: h, reason: collision with root package name */ private i f4536h; /* renamed from: i, reason: collision with root package name */ private int f4537i; /* renamed from: j, reason: collision with root package name */ private CharSequence f4538j; /* renamed from: k, reason: collision with root package name */ private boolean f4539k; /* renamed from: l, reason: collision with root package name */ private TextView f4540l; /* renamed from: m, reason: collision with root package name */ private CheckableImageButton f4541m; /* renamed from: n, reason: collision with root package name */ private p3.g f4542n; /* renamed from: o, reason: collision with root package name */ private Button f4543o; class a implements o { a() { } } class b implements View.OnClickListener { b() { } @Override // android.view.View.OnClickListener public void onClick(View view) { j.this.f4541m.toggle(); j jVar = j.this; jVar.v(jVar.f4541m); j.this.s(); } } private static Drawable l(Context context) { StateListDrawable stateListDrawable = new StateListDrawable(); stateListDrawable.addState(new int[]{R.attr.state_checked}, e.b.d(context, c3.d.f3495b)); stateListDrawable.addState(new int[0], e.b.d(context, c3.d.f3496c)); return stateListDrawable; } private static int m(Context context) { Resources resources = context.getResources(); int dimensionPixelSize = resources.getDimensionPixelSize(c3.c.f3486o) + resources.getDimensionPixelOffset(c3.c.f3487p) + resources.getDimensionPixelOffset(c3.c.f3485n); int dimensionPixelSize2 = resources.getDimensionPixelSize(c3.c.f3481j); int i10 = m.f4555d; return dimensionPixelSize + dimensionPixelSize2 + (resources.getDimensionPixelSize(c3.c.f3479h) * i10) + ((i10 - 1) * resources.getDimensionPixelOffset(c3.c.f3484m)) + resources.getDimensionPixelOffset(c3.c.f3477f); } private static int o(Context context) { Resources resources = context.getResources(); int dimensionPixelOffset = resources.getDimensionPixelOffset(c3.c.f3478g); int i10 = l.j().f4552e; return (dimensionPixelOffset * 2) + (resources.getDimensionPixelSize(c3.c.f3480i) * i10) + ((i10 - 1) * resources.getDimensionPixelOffset(c3.c.f3483l)); } private int p(Context context) { int i10 = this.f4533e; if (i10 != 0) { return i10; } throw null; } private void q(Context context) { this.f4541m.setTag(f4528r); this.f4541m.setImageDrawable(l(context)); n0.n0(this.f4541m, null); v(this.f4541m); this.f4541m.setOnClickListener(new b()); } static boolean r(Context context) { TypedArray obtainStyledAttributes = context.obtainStyledAttributes(m3.b.c(context, c3.a.f3460p, i.class.getCanonicalName()), new int[]{R.attr.windowFullscreen}); boolean z10 = obtainStyledAttributes.getBoolean(0, false); obtainStyledAttributes.recycle(); return z10; } /* JADX INFO: Access modifiers changed from: private */ public void s() { this.f4536h = i.v(null, p(requireContext()), this.f4535g); this.f4534f = this.f4541m.isChecked() ? k.i(null, this.f4535g) : this.f4536h; u(); androidx.fragment.app.v m10 = getChildFragmentManager().m(); m10.m(c3.e.f3512l, this.f4534f); m10.h(); this.f4534f.g(new a()); } public static long t() { return l.j().f4554g; } private void u() { String n10 = n(); this.f4540l.setContentDescription(String.format(getString(c3.h.f3543h), n10)); this.f4540l.setText(n10); } /* JADX INFO: Access modifiers changed from: private */ public void v(CheckableImageButton checkableImageButton) { this.f4541m.setContentDescription(this.f4541m.isChecked() ? checkableImageButton.getContext().getString(c3.h.f3546k) : checkableImageButton.getContext().getString(c3.h.f3548m)); } public String n() { getContext(); throw null; } @Override // androidx.fragment.app.d, android.content.DialogInterface.OnCancelListener public final void onCancel(DialogInterface dialogInterface) { Iterator it = this.f4531c.iterator(); while (it.hasNext()) { ((DialogInterface.OnCancelListener) it.next()).onCancel(dialogInterface); } super.onCancel(dialogInterface); } @Override // androidx.fragment.app.d, androidx.fragment.app.Fragment public final void onCreate(Bundle bundle) { super.onCreate(bundle); if (bundle == null) { bundle = getArguments(); } this.f4533e = bundle.getInt("OVERRIDE_THEME_RES_ID"); androidx.appcompat.app.m.a(bundle.getParcelable("DATE_SELECTOR_KEY")); this.f4535g = (com.google.android.material.datepicker.a) bundle.getParcelable("CALENDAR_CONSTRAINTS_KEY"); this.f4537i = bundle.getInt("TITLE_TEXT_RES_ID_KEY"); this.f4538j = bundle.getCharSequence("TITLE_TEXT_KEY"); } @Override // androidx.fragment.app.d public final Dialog onCreateDialog(Bundle bundle) { Dialog dialog = new Dialog(requireContext(), p(requireContext())); Context context = dialog.getContext(); this.f4539k = r(context); int c10 = m3.b.c(context, c3.a.f3454j, j.class.getCanonicalName()); p3.g gVar = new p3.g(context, null, c3.a.f3460p, c3.i.f3561k); this.f4542n = gVar; gVar.J(context); this.f4542n.R(ColorStateList.valueOf(c10)); this.f4542n.Q(n0.v(dialog.getWindow().getDecorView())); return dialog; } @Override // androidx.fragment.app.Fragment public final View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) { View inflate = layoutInflater.inflate(this.f4539k ? c3.g.f3535k : c3.g.f3534j, viewGroup); Context context = inflate.getContext(); if (this.f4539k) { inflate.findViewById(c3.e.f3512l).setLayoutParams(new LinearLayout.LayoutParams(o(context), -2)); } else { View findViewById = inflate.findViewById(c3.e.f3513m); View findViewById2 = inflate.findViewById(c3.e.f3512l); findViewById.setLayoutParams(new LinearLayout.LayoutParams(o(context), -1)); findViewById2.setMinimumHeight(m(requireContext())); } TextView textView = (TextView) inflate.findViewById(c3.e.f3516p); this.f4540l = textView; n0.p0(textView, 1); this.f4541m = (CheckableImageButton) inflate.findViewById(c3.e.f3517q); TextView textView2 = (TextView) inflate.findViewById(c3.e.f3518r); CharSequence charSequence = this.f4538j; if (charSequence != null) { textView2.setText(charSequence); } else { textView2.setText(this.f4537i); } q(context); this.f4543o = (Button) inflate.findViewById(c3.e.f3502b); throw null; } @Override // androidx.fragment.app.d, android.content.DialogInterface.OnDismissListener public final void onDismiss(DialogInterface dialogInterface) { Iterator it = this.f4532d.iterator(); while (it.hasNext()) { ((DialogInterface.OnDismissListener) it.next()).onDismiss(dialogInterface); } ViewGroup viewGroup = (ViewGroup) getView(); if (viewGroup != null) { viewGroup.removeAllViews(); } super.onDismiss(dialogInterface); } @Override // androidx.fragment.app.d, androidx.fragment.app.Fragment public final void onSaveInstanceState(Bundle bundle) { super.onSaveInstanceState(bundle); bundle.putInt("OVERRIDE_THEME_RES_ID", this.f4533e); bundle.putParcelable("DATE_SELECTOR_KEY", null); a.b bVar = new a.b(this.f4535g); if (this.f4536h.r() != null) { bVar.b(this.f4536h.r().f4554g); } bundle.putParcelable("CALENDAR_CONSTRAINTS_KEY", bVar.a()); bundle.putInt("TITLE_TEXT_RES_ID_KEY", this.f4537i); bundle.putCharSequence("TITLE_TEXT_KEY", this.f4538j); } @Override // androidx.fragment.app.d, androidx.fragment.app.Fragment public void onStart() { super.onStart(); Window window = requireDialog().getWindow(); if (this.f4539k) { window.setLayout(-1, -1); window.setBackgroundDrawable(this.f4542n); } else { window.setLayout(-2, -2); int dimensionPixelOffset = getResources().getDimensionPixelOffset(c3.c.f3482k); Rect rect = new Rect(dimensionPixelOffset, dimensionPixelOffset, dimensionPixelOffset, dimensionPixelOffset); window.setBackgroundDrawable(new InsetDrawable((Drawable) this.f4542n, dimensionPixelOffset, dimensionPixelOffset, dimensionPixelOffset, dimensionPixelOffset)); window.getDecorView().setOnTouchListener(new h3.a(requireDialog(), rect)); } s(); } @Override // androidx.fragment.app.d, androidx.fragment.app.Fragment public void onStop() { this.f4534f.h(); super.onStop(); } }