package o;

import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.content.res.TypedArray;
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.ImageView;
import android.widget.LinearLayout;
import com.google.android.gms.common.R;
import com.google.android.material.internal.CheckableImageButton;
import com.google.android.material.textfield.TextInputLayout;
import java.util.WeakHashMap;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* renamed from: o.ra0, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public final class C2342ra0 extends LinearLayout {
    public final TextInputLayout l;
    public final E8 m;
    public CharSequence n;

    /* renamed from: o, reason: collision with root package name */
    public final CheckableImageButton f702o;
    public ColorStateList p;
    public PorterDuff.Mode q;
    public int r;
    public ImageView.ScaleType s;
    public View.OnLongClickListener t;
    public boolean u;

    public C2342ra0(TextInputLayout textInputLayout, C70 c70) {
        CharSequence text;
        super(textInputLayout.getContext());
        this.l = textInputLayout;
        setVisibility(8);
        setOrientation(0);
        setLayoutParams(new FrameLayout.LayoutParams(-2, -1, 8388611));
        CheckableImageButton checkableImageButton = (CheckableImageButton) LayoutInflater.from(getContext()).inflate(R.layout.design_text_input_start_icon, (ViewGroup) this, false);
        this.f702o = checkableImageButton;
        E8 e8 = new E8(getContext(), null);
        this.m = e8;
        if (AbstractC2461sm0.B(getContext())) {
            ((ViewGroup.MarginLayoutParams) checkableImageButton.getLayoutParams()).setMarginEnd(0);
        }
        View.OnLongClickListener onLongClickListener = this.t;
        checkableImageButton.setOnClickListener(null);
        IJ.F(checkableImageButton, onLongClickListener);
        this.t = null;
        checkableImageButton.setOnLongClickListener(null);
        IJ.F(checkableImageButton, null);
        TypedArray typedArray = (TypedArray) c70.n;
        if (typedArray.hasValue(69)) {
            this.p = AbstractC2461sm0.r(getContext(), c70, 69);
        }
        if (typedArray.hasValue(70)) {
            this.q = Co0.J(typedArray.getInt(70, -1), null);
        }
        if (typedArray.hasValue(66)) {
            b(c70.m(66));
            if (typedArray.hasValue(65) && checkableImageButton.getContentDescription() != (text = typedArray.getText(65))) {
                checkableImageButton.setContentDescription(text);
            }
            checkableImageButton.setCheckable(typedArray.getBoolean(64, true));
        }
        int dimensionPixelSize = typedArray.getDimensionPixelSize(67, getResources().getDimensionPixelSize(R.dimen.mtrl_min_touch_target_size));
        if (dimensionPixelSize < 0) {
            throw new IllegalArgumentException("startIconSize cannot be less than 0");
        }
        if (dimensionPixelSize != this.r) {
            this.r = dimensionPixelSize;
            checkableImageButton.setMinimumWidth(dimensionPixelSize);
            checkableImageButton.setMinimumHeight(dimensionPixelSize);
        }
        if (typedArray.hasValue(68)) {
            ImageView.ScaleType scaleTypeH = IJ.h(typedArray.getInt(68, -1));
            this.s = scaleTypeH;
            checkableImageButton.setScaleType(scaleTypeH);
        }
        e8.setVisibility(8);
        e8.setId(R.id.textinput_prefix_text);
        e8.setLayoutParams(new LinearLayout.LayoutParams(-2, -2));
        WeakHashMap weakHashMap = Oj0.a;
        e8.setAccessibilityLiveRegion(1);
        e8.setTextAppearance(typedArray.getResourceId(60, 0));
        if (typedArray.hasValue(61)) {
            e8.setTextColor(c70.l(61));
        }
        CharSequence text2 = typedArray.getText(59);
        this.n = TextUtils.isEmpty(text2) ? null : text2;
        e8.setText(text2);
        e();
        addView(checkableImageButton);
        addView(e8);
    }

    public final int a() {
        int marginEnd;
        CheckableImageButton checkableImageButton = this.f702o;
        if (checkableImageButton.getVisibility() == 0) {
            marginEnd = ((ViewGroup.MarginLayoutParams) checkableImageButton.getLayoutParams()).getMarginEnd() + checkableImageButton.getMeasuredWidth();
        } else {
            marginEnd = 0;
        }
        WeakHashMap weakHashMap = Oj0.a;
        return this.m.getPaddingStart() + getPaddingStart() + marginEnd;
    }

    public final void b(Drawable drawable) {
        CheckableImageButton checkableImageButton = this.f702o;
        checkableImageButton.setImageDrawable(drawable);
        if (drawable != null) {
            ColorStateList colorStateList = this.p;
            PorterDuff.Mode mode = this.q;
            TextInputLayout textInputLayout = this.l;
            IJ.b(textInputLayout, checkableImageButton, colorStateList, mode);
            c(true);
            IJ.C(textInputLayout, checkableImageButton, this.p);
            return;
        }
        c(false);
        View.OnLongClickListener onLongClickListener = this.t;
        checkableImageButton.setOnClickListener(null);
        IJ.F(checkableImageButton, onLongClickListener);
        this.t = null;
        checkableImageButton.setOnLongClickListener(null);
        IJ.F(checkableImageButton, null);
        if (checkableImageButton.getContentDescription() != null) {
            checkableImageButton.setContentDescription(null);
        }
    }

    public final void c(boolean z) {
        CheckableImageButton checkableImageButton = this.f702o;
        if ((checkableImageButton.getVisibility() == 0) != z) {
            checkableImageButton.setVisibility(z ? 0 : 8);
            d();
            e();
        }
    }

    public final void d() throws Resources.NotFoundException {
        int paddingStart;
        EditText editText = this.l.f30o;
        if (editText == null) {
            return;
        }
        if (this.f702o.getVisibility() == 0) {
            paddingStart = 0;
        } else {
            WeakHashMap weakHashMap = Oj0.a;
            paddingStart = editText.getPaddingStart();
        }
        int compoundPaddingTop = editText.getCompoundPaddingTop();
        int dimensionPixelSize = getContext().getResources().getDimensionPixelSize(R.dimen.material_input_text_to_prefix_suffix_padding);
        int compoundPaddingBottom = editText.getCompoundPaddingBottom();
        WeakHashMap weakHashMap2 = Oj0.a;
        this.m.setPaddingRelative(paddingStart, compoundPaddingTop, dimensionPixelSize, compoundPaddingBottom);
    }

    public final void e() {
        int i = (this.n == null || this.u) ? 8 : 0;
        setVisibility((this.f702o.getVisibility() == 0 || i == 0) ? 0 : 8);
        this.m.setVisibility(i);
        this.l.q();
    }

    @Override // android.widget.LinearLayout, android.view.View
    public final void onMeasure(int i, int i2) throws Resources.NotFoundException {
        super.onMeasure(i, i2);
        d();
    }
}
