package o;

import android.text.InputFilter;
import android.text.method.PasswordTransformationMethod;
import android.text.method.TransformationMethod;
import android.util.SparseArray;
import android.widget.TextView;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* renamed from: o.Cv, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public final class C0073Cv extends IJ {
    public final TextView m;
    public final C2858wv n;

    /* renamed from: o, reason: collision with root package name */
    public boolean f71o = true;

    public C0073Cv(TextView textView) {
        this.m = textView;
        this.n = new C2858wv(textView);
    }

    @Override // o.IJ
    public final void D(boolean z) {
        if (z) {
            L();
        }
    }

    @Override // o.IJ
    public final void E(boolean z) {
        this.f71o = z;
        L();
        TextView textView = this.m;
        textView.setFilters(p(textView.getFilters()));
    }

    public final void L() {
        TextView textView = this.m;
        TransformationMethod transformationMethod = textView.getTransformationMethod();
        if (this.f71o) {
            if (!(transformationMethod instanceof C0177Gv) && !(transformationMethod instanceof PasswordTransformationMethod)) {
                transformationMethod = new C0177Gv(transformationMethod);
            }
        } else if (transformationMethod instanceof C0177Gv) {
            transformationMethod = ((C0177Gv) transformationMethod).l;
        }
        textView.setTransformationMethod(transformationMethod);
    }

    @Override // o.IJ
    public final InputFilter[] p(InputFilter[] inputFilterArr) {
        if (!this.f71o) {
            SparseArray sparseArray = new SparseArray(1);
            for (int i = 0; i < inputFilterArr.length; i++) {
                InputFilter inputFilter = inputFilterArr[i];
                if (inputFilter instanceof C2858wv) {
                    sparseArray.put(i, inputFilter);
                }
            }
            if (sparseArray.size() == 0) {
                return inputFilterArr;
            }
            int length = inputFilterArr.length;
            InputFilter[] inputFilterArr2 = new InputFilter[inputFilterArr.length - sparseArray.size()];
            int i2 = 0;
            for (int i3 = 0; i3 < length; i3++) {
                if (sparseArray.indexOfKey(i3) < 0) {
                    inputFilterArr2[i2] = inputFilterArr[i3];
                    i2++;
                }
            }
            return inputFilterArr2;
        }
        int length2 = inputFilterArr.length;
        int i4 = 0;
        while (true) {
            C2858wv c2858wv = this.n;
            if (i4 >= length2) {
                InputFilter[] inputFilterArr3 = new InputFilter[inputFilterArr.length + 1];
                System.arraycopy(inputFilterArr, 0, inputFilterArr3, 0, length2);
                inputFilterArr3[length2] = c2858wv;
                return inputFilterArr3;
            }
            if (inputFilterArr[i4] == c2858wv) {
                return inputFilterArr;
            }
            i4++;
        }
    }
}
