package com.google.android.material.textfield; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.AnimatorSet; import android.animation.ObjectAnimator; import android.content.Context; import android.content.res.ColorStateList; import android.graphics.Typeface; import android.text.TextUtils; import android.util.Property; import android.view.View; import android.view.ViewGroup; import android.widget.FrameLayout; import android.widget.LinearLayout; import android.widget.Space; import android.widget.TextView; import androidx.appcompat.widget.r0; import androidx.core.view.n0; import androidx.core.widget.t; import java.util.ArrayList; import java.util.List; /* loaded from: classes2.dex */ final class f { /* renamed from: a, reason: collision with root package name */ private final Context f4747a; /* renamed from: b, reason: collision with root package name */ private final TextInputLayout f4748b; /* renamed from: c, reason: collision with root package name */ private LinearLayout f4749c; /* renamed from: d, reason: collision with root package name */ private int f4750d; /* renamed from: e, reason: collision with root package name */ private FrameLayout f4751e; /* renamed from: f, reason: collision with root package name */ private int f4752f; /* renamed from: g, reason: collision with root package name */ private Animator f4753g; /* renamed from: h, reason: collision with root package name */ private final float f4754h; /* renamed from: i, reason: collision with root package name */ private int f4755i; /* renamed from: j, reason: collision with root package name */ private int f4756j; /* renamed from: k, reason: collision with root package name */ private CharSequence f4757k; /* renamed from: l, reason: collision with root package name */ private boolean f4758l; /* renamed from: m, reason: collision with root package name */ private TextView f4759m; /* renamed from: n, reason: collision with root package name */ private int f4760n; /* renamed from: o, reason: collision with root package name */ private ColorStateList f4761o; /* renamed from: p, reason: collision with root package name */ private CharSequence f4762p; /* renamed from: q, reason: collision with root package name */ private boolean f4763q; /* renamed from: r, reason: collision with root package name */ private TextView f4764r; /* renamed from: s, reason: collision with root package name */ private int f4765s; /* renamed from: t, reason: collision with root package name */ private ColorStateList f4766t; /* renamed from: u, reason: collision with root package name */ private Typeface f4767u; class a extends AnimatorListenerAdapter { /* renamed from: a, reason: collision with root package name */ final /* synthetic */ int f4768a; /* renamed from: b, reason: collision with root package name */ final /* synthetic */ TextView f4769b; /* renamed from: c, reason: collision with root package name */ final /* synthetic */ int f4770c; /* renamed from: d, reason: collision with root package name */ final /* synthetic */ TextView f4771d; a(int i10, TextView textView, int i11, TextView textView2) { this.f4768a = i10; this.f4769b = textView; this.f4770c = i11; this.f4771d = textView2; } @Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener public void onAnimationEnd(Animator animator) { f.this.f4755i = this.f4768a; f.this.f4753g = null; TextView textView = this.f4769b; if (textView != null) { textView.setVisibility(4); if (this.f4770c == 1 && f.this.f4759m != null) { f.this.f4759m.setText((CharSequence) null); } TextView textView2 = this.f4771d; if (textView2 != null) { textView2.setTranslationY(0.0f); this.f4771d.setAlpha(1.0f); } } } @Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener public void onAnimationStart(Animator animator) { TextView textView = this.f4771d; if (textView != null) { textView.setVisibility(0); } } } public f(TextInputLayout textInputLayout) { this.f4747a = textInputLayout.getContext(); this.f4748b = textInputLayout; this.f4754h = r0.getResources().getDimensionPixelSize(c3.c.f3476e); } private void F(TextView textView, Typeface typeface) { if (textView != null) { textView.setTypeface(typeface); } } private void H(ViewGroup viewGroup, int i10) { if (i10 == 0) { viewGroup.setVisibility(8); } } private boolean I(TextView textView, CharSequence charSequence) { return n0.R(this.f4748b) && this.f4748b.isEnabled() && !(this.f4756j == this.f4755i && textView != null && TextUtils.equals(textView.getText(), charSequence)); } private void L(int i10, int i11, boolean z10) { if (z10) { AnimatorSet animatorSet = new AnimatorSet(); this.f4753g = animatorSet; ArrayList arrayList = new ArrayList(); h(arrayList, this.f4763q, this.f4764r, 2, i10, i11); h(arrayList, this.f4758l, this.f4759m, 1, i10, i11); d3.b.a(animatorSet, arrayList); animatorSet.addListener(new a(i11, l(i10), i10, l(i11))); animatorSet.start(); } else { y(i10, i11); } this.f4748b.Y(); this.f4748b.c0(z10); this.f4748b.e0(); } private boolean f() { return (this.f4749c == null || this.f4748b.getEditText() == null) ? false : true; } private void h(List list, boolean z10, TextView textView, int i10, int i11, int i12) { if (textView == null || !z10) { return; } if (i10 == i12 || i10 == i11) { list.add(i(textView, i12 == i10)); if (i12 == i10) { list.add(j(textView)); } } } private ObjectAnimator i(TextView textView, boolean z10) { ObjectAnimator ofFloat = ObjectAnimator.ofFloat(textView, (Property) View.ALPHA, z10 ? 1.0f : 0.0f); ofFloat.setDuration(167L); ofFloat.setInterpolator(d3.a.f9105a); return ofFloat; } private ObjectAnimator j(TextView textView) { ObjectAnimator ofFloat = ObjectAnimator.ofFloat(textView, (Property) View.TRANSLATION_Y, -this.f4754h, 0.0f); ofFloat.setDuration(217L); ofFloat.setInterpolator(d3.a.f9108d); return ofFloat; } private TextView l(int i10) { if (i10 == 1) { return this.f4759m; } if (i10 != 2) { return null; } return this.f4764r; } private boolean t(int i10) { return (i10 != 1 || this.f4759m == null || TextUtils.isEmpty(this.f4757k)) ? false : true; } private void y(int i10, int i11) { TextView l10; TextView l11; if (i10 == i11) { return; } if (i11 != 0 && (l11 = l(i11)) != null) { l11.setVisibility(0); l11.setAlpha(1.0f); } if (i10 != 0 && (l10 = l(i10)) != null) { l10.setVisibility(4); if (i10 == 1) { l10.setText((CharSequence) null); } } this.f4755i = i11; } void A(int i10) { this.f4760n = i10; TextView textView = this.f4759m; if (textView != null) { this.f4748b.Q(textView, i10); } } void B(ColorStateList colorStateList) { this.f4761o = colorStateList; TextView textView = this.f4759m; if (textView == null || colorStateList == null) { return; } textView.setTextColor(colorStateList); } void C(int i10) { this.f4765s = i10; TextView textView = this.f4764r; if (textView != null) { t.n(textView, i10); } } void D(boolean z10) { if (this.f4763q == z10) { return; } g(); if (z10) { r0 r0Var = new r0(this.f4747a); this.f4764r = r0Var; r0Var.setId(c3.e.f3523w); Typeface typeface = this.f4767u; if (typeface != null) { this.f4764r.setTypeface(typeface); } this.f4764r.setVisibility(4); n0.p0(this.f4764r, 1); C(this.f4765s); E(this.f4766t); d(this.f4764r, 1); } else { s(); x(this.f4764r, 1); this.f4764r = null; this.f4748b.Y(); this.f4748b.e0(); } this.f4763q = z10; } void E(ColorStateList colorStateList) { this.f4766t = colorStateList; TextView textView = this.f4764r; if (textView == null || colorStateList == null) { return; } textView.setTextColor(colorStateList); } void G(Typeface typeface) { if (typeface != this.f4767u) { this.f4767u = typeface; F(this.f4759m, typeface); F(this.f4764r, typeface); } } void J(CharSequence charSequence) { g(); this.f4757k = charSequence; this.f4759m.setText(charSequence); int i10 = this.f4755i; if (i10 != 1) { this.f4756j = 1; } L(i10, this.f4756j, I(this.f4759m, charSequence)); } void K(CharSequence charSequence) { g(); this.f4762p = charSequence; this.f4764r.setText(charSequence); int i10 = this.f4755i; if (i10 != 2) { this.f4756j = 2; } L(i10, this.f4756j, I(this.f4764r, charSequence)); } void d(TextView textView, int i10) { if (this.f4749c == null && this.f4751e == null) { LinearLayout linearLayout = new LinearLayout(this.f4747a); this.f4749c = linearLayout; linearLayout.setOrientation(0); this.f4748b.addView(this.f4749c, -1, -2); FrameLayout frameLayout = new FrameLayout(this.f4747a); this.f4751e = frameLayout; this.f4749c.addView(frameLayout, -1, new FrameLayout.LayoutParams(-2, -2)); this.f4749c.addView(new Space(this.f4747a), new LinearLayout.LayoutParams(0, 0, 1.0f)); if (this.f4748b.getEditText() != null) { e(); } } if (u(i10)) { this.f4751e.setVisibility(0); this.f4751e.addView(textView); this.f4752f++; } else { this.f4749c.addView(textView, i10); } this.f4749c.setVisibility(0); this.f4750d++; } void e() { if (f()) { n0.z0(this.f4749c, n0.G(this.f4748b.getEditText()), 0, n0.F(this.f4748b.getEditText()), 0); } } void g() { Animator animator = this.f4753g; if (animator != null) { animator.cancel(); } } boolean k() { return t(this.f4756j); } CharSequence m() { return this.f4757k; } int n() { TextView textView = this.f4759m; if (textView != null) { return textView.getCurrentTextColor(); } return -1; } ColorStateList o() { TextView textView = this.f4759m; if (textView != null) { return textView.getTextColors(); } return null; } CharSequence p() { return this.f4762p; } int q() { TextView textView = this.f4764r; if (textView != null) { return textView.getCurrentTextColor(); } return -1; } void r() { this.f4757k = null; g(); if (this.f4755i == 1) { if (!this.f4763q || TextUtils.isEmpty(this.f4762p)) { this.f4756j = 0; } else { this.f4756j = 2; } } L(this.f4755i, this.f4756j, I(this.f4759m, null)); } void s() { g(); int i10 = this.f4755i; if (i10 == 2) { this.f4756j = 0; } L(i10, this.f4756j, I(this.f4764r, null)); } boolean u(int i10) { return i10 == 0 || i10 == 1; } boolean v() { return this.f4758l; } boolean w() { return this.f4763q; } void x(TextView textView, int i10) { FrameLayout frameLayout; if (this.f4749c == null) { return; } if (!u(i10) || (frameLayout = this.f4751e) == null) { this.f4749c.removeView(textView); } else { int i11 = this.f4752f - 1; this.f4752f = i11; H(frameLayout, i11); this.f4751e.removeView(textView); } int i12 = this.f4750d - 1; this.f4750d = i12; H(this.f4749c, i12); } void z(boolean z10) { if (this.f4758l == z10) { return; } g(); if (z10) { r0 r0Var = new r0(this.f4747a); this.f4759m = r0Var; r0Var.setId(c3.e.f3522v); Typeface typeface = this.f4767u; if (typeface != null) { this.f4759m.setTypeface(typeface); } A(this.f4760n); B(this.f4761o); this.f4759m.setVisibility(4); n0.p0(this.f4759m, 1); d(this.f4759m, 0); } else { r(); x(this.f4759m, 0); this.f4759m = null; this.f4748b.Y(); this.f4748b.e0(); } this.f4758l = z10; } }