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

import android.app.ProgressDialog;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.MenuItem;
import android.view.MenuItem.OnMenuItemClickListener;
import android.view.View;
import android.view.View.OnKeyListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import com.google.android.gms.common.util.CrashUtils.ErrorDialogData;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.ai.f;
import com.tencent.mm.ai.m;
import com.tencent.mm.g.a.jk;
import com.tencent.mm.kernel.g;
import com.tencent.mm.model.bk;
import com.tencent.mm.modelsimple.q;
import com.tencent.mm.platformtools.e;
import com.tencent.mm.platformtools.w;
import com.tencent.mm.platformtools.z;
import com.tencent.mm.plugin.account.a.a;
import com.tencent.mm.plugin.account.friend.a.l;
import com.tencent.mm.plugin.appbrand.appstorage.ZipJNI;
import com.tencent.mm.protocal.d;
import com.tencent.mm.sdk.b.b;
import com.tencent.mm.sdk.b.c;
import com.tencent.mm.sdk.platformtools.ab;
import com.tencent.mm.sdk.platformtools.ah;
import com.tencent.mm.sdk.platformtools.ak;
import com.tencent.mm.sdk.platformtools.av;
import com.tencent.mm.sdk.platformtools.bo;
import com.tencent.mm.ui.MMActivity;
import com.tencent.mm.ui.applet.SecurityImage;
import com.tencent.mm.ui.base.h;
import com.tencent.mm.ui.base.p;
import com.tencent.smtt.sdk.TbsMediaPlayer$TbsMediaPlayerListener;
import com.tencent.ytcommon.BuildConfig;

public class LoginIndepPass extends MMActivity implements f {
    private String account;
    private String cOG;
    private ProgressDialog ehJ = null;
    private c gAY = new c<jk>() {
        {
            AppMethodBeat.i(124967);
            this.xxI = jk.class.getName().hashCode();
            AppMethodBeat.o(124967);
        }

        public final /* synthetic */ boolean a(b bVar) {
            AppMethodBeat.i(124968);
            jk jkVar = (jk) bVar;
            if (jkVar == null || jkVar.cEJ == null) {
                AppMethodBeat.o(124968);
                return false;
            }
            ab.i("MicroMsg.LoginIndepPass", "summerdiz loginDisasterListener callback content[%s], url[%s]", new Object[]{jkVar.cEJ.content, jkVar.cEJ.url});
            Intent intent = new Intent();
            intent.putExtra("key_disaster_content", jkVar.cEJ.content);
            intent.putExtra("key_disaster_url", jkVar.cEJ.url);
            intent.setClass(ah.getContext(), DisasterUI.class).addFlags(ErrorDialogData.BINDER_CRASH);
            ah.getContext().startActivity(intent);
            AppMethodBeat.o(124968);
            return true;
        }
    };
    private f gBT = new f();
    private String gBV;
    private String gBW;
    private EditText gCB;
    private String gCC;
    private Button gCD;
    private String gsF;
    private p guc;
    private SecurityImage gue = null;
    private String gzO;

    public void onWindowFocusChanged(boolean z) {
        super.onWindowFocusChanged(z);
        AppMethodBeat.at(this, z);
    }

    public LoginIndepPass() {
        AppMethodBeat.i(124985);
        AppMethodBeat.o(124985);
    }

    static /* synthetic */ void a(LoginIndepPass loginIndepPass) {
        AppMethodBeat.i(124995);
        loginIndepPass.aqU();
        AppMethodBeat.o(124995);
    }

    public final int getLayoutId() {
        return 2130969951;
    }

    public void onCreate(Bundle bundle) {
        AppMethodBeat.i(124986);
        super.onCreate(bundle);
        String string = getString(2131301022);
        if (d.vxr) {
            string = getString(2131296982) + getString(2131296513);
        }
        setMMTitle(string);
        this.gCC = getIntent().getStringExtra("bindmcontact_mobile");
        if (this.gCC != null) {
            this.account = av.amN(this.gCC);
        }
        a.gkF.BV();
        this.gsF = com.tencent.mm.plugin.b.a.arO();
        initView();
        AppMethodBeat.o(124986);
    }

    public void onResume() {
        AppMethodBeat.i(124987);
        com.tencent.mm.sdk.b.a.xxA.c(this.gAY);
        super.onResume();
        StringBuilder stringBuilder = new StringBuilder();
        g.RN();
        stringBuilder = stringBuilder.append(com.tencent.mm.kernel.a.Rb()).append(",").append(getClass().getName()).append(",L200_200,");
        g.RN();
        com.tencent.mm.plugin.b.a.f(true, stringBuilder.append(com.tencent.mm.kernel.a.lF("L200_200")).append(",1").toString());
        com.tencent.mm.plugin.b.a.wz("L200_200");
        AppMethodBeat.o(124987);
    }

    public void onPause() {
        AppMethodBeat.i(124988);
        super.onPause();
        com.tencent.mm.sdk.b.a.xxA.d(this.gAY);
        StringBuilder stringBuilder = new StringBuilder();
        g.RN();
        stringBuilder = stringBuilder.append(com.tencent.mm.kernel.a.Rb()).append(",").append(getClass().getName()).append(",L200_200,");
        g.RN();
        com.tencent.mm.plugin.b.a.f(false, stringBuilder.append(com.tencent.mm.kernel.a.lF("L200_200")).append(",2").toString());
        AppMethodBeat.o(124988);
    }

    public void onDestroy() {
        AppMethodBeat.i(124989);
        g.Rg().b(TbsMediaPlayer$TbsMediaPlayerListener.MEDIA_INFO_BUFFERING_START, this);
        g.Rg().b(252, this);
        super.onDestroy();
        AppMethodBeat.o(124989);
    }

    public final void initView() {
        AppMethodBeat.i(124990);
        this.gCB = (EditText) findViewById(2131825314);
        this.gCD = (Button) findViewById(2131825315);
        enableOptionMenu(false);
        addTextOptionMenu(0, getString(2131301024), new 9(this));
        this.gCB.addTextChangedListener(new 10(this));
        this.gCB.setOnEditorActionListener(new 11(this));
        this.gCB.setOnKeyListener(new OnKeyListener() {
            public final boolean onKey(View view, int i, KeyEvent keyEvent) {
                AppMethodBeat.i(124978);
                if (66 == i && keyEvent.getAction() == 0) {
                    LoginIndepPass.a(LoginIndepPass.this);
                    AppMethodBeat.o(124978);
                    return true;
                }
                AppMethodBeat.o(124978);
                return false;
            }
        });
        this.gCD.setText(getString(2131301028));
        this.gCD.setOnClickListener(new 13(this));
        setBackBtn(new OnMenuItemClickListener() {
            public final boolean onMenuItemClick(MenuItem menuItem) {
                AppMethodBeat.i(124982);
                com.tencent.mm.plugin.b.a.wA("L200_100");
                Intent intent = new Intent(LoginIndepPass.this, MobileInputUI.class);
                intent.putExtra("mobile_input_purpose", 1);
                intent.addFlags(67108864);
                LoginIndepPass.this.startActivity(intent);
                LoginIndepPass.this.finish();
                AppMethodBeat.o(124982);
                return true;
            }
        });
        this.gzO = getIntent().getStringExtra("auth_ticket");
        if (!bo.isNullOrNil(this.gzO)) {
            new ak().postDelayed(new Runnable() {
                public final void run() {
                    AppMethodBeat.i(124983);
                    LoginIndepPass.a(LoginIndepPass.this, f.ara(), f.arb());
                    AppMethodBeat.o(124983);
                }
            }, 500);
        }
        AppMethodBeat.o(124990);
    }

    private void aqU() {
        AppMethodBeat.i(124991);
        String obj = this.gCB.getText().toString();
        if (bo.isNullOrNil(this.account)) {
            h.g(this, 2131304239, 2131301017);
            AppMethodBeat.o(124991);
        } else if (obj.equals(BuildConfig.FLAVOR)) {
            h.g(this, 2131304235, 2131301017);
            AppMethodBeat.o(124991);
        } else {
            aqX();
            g.Rg().a(TbsMediaPlayer$TbsMediaPlayerListener.MEDIA_INFO_BUFFERING_START, this);
            g.Rg().a(252, this);
            q qVar = new q(this.account, obj, null, 1);
            g.Rg().a(qVar, 0);
            getString(2131297061);
            this.ehJ = h.b(this, getString(2131301031), true, new 16(this, qVar));
            AppMethodBeat.o(124991);
        }
    }

    public void onSceneEnd(int i, int i2, String str, m mVar) {
        AppMethodBeat.i(124992);
        ab.i("MicroMsg.LoginIndepPass", "onSceneEnd: errType = " + i + " errCode = " + i2 + " errMsg = " + str);
        if (this.ehJ != null) {
            this.ehJ.dismiss();
            this.ehJ = null;
        }
        if (this.guc != null) {
            this.guc.dismiss();
            this.guc = null;
        }
        if (mVar.getType() == 252 || mVar.getType() == TbsMediaPlayer$TbsMediaPlayerListener.MEDIA_INFO_BUFFERING_START) {
            this.cOG = ((q) mVar).ajm();
            g.Rg().b(TbsMediaPlayer$TbsMediaPlayerListener.MEDIA_INFO_BUFFERING_START, this);
            g.Rg().b(252, this);
            this.gBT.guh = ((q) mVar).ajn();
            this.gBT.gug = ((q) mVar).ajo();
            this.gBT.gui = ((q) mVar).ajp();
            this.gBT.gCL = ((q) mVar).getSecCodeType();
            this.gBT.account = this.account;
            this.gBT.guf = this.gCB.getText().toString();
            if (i2 == -75) {
                z.cu(this.mController.ylL);
                AppMethodBeat.o(124992);
            } else if (i2 == ZipJNI.UNZ_ERR_OPEN_WRITE) {
                z.f(this, str, 0);
                AppMethodBeat.o(124992);
            } else if (i2 == -217) {
                z.a(this, e.a((q) mVar), i2);
                AppMethodBeat.o(124992);
            } else if (i2 == -205) {
                this.gzO = ((q) mVar).agh();
                this.gBV = ((q) mVar).ajq();
                this.gBW = ((q) mVar).ajt();
                ab.i("MicroMsg.LoginIndepPass", "summerphone MM_ERR_QQ_OK_NEED_MOBILE authTicket[%s], closeShowStyle[%s]", new Object[]{bo.anv(this.gzO), this.gBW});
                f.a(this.gBT);
                Intent intent = new Intent();
                intent.putExtra("auth_ticket", this.gzO);
                intent.putExtra("binded_mobile", this.gBV);
                intent.putExtra("close_safe_device_style", this.gBW);
                intent.putExtra("from_source", 5);
                a.gkE.g(this, intent);
                AppMethodBeat.o(124992);
            } else if (i2 == -140) {
                if (!bo.isNullOrNil(this.cOG)) {
                    z.o(this, str, this.cOG);
                }
                AppMethodBeat.o(124992);
            } else {
                boolean z;
                if (i == 4 && (i2 == -16 || i2 == -17)) {
                    g.Rg().a(new bk(new 3(this)), 0);
                    z = true;
                } else {
                    z = false;
                }
                if (i2 == -6 || i2 == -311 || i2 == -310) {
                    g.Rg().a(TbsMediaPlayer$TbsMediaPlayerListener.MEDIA_INFO_BUFFERING_START, this);
                    g.Rg().a(252, this);
                    if (this.gue == null) {
                        this.gue = SecurityImage.a.a(this.mController.ylL, this.gBT.gCL, this.gBT.gug, this.gBT.guh, this.gBT.gui, new 4(this), null, new 5(this), this.gBT);
                        AppMethodBeat.o(124992);
                        return;
                    }
                    ab.d("MicroMsg.LoginIndepPass", "imgSid:" + this.gBT.guh + " img len" + this.gBT.gug.length + " " + com.tencent.mm.compatible.util.g.Mq());
                    this.gue.b(this.gBT.gCL, this.gBT.gug, this.gBT.guh, this.gBT.gui);
                    AppMethodBeat.o(124992);
                } else if (z || (i == 0 && i2 == 0)) {
                    com.tencent.mm.kernel.a.unhold();
                    l.apX();
                    z.vx(this.gBT.account);
                    w.cm(this);
                    z.showAddrBookUploadConfirm(this, new 6(this), false, 2);
                    AppMethodBeat.o(124992);
                } else if (j(i, i2, str)) {
                    AppMethodBeat.o(124992);
                } else {
                    if (mVar.getType() == 252 || mVar.getType() == TbsMediaPlayer$TbsMediaPlayerListener.MEDIA_INFO_BUFFERING_START) {
                        com.tencent.mm.h.a jY = com.tencent.mm.h.a.jY(str);
                        if (jY != null && jY.a(this, null, null)) {
                            AppMethodBeat.o(124992);
                            return;
                        }
                    }
                    Toast.makeText(this, getString(2131299925, new Object[]{Integer.valueOf(i), Integer.valueOf(i2)}), 0).show();
                    AppMethodBeat.o(124992);
                }
            }
        } else if (mVar.getType() == 145) {
            g.Rg().b(145, this);
            String agi = ((com.tencent.mm.modelfriend.a) mVar).agi();
            if (i2 == -41) {
                h.g(this, 2131302269, 2131302270);
                AppMethodBeat.o(124992);
            } else if (i2 == -75) {
                h.b(this, getString(2131296515), BuildConfig.FLAVOR, true);
                AppMethodBeat.o(124992);
            } else {
                com.tencent.mm.plugin.b.a.wA("L3");
                StringBuilder stringBuilder = new StringBuilder();
                g.RN();
                stringBuilder = stringBuilder.append(com.tencent.mm.kernel.a.Rb()).append(",").append(getClass().getName()).append(",L3,");
                g.RN();
                com.tencent.mm.plugin.b.a.f(true, stringBuilder.append(com.tencent.mm.kernel.a.lF("L3")).append(",1").toString());
                Intent intent2 = new Intent();
                intent2.putExtra("bindmcontact_mobile", this.gCC);
                intent2.putExtra("bindmcontact_shortmobile", agi);
                intent2.putExtra("mobile_verify_purpose", 1);
                intent2.putExtra("mobileverify_countdownsec", ((com.tencent.mm.modelfriend.a) mVar).agn());
                intent2.putExtra("mobileverify_countdownstyle", ((com.tencent.mm.modelfriend.a) mVar).ago());
                intent2.putExtra("mobileverify_fb", ((com.tencent.mm.modelfriend.a) mVar).agp());
                a(MobileVerifyUI.class, intent2);
                AppMethodBeat.o(124992);
            }
        } else if (j(i, i2, str)) {
            AppMethodBeat.o(124992);
        } else {
            if (!(i == 0 && i2 == 0)) {
                Toast.makeText(this, getString(2131299925, new Object[]{Integer.valueOf(i), Integer.valueOf(i2)}), 0).show();
            }
            AppMethodBeat.o(124992);
        }
    }

    private boolean j(int i, int i2, String str) {
        AppMethodBeat.i(124993);
        if (a.gkF.a(this.mController.ylL, i, i2, str)) {
            AppMethodBeat.o(124993);
            return true;
        }
        if (i == 4) {
            switch (i2) {
                case -140:
                    if (!bo.isNullOrNil(this.cOG)) {
                        z.o(this.mController.ylL, str, this.cOG);
                    }
                    AppMethodBeat.o(124993);
                    return true;
                case ZipJNI.UNZ_END_OF_LIST_OF_FILE /*-100*/:
                    String an;
                    com.tencent.mm.kernel.a.hold();
                    AppCompatActivity appCompatActivity = this.mController.ylL;
                    g.RN();
                    if (TextUtils.isEmpty(com.tencent.mm.kernel.a.QH())) {
                        an = com.tencent.mm.bz.a.an(this.mController.ylL, 2131301294);
                    } else {
                        g.RN();
                        an = com.tencent.mm.kernel.a.QH();
                    }
                    h.a(appCompatActivity, an, this.mController.ylL.getString(2131297061), new 7(this), new 8(this));
                    AppMethodBeat.o(124993);
                    return true;
                case -9:
                    h.g(this, 2131301016, 2131301017);
                    AppMethodBeat.o(124993);
                    return true;
                case -4:
                case -3:
                    h.g(this, 2131299241, 2131301017);
                    AppMethodBeat.o(124993);
                    return true;
                case -1:
                    if (g.Rg().acS() == 5) {
                        h.g(this, 2131301656, 2131301655);
                        AppMethodBeat.o(124993);
                        return true;
                    }
                    AppMethodBeat.o(124993);
                    return false;
            }
        }
        AppMethodBeat.o(124993);
        return false;
    }

    public void onActivityResult(int i, int i2, Intent intent) {
        int i3 = 0;
        AppMethodBeat.i(124994);
        super.onActivityResult(i, i2, intent);
        String str = "MicroMsg.LoginIndepPass";
        String str2 = "onActivityResult, requestCode:%d, resultCode:%d, data==null:%b";
        Object[] objArr = new Object[3];
        objArr[0] = Integer.valueOf(i);
        objArr[1] = Integer.valueOf(i2);
        objArr[2] = Boolean.valueOf(intent == null);
        ab.d(str, str2, objArr);
        if (i2 == -1 && i == 1024 && intent != null) {
            String stringExtra = intent.getStringExtra("VoiceLoginAuthPwd");
            int intExtra = intent.getIntExtra("KVoiceHelpCode", 0);
            str2 = "MicroMsg.LoginIndepPass";
            String str3 = "onActivityResult, do voiceprint auth, authPwd is null:%b, authPwd.len:%d, lastErrCode:%d";
            Object[] objArr2 = new Object[3];
            objArr2[0] = Boolean.valueOf(bo.isNullOrNil(stringExtra));
            if (!bo.isNullOrNil(stringExtra)) {
                i3 = stringExtra.length();
            }
            objArr2[1] = Integer.valueOf(i3);
            objArr2[2] = Integer.valueOf(intExtra);
            ab.d(str2, str3, objArr2);
            if (intExtra == -217) {
                aqU();
                AppMethodBeat.o(124994);
                return;
            }
        }
        AppMethodBeat.o(124994);
    }

    static /* synthetic */ void b(LoginIndepPass loginIndepPass) {
        AppMethodBeat.i(124996);
        if (bo.isNullOrNil(loginIndepPass.gCB.getText().toString().trim())) {
            loginIndepPass.enableOptionMenu(false);
            AppMethodBeat.o(124996);
            return;
        }
        loginIndepPass.enableOptionMenu(true);
        AppMethodBeat.o(124996);
    }

    static /* synthetic */ void a(LoginIndepPass loginIndepPass, String str, String str2) {
        AppMethodBeat.i(124997);
        if (bo.isNullOrNil(str)) {
            h.g(loginIndepPass, 2131304239, 2131301017);
            AppMethodBeat.o(124997);
        } else if (bo.isNullOrNil(str2)) {
            h.g(loginIndepPass, 2131304235, 2131301017);
            AppMethodBeat.o(124997);
        } else {
            loginIndepPass.gCB.setText(str2);
            loginIndepPass.aqX();
            g.Rg().a(TbsMediaPlayer$TbsMediaPlayerListener.MEDIA_INFO_BUFFERING_START, loginIndepPass);
            g.Rg().a(252, loginIndepPass);
            q qVar = new q(str, str2, null, 1);
            g.Rg().a(qVar, 0);
            loginIndepPass.getString(2131297061);
            loginIndepPass.ehJ = h.b(loginIndepPass, loginIndepPass.getString(2131301031), true, new 2(loginIndepPass, qVar));
            AppMethodBeat.o(124997);
        }
    }
}
