package o; import android.content.res.Resources; import android.text.Editable; import android.text.TextUtils; import android.text.TextWatcher; import android.view.View; import android.widget.EditText; import android.widget.LinearLayout; import android.widget.TextView; import androidx.core.view.accessibility.AccessibilityNodeInfoCompat; import com.google.android.material.button.MaterialButtonToggleGroup; import com.google.android.material.textfield.TextInputLayout; import com.google.android.material.timepicker.ChipTextInputComboView; import com.google.android.material.timepicker.TimePickerView; import java.util.Locale; import o.C17052tZT; /* loaded from: classes2.dex */ public final class nNq implements TimePickerView.HBt, kxR { private final EditText a; public final ChipTextInputComboView b; final VPp c; public final ChipTextInputComboView d; private final SpB e; private final TextWatcher f; private MaterialButtonToggleGroup g; private final LinearLayout h; private final EditText i; private final TextWatcher j; public nNq(LinearLayout linearLayout, VPp vPp) { GES ges = new GES(this) { // from class: o.nNq.4 private nNq c; { this.c = this; } @Override // o.GES, android.text.TextWatcher public final void afterTextChanged(Editable editable) { try { if (!TextUtils.isEmpty(editable)) { this.c.c.b = Integer.parseInt(editable.toString()) % 60; return; } this.c.c.b = 0; } catch (NumberFormatException unused) { } } }; this.j = ges; GES ges2 = new GES(this) { // from class: o.nNq.3 private nNq c; { this.c = this; } @Override // o.GES, android.text.TextWatcher public final void afterTextChanged(Editable editable) { try { if (TextUtils.isEmpty(editable)) { this.c.c.e(0); } else { this.c.c.e(Integer.parseInt(editable.toString())); } } catch (NumberFormatException unused) { } } }; this.f = ges2; this.h = linearLayout; this.c = vPp; Resources resources = linearLayout.getResources(); ChipTextInputComboView chipTextInputComboView = (ChipTextInputComboView) linearLayout.findViewById(C17052tZT.ZqN.material_minute_text_input); this.d = chipTextInputComboView; ChipTextInputComboView chipTextInputComboView2 = (ChipTextInputComboView) linearLayout.findViewById(C17052tZT.ZqN.material_hour_text_input); this.b = chipTextInputComboView2; TextView textView = (TextView) chipTextInputComboView.findViewById(C17052tZT.ZqN.material_label); TextView textView2 = (TextView) chipTextInputComboView2.findViewById(C17052tZT.ZqN.material_label); textView.setText(resources.getString(C17052tZT.ojQ.material_timepicker_minute)); textView2.setText(resources.getString(C17052tZT.ojQ.material_timepicker_hour)); chipTextInputComboView.setTag(C17052tZT.ZqN.selection_type, 12); chipTextInputComboView2.setTag(C17052tZT.ZqN.selection_type, 10); if (vPp.e == 0) { MaterialButtonToggleGroup materialButtonToggleGroup = (MaterialButtonToggleGroup) linearLayout.findViewById(C17052tZT.ZqN.material_clock_period_toggle); this.g = materialButtonToggleGroup; materialButtonToggleGroup.b.add(new MaterialButtonToggleGroup.RVV(this) { // from class: o.gUY private nNq c; @Override // com.google.android.material.button.MaterialButtonToggleGroup.RVV public final void a(int i, boolean z) { nNq nnq = this.c; if (z) { nnq.c.b(i == C17052tZT.ZqN.material_clock_period_pm_button ? 1 : 0); } } { this.c = this; } }); this.g.setVisibility(0); d(); } View.OnClickListener onClickListener = new View.OnClickListener(this) { // from class: o.nNq.2 private nNq b; { this.b = this; } @Override // android.view.View.OnClickListener public final void onClick(View view) { this.b.c(((Integer) view.getTag(C17052tZT.ZqN.selection_type)).intValue()); } }; chipTextInputComboView2.setOnClickListener(onClickListener); chipTextInputComboView.setOnClickListener(onClickListener); chipTextInputComboView2.MR_(vPp.c); chipTextInputComboView.MR_(vPp.d); EditText editText = chipTextInputComboView2.e.f; this.a = editText; EditText editText2 = chipTextInputComboView.e.f; this.i = editText2; SpB spB = new SpB(chipTextInputComboView2, chipTextInputComboView, vPp); this.e = spB; chipTextInputComboView2.setChipDelegate(new uVC(this, linearLayout.getContext(), C17052tZT.ojQ.material_hour_selection, vPp) { // from class: o.nNq.5 private nNq c; private VPp e; { this.c = this; this.e = vPp; } @Override // o.uVC, o.yZt public final void onInitializeAccessibilityNodeInfo(View view, AccessibilityNodeInfoCompat accessibilityNodeInfoCompat) { super.onInitializeAccessibilityNodeInfo(view, accessibilityNodeInfoCompat); accessibilityNodeInfoCompat.d((CharSequence) view.getResources().getString(this.e.e == 1 ? C17052tZT.ojQ.material_hour_24h_suffix : C17052tZT.ojQ.material_hour_suffix, String.valueOf(this.e.e()))); } }); chipTextInputComboView.setChipDelegate(new uVC(this, linearLayout.getContext(), C17052tZT.ojQ.material_minute_selection, vPp) { // from class: o.nNq.1 private VPp d; private nNq e; { this.e = this; this.d = vPp; } @Override // o.uVC, o.yZt public final void onInitializeAccessibilityNodeInfo(View view, AccessibilityNodeInfoCompat accessibilityNodeInfoCompat) { super.onInitializeAccessibilityNodeInfo(view, accessibilityNodeInfoCompat); accessibilityNodeInfoCompat.d((CharSequence) view.getResources().getString(C17052tZT.ojQ.material_minute_suffix, String.valueOf(this.d.b))); } }); editText.addTextChangedListener(ges2); editText2.addTextChangedListener(ges); a(vPp); TextInputLayout textInputLayout = spB.b.e; TextInputLayout textInputLayout2 = spB.d.e; EditText editText3 = textInputLayout.f; EditText editText4 = textInputLayout2.f; editText3.setImeOptions(268435461); editText4.setImeOptions(268435462); editText3.setOnEditorActionListener(spB); editText3.setOnKeyListener(spB); editText4.setOnKeyListener(spB); } private void a(VPp vPp) { this.a.removeTextChangedListener(this.f); this.i.removeTextChangedListener(this.j); Locale locale = this.h.getResources().getConfiguration().locale; String format = String.format(locale, "%02d", Integer.valueOf(vPp.b)); String format2 = String.format(locale, "%02d", Integer.valueOf(vPp.e())); this.d.setText(format); this.b.setText(format2); this.a.addTextChangedListener(this.f); this.i.addTextChangedListener(this.j); d(); } private void d() { int i; MaterialButtonToggleGroup materialButtonToggleGroup = this.g; if (materialButtonToggleGroup == null) { return; } if (this.c.i == 0) { i = C17052tZT.ZqN.material_clock_period_am_button; } else { i = C17052tZT.ZqN.material_clock_period_pm_button; } materialButtonToggleGroup.b(i, true); } @Override // com.google.android.material.timepicker.TimePickerView.HBt public final void c(int i) { this.c.f = i; this.d.setChecked(i == 12); this.b.setChecked(i == 10); d(); } @Override // o.kxR public final void e() { this.h.setVisibility(0); c(this.c.f); } @Override // o.kxR public final void b() { View focusedChild = this.h.getFocusedChild(); if (focusedChild != null) { Lot.e(focusedChild, true); } this.h.setVisibility(8); } @Override // o.kxR public final void c() { a(this.c); } public final void a() { this.d.setChecked(this.c.f == 12); this.b.setChecked(this.c.f == 10); } }