package com.google.android.material.textfield;

import android.annotation.SuppressLint;
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.a1;
import androidx.appcompat.widget.d0;
import androidx.core.view.y;
import com.google.android.material.internal.CheckableImageButton;
import com.google.android.material.internal.o;

/* JADX INFO: compiled from: StartCompoundLayout.java */
/* JADX INFO: loaded from: classes.dex */
@SuppressLint({"ViewConstructor"})
class k extends LinearLayout {

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    private final TextInputLayout f4342e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    private final TextView f4343f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    private CharSequence f4344g;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    private final CheckableImageButton f4345h;

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    private ColorStateList f4346i;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    private PorterDuff.Mode f4347j;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    private View.OnLongClickListener f4348k;

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    private boolean f4349l;

    k(TextInputLayout textInputLayout, a1 a1Var) {
        super(textInputLayout.getContext());
        this.f4342e = textInputLayout;
        setVisibility(8);
        setOrientation(0);
        setLayoutParams(new FrameLayout.LayoutParams(-2, -1, 8388611));
        CheckableImageButton checkableImageButton = (CheckableImageButton) LayoutInflater.from(getContext()).inflate(l0.h.f5414c, (ViewGroup) this, false);
        this.f4345h = checkableImageButton;
        d0 d0Var = new d0(getContext());
        this.f4343f = d0Var;
        g(a1Var);
        f(a1Var);
        addView(checkableImageButton);
        addView(d0Var);
    }

    private void f(a1 a1Var) {
        this.f4343f.setVisibility(8);
        this.f4343f.setId(l0.f.O);
        this.f4343f.setLayoutParams(new LinearLayout.LayoutParams(-2, -2));
        y.t0(this.f4343f, 1);
        l(a1Var.n(l0.k.d4, 0));
        int i3 = l0.k.e4;
        if (a1Var.s(i3)) {
            m(a1Var.c(i3));
        }
        k(a1Var.p(l0.k.c4));
    }

    private void g(a1 a1Var) {
        if (z0.c.g(getContext())) {
            androidx.core.view.h.c((ViewGroup.MarginLayoutParams) this.f4345h.getLayoutParams(), 0);
        }
        q(null);
        r(null);
        int i3 = l0.k.i4;
        if (a1Var.s(i3)) {
            this.f4346i = z0.c.b(getContext(), a1Var, i3);
        }
        int i4 = l0.k.j4;
        if (a1Var.s(i4)) {
            this.f4347j = o.f(a1Var.k(i4, -1), null);
        }
        int i5 = l0.k.h4;
        if (a1Var.s(i5)) {
            p(a1Var.g(i5));
            int i6 = l0.k.g4;
            if (a1Var.s(i6)) {
                o(a1Var.p(i6));
            }
            n(a1Var.a(l0.k.f4, true));
        }
    }

    private void x() {
        int i3 = (this.f4344g == null || this.f4349l) ? 8 : 0;
        setVisibility(this.f4345h.getVisibility() == 0 || i3 == 0 ? 0 : 8);
        this.f4343f.setVisibility(i3);
        this.f4342e.q0();
    }

    CharSequence a() {
        return this.f4344g;
    }

    ColorStateList b() {
        return this.f4343f.getTextColors();
    }

    TextView c() {
        return this.f4343f;
    }

    CharSequence d() {
        return this.f4345h.getContentDescription();
    }

    Drawable e() {
        return this.f4345h.getDrawable();
    }

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

    void i(boolean z2) {
        this.f4349l = z2;
        x();
    }

    void j() {
        f.c(this.f4342e, this.f4345h, this.f4346i);
    }

    void k(CharSequence charSequence) {
        this.f4344g = TextUtils.isEmpty(charSequence) ? null : charSequence;
        this.f4343f.setText(charSequence);
        x();
    }

    void l(int i3) {
        androidx.core.widget.j.n(this.f4343f, i3);
    }

    void m(ColorStateList colorStateList) {
        this.f4343f.setTextColor(colorStateList);
    }

    void n(boolean z2) {
        this.f4345h.setCheckable(z2);
    }

    void o(CharSequence charSequence) {
        if (d() != charSequence) {
            this.f4345h.setContentDescription(charSequence);
        }
    }

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

    void p(Drawable drawable) {
        this.f4345h.setImageDrawable(drawable);
        if (drawable != null) {
            f.a(this.f4342e, this.f4345h, this.f4346i, this.f4347j);
            u(true);
            j();
        } else {
            u(false);
            q(null);
            r(null);
            o(null);
        }
    }

    void q(View.OnClickListener onClickListener) {
        f.e(this.f4345h, onClickListener, this.f4348k);
    }

    void r(View.OnLongClickListener onLongClickListener) {
        this.f4348k = onLongClickListener;
        f.f(this.f4345h, onLongClickListener);
    }

    void s(ColorStateList colorStateList) {
        if (this.f4346i != colorStateList) {
            this.f4346i = colorStateList;
            f.a(this.f4342e, this.f4345h, colorStateList, this.f4347j);
        }
    }

    void t(PorterDuff.Mode mode) {
        if (this.f4347j != mode) {
            this.f4347j = mode;
            f.a(this.f4342e, this.f4345h, this.f4346i, mode);
        }
    }

    void u(boolean z2) {
        if (h() != z2) {
            this.f4345h.setVisibility(z2 ? 0 : 8);
            w();
            x();
        }
    }

    void v(androidx.core.view.accessibility.d dVar) {
        if (this.f4343f.getVisibility() != 0) {
            dVar.t0(this.f4345h);
        } else {
            dVar.h0(this.f4343f);
            dVar.t0(this.f4343f);
        }
    }

    void w() {
        EditText editText = this.f4342e.f4201i;
        if (editText == null) {
            return;
        }
        y.E0(this.f4343f, h() ? 0 : y.J(editText), editText.getCompoundPaddingTop(), getContext().getResources().getDimensionPixelSize(l0.d.f5371v), editText.getCompoundPaddingBottom());
    }
}
