package com.tencent.mm.plugin.ipcall.ui;

import android.graphics.Typeface;
import android.text.TextWatcher;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.TextView;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.compatible.util.d;
import com.tencent.mm.plugin.ipcall.b.a;
import com.tencent.mm.plugin.ipcall.b.c;
import com.tencent.mm.protocal.protobuf.crw;
import com.tencent.mm.sdk.platformtools.ah;
import com.tencent.mm.sdk.platformtools.al;
import com.tencent.mm.sdk.platformtools.av;
import com.tencent.mm.sdk.platformtools.bo;
import com.tencent.mm.ui.MMActivity;
import com.tencent.ytcommon.BuildConfig;
import java.util.Iterator;
import java.util.LinkedList;

public final class b {
    MMActivity crP;
    String fmB;
    private av gGg;
    TextView goa;
    String nAa;
    String nAb = BuildConfig.FLAVOR;
    String nAc;
    LinkedList<crw> nAd;
    long nAe = 0;
    boolean nAf = false;
    private Runnable nAg = new 1(this);
    private al nAh = new al("IPCallDialQueryPhoneNumber");
    boolean nAi = false;
    private TextWatcher nAj = new 2(this);
    String nAk = BuildConfig.FLAVOR;
    a nzQ;
    private DialPad nzR;
    TextView nzS;
    EditText nzT;
    View nzU;
    private ImageButton nzV;
    View nzW;
    TextView nzX;
    TextView nzY;
    String nzZ;

    public b(MMActivity mMActivity, EditText editText, TextView textView, View view, DialPad dialPad, ImageButton imageButton, TextView textView2, View view2, TextView textView3, TextView textView4) {
        AppMethodBeat.i(21980);
        this.crP = mMActivity;
        this.nzT = editText;
        this.nzS = textView;
        this.nzU = view;
        this.nzR = dialPad;
        this.nzV = imageButton;
        this.goa = textView2;
        this.nzW = view2;
        this.nzX = textView3;
        this.nzY = textView4;
        this.gGg = new av();
        this.nAa = c.bIR();
        String string = ah.getContext().getSharedPreferences("IPCall_LastInputPref", 0).getString("IPCall_LastInputCountryName", BuildConfig.FLAVOR);
        if (bo.isNullOrNil(string)) {
            string = a.Pq(a.bIN());
        }
        this.nzZ = string;
        this.nzS.addTextChangedListener(this.nAj);
        this.nzS.setText("+" + this.nAa);
        this.nzR.setDialButtonClickListener(new 3(this));
        this.nzU.setOnClickListener(new 4(this));
        this.nzU.setOnLongClickListener(new 5(this));
        this.nzS.setOnClickListener(new 6(this));
        this.nzV.setOnClickListener(new 7(this));
        this.nzT.setHorizontallyScrolling(true);
        this.nzT.setOnClickListener(new 8(this));
        this.nzT.addTextChangedListener(new 9(this));
        if (d.iW(16)) {
            this.nzS.setTypeface(Typeface.create("sans-serif-light", 0));
            this.nzT.setTypeface(Typeface.create("sans-serif-light", 0));
            this.goa.setTypeface(Typeface.create("sans-serif-light", 0));
        }
        AppMethodBeat.o(21980);
    }

    public final void OZ(String str) {
        AppMethodBeat.i(21981);
        this.nAa = str;
        if (this.nzS != null) {
            this.nzS.setText("+".concat(String.valueOf(str)));
        }
        AppMethodBeat.o(21981);
    }

    public final void ae(LinkedList<crw> linkedList) {
        int i;
        AppMethodBeat.i(21982);
        this.nAd = linkedList;
        String replace = this.nzS.getText().toString().replace("+", BuildConfig.FLAVOR);
        if (a.Pt(replace) && this.nAd != null && this.nAd.size() > 0) {
            String Pr = a.Pr(replace);
            Iterator it = this.nAd.iterator();
            while (it.hasNext()) {
                crw crw = (crw) it.next();
                if (crw != null && crw.guW.equals(Pr)) {
                    i = 1;
                    break;
                }
            }
        }
        i = 0;
        if (i != 0) {
            this.nzY.setVisibility(0);
            AppMethodBeat.o(21982);
            return;
        }
        this.nzY.setVisibility(8);
        AppMethodBeat.o(21982);
    }

    static String eL(String str, String str2) {
        AppMethodBeat.i(21983);
        String formatNumber = av.formatNumber(str, c.PA(str2));
        if (bo.isNullOrNil(formatNumber)) {
            AppMethodBeat.o(21983);
            return str2;
        }
        AppMethodBeat.o(21983);
        return formatNumber;
    }

    public final void cq(String str, int i) {
        AppMethodBeat.i(21984);
        this.nzT.setText(str);
        if (!bo.isNullOrNil(str)) {
            if (i != -1) {
                if (this.nAi) {
                    if (i > 0 && i <= this.nzT.getText().length()) {
                        this.nzT.setSelection(i);
                    }
                }
            }
            this.nzT.setSelection(this.nzT.getText().length());
        }
        this.nAb = str;
        AppMethodBeat.o(21984);
    }

    public final void bId() {
        AppMethodBeat.i(21985);
        this.nAh.doN().removeCallbacks(this.nAg);
        this.nAh.m(this.nAg, 500);
        AppMethodBeat.o(21985);
    }
}
