package com.google.android.material.textfield; import android.R; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.ValueAnimator; import android.content.res.ColorStateList; import android.graphics.drawable.Drawable; import android.graphics.drawable.LayerDrawable; import android.graphics.drawable.RippleDrawable; import android.graphics.drawable.StateListDrawable; import android.text.Editable; import android.text.TextWatcher; import android.view.MotionEvent; import android.view.View; import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityManager; import android.widget.AutoCompleteTextView; import android.widget.EditText; import android.widget.Spinner; import androidx.core.view.n0; import com.google.android.material.textfield.TextInputLayout; import p3.k; import z.a0; /* loaded from: classes2.dex */ class d extends com.google.android.material.textfield.e { /* renamed from: o, reason: collision with root package name */ private static final boolean f4720o = true; /* renamed from: d, reason: collision with root package name */ private final TextWatcher f4721d; /* renamed from: e, reason: collision with root package name */ private final TextInputLayout.e f4722e; /* renamed from: f, reason: collision with root package name */ private final TextInputLayout.f f4723f; /* renamed from: g, reason: collision with root package name */ private boolean f4724g; /* renamed from: h, reason: collision with root package name */ private boolean f4725h; /* renamed from: i, reason: collision with root package name */ private long f4726i; /* renamed from: j, reason: collision with root package name */ private StateListDrawable f4727j; /* renamed from: k, reason: collision with root package name */ private p3.g f4728k; /* renamed from: l, reason: collision with root package name */ private AccessibilityManager f4729l; /* renamed from: m, reason: collision with root package name */ private ValueAnimator f4730m; /* renamed from: n, reason: collision with root package name */ private ValueAnimator f4731n; class a implements TextWatcher { /* renamed from: com.google.android.material.textfield.d$a$a, reason: collision with other inner class name */ class RunnableC0074a implements Runnable { /* renamed from: a, reason: collision with root package name */ final /* synthetic */ AutoCompleteTextView f4733a; RunnableC0074a(AutoCompleteTextView autoCompleteTextView) { this.f4733a = autoCompleteTextView; } @Override // java.lang.Runnable public void run() { boolean isPopupShowing = this.f4733a.isPopupShowing(); d.this.z(isPopupShowing); d.this.f4724g = isPopupShowing; } } a() { } @Override // android.text.TextWatcher public void afterTextChanged(Editable editable) { d dVar = d.this; AutoCompleteTextView u10 = dVar.u(dVar.f4744a.getEditText()); u10.post(new RunnableC0074a(u10)); } @Override // android.text.TextWatcher public void beforeTextChanged(CharSequence charSequence, int i10, int i11, int i12) { } @Override // android.text.TextWatcher public void onTextChanged(CharSequence charSequence, int i10, int i11, int i12) { } } class b extends TextInputLayout.e { b(TextInputLayout textInputLayout) { super(textInputLayout); } @Override // com.google.android.material.textfield.TextInputLayout.e, androidx.core.view.a public void g(View view, a0 a0Var) { super.g(view, a0Var); a0Var.W(Spinner.class.getName()); if (a0Var.J()) { a0Var.h0(null); } } @Override // androidx.core.view.a public void h(View view, AccessibilityEvent accessibilityEvent) { super.h(view, accessibilityEvent); d dVar = d.this; AutoCompleteTextView u10 = dVar.u(dVar.f4744a.getEditText()); if (accessibilityEvent.getEventType() == 1 && d.this.f4729l.isTouchExplorationEnabled()) { d.this.C(u10); } } } class c implements TextInputLayout.f { c() { } @Override // com.google.android.material.textfield.TextInputLayout.f public void a(TextInputLayout textInputLayout) { AutoCompleteTextView u10 = d.this.u(textInputLayout.getEditText()); d.this.A(u10); d.this.r(u10); d.this.B(u10); u10.setThreshold(0); u10.removeTextChangedListener(d.this.f4721d); u10.addTextChangedListener(d.this.f4721d); textInputLayout.setErrorIconDrawable((Drawable) null); textInputLayout.setTextInputAccessibilityDelegate(d.this.f4722e); textInputLayout.setEndIconVisible(true); } } /* renamed from: com.google.android.material.textfield.d$d, reason: collision with other inner class name */ class ViewOnClickListenerC0075d implements View.OnClickListener { ViewOnClickListenerC0075d() { } @Override // android.view.View.OnClickListener public void onClick(View view) { d.this.C((AutoCompleteTextView) d.this.f4744a.getEditText()); } } class e implements View.OnTouchListener { /* renamed from: a, reason: collision with root package name */ final /* synthetic */ AutoCompleteTextView f4738a; e(AutoCompleteTextView autoCompleteTextView) { this.f4738a = autoCompleteTextView; } @Override // android.view.View.OnTouchListener public boolean onTouch(View view, MotionEvent motionEvent) { if (motionEvent.getAction() == 1) { if (d.this.y()) { d.this.f4724g = false; } d.this.C(this.f4738a); view.performClick(); } return false; } } class f implements View.OnFocusChangeListener { f() { } @Override // android.view.View.OnFocusChangeListener public void onFocusChange(View view, boolean z10) { d.this.f4744a.setEndIconActivated(z10); if (z10) { return; } d.this.z(false); d.this.f4724g = false; } } class g implements AutoCompleteTextView.OnDismissListener { g() { } @Override // android.widget.AutoCompleteTextView.OnDismissListener public void onDismiss() { d.this.f4724g = true; d.this.f4726i = System.currentTimeMillis(); d.this.z(false); } } class h extends AnimatorListenerAdapter { h() { } @Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener public void onAnimationEnd(Animator animator) { d dVar = d.this; dVar.f4746c.setChecked(dVar.f4725h); d.this.f4731n.start(); } } class i implements ValueAnimator.AnimatorUpdateListener { i() { } @Override // android.animation.ValueAnimator.AnimatorUpdateListener public void onAnimationUpdate(ValueAnimator valueAnimator) { d.this.f4746c.setAlpha(((Float) valueAnimator.getAnimatedValue()).floatValue()); } } d(TextInputLayout textInputLayout) { super(textInputLayout); this.f4721d = new a(); this.f4722e = new b(this.f4744a); this.f4723f = new c(); this.f4724g = false; this.f4725h = false; this.f4726i = Long.MAX_VALUE; } /* JADX INFO: Access modifiers changed from: private */ public void A(AutoCompleteTextView autoCompleteTextView) { if (f4720o) { int boxBackgroundMode = this.f4744a.getBoxBackgroundMode(); if (boxBackgroundMode == 2) { autoCompleteTextView.setDropDownBackgroundDrawable(this.f4728k); } else if (boxBackgroundMode == 1) { autoCompleteTextView.setDropDownBackgroundDrawable(this.f4727j); } } } /* JADX INFO: Access modifiers changed from: private */ public void B(AutoCompleteTextView autoCompleteTextView) { autoCompleteTextView.setOnTouchListener(new e(autoCompleteTextView)); autoCompleteTextView.setOnFocusChangeListener(new f()); if (f4720o) { autoCompleteTextView.setOnDismissListener(new g()); } } /* JADX INFO: Access modifiers changed from: private */ public void C(AutoCompleteTextView autoCompleteTextView) { if (autoCompleteTextView == null) { return; } if (y()) { this.f4724g = false; } if (this.f4724g) { this.f4724g = false; return; } if (f4720o) { z(!this.f4725h); } else { this.f4725h = !this.f4725h; this.f4746c.toggle(); } if (!this.f4725h) { autoCompleteTextView.dismissDropDown(); } else { autoCompleteTextView.requestFocus(); autoCompleteTextView.showDropDown(); } } /* JADX INFO: Access modifiers changed from: private */ public void r(AutoCompleteTextView autoCompleteTextView) { if (autoCompleteTextView.getKeyListener() != null) { return; } int boxBackgroundMode = this.f4744a.getBoxBackgroundMode(); p3.g boxBackground = this.f4744a.getBoxBackground(); int c10 = g3.a.c(autoCompleteTextView, c3.a.f3450f); int[][] iArr = {new int[]{R.attr.state_pressed}, new int[0]}; if (boxBackgroundMode == 2) { t(autoCompleteTextView, c10, iArr, boxBackground); } else if (boxBackgroundMode == 1) { s(autoCompleteTextView, c10, iArr, boxBackground); } } private void s(AutoCompleteTextView autoCompleteTextView, int i10, int[][] iArr, p3.g gVar) { int boxBackgroundColor = this.f4744a.getBoxBackgroundColor(); int[] iArr2 = {g3.a.f(i10, boxBackgroundColor, 0.1f), boxBackgroundColor}; if (f4720o) { n0.q0(autoCompleteTextView, new RippleDrawable(new ColorStateList(iArr, iArr2), gVar, gVar)); return; } p3.g gVar2 = new p3.g(gVar.A()); gVar2.R(new ColorStateList(iArr, iArr2)); LayerDrawable layerDrawable = new LayerDrawable(new Drawable[]{gVar, gVar2}); int G = n0.G(autoCompleteTextView); int paddingTop = autoCompleteTextView.getPaddingTop(); int F = n0.F(autoCompleteTextView); int paddingBottom = autoCompleteTextView.getPaddingBottom(); n0.q0(autoCompleteTextView, layerDrawable); n0.z0(autoCompleteTextView, G, paddingTop, F, paddingBottom); } private void t(AutoCompleteTextView autoCompleteTextView, int i10, int[][] iArr, p3.g gVar) { LayerDrawable layerDrawable; int c10 = g3.a.c(autoCompleteTextView, c3.a.f3454j); p3.g gVar2 = new p3.g(gVar.A()); int f10 = g3.a.f(i10, c10, 0.1f); gVar2.R(new ColorStateList(iArr, new int[]{f10, 0})); if (f4720o) { gVar2.setTint(c10); ColorStateList colorStateList = new ColorStateList(iArr, new int[]{f10, c10}); p3.g gVar3 = new p3.g(gVar.A()); gVar3.setTint(-1); layerDrawable = new LayerDrawable(new Drawable[]{new RippleDrawable(colorStateList, gVar2, gVar3), gVar}); } else { layerDrawable = new LayerDrawable(new Drawable[]{gVar2, gVar}); } n0.q0(autoCompleteTextView, layerDrawable); } /* JADX INFO: Access modifiers changed from: private */ public AutoCompleteTextView u(EditText editText) { if (editText instanceof AutoCompleteTextView) { return (AutoCompleteTextView) editText; } throw new RuntimeException("EditText needs to be an AutoCompleteTextView if an Exposed Dropdown Menu is being used."); } private ValueAnimator v(int i10, float... fArr) { ValueAnimator ofFloat = ValueAnimator.ofFloat(fArr); ofFloat.setInterpolator(d3.a.f9105a); ofFloat.setDuration(i10); ofFloat.addUpdateListener(new i()); return ofFloat; } private p3.g w(float f10, float f11, float f12, int i10) { k m10 = k.a().z(f10).D(f10).r(f11).v(f11).m(); p3.g l10 = p3.g.l(this.f4745b, f12); l10.setShapeAppearanceModel(m10); l10.T(0, i10, 0, i10); return l10; } private void x() { this.f4731n = v(67, 0.0f, 1.0f); ValueAnimator v10 = v(50, 1.0f, 0.0f); this.f4730m = v10; v10.addListener(new h()); } /* JADX INFO: Access modifiers changed from: private */ public boolean y() { long currentTimeMillis = System.currentTimeMillis() - this.f4726i; return currentTimeMillis < 0 || currentTimeMillis > 300; } /* JADX INFO: Access modifiers changed from: private */ public void z(boolean z10) { if (this.f4725h != z10) { this.f4725h = z10; this.f4731n.cancel(); this.f4730m.start(); } } @Override // com.google.android.material.textfield.e void a() { float dimensionPixelOffset = this.f4745b.getResources().getDimensionPixelOffset(c3.c.f3490s); float dimensionPixelOffset2 = this.f4745b.getResources().getDimensionPixelOffset(c3.c.f3488q); int dimensionPixelOffset3 = this.f4745b.getResources().getDimensionPixelOffset(c3.c.f3489r); p3.g w10 = w(dimensionPixelOffset, dimensionPixelOffset, dimensionPixelOffset2, dimensionPixelOffset3); p3.g w11 = w(0.0f, dimensionPixelOffset, dimensionPixelOffset2, dimensionPixelOffset3); this.f4728k = w10; StateListDrawable stateListDrawable = new StateListDrawable(); this.f4727j = stateListDrawable; stateListDrawable.addState(new int[]{R.attr.state_above_anchor}, w10); this.f4727j.addState(new int[0], w11); this.f4744a.setEndIconDrawable(e.b.d(this.f4745b, f4720o ? c3.d.f3497d : c3.d.f3498e)); TextInputLayout textInputLayout = this.f4744a; textInputLayout.setEndIconContentDescription(textInputLayout.getResources().getText(c3.h.f3541f)); this.f4744a.setEndIconOnClickListener(new ViewOnClickListenerC0075d()); this.f4744a.c(this.f4723f); x(); n0.w0(this.f4746c, 2); this.f4729l = (AccessibilityManager) this.f4745b.getSystemService("accessibility"); } @Override // com.google.android.material.textfield.e boolean b(int i10) { return i10 != 0; } @Override // com.google.android.material.textfield.e boolean c() { return true; } }