package com.google.android.material.textfield;

import android.content.res.ColorStateList;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.appcompat.widget.AppCompatTextView;
import androidx.appcompat.widget.v0;
import androidx.core.view.s0;
import androidx.core.view.u;
import com.google.android.material.internal.CheckableImageButton;
import com.google.android.material.internal.q;
import vi.l;

/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes3.dex */
public class j extends LinearLayout {

    /* renamed from: p, reason: collision with root package name */
    private final TextInputLayout f13734p;

    /* renamed from: q, reason: collision with root package name */
    private final TextView f13735q;

    /* renamed from: r, reason: collision with root package name */
    private CharSequence f13736r;

    /* renamed from: s, reason: collision with root package name */
    private final CheckableImageButton f13737s;

    /* renamed from: t, reason: collision with root package name */
    private ColorStateList f13738t;

    /* renamed from: u, reason: collision with root package name */
    private PorterDuff.Mode f13739u;

    /* renamed from: v, reason: collision with root package name */
    private View.OnLongClickListener f13740v;

    /* renamed from: w, reason: collision with root package name */
    private boolean f13741w;

    /* JADX INFO: Access modifiers changed from: package-private */
    public j(TextInputLayout textInputLayout, v0 v0Var) {
        super(textInputLayout.getContext());
        this.f13734p = textInputLayout;
        setVisibility(8);
        setOrientation(0);
        setLayoutParams(new FrameLayout.LayoutParams(-2, -1, 8388611));
        CheckableImageButton checkableImageButton = (CheckableImageButton) LayoutInflater.from(getContext()).inflate(vi.h.f39841i, (ViewGroup) this, false);
        this.f13737s = checkableImageButton;
        AppCompatTextView appCompatTextView = new AppCompatTextView(getContext());
        this.f13735q = appCompatTextView;
        g(v0Var);
        f(v0Var);
        addView(checkableImageButton);
        addView(appCompatTextView);
    }

    private void f(v0 v0Var) {
        this.f13735q.setVisibility(8);
        this.f13735q.setId(vi.f.X);
        this.f13735q.setLayoutParams(new LinearLayout.LayoutParams(-2, -2));
        s0.o0(this.f13735q, 1);
        l(v0Var.n(l.f39991h8, 0));
        int i10 = l.f40001i8;
        if (v0Var.s(i10)) {
            m(v0Var.c(i10));
        }
        k(v0Var.p(l.f39981g8));
    }

    private void g(v0 v0Var) {
        if (ij.c.i(getContext())) {
            u.c((ViewGroup.MarginLayoutParams) this.f13737s.getLayoutParams(), 0);
        }
        q(null);
        r(null);
        int i10 = l.f40041m8;
        if (v0Var.s(i10)) {
            this.f13738t = ij.c.b(getContext(), v0Var, i10);
        }
        int i11 = l.f40051n8;
        if (v0Var.s(i11)) {
            this.f13739u = q.f(v0Var.k(i11, -1), null);
        }
        int i12 = l.f40031l8;
        if (v0Var.s(i12)) {
            p(v0Var.g(i12));
            int i13 = l.f40021k8;
            if (v0Var.s(i13)) {
                o(v0Var.p(i13));
            }
            n(v0Var.a(l.f40011j8, true));
        }
    }

    private void x() {
        int i10 = (this.f13736r == null || this.f13741w) ? 8 : 0;
        setVisibility(this.f13737s.getVisibility() == 0 || i10 == 0 ? 0 : 8);
        this.f13735q.setVisibility(i10);
        this.f13734p.q0();
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public CharSequence a() {
        return this.f13736r;
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public ColorStateList b() {
        return this.f13735q.getTextColors();
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public TextView c() {
        return this.f13735q;
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public CharSequence d() {
        return this.f13737s.getContentDescription();
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public Drawable e() {
        return this.f13737s.getDrawable();
    }

    boolean h() {
        return this.f13737s.getVisibility() == 0;
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public void i(boolean z10) {
        this.f13741w = z10;
        x();
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public void j() {
        f.c(this.f13734p, this.f13737s, this.f13738t);
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public void k(CharSequence charSequence) {
        this.f13736r = TextUtils.isEmpty(charSequence) ? null : charSequence;
        this.f13735q.setText(charSequence);
        x();
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public void l(int i10) {
        androidx.core.widget.j.n(this.f13735q, i10);
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public void m(ColorStateList colorStateList) {
        this.f13735q.setTextColor(colorStateList);
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public void n(boolean z10) {
        this.f13737s.setCheckable(z10);
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public void o(CharSequence charSequence) {
        if (d() != charSequence) {
            this.f13737s.setContentDescription(charSequence);
        }
    }

    @Override // android.widget.LinearLayout, android.view.View
    protected void onMeasure(int i10, int i11) {
        super.onMeasure(i10, i11);
        w();
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public void p(Drawable drawable) {
        this.f13737s.setImageDrawable(drawable);
        if (drawable != null) {
            f.a(this.f13734p, this.f13737s, this.f13738t, this.f13739u);
            u(true);
            j();
        } else {
            u(false);
            q(null);
            r(null);
            o(null);
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public void q(View.OnClickListener onClickListener) {
        f.e(this.f13737s, onClickListener, this.f13740v);
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public void r(View.OnLongClickListener onLongClickListener) {
        this.f13740v = onLongClickListener;
        f.f(this.f13737s, onLongClickListener);
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public void s(ColorStateList colorStateList) {
        if (this.f13738t != colorStateList) {
            this.f13738t = colorStateList;
            f.a(this.f13734p, this.f13737s, colorStateList, this.f13739u);
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public void t(PorterDuff.Mode mode) {
        if (this.f13739u != mode) {
            this.f13739u = mode;
            f.a(this.f13734p, this.f13737s, this.f13738t, mode);
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public void u(boolean z10) {
        if (h() != z10) {
            this.f13737s.setVisibility(z10 ? 0 : 8);
            w();
            x();
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public void v(t3.h hVar) {
        if (this.f13735q.getVisibility() != 0) {
            hVar.O0(this.f13737s);
        } else {
            hVar.v0(this.f13735q);
            hVar.O0(this.f13735q);
        }
    }

    void w() {
        EditText editText = this.f13734p.f13620t;
        if (editText == null) {
            return;
        }
        s0.B0(this.f13735q, h() ? 0 : s0.E(editText), editText.getCompoundPaddingTop(), getContext().getResources().getDimensionPixelSize(vi.d.E), editText.getCompoundPaddingBottom());
    }
}
