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

import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.at.a.a.c;
import com.tencent.mm.at.o;
import com.tencent.mm.compatible.e.q;
import com.tencent.mm.plugin.freewifi.g;
import com.tencent.mm.plugin.freewifi.k;
import com.tencent.mm.plugin.freewifi.k.b;
import com.tencent.mm.plugin.freewifi.l;
import com.tencent.mm.plugin.freewifi.m;
import com.tencent.mm.plugin.freewifi.model.d;
import com.tencent.mm.plugin.freewifi.model.j;
import com.tencent.mm.sdk.e.k.a;
import com.tencent.mm.sdk.platformtools.ab;
import com.tencent.mm.sdk.platformtools.ag;
import com.tencent.mm.sdk.platformtools.ap;
import com.tencent.mm.sdk.platformtools.bo;
import com.tencent.mm.ui.MMActivity;
import com.tencent.mm.ui.base.h;
import com.tencent.mm.ui.base.p;
import com.tencent.ytcommon.BuildConfig;

@Deprecated
public class ProtocolThreeOneUI extends MMActivity {
    protected String cBb;
    protected int cdf;
    private boolean chh = false;
    protected String csB;
    private String cuH;
    protected int cvd;
    private String cxb;
    private int cxs = 1;
    private final c fGS;
    private Intent intent;
    protected String jUg;
    protected String mAa;
    protected String mAb;
    private ap mAw = new ap(new 1(this), false);
    protected String mwH;
    private String mwQ;
    private int mwR = 0;
    protected String mxW;
    private TextView myB;
    private ImageView myQ;
    private TextView myR;
    private TextView myS;
    private Button myT;
    private Button myU;
    protected String myX;
    protected String myY;
    protected String myZ;
    private a myc;
    private p mzU;
    protected int mzZ;
    protected String mza;
    protected String signature;
    protected String ssid;

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

    public ProtocolThreeOneUI() {
        AppMethodBeat.i(21134);
        c.a aVar = new c.a();
        aVar.ePF = true;
        aVar.ePG = true;
        aVar.ePT = 2130838837;
        aVar.eQf = true;
        aVar.eQg = 0.0f;
        this.fGS = aVar.ahG();
        AppMethodBeat.o(21134);
    }

    static /* synthetic */ void a(ProtocolThreeOneUI protocolThreeOneUI, int i, String str) {
        AppMethodBeat.i(21144);
        protocolThreeOneUI.aH(i, str);
        AppMethodBeat.o(21144);
    }

    static /* synthetic */ void c(ProtocolThreeOneUI protocolThreeOneUI) {
        AppMethodBeat.i(21145);
        protocolThreeOneUI.goBack();
        AppMethodBeat.o(21145);
    }

    public void onCreate(Bundle bundle) {
        AppMethodBeat.i(21135);
        super.onCreate(bundle);
        this.intent = getIntent();
        this.cuH = getIntent().getStringExtra("free_wifi_ap_key");
        this.cxb = getIntent().getStringExtra("free_wifi_schema_ticket");
        this.mwQ = getIntent().getStringExtra("free_wifi_portal_ap_info_authurl_with_params");
        ab.i("MicroMsg.FreeWifi.Protocol31UI", "sessionKey=%s, step=%d, method=Protocol31UI.onCreate, desc=it goes into Protocol31 connect frontpage. apKey=%s, ticket=%s", new Object[]{m.V(getIntent()), Integer.valueOf(m.W(getIntent())), this.cuH, this.cxb});
        initView();
        if (bo.isNullOrNil(this.ssid)) {
            ab.e("MicroMsg.FreeWifi.Protocol31UI", "ssid is null");
        } else {
            int i;
            com.tencent.mm.plugin.freewifi.g.c ML = j.byW().ML(this.ssid);
            if (ML == null) {
                ML = new com.tencent.mm.plugin.freewifi.g.c();
                ML.field_ssidmd5 = ag.ck(this.ssid);
                ML.field_ssid = this.ssid;
                i = 1;
            } else {
                i = 0;
            }
            ML.field_url = this.jUg;
            ML.field_mid = this.mxW;
            ML.field_wifiType = 3;
            ML.field_connectState = 1;
            if (i != 0) {
                j.byW().b(ML);
            } else {
                j.byW().c(ML, new String[0]);
            }
            ab.i("MicroMsg.FreeWifi.Protocol31UI", "ssid : %s, mid : %s, source : %d", new Object[]{this.ssid, this.mxW, Integer.valueOf(this.cvd)});
            this.myc = new 5(this);
            j.byW().c(this.myc);
            ab.i("MicroMsg.FreeWifi.Protocol31UI", "sessionKey=%s, step=%d, method=Protocol31UI.initModel, desc=Initializing the model behind the view, so anything that changes the model will notify the view. model : field_ssidmd5=%s, field_ssid=%s, field_url=%s, field_mid=%s, field_wifiType=%d, field_connectState=%d", new Object[]{m.V(getIntent()), Integer.valueOf(m.W(getIntent())), ML.field_ssidmd5, ML.field_ssid, ML.field_url, ML.field_mid, Integer.valueOf(ML.field_wifiType), Integer.valueOf(ML.field_connectState)});
            ab.i("MicroMsg.FreeWifi.Protocol31UI", "sessionKey=%s, step=%d, method=Protocol31UI.initModel, desc=it initializes the front page. ", new Object[]{m.V(getIntent()), Integer.valueOf(m.W(getIntent()))});
            d.a(this.ssid, 4, getIntent());
        }
        l.v(d.byN(), getIntent().getStringExtra("free_wifi_ap_key"), getIntent().getIntExtra("free_wifi_protocol_type", 0));
        AppMethodBeat.o(21135);
    }

    public final void initView() {
        AppMethodBeat.i(21136);
        this.ssid = getIntent().getStringExtra("free_wifi_ssid");
        this.mxW = getIntent().getStringExtra("free_wifi_mid");
        this.jUg = getIntent().getStringExtra("free_wifi_url");
        this.cvd = getIntent().getIntExtra("free_wifi_source", 1);
        this.cdf = getIntent().getIntExtra("free_wifi_channel_id", 0);
        this.csB = getIntent().getStringExtra("free_wifi_appid");
        this.myX = getIntent().getStringExtra("free_wifi_head_img_url");
        this.myY = getIntent().getStringExtra("free_wifi_welcome_msg");
        this.myZ = getIntent().getStringExtra("free_wifi_welcome_sub_title");
        this.mza = getIntent().getStringExtra("free_wifi_privacy_url");
        this.mwH = getIntent().getStringExtra("free_wifi_app_nickname");
        ab.i("MicroMsg.FreeWifi.Protocol31UI", "sessionKey=%s, step=%d, method=Protocol31UI.initView, desc=Initializing the view. ssid=%s, mid=%s, fullUrl=%s, source=%d, channel=%d, appid=%s, headImgUrl=%s, welcomeMsg=%s, privacyUrl=%s", new Object[]{m.V(getIntent()), Integer.valueOf(m.W(getIntent())), this.ssid, this.mxW, this.jUg, Integer.valueOf(this.cvd), Integer.valueOf(this.cdf), this.csB, this.myX, this.myY, this.mza});
        setBackBtn(new 2(this));
        findViewById(2131824137).setVisibility(0);
        this.myQ = (ImageView) findViewById(2131824129);
        this.myR = (TextView) findViewById(2131824130);
        this.myS = (TextView) findViewById(2131824131);
        this.myB = (TextView) findViewById(2131824132);
        this.myT = (Button) findViewById(2131824135);
        this.myT.setOnClickListener(new 3(this));
        this.myU = (Button) findViewById(2131824136);
        this.myU.setOnClickListener(new 4(this));
        if (bo.isNullOrNil(this.ssid)) {
            this.myS.setText(getString(2131300076));
            this.myT.setVisibility(4);
        }
        setMMTitle(getString(2131300078));
        AppMethodBeat.o(21136);
    }

    /* Access modifiers changed, original: protected|final */
    public final void connect() {
        AppMethodBeat.i(21137);
        this.cxs = bzz();
        ab.i("MicroMsg.FreeWifi.Protocol31UI", "sessionKey=%s, step=%d, method=Protocol31UI.connect, desc=it starts connecting wifi by protocol 3.1. current connect state=%s", new Object[]{m.V(getIntent()), Integer.valueOf(m.W(getIntent())), d.vR(this.cxs)});
        if (this.cxs != 2) {
            this.mAw.ae(15000, 15000);
            ab.i("MicroMsg.FreeWifi.Protocol31UI", "sessionKey=%s, step=%d, method=Protocol31UI.connect, desc=it starts connectTimeoutHandler. timeout=%d s", new Object[]{m.V(getIntent()), Integer.valueOf(m.W(getIntent())), Integer.valueOf(60)});
            j.byZ().byI().post(new 6(this, this.mwQ));
            AppMethodBeat.o(21137);
            return;
        }
        d.a(this.ssid, 2, getIntent());
        AppMethodBeat.o(21137);
    }

    /* Access modifiers changed, original: protected|final */
    public final void vT(int i) {
        AppMethodBeat.i(21138);
        ab.i("MicroMsg.FreeWifi.Protocol31UI", "sessionKey=%s, step=%d, method=Protocol31UI.onConnectStateChange, desc=it receives notifications whenever the connect state of model changes and then updates the view accordingly. state=%d", new Object[]{m.V(getIntent()), Integer.valueOf(m.W(getIntent())), Integer.valueOf(i)});
        switch (i) {
            case 1:
                this.myB.setVisibility(4);
                this.myT.setText(2131298432);
                this.mzU = h.b(this.mController.ylL, getString(2131298432), true, new 9(this));
                ab.i("MicroMsg.FreeWifi.Protocol31UI", "sessionKey=%s, step=%d, method=Protocol31UI.toConnecting, desc=it adds a loading ui on the connect front page.", new Object[]{m.V(getIntent()), Integer.valueOf(m.W(getIntent()))});
                AppMethodBeat.o(21138);
                return;
            case 2:
                if (this.mzU != null) {
                    this.mzU.dismiss();
                }
                this.mAw.stopTimer();
                this.myT.setText(2131298429);
                this.myT.setClickable(false);
                Intent intent = getIntent();
                intent.putExtra("free_wifi_appid", this.csB);
                intent.putExtra("free_wifi_app_nickname", this.mwH);
                intent.putExtra("free_wifi_app_username", this.cBb);
                intent.putExtra("free_wifi_signature", this.signature);
                intent.putExtra("free_wifi_finish_actioncode", this.mzZ);
                intent.putExtra("free_wifi_finish_url", this.mAa);
                if (bo.isNullOrNil(this.mAb)) {
                    intent.setClass(this, FreeWifiSuccUI.class);
                } else {
                    intent.putExtra("free_wifi_qinghuai_url", this.mAb);
                    intent.setClass(this, FreeWifiSuccWebViewUI.class);
                }
                finish();
                startActivity(intent);
                d.IF();
                ab.i("MicroMsg.FreeWifi.Protocol31UI", "sessionKey=%s, step=%d, method=Protocol31UI.toSuccess, desc=connect succeeded.", new Object[]{m.V(getIntent()), Integer.valueOf(m.W(getIntent()))});
                break;
            case 3:
                if (this.mzU != null) {
                    this.mzU.dismiss();
                }
                this.mAw.stopTimer();
                this.myB.setVisibility(0);
                this.myT.setText(2131300074);
                ab.i("MicroMsg.FreeWifi.Protocol31UI", "sessionKey=%s, step=%d, method=Protocol31UI.toFail, desc=connect failed.", new Object[]{m.V(getIntent()), Integer.valueOf(m.W(getIntent()))});
                AppMethodBeat.o(21138);
                return;
            case 4:
                if (this.mzU != null) {
                    this.mzU.dismiss();
                }
                this.mAw.stopTimer();
                this.myB.setVisibility(4);
                this.myT.setText(2131298435);
                if (!(m.Y(getIntent()) != 10 || m.isEmpty(q.eth.etR) || m.isEmpty(q.bB(this.mController.ylL)))) {
                    this.myT.setText(String.format(getString(2131300035), new Object[]{q.bB(this.mController.ylL)}));
                }
                if (this.cvd == 3) {
                    this.myS.setText(getString(2131301435, new Object[]{this.ssid}));
                } else if (bo.isNullOrNil(this.myZ)) {
                    this.myS.setText(getString(2131298431));
                } else {
                    this.myS.setText(this.myZ);
                }
                if (!bo.isNullOrNil(this.csB)) {
                    if (!bo.isNullOrNil(this.mwH)) {
                        this.myR.setText(this.mwH);
                    }
                    if (!bo.isNullOrNil(this.myX)) {
                        o.ahp().a(this.myX, this.myQ, this.fGS);
                    }
                }
                ab.i("MicroMsg.FreeWifi.Protocol31UI", "sessionKey=%s, step=%d, method=Protocol31UI.toConnectStart, desc=it initializes the connect front page.", new Object[]{m.V(getIntent()), Integer.valueOf(m.W(getIntent()))});
                AppMethodBeat.o(21138);
                return;
        }
        AppMethodBeat.o(21138);
    }

    public final int getLayoutId() {
        return 2130969591;
    }

    public boolean onKeyDown(int i, KeyEvent keyEvent) {
        AppMethodBeat.i(21139);
        if (i == 4 && keyEvent.getRepeatCount() == 0) {
            goBack();
            AppMethodBeat.o(21139);
            return true;
        }
        boolean onKeyDown = super.onKeyDown(i, keyEvent);
        AppMethodBeat.o(21139);
        return onKeyDown;
    }

    private void goBack() {
        AppMethodBeat.i(21140);
        l.x(d.byN(), getIntent().getStringExtra("free_wifi_ap_key"), getIntent().getIntExtra("free_wifi_protocol_type", 0));
        g.gkE.h(new Intent(), this);
        finish();
        AppMethodBeat.o(21140);
    }

    /* Access modifiers changed, original: protected|final */
    public final int bzz() {
        AppMethodBeat.i(21141);
        if (bo.isNullOrNil(this.ssid)) {
            ab.d("MicroMsg.FreeWifi.Protocol31UI", "Illegal SSID");
            AppMethodBeat.o(21141);
            return 0;
        }
        com.tencent.mm.plugin.freewifi.g.c ML = j.byW().ML(this.ssid);
        if (ML == null || !ML.field_ssid.equalsIgnoreCase(this.ssid)) {
            AppMethodBeat.o(21141);
            return 0;
        }
        int i = ML.field_connectState;
        AppMethodBeat.o(21141);
        return i;
    }

    public final int getForceOrientation() {
        return 1;
    }

    private void aH(int i, String str) {
        AppMethodBeat.i(21142);
        k.a byo = k.byo();
        byo.ssid = this.ssid;
        byo.bssid = m.My("MicroMsg.FreeWifi.Protocol31UI");
        byo.cuI = m.Mz("MicroMsg.FreeWifi.Protocol31UI");
        byo.cuH = this.cuH;
        byo.mud = this.csB;
        byo.kBq = m.V(this.intent);
        byo.mue = m.X(this.intent);
        byo.muf = b.muG.muQ;
        byo.mug = b.muG.name;
        byo.result = i;
        byo.ehr = str;
        byo.cIb = m.Y(this.intent);
        byo.muh = this.cBb;
        byo.byq().byp();
        AppMethodBeat.o(21142);
    }

    public void onDestroy() {
        AppMethodBeat.i(21143);
        super.onDestroy();
        if (this.myc != null) {
            j.byW().d(this.myc);
        }
        this.mAw.stopTimer();
        j.byZ().release();
        AppMethodBeat.o(21143);
    }

    static /* synthetic */ void e(ProtocolThreeOneUI protocolThreeOneUI) {
        AppMethodBeat.i(21146);
        protocolThreeOneUI.aH(0, BuildConfig.FLAVOR);
        j.byZ().byI().post(new 8(protocolThreeOneUI));
        AppMethodBeat.o(21146);
    }
}
