TikTok.apk(点击下载) / CodeInputView.java


package com.ss.android.ugc.aweme.account.ui;

import X.AbstractC23460wR;
import X.AnonymousClass1IL;
import X.AnonymousClass1PN;
import X.AnonymousClass1ZS;
import X.C017906e;
import X.C13530gQ;
import X.C21090sc;
import X.C43481H5q;
import X.HOM;
import X.HON;
import X.HOO;
import X.HOP;
import X.HOQ;
import X.HOR;
import X.View$OnClickListenerC43395H2i;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.os.Parcelable;
import android.text.Editable;
import android.text.TextPaint;
import android.text.TextWatcher;
import android.util.AttributeSet;
import android.view.View;
import androidx.core.h.w;
import com.bytedance.covode.number.Covode;
import com.bytedance.ies.dmt.ui.widget.DmtEditText;
import com.zhiliaoapp.musically.R;
import java.util.Objects;
import kotlin.g.b.m;

public final class CodeInputView extends DmtEditText implements TextWatcher {
    public static final HOR LIZIZ = new HOR((byte) 0);
    public View.OnClickListener LIZ;
    public boolean LIZJ;
    public Boolean LIZLLL;
    public int LJ;
    public float LJFF;
    public float LJI;
    public float LJII;
    public Integer LJIIIIZZ;
    public int LJIIIZ;
    public int LJIIJ;
    public int LJIIJJI;
    public int LJIIL;
    public int LJIILIIL;
    public int LJIILJJIL;
    public int LJIILL;
    public int LJIILLIIL;
    public int LJIIZILJ;
    public final AbstractC23460wR LJIJ;
    public final AbstractC23460wR LJIJI;
    public final AbstractC23460wR LJIJJ;
    public int LJIJJLI;
    public HOQ LJIL;

    static {
        Covode.recordClassIndex(45687);
    }

    public CodeInputView(Context context, AttributeSet attributeSet) {
        this(context, attributeSet, (byte) 0);
    }

    public /* synthetic */ CodeInputView(Context context, AttributeSet attributeSet, byte b) {
        this(context, attributeSet, (char) 0);
    }

    /* JADX INFO: super call moved to the top of the method (can break code semantics) */
    public CodeInputView(Context context, AttributeSet attributeSet, char c) {
        super(context, attributeSet, R.attr.uo);
        C21090sc.LIZ(context);
        this.LJIIIIZZ = Integer.valueOf((int) R.color.a2);
        this.LJIJ = AnonymousClass1PN.LIZ((AnonymousClass1IL) HOO.LIZ);
        this.LJIJI = AnonymousClass1PN.LIZ((AnonymousClass1IL) HON.LIZ);
        this.LJIJJ = AnonymousClass1PN.LIZ((AnonymousClass1IL) HOM.LIZ);
        setBackgroundResource(0);
        this.LJIILL = attributeSet != null ? attributeSet.getAttributeIntValue("http://schemas.android.com/apk/res/android", "maxLength", 4) : 4;
        this.LJIIIIZZ = attributeSet != null ? Integer.valueOf(attributeSet.getAttributeResourceValue("http://schemas.android.com/apk/res/android", "textColor", R.color.a2)) : null;
        TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, new int[]{R.attr.sw, R.attr.sy, R.attr.vh, R.attr.xb, R.attr.a4t, R.attr.a4u, R.attr.a4v});
        m.LIZIZ(obtainStyledAttributes, "");
        this.LJIIJ = obtainStyledAttributes.getColor(4, -16777216);
        this.LJIIJJI = obtainStyledAttributes.getColor(0, -65536);
        this.LJIIL = obtainStyledAttributes.getColor(2, -65536);
        this.LJIIIZ = obtainStyledAttributes.getDimensionPixelSize(1, C13530gQ.LIZ(2.0d));
        this.LJIILIIL = obtainStyledAttributes.getDimensionPixelSize(5, C13530gQ.LIZ(1.0d));
        this.LJIILJJIL = obtainStyledAttributes.getDimensionPixelSize(3, C13530gQ.LIZ(10.0d));
        this.LJIIZILJ = obtainStyledAttributes.getDimensionPixelSize(6, C13530gQ.LIZ(5.0d));
        obtainStyledAttributes.recycle();
        TextPaint paint = getPaint();
        m.LIZIZ(paint, "");
        Integer num = this.LJIIIIZZ;
        if (num == null) {
            m.LIZIZ();
        }
        paint.setColor(C017906e.LIZJ(context, num.intValue()));
        getLinePaint().setColor(this.LJIIJ);
        getLinePaint().setStrokeWidth((float) this.LJIILIIL);
        getLinePaint().setAntiAlias(true);
        getCursorPaint().setColor(this.LJIIJJI);
        getCursorPaint().setStrokeWidth((float) this.LJIIIZ);
        getCursorPaint().setAntiAlias(true);
        getCursorPaint().setStrokeCap(Paint.Cap.ROUND);
        this.LJII = getCursorPaint().getStrokeWidth() / 2.0f;
        setCursorVisible(false);
        this.LJIJJLI = getGravity();
        addTextChangedListener(this);
    }

    private final Rect getCharBounds() {
        return (Rect) this.LJIJJ.getValue();
    }

    private final Paint getCursorPaint() {
        return (Paint) this.LJIJI.getValue();
    }

    private final Paint getLinePaint() {
        return (Paint) this.LJIJ.getValue();
    }

    private final void getNumberHeight() {
        boolean z;
        Editable text = getText();
        if (text == null || text.length() != 0) {
            z = false;
        } else {
            z = true;
            setText("0");
        }
        getCharBounds().setEmpty();
        getPaint().getTextBounds(String.valueOf(getText()), 0, 1, getCharBounds());
        this.LJI = (float) (getCharBounds().bottom - getCharBounds().top);
        if (z) {
            setText("");
        }
    }

    public final void LIZ() {
        super.setOnClickListener(new View$OnClickListenerC43395H2i(this));
    }

    public final void LIZIZ() {
        super.setCustomSelectionActionModeCallback(new HOP());
    }

    public final void LIZJ() {
        getLinePaint().setColor(this.LJIIL);
        invalidate();
    }

    public final void LIZLLL() {
        getLinePaint().setColor(this.LJIIJ);
        invalidate();
    }

    public final void afterTextChanged(Editable editable) {
        HOQ hoq;
        HOQ hoq2;
        if (this.LJIL != null) {
            int length = editable != null ? editable.length() : 0;
            int i2 = this.LJ;
            if (i2 > 0 && length >= 0 && i2 > length && (hoq2 = this.LJIL) != null) {
                hoq2.LIZIZ(String.valueOf(editable));
            }
            if (((!m.LIZ((Object) this.LIZLLL, (Object) true)) || this.LIZJ) && length > 0 && length == this.LJIILL && (hoq = this.LJIL) != null) {
                String valueOf = String.valueOf(editable);
                Objects.requireNonNull(valueOf, "null cannot be cast to non-null type kotlin.CharSequence");
                String obj = AnonymousClass1ZS.LIZIZ((CharSequence) valueOf).toString();
                Objects.requireNonNull(obj, "null cannot be cast to non-null type java.lang.String");
                String lowerCase = obj.toLowerCase();
                m.LIZIZ(lowerCase, "");
                hoq.a_(lowerCase);
            }
        }
    }

    public final void beforeTextChanged(CharSequence charSequence, int i2, int i3, int i4) {
        this.LJ = charSequence != null ? charSequence.length() : 0;
    }

    public final HOQ getCallback() {
        return this.LJIL;
    }

    /* JADX WARNING: Removed duplicated region for block: B:46:0x00e9  */
    /* JADX WARNING: Removed duplicated region for block: B:61:0x0120  */
    /* JADX WARNING: Removed duplicated region for block: B:64:0x0132  */
    /* JADX WARNING: Removed duplicated region for block: B:67:0x0143  */
    /* JADX WARNING: Removed duplicated region for block: B:69:0x014f  */
    /* JADX WARNING: Removed duplicated region for block: B:70:0x0154  */
    public final void onDraw(Canvas canvas) {
        boolean z;
        int i2;
        int i3;
        boolean z2;
        float f;
        CharSequence text;
        Editable text2;
        int i4;
        int LJFF2 = w.LJFF(this);
        int LJI2 = w.LJI(this);
        if (w.LJ(this) == 1) {
            z = true;
            i2 = -1;
        } else {
            z = false;
            i2 = 1;
        }
        if (this.LJIILLIIL == 0) {
            int width = (getWidth() - LJFF2) - LJI2;
            int i5 = this.LJIILJJIL;
            if (i5 < 0) {
                i4 = width / ((this.LJIILL * 2) - 1);
            } else {
                int i6 = this.LJIILL;
                i4 = (width - (i5 * (i6 - 1))) / i6;
            }
            this.LJIILLIIL = i4;
        }
        if (this.LJFF == 0.0f && (text2 = getText()) != null && text2.length() > 0) {
            Editable text3 = getText();
            if (text3 == null) {
                m.LIZIZ();
            }
            int length = text3.length();
            float[] fArr = new float[length];
            getPaint().getTextWidths(getText(), 0, length, fArr);
            this.LJFF = fArr[0];
        }
        if (this.LJI == 0.0f) {
            getNumberHeight();
        }
        if (z) {
            LJFF2 = (getWidth() - LJFF2) - this.LJIILLIIL;
        }
        float f2 = (float) LJFF2;
        float height = (float) (getHeight() - getPaddingBottom());
        int i7 = this.LJIILL;
        for (int i8 = 0; i8 < i7; i8 = i3 + 1) {
            if (canvas != null) {
                canvas.drawLine(f2, height, f2 + ((float) this.LJIILLIIL), height, getLinePaint());
            }
            float f3 = f2 + ((float) (this.LJIILLIIL / 2));
            Editable text4 = getText();
            int length2 = text4 != null ? text4.length() : 0;
            if (length2 > i8) {
                if (length2 <= 1 || !z) {
                    text = getText();
                    if (text == null) {
                        m.LIZIZ();
                    }
                } else {
                    Editable text5 = getText();
                    if (text5 == null) {
                        m.LIZIZ();
                    }
                    m.LIZIZ(text5, "");
                    C21090sc.LIZ(text5);
                    text = new StringBuilder(text5).reverse();
                }
                m.LIZIZ(text, "");
                CharSequence charSequence = text;
                if (canvas != null) {
                    i3 = i8;
                    canvas.drawText(charSequence, i3, i8 + 1, f3 - (this.LJFF / 2.0f), height - ((float) this.LJIIZILJ), getPaint());
                    if (i3 == this.LJIILL - 1) {
                        Editable text6 = getText();
                        if (text6 == null) {
                            m.LIZIZ();
                        }
                        if (text6.length() == this.LJIILL) {
                            z2 = true;
                            if (isFocused() && getSelectionStart() == getSelectionEnd() && (i3 == getSelectionStart() || z2)) {
                                float f4 = height - ((float) this.LJIIZILJ);
                                float f5 = this.LJI;
                                float f6 = 0.2f * f5;
                                if (z2) {
                                    float f7 = this.LJFF;
                                    f = (f7 / 2.0f) + (f7 * 0.25f);
                                } else {
                                    f = 0.0f;
                                }
                                float f8 = f * ((float) i2);
                                float f9 = (f4 - f5) - f6;
                                float f10 = f4 + f6;
                                if (canvas != null) {
                                    float f11 = f3 + f8;
                                    canvas.drawLine(f11, f9, f11, f10, getCursorPaint());
                                }
                            }
                            int i9 = this.LJIILJJIL;
                            f2 += (float) (i9 < 0 ? this.LJIILLIIL * i2 * 2 : (this.LJIILLIIL + i9) * i2);
                        }
                    }
                    z2 = false;
                    float f42 = height - ((float) this.LJIIZILJ);
                    float f52 = this.LJI;
                    float f62 = 0.2f * f52;
                    if (z2) {
                    }
                    float f82 = f * ((float) i2);
                    float f92 = (f42 - f52) - f62;
                    float f102 = f42 + f62;
                    if (canvas != null) {
                    }
                    int i92 = this.LJIILJJIL;
                    f2 += (float) (i92 < 0 ? this.LJIILLIIL * i2 * 2 : (this.LJIILLIIL + i92) * i2);
                }
            }
            i3 = i8;
            if (i3 == this.LJIILL - 1) {
            }
            z2 = false;
            float f422 = height - ((float) this.LJIIZILJ);
            float f522 = this.LJI;
            float f622 = 0.2f * f522;
            if (z2) {
            }
            float f822 = f * ((float) i2);
            float f922 = (f422 - f522) - f622;
            float f1022 = f422 + f622;
            if (canvas != null) {
            }
            int i922 = this.LJIILJJIL;
            f2 += (float) (i922 < 0 ? this.LJIILLIIL * i2 * 2 : (this.LJIILLIIL + i922) * i2);
        }
    }

    public final void onRestoreInstanceState(Parcelable parcelable) {
        this.LIZLLL = true;
        super.onRestoreInstanceState(parcelable);
        this.LIZLLL = false;
    }

    public final void onTextChanged(CharSequence charSequence, int i2, int i3, int i4) {
    }

    public final void setCallback(HOQ hoq) {
        this.LJIL = hoq;
    }

    public final void setGravity(int i2) {
        super.setGravity(i2);
        this.LJIJJLI = i2;
    }

    public final void setInputLength(int i2) {
        if (i2 > 0) {
            this.LJIILLIIL = 0;
            this.LJIILL = i2;
            C43481H5q.LIZ(this, i2);
            invalidate();
        }
    }

    public final void setInputType(int i2) {
        super.setInputType(i2);
        if (w.LJ(this) == 1) {
            setGravity(i2 == 2 ? 8388613 : this.LJIJJLI);
        }
    }

    public final void setOnClickListener(View.OnClickListener onClickListener) {
        this.LIZ = onClickListener;
    }

    public final void setTextAndAutoCheck(CharSequence charSequence) {
        this.LIZJ = true;
        setText(charSequence);
        this.LIZJ = false;
    }
}