package p044o0;

import android.os.Build;
import android.text.InputFilter;
import android.text.method.PasswordTransformationMethod;
import android.text.method.TransformationMethod;
import android.util.SparseArray;
import android.widget.TextView;
import androidx.emoji2.text.C0229g;
import p020g0.C0737f;

/* renamed from: o0.g */
/* loaded from: classes.dex */
public final class C1523g {

    /* renamed from: a */
    public final C1525b f3377a;

    /* renamed from: o0.g$a */
    /* loaded from: classes.dex */
    public static class C1524a extends C1525b {

        /* renamed from: a */
        public final TextView f3378a;

        /* renamed from: b */
        public final C1519e f3379b;

        /* renamed from: c */
        public boolean f3380c = true;

        public C1524a(TextView textView) {
            this.f3378a = textView;
            this.f3379b = new C1519e(textView);
        }

        @Override // p044o0.C1523g.C1525b
        /* renamed from: a */
        public InputFilter[] mo1111a(InputFilter[] inputFilterArr) {
            return !this.f3380c ? m1118f(inputFilterArr) : m1120d(inputFilterArr);
        }

        @Override // p044o0.C1523g.C1525b
        /* renamed from: b */
        public void mo1110b(boolean z) {
            if (z) {
                m1114j();
            }
        }

        @Override // p044o0.C1523g.C1525b
        /* renamed from: c */
        public void mo1109c(boolean z) {
            this.f3380c = z;
            m1114j();
            m1115i();
        }

        /* renamed from: d */
        public final InputFilter[] m1120d(InputFilter[] inputFilterArr) {
            int length = inputFilterArr.length;
            for (InputFilter inputFilter : inputFilterArr) {
                if (inputFilter == this.f3379b) {
                    return inputFilterArr;
                }
            }
            InputFilter[] inputFilterArr2 = new InputFilter[inputFilterArr.length + 1];
            System.arraycopy(inputFilterArr, 0, inputFilterArr2, 0, length);
            inputFilterArr2[length] = this.f3379b;
            return inputFilterArr2;
        }

        /* renamed from: e */
        public final SparseArray<InputFilter> m1119e(InputFilter[] inputFilterArr) {
            SparseArray<InputFilter> sparseArray = new SparseArray<>(1);
            for (int i = 0; i < inputFilterArr.length; i++) {
                InputFilter inputFilter = inputFilterArr[i];
                if (inputFilter instanceof C1519e) {
                    sparseArray.put(i, inputFilter);
                }
            }
            return sparseArray;
        }

        /* renamed from: f */
        public final InputFilter[] m1118f(InputFilter[] inputFilterArr) {
            SparseArray<InputFilter> m1119e = m1119e(inputFilterArr);
            if (m1119e.size() == 0) {
                return inputFilterArr;
            }
            int length = inputFilterArr.length;
            InputFilter[] inputFilterArr2 = new InputFilter[inputFilterArr.length - m1119e.size()];
            int i = 0;
            for (int i2 = 0; i2 < length; i2++) {
                if (m1119e.indexOfKey(i2) < 0) {
                    inputFilterArr2[i] = inputFilterArr[i2];
                    i++;
                }
            }
            return inputFilterArr2;
        }

        /* renamed from: g */
        public void m1117g(boolean z) {
            this.f3380c = z;
        }

        /* renamed from: h */
        public final TransformationMethod m1116h(TransformationMethod transformationMethod) {
            return transformationMethod instanceof C1530j ? ((C1530j) transformationMethod).m1101a() : transformationMethod;
        }

        /* renamed from: i */
        public final void m1115i() {
            this.f3378a.setFilters(mo1111a(this.f3378a.getFilters()));
        }

        /* renamed from: j */
        public void m1114j() {
            this.f3378a.setTransformationMethod(m1112l(this.f3378a.getTransformationMethod()));
        }

        /* renamed from: k */
        public final TransformationMethod m1113k(TransformationMethod transformationMethod) {
            return ((transformationMethod instanceof C1530j) || (transformationMethod instanceof PasswordTransformationMethod)) ? transformationMethod : new C1530j(transformationMethod);
        }

        /* renamed from: l */
        public TransformationMethod m1112l(TransformationMethod transformationMethod) {
            return this.f3380c ? m1113k(transformationMethod) : m1116h(transformationMethod);
        }
    }

    /* renamed from: o0.g$b */
    /* loaded from: classes.dex */
    public static class C1525b {
        /* renamed from: a */
        public InputFilter[] mo1111a(InputFilter[] inputFilterArr) {
            return inputFilterArr;
        }

        /* renamed from: b */
        public void mo1110b(boolean z) {
        }

        /* renamed from: c */
        public void mo1109c(boolean z) {
        }
    }

    /* renamed from: o0.g$c */
    /* loaded from: classes.dex */
    public static class C1526c extends C1525b {

        /* renamed from: a */
        public final C1524a f3381a;

        public C1526c(TextView textView) {
            this.f3381a = new C1524a(textView);
        }

        @Override // p044o0.C1523g.C1525b
        /* renamed from: a */
        public InputFilter[] mo1111a(InputFilter[] inputFilterArr) {
            return m1108d() ? inputFilterArr : this.f3381a.mo1111a(inputFilterArr);
        }

        @Override // p044o0.C1523g.C1525b
        /* renamed from: b */
        public void mo1110b(boolean z) {
            if (m1108d()) {
                return;
            }
            this.f3381a.mo1110b(z);
        }

        @Override // p044o0.C1523g.C1525b
        /* renamed from: c */
        public void mo1109c(boolean z) {
            if (m1108d()) {
                this.f3381a.m1117g(z);
            } else {
                this.f3381a.mo1109c(z);
            }
        }

        /* renamed from: d */
        public final boolean m1108d() {
            return !C0229g.m4397h();
        }
    }

    public C1523g(TextView textView, boolean z) {
        C0737f.m3032g(textView, "textView cannot be null");
        if (Build.VERSION.SDK_INT < 19) {
            this.f3377a = new C1525b();
        } else {
            this.f3377a = !z ? new C1526c(textView) : new C1524a(textView);
        }
    }

    /* renamed from: a */
    public InputFilter[] m1123a(InputFilter[] inputFilterArr) {
        return this.f3377a.mo1111a(inputFilterArr);
    }

    /* renamed from: b */
    public void m1122b(boolean z) {
        this.f3377a.mo1110b(z);
    }

    /* renamed from: c */
    public void m1121c(boolean z) {
        this.f3377a.mo1109c(z);
    }
}