省心素材.apk(点击下载) / LoginAuthActivity.java


package com.cmic.sso.sdk.activity;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.Point;
import android.graphics.drawable.ColorDrawable;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;
import android.text.method.LinkMovementMethod;
import android.util.DisplayMetrics;
import android.view.KeyEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.view.WindowManager;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import androidx.exifinterface.media.ExifInterface;
import com.cmic.sso.sdk.AuthThemeConfig;
import com.cmic.sso.sdk.auth.AuthnHelper;
import com.cmic.sso.sdk.auth.TokenListener;
import com.cmic.sso.sdk.h.g;
import com.cmic.sso.sdk.h.n;
import com.cmic.sso.sdk.h.u;
import com.cmic.sso.sdk.h.w;
import com.cmic.sso.sdk.h.y;
import com.google.android.exoplayer2.source.rtsp.SessionDescription;
import java.lang.ref.WeakReference;
import org.json.JSONException;
import org.json.JSONObject;

public class LoginAuthActivity extends Activity implements View.OnClickListener {
    protected static final String y = LoginAuthActivity.class.getSimpleName();
    private Handler a;
    private Context b;
    private RelativeLayout c;
    private com.cmic.sso.sdk.widget.a d;
    private com.cmic.sso.sdk.widget.a e;
    private com.cmic.sso.sdk.widget.a f;
    private com.cmic.sso.sdk.a g;
    private com.cmic.sso.sdk.auth.a h;
    private String i = "";
    private CheckBox j;
    private LinearLayout k;
    private RelativeLayout l;
    private long m = 0;
    private int n = 0;
    private g o = null;
    private TokenListener p;
    private boolean q = true;
    private LinearLayout r;
    private String s;
    private AuthThemeConfig t;
    private int u;
    private int v;
    private boolean w;
    private Dialog x;

    /* access modifiers changed from: package-private */
    public class a implements DialogInterface.OnKeyListener {
        a() {
        }

        public boolean onKey(DialogInterface dialogInterface, int i, KeyEvent keyEvent) {
            if (i == 4 && keyEvent.getAction() == 1 && keyEvent.getRepeatCount() == 0) {
                LoginAuthActivity.this.d.dismiss();
            }
            return true;
        }
    }

    /* access modifiers changed from: package-private */
    public class b implements DialogInterface.OnKeyListener {
        b() {
        }

        public boolean onKey(DialogInterface dialogInterface, int i, KeyEvent keyEvent) {
            if (i == 4 && keyEvent.getAction() == 1 && keyEvent.getRepeatCount() == 0) {
                LoginAuthActivity.this.e.dismiss();
            }
            return true;
        }
    }

    /* access modifiers changed from: package-private */
    public class c implements DialogInterface.OnKeyListener {
        c() {
        }

        public boolean onKey(DialogInterface dialogInterface, int i, KeyEvent keyEvent) {
            if (i == 4 && keyEvent.getAction() == 1 && keyEvent.getRepeatCount() == 0) {
                LoginAuthActivity.this.f.dismiss();
            }
            return true;
        }
    }

    /* access modifiers changed from: package-private */
    public class d implements g.a {
        d() {
        }

        @Override // com.cmic.sso.sdk.h.g.a
        public void a() {
            LoginAuthActivity.this.a.removeCallbacksAndMessages(null);
            if (LoginAuthActivity.this.d != null && LoginAuthActivity.this.d.isShowing()) {
                LoginAuthActivity.this.d.dismiss();
            }
            if (LoginAuthActivity.this.e != null && LoginAuthActivity.this.e.isShowing()) {
                LoginAuthActivity.this.e.dismiss();
            }
            LoginAuthActivity.this.a((LoginAuthActivity) true);
        }
    }

    /* access modifiers changed from: package-private */
    public class e implements CompoundButton.OnCheckedChangeListener {
        e() {
        }

        public void onCheckedChanged(CompoundButton compoundButton, boolean z) {
            LoginAuthActivity loginAuthActivity;
            CheckBox checkBox;
            String str;
            if (z) {
                LoginAuthActivity.this.c.setEnabled(true);
                try {
                    CheckBox checkBox2 = LoginAuthActivity.this.j;
                    LoginAuthActivity loginAuthActivity2 = LoginAuthActivity.this;
                    checkBox2.setBackgroundResource(n.b(loginAuthActivity2, loginAuthActivity2.t.getCheckedImgPath()));
                    return;
                } catch (Exception unused) {
                    checkBox = LoginAuthActivity.this.j;
                    loginAuthActivity = LoginAuthActivity.this;
                    str = "umcsdk_check_image";
                }
            } else {
                LoginAuthActivity.this.c.setEnabled(true ^ TextUtils.isEmpty(LoginAuthActivity.this.t.getCheckTipText()));
                try {
                    CheckBox checkBox3 = LoginAuthActivity.this.j;
                    LoginAuthActivity loginAuthActivity3 = LoginAuthActivity.this;
                    checkBox3.setBackgroundResource(n.b(loginAuthActivity3, loginAuthActivity3.t.getUncheckedImgPath()));
                    return;
                } catch (Exception unused2) {
                    checkBox = LoginAuthActivity.this.j;
                    loginAuthActivity = LoginAuthActivity.this;
                    str = "umcsdk_uncheck_image";
                }
            }
            checkBox.setBackgroundResource(n.b(loginAuthActivity, str));
        }
    }

    /* access modifiers changed from: package-private */
    public class f implements DialogInterface.OnKeyListener {
        f(LoginAuthActivity loginAuthActivity) {
        }

        public boolean onKey(DialogInterface dialogInterface, int i, KeyEvent keyEvent) {
            return i == 4;
        }
    }

    /* access modifiers changed from: private */
    public static class g extends Handler {
        WeakReference<LoginAuthActivity> a;

        g(LoginAuthActivity loginAuthActivity) {
            this.a = new WeakReference<>(loginAuthActivity);
        }

        private void a(Message message) {
            LoginAuthActivity loginAuthActivity = this.a.get();
            if (loginAuthActivity != null && message.what == 13) {
                loginAuthActivity.i();
                loginAuthActivity.l();
            }
        }

        public void handleMessage(Message message) {
            try {
                a(message);
            } catch (Exception e) {
                com.cmic.sso.sdk.g.a.I.add(e);
                e.printStackTrace();
            }
        }
    }

    /* access modifiers changed from: private */
    public static class h extends u.a {
        WeakReference<LoginAuthActivity> b;
        WeakReference<i> c;

        class a implements com.cmic.sso.sdk.auth.b {
            final /* synthetic */ LoginAuthActivity a;

            /* renamed from: com.cmic.sso.sdk.activity.LoginAuthActivity$h$a$a  reason: collision with other inner class name */
            class C0022a implements com.cmic.sso.sdk.auth.b {
                C0022a() {
                }

                @Override // com.cmic.sso.sdk.auth.b
                public void a(String str, String str2, com.cmic.sso.sdk.a aVar, JSONObject jSONObject) {
                    if (h.this.b()) {
                        long b = aVar.b("loginTime");
                        if (b != 0) {
                            aVar.b("loginTime", System.currentTimeMillis() - b);
                        }
                        String c = aVar.c("phonescrip");
                        if (!"103000".equals(str) || TextUtils.isEmpty(c)) {
                            a.this.a.q = false;
                            com.cmic.sso.sdk.h.c.a("authClickFailed");
                        } else {
                            com.cmic.sso.sdk.h.c.a("authClickSuccess");
                            a.this.a.q = true;
                        }
                        a.this.a.a(str, str2, aVar, jSONObject);
                        try {
                            Thread.sleep(1000);
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                        a.this.a.o.sendEmptyMessage(13);
                    }
                }
            }

            a(LoginAuthActivity loginAuthActivity) {
                this.a = loginAuthActivity;
            }

            @Override // com.cmic.sso.sdk.auth.b
            public void a(String str, String str2, com.cmic.sso.sdk.a aVar, JSONObject jSONObject) {
                if (h.this.b()) {
                    if ("103000".equals(str)) {
                        this.a.h.a(this.a.g, new C0022a());
                        return;
                    }
                    this.a.q = false;
                    this.a.a(str, str2, aVar, jSONObject);
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    this.a.o.sendEmptyMessage(13);
                }
            }
        }

        class b implements com.cmic.sso.sdk.auth.b {
            final /* synthetic */ LoginAuthActivity a;

            b(LoginAuthActivity loginAuthActivity) {
                this.a = loginAuthActivity;
            }

            @Override // com.cmic.sso.sdk.auth.b
            public void a(String str, String str2, com.cmic.sso.sdk.a aVar, JSONObject jSONObject) {
                if (h.this.b()) {
                    long b2 = aVar.b("loginTime");
                    String c = aVar.c("phonescrip");
                    if (b2 != 0) {
                        aVar.b("loginTime", System.currentTimeMillis() - b2);
                    }
                    if (!"103000".equals(str) || TextUtils.isEmpty(c)) {
                        this.a.q = false;
                        com.cmic.sso.sdk.h.c.a("authClickFailed");
                    } else {
                        com.cmic.sso.sdk.h.c.a("authClickSuccess");
                        this.a.q = true;
                    }
                    this.a.a(str, str2, aVar, jSONObject);
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    this.a.o.sendEmptyMessage(13);
                }
            }
        }

        protected h(LoginAuthActivity loginAuthActivity, i iVar) {
            this.b = new WeakReference<>(loginAuthActivity);
            this.c = new WeakReference<>(iVar);
        }

        /* access modifiers changed from: private */
        /* access modifiers changed from: public */
        private boolean b() {
            i iVar = this.c.get();
            if (this.b.get() == null || iVar == null) {
                return false;
            }
            return iVar.a(false);
        }

        /* access modifiers changed from: protected */
        @Override // com.cmic.sso.sdk.h.u.a
        public void a() {
            LoginAuthActivity loginAuthActivity = this.b.get();
            if (!loginAuthActivity.q) {
                loginAuthActivity.h.a(loginAuthActivity.g, String.valueOf(3), new a(loginAuthActivity));
            } else {
                loginAuthActivity.h.a(loginAuthActivity.g, new b(loginAuthActivity));
            }
        }
    }

    /* access modifiers changed from: private */
    public class i implements Runnable {
        private com.cmic.sso.sdk.a a;
        private boolean b;

        i(com.cmic.sso.sdk.a aVar) {
            this.a = aVar;
        }

        /* access modifiers changed from: private */
        /* access modifiers changed from: public */
        private synchronized boolean a(boolean z) {
            boolean z2;
            z2 = this.b;
            this.b = z;
            return !z2;
        }

        public void run() {
            if (a(true)) {
                JSONObject jSONObject = new JSONObject();
                try {
                    jSONObject.put("resultCode", "102507");
                    jSONObject.put("resultString", "请求超时");
                } catch (JSONException e) {
                    e.printStackTrace();
                }
                LoginAuthActivity.this.q = false;
                com.cmic.sso.sdk.h.c.a("authClickFailed");
                LoginAuthActivity.this.o.sendEmptyMessage(13);
                long b2 = this.a.b("loginTime");
                if (b2 != 0) {
                    this.a.b("loginTime", System.currentTimeMillis() - b2);
                }
                LoginAuthActivity.this.a("102507", "请求超时", this.a, jSONObject);
            }
        }
    }

    private void a() {
        try {
            if (this.n >= 5) {
                Toast.makeText(this.b, "网络不稳定,请返回重试其他登录方式", 1).show();
                this.c.setClickable(true);
                return;
            }
            StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
            StringBuilder sb = new StringBuilder();
            for (StackTraceElement stackTraceElement : stackTrace) {
                com.cmic.sso.sdk.h.f.c("stack", stackTraceElement.getClassName());
                String className = stackTraceElement.getClassName();
                if (!TextUtils.isEmpty(className) && className.contains("com.cmic.sso.sdk.activity") && !sb.toString().contains(className)) {
                    sb.append(className);
                    sb.append(com.alipay.sdk.util.i.b);
                }
            }
            this.g.b("caller", sb.toString());
            this.g.b("loginTime", System.currentTimeMillis());
            String a2 = this.g.a("traceId", "");
            if (!TextUtils.isEmpty(a2) && com.cmic.sso.sdk.h.i.d(a2)) {
                String b2 = y.b();
                this.g.b("traceId", b2);
                com.cmic.sso.sdk.h.i.a(b2, this.p);
            }
            j();
            m();
            i iVar = new i(this.g);
            this.a.postDelayed(iVar, AuthnHelper.getInstance(this).getOverTime());
            u.a(new h(this, iVar));
        } catch (Exception e2) {
            e2.printStackTrace();
        }
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void a(String str, String str2, com.cmic.sso.sdk.a aVar, JSONObject jSONObject) {
        try {
            this.a.removeCallbacksAndMessages(null);
            if ("103000".equals(str)) {
                if (AuthnHelper.getInstance(this) != null && com.cmic.sso.sdk.h.i.b(aVar.c("traceId")) != null) {
                    AuthnHelper.getInstance(this).callBackResult(str, str2, aVar, jSONObject, null, true);
                }
            } else if (!"200020".equals(str)) {
                AuthnHelper.getInstance(this).callBackResult(str, str2, aVar, jSONObject, null, true);
            } else if (AuthnHelper.getInstance(this) != null) {
                if (com.cmic.sso.sdk.h.i.b(aVar.c("traceId")) != null) {
                    AuthnHelper.getInstance(this).callBackResult(str, str2, aVar, jSONObject, null);
                }
                k();
            }
        } catch (Exception e2) {
            com.cmic.sso.sdk.h.f.c(y, "CallbackResult:未知错误");
            e2.printStackTrace();
        }
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void a(boolean z) {
        try {
            com.cmic.sso.sdk.h.c.a("authPageOut");
            a("200020", "登录页面关闭", this.g, null);
        } catch (Exception e2) {
            com.cmic.sso.sdk.g.a.I.add(e2);
            e2.printStackTrace();
        }
    }

    /* JADX WARNING: Removed duplicated region for block: B:35:0x01b6  */
    /* JADX WARNING: Removed duplicated region for block: B:39:0x01d4  */
    /* JADX WARNING: Removed duplicated region for block: B:45:0x0203  */
    /* JADX WARNING: Removed duplicated region for block: B:55:0x0290  */
    private void b() {
        RelativeLayout.LayoutParams layoutParams;
        int privacyMarginLeft;
        int max;
        RelativeLayout.LayoutParams layoutParams2 = (RelativeLayout.LayoutParams) this.l.getLayoutParams();
        if (this.t.getNumFieldOffsetY() > 0 || this.t.getNumFieldOffsetY_B() < 0) {
            int makeMeasureSpec = View.MeasureSpec.makeMeasureSpec(0, 0);
            this.l.measure(makeMeasureSpec, makeMeasureSpec);
            String str = y;
            com.cmic.sso.sdk.h.f.a(str, "mPhoneLayout.getMeasuredHeight()=" + this.l.getMeasuredHeight());
            if (this.t.getNumFieldOffsetY() <= 0 || (this.u - this.l.getMeasuredHeight()) - w.a(this.b, (float) this.t.getNumFieldOffsetY()) <= 0) {
                layoutParams2.addRule(12, -1);
            } else {
                com.cmic.sso.sdk.h.f.a(str, "numberField_top");
                layoutParams2.addRule(10, -1);
                layoutParams2.setMargins(0, w.a(this.b, (float) this.t.getNumFieldOffsetY()), 0, 0);
            }
        } else if (this.t.getNumFieldOffsetY_B() <= 0 || (this.u - this.l.getMeasuredHeight()) - w.a(this.b, (float) this.t.getNumFieldOffsetY_B()) <= 0) {
            layoutParams2.addRule(10, -1);
        } else {
            com.cmic.sso.sdk.h.f.a(y, "numberField_bottom");
            layoutParams2.addRule(12, -1);
            layoutParams2.setMargins(0, 0, 0, w.a(this.b, (float) this.t.getNumFieldOffsetY_B()));
        }
        this.l.setLayoutParams(layoutParams2);
        RelativeLayout.LayoutParams layoutParams3 = (RelativeLayout.LayoutParams) this.c.getLayoutParams();
        int max2 = Math.max(this.t.getLogBtnMarginLeft(), 0);
        int max3 = Math.max(this.t.getLogBtnMarginRight(), 0);
        if (this.t.getLogBtnOffsetY() > 0 || this.t.getLogBtnOffsetY_B() < 0) {
            if (this.t.getLogBtnOffsetY() <= 0 || this.u - w.a(this.b, (float) (this.t.getLogBtnHeight() + this.t.getLogBtnOffsetY())) <= 0) {
                layoutParams3.addRule(12, -1);
            } else {
                com.cmic.sso.sdk.h.f.a(y, "logBtn_top");
                layoutParams3.addRule(10, -1);
                layoutParams3.setMargins(w.a(this.b, (float) max2), w.a(this.b, (float) this.t.getLogBtnOffsetY()), w.a(this.b, (float) max3), 0);
                this.c.setLayoutParams(layoutParams3);
                layoutParams = (RelativeLayout.LayoutParams) this.k.getLayoutParams();
                privacyMarginLeft = this.t.getPrivacyMarginLeft() >= 0 ? this.t.getCheckedImgWidth() > 30 ? this.t.getPrivacyMarginLeft() : this.t.getPrivacyMarginLeft() - (30 - this.t.getCheckedImgWidth()) : this.t.getCheckedImgWidth() > 30 ? 0 : -(30 - this.t.getCheckedImgWidth());
                max = Math.max(this.t.getPrivacyMarginRight(), 0);
                int makeMeasureSpec2 = View.MeasureSpec.makeMeasureSpec(0, 0);
                this.k.measure(makeMeasureSpec2, makeMeasureSpec2);
                if (this.t.getPrivacyOffsetY() <= 0 || this.t.getPrivacyOffsetY_B() < 0) {
                    if (this.t.getPrivacyOffsetY() > 0 || (this.u - this.k.getMeasuredHeight()) - w.a(this.b, (float) this.t.getPrivacyOffsetY()) <= 0) {
                        String str2 = y;
                        com.cmic.sso.sdk.h.f.a(str2, "privacy_bottom=" + privacyMarginLeft);
                        layoutParams.addRule(12, -1);
                        layoutParams.setMargins(w.a(this.b, (float) privacyMarginLeft), 0, w.a(this.b, (float) max), 0);
                    } else {
                        String str3 = y;
                        com.cmic.sso.sdk.h.f.a(str3, "privacy_top = " + this.k.getMeasuredHeight());
                        layoutParams.addRule(10, -1);
                        layoutParams.setMargins(w.a(this.b, (float) privacyMarginLeft), w.a(this.b, (float) this.t.getPrivacyOffsetY()), w.a(this.b, (float) max), 0);
                    }
                } else if (this.t.getPrivacyOffsetY_B() <= 0 || (this.u - this.k.getMeasuredHeight()) - w.a(this.b, (float) this.t.getPrivacyOffsetY_B()) <= 0) {
                    layoutParams.addRule(10, -1);
                    layoutParams.setMargins(w.a(this.b, (float) privacyMarginLeft), 0, w.a(this.b, (float) max), 0);
                    com.cmic.sso.sdk.h.f.a(y, "privacy_top");
                } else {
                    String str4 = y;
                    com.cmic.sso.sdk.h.f.a(str4, "privacy_bottom=" + this.k.getMeasuredHeight());
                    layoutParams.addRule(12, -1);
                    layoutParams.setMargins(w.a(this.b, (float) privacyMarginLeft), 0, w.a(this.b, (float) max), w.a(this.b, (float) this.t.getPrivacyOffsetY_B()));
                }
                this.k.setLayoutParams(layoutParams);
            }
        } else if (this.t.getLogBtnOffsetY_B() <= 0 || this.u - w.a(this.b, (float) (this.t.getLogBtnHeight() + this.t.getLogBtnOffsetY_B())) <= 0) {
            layoutParams3.addRule(10, -1);
        } else {
            com.cmic.sso.sdk.h.f.a(y, "logBtn_bottom");
            layoutParams3.addRule(12, -1);
            layoutParams3.setMargins(w.a(this.b, (float) max2), 0, w.a(this.b, (float) max3), w.a(this.b, (float) this.t.getLogBtnOffsetY_B()));
            this.c.setLayoutParams(layoutParams3);
            layoutParams = (RelativeLayout.LayoutParams) this.k.getLayoutParams();
            if (this.t.getPrivacyMarginLeft() >= 0) {
            }
            max = Math.max(this.t.getPrivacyMarginRight(), 0);
            int makeMeasureSpec22 = View.MeasureSpec.makeMeasureSpec(0, 0);
            this.k.measure(makeMeasureSpec22, makeMeasureSpec22);
            if (this.t.getPrivacyOffsetY() <= 0) {
            }
            if (this.t.getPrivacyOffsetY() > 0) {
            }
            String str22 = y;
            com.cmic.sso.sdk.h.f.a(str22, "privacy_bottom=" + privacyMarginLeft);
            layoutParams.addRule(12, -1);
            layoutParams.setMargins(w.a(this.b, (float) privacyMarginLeft), 0, w.a(this.b, (float) max), 0);
            this.k.setLayoutParams(layoutParams);
        }
        layoutParams3.setMargins(w.a(this.b, (float) max2), 0, w.a(this.b, (float) max3), 0);
        this.c.setLayoutParams(layoutParams3);
        layoutParams = (RelativeLayout.LayoutParams) this.k.getLayoutParams();
        if (this.t.getPrivacyMarginLeft() >= 0) {
        }
        max = Math.max(this.t.getPrivacyMarginRight(), 0);
        int makeMeasureSpec222 = View.MeasureSpec.makeMeasureSpec(0, 0);
        this.k.measure(makeMeasureSpec222, makeMeasureSpec222);
        if (this.t.getPrivacyOffsetY() <= 0) {
        }
        if (this.t.getPrivacyOffsetY() > 0) {
        }
        String str222 = y;
        com.cmic.sso.sdk.h.f.a(str222, "privacy_bottom=" + privacyMarginLeft);
        layoutParams.addRule(12, -1);
        layoutParams.setMargins(w.a(this.b, (float) privacyMarginLeft), 0, w.a(this.b, (float) max), 0);
        this.k.setLayoutParams(layoutParams);
    }

    private String c() {
        if (!this.t.getPrivacy().contains(AuthThemeConfig.PLACEHOLDER2)) {
            return this.t.getPrivacy().replace(AuthThemeConfig.PLACEHOLDER, this.s);
        }
        this.s = "《" + this.s + "》";
        return this.t.getPrivacy().replace(AuthThemeConfig.PLACEHOLDER2, this.s);
    }

    private LinearLayout d() {
        LinearLayout linearLayout = new LinearLayout(this);
        this.k = linearLayout;
        linearLayout.setOrientation(0);
        this.k.setHorizontalGravity(1);
        this.k.setLayoutParams(new RelativeLayout.LayoutParams(-1, -2));
        int checkedImgWidth = this.t.getCheckedImgWidth();
        int checkedImgHeight = this.t.getCheckedImgHeight();
        float f2 = 30.0f;
        int a2 = w.a(this.b, checkedImgWidth > 30 ? (float) checkedImgWidth : 30.0f);
        Context context = this.b;
        if (checkedImgHeight > 30) {
            f2 = (float) checkedImgHeight;
        }
        LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(a2, w.a(context, f2));
        LinearLayout linearLayout2 = new LinearLayout(this);
        this.r = linearLayout2;
        linearLayout2.setOrientation(0);
        this.r.setId(34952);
        this.r.setLayoutParams(layoutParams);
        CheckBox checkBox = new CheckBox(this);
        this.j = checkBox;
        checkBox.setChecked(false);
        LinearLayout.LayoutParams layoutParams2 = new LinearLayout.LayoutParams(w.a(this.b, (float) this.t.getCheckedImgWidth()), w.a(this.b, (float) this.t.getCheckedImgHeight()));
        layoutParams2.setMargins(w.a(this.b, checkedImgWidth > 30 ? 0.0f : (float) (30 - checkedImgWidth)), 0, 0, 0);
        this.j.setLayoutParams(layoutParams2);
        this.r.addView(this.j);
        this.k.addView(this.r);
        TextView textView = new TextView(this);
        textView.setTextSize(2, (float) this.t.getPrivacyTextSize());
        LinearLayout.LayoutParams layoutParams3 = new LinearLayout.LayoutParams(-2, -2);
        layoutParams3.setMargins(w.a(this.b, 5.0f), 0, 0, w.a(this.b, 5.0f));
        textView.setLayoutParams(layoutParams3);
        this.k.addView(textView);
        textView.setTextColor(this.t.getClauseBaseColor());
        textView.setText(w.a(this, c(), this.s, this.d, this.e, this.f));
        textView.setLineSpacing(8.0f, 1.0f);
        textView.setIncludeFontPadding(false);
        if (this.t.isPrivacyTextGravityCenter()) {
            textView.setGravity(17);
        }
        textView.setHighlightColor(getResources().getColor(17170445));
        textView.setMovementMethod(LinkMovementMethod.getInstance());
        this.j.setButtonDrawable(new ColorDrawable());
        try {
            this.j.setBackgroundResource(n.b(this, this.t.getUncheckedImgPath()));
        } catch (Exception unused) {
            this.j.setBackgroundResource(n.b(this, "umcsdk_uncheck_image"));
        }
        return this.k;
    }

    private void e() {
        String str;
        com.cmic.sso.sdk.a a2 = com.cmic.sso.sdk.h.i.a(getIntent().getStringExtra("traceId"));
        this.g = a2;
        if (a2 == null) {
            this.g = new com.cmic.sso.sdk.a(0);
        }
        this.p = com.cmic.sso.sdk.h.i.b(this.g.a("traceId", ""));
        getWindowManager().getDefaultDisplay().getMetrics(new DisplayMetrics());
        this.a = new Handler(getMainLooper());
        this.o = new g(this);
        this.i = this.g.c("securityphone");
        String str2 = y;
        com.cmic.sso.sdk.h.f.a(str2, "mSecurityPhone value is " + this.i);
        String a3 = this.g.a("operatorType", "");
        com.cmic.sso.sdk.h.f.a(str2, "operator value is " + a3);
        if (a3.equals("1")) {
            this.s = "中国移动认证服务条款";
            str = "http://wap.cmpassport.com/resources/html/contract.html";
        } else if (a3.equals(ExifInterface.GPS_MEASUREMENT_3D)) {
            this.s = "中国电信天翼账号服务条款";
            str = "https://e.189.cn/sdk/agreement/detail.do";
        } else {
            this.s = "中国联通认证服务协议";
            str = "https://opencloud.wostore.cn/authz/resource/html/disclaimer.html?fromsdk=true";
        }
        com.cmic.sso.sdk.widget.a aVar = new com.cmic.sso.sdk.widget.a(this.b, 16973840, null, str);
        this.d = aVar;
        aVar.setOnKeyListener(new a());
        if (!TextUtils.isEmpty(this.t.getClauseUrl())) {
            com.cmic.sso.sdk.widget.a aVar2 = new com.cmic.sso.sdk.widget.a(this.b, 16973840, this.t.getClauseName(), this.t.getClauseUrl());
            this.e = aVar2;
            aVar2.setOnKeyListener(new b());
        }
        if (!TextUtils.isEmpty(this.t.getClauseUrl2())) {
            com.cmic.sso.sdk.widget.a aVar3 = new com.cmic.sso.sdk.widget.a(this.b, 16973840, this.t.getClauseName2(), this.t.getClauseUrl2());
            this.f = aVar3;
            aVar3.setOnKeyListener(new c());
        }
        com.cmic.sso.sdk.h.g.a().a(new d());
    }

    private RelativeLayout f() {
        RelativeLayout relativeLayout = new RelativeLayout(this);
        this.c = relativeLayout;
        relativeLayout.setId(17476);
        this.c.setLayoutParams(new RelativeLayout.LayoutParams(w.a(this.b, (float) this.t.getLogBtnWidth()), w.a(this.b, (float) this.t.getLogBtnHeight())));
        TextView textView = new TextView(this);
        textView.setTextSize(2, (float) this.t.getLogBtnTextSize());
        RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(-2, -2);
        layoutParams.addRule(13);
        textView.setLayoutParams(layoutParams);
        this.c.addView(textView);
        textView.setText(this.t.getLogBtnText());
        try {
            textView.setTextColor(this.t.getLogBtnTextColor());
        } catch (Exception unused) {
            textView.setTextColor(-1);
        }
        try {
            this.c.setBackgroundResource(n.b(this.b, this.t.getLogBtnBackgroundPath()));
        } catch (Exception e2) {
            e2.printStackTrace();
            this.c.setBackgroundResource(n.b(this.b, "umcsdk_login_btn_bg"));
        }
        return this.c;
    }

    private void g() {
        int i2;
        RelativeLayout relativeLayout = new RelativeLayout(this);
        this.l = relativeLayout;
        relativeLayout.setId(13107);
        this.l.setLayoutParams(new RelativeLayout.LayoutParams(-1, -2));
        TextView textView = new TextView(this);
        RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(-2, -2);
        textView.setGravity(15);
        int numberOffsetX = this.t.getNumberOffsetX();
        if (numberOffsetX == 0) {
            i2 = 13;
        } else {
            if (numberOffsetX > 0) {
                float f2 = (float) numberOffsetX;
                if ((this.v - textView.getWidth()) - w.a(this.b, f2) > 0) {
                    layoutParams.setMargins(w.a(this.b, f2), 0, 0, 0);
                } else {
                    com.cmic.sso.sdk.h.f.a(y, "RelativeLayout.ALIGN_PARENT_RIGHT");
                    i2 = 11;
                }
            }
            textView.setTextSize(2, (float) this.t.getNumberSize());
            textView.setText(this.i);
            textView.setId(30583);
            this.l.addView(textView, layoutParams);
            textView.setTextColor(this.t.getNumberColor());
            int makeMeasureSpec = View.MeasureSpec.makeMeasureSpec(0, 0);
            this.l.measure(makeMeasureSpec, makeMeasureSpec);
            String str = y;
            com.cmic.sso.sdk.h.f.a(str, "mPhoneLayout.getMeasuredHeight()=" + this.l.getMeasuredHeight());
        }
        layoutParams.addRule(i2);
        try {
            textView.setTextSize(2, (float) this.t.getNumberSize());
        } catch (Exception unused) {
            textView.setTextSize(2, 18.0f);
        }
        textView.setText(this.i);
        textView.setId(30583);
        this.l.addView(textView, layoutParams);
        try {
            textView.setTextColor(this.t.getNumberColor());
        } catch (Exception unused2) {
            textView.setTextColor(-13421773);
        }
        int makeMeasureSpec2 = View.MeasureSpec.makeMeasureSpec(0, 0);
        this.l.measure(makeMeasureSpec2, makeMeasureSpec2);
        String str2 = y;
        com.cmic.sso.sdk.h.f.a(str2, "mPhoneLayout.getMeasuredHeight()=" + this.l.getMeasuredHeight());
    }

    private void h() {
        int i2 = Build.VERSION.SDK_INT;
        if (i2 >= 21) {
            getWindow().addFlags(67108864);
            getWindow().addFlags(134217728);
            if (this.t.getStatusBarColor() != 0) {
                getWindow().addFlags(Integer.MIN_VALUE);
                getWindow().clearFlags(67108864);
                getWindow().setStatusBarColor(this.t.getStatusBarColor());
                getWindow().setNavigationBarColor(this.t.getStatusBarColor());
            }
        }
        if (i2 >= 23) {
            if (this.t.isLightColor()) {
                getWindow().getDecorView().setSystemUiVisibility(8192);
            } else {
                getWindow().getDecorView().setSystemUiVisibility(0);
            }
        }
        RelativeLayout relativeLayout = new RelativeLayout(this);
        relativeLayout.setLayoutParams(new RelativeLayout.LayoutParams(-1, -1));
        View contentView = this.t.getContentView();
        if (contentView != null) {
            ViewParent parent = contentView.getParent();
            if (parent != null) {
                ((ViewGroup) parent).removeView(contentView);
            }
            relativeLayout.addView(contentView);
        } else if (this.t.getLayoutResID() != -1) {
            getLayoutInflater().inflate(this.t.getLayoutResID(), relativeLayout);
        }
        setContentView(relativeLayout);
        int requestedOrientation = getRequestedOrientation();
        this.u = w.a(this.b);
        int b2 = w.b(this.b);
        this.v = b2;
        if ((requestedOrientation == 1 && b2 > this.u) || (requestedOrientation == 0 && b2 < this.u)) {
            this.v = this.u;
            this.u = b2;
        }
        String str = y;
        com.cmic.sso.sdk.h.f.b(str, "orientation = " + requestedOrientation + "--screenWidth = " + this.v + "--screenHeight = " + this.u);
        WindowManager.LayoutParams attributes = getWindow().getAttributes();
        if (this.t.getWindowWidth() != 0) {
            getWindow().getWindowManager().getDefaultDisplay().getMetrics(new DisplayMetrics());
            getWindowManager().getDefaultDisplay().getSize(new Point());
            attributes.width = w.a(this.b, (float) this.t.getWindowWidth());
            int a2 = w.a(this.b, (float) this.t.getWindowHeight());
            attributes.height = a2;
            this.v = attributes.width;
            this.u = a2;
            attributes.x = w.a(this.b, (float) this.t.getWindowX());
            if (this.t.getWindowBottom() == 1) {
                getWindow().setGravity(80);
            } else {
                attributes.y = w.a(this.b, (float) this.t.getWindowY());
            }
            getWindow().setAttributes(attributes);
        }
        relativeLayout.setFitsSystemWindows(true);
        relativeLayout.setClipToPadding(true);
        try {
            g();
            relativeLayout.addView(this.l);
            relativeLayout.addView(f());
            relativeLayout.addView(d());
            b();
            this.c.setOnClickListener(this);
            this.r.setOnClickListener(this);
            this.j.setOnCheckedChangeListener(new e());
            l();
            try {
                if (this.t.isPrivacyState()) {
                    this.j.setChecked(true);
                    this.j.setBackgroundResource(n.b(this, this.t.getCheckedImgPath()));
                    this.c.setEnabled(true);
                    return;
                }
                this.j.setChecked(false);
                this.c.setEnabled(!TextUtils.isEmpty(this.t.getCheckTipText()));
                this.j.setBackgroundResource(n.b(this, this.t.getUncheckedImgPath()));
            } catch (Exception unused) {
                this.j.setChecked(false);
            }
        } catch (Exception e2) {
            com.cmic.sso.sdk.g.a.I.add(e2);
            e2.printStackTrace();
            com.cmic.sso.sdk.h.f.c(y, e2.toString());
            a("200040", "UI资源加载异常", this.g, null);
        }
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void l() {
        this.c.setClickable(true);
        this.j.setClickable(true);
    }

    private void m() {
        this.c.setClickable(false);
        this.j.setClickable(false);
    }

    public void i() {
        try {
            com.cmic.sso.sdk.h.f.c(y, "loginClickComplete");
            if (this.t.getLoginClickListener() == null || !this.w) {
                Dialog dialog = this.x;
                if (dialog != null && dialog.isShowing()) {
                    this.x.dismiss();
                    return;
                }
                return;
            }
            this.w = false;
            this.t.getLoginClickListener().onLoginClickComplete(this.b, null);
        } catch (Exception e2) {
            e2.printStackTrace();
        }
    }

    public void j() {
        com.cmic.sso.sdk.h.f.c(y, "loginClickStart");
        try {
            this.w = true;
            if (this.t.getLoginClickListener() != null) {
                this.t.getLoginClickListener().onLoginClickStart(this.b, null);
            } else {
                Dialog dialog = this.x;
                if (dialog != null) {
                    dialog.show();
                    return;
                }
                AlertDialog create = new AlertDialog.Builder(this).create();
                this.x = create;
                create.setCancelable(false);
                this.x.setCanceledOnTouchOutside(false);
                this.x.setOnKeyListener(new f(this));
                RelativeLayout relativeLayout = new RelativeLayout(this.x.getContext());
                relativeLayout.setLayoutParams(new RelativeLayout.LayoutParams(-1, -2));
                ImageView imageView = new ImageView(this.x.getContext());
                imageView.setImageResource(n.b(this.b, "dialog_loading"));
                RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(80, 80);
                layoutParams.addRule(13, -1);
                relativeLayout.addView(imageView, layoutParams);
                if (this.x.getWindow() != null) {
                    this.x.getWindow().setDimAmount(0.0f);
                }
                this.x.show();
                this.x.setContentView(relativeLayout);
            }
        } catch (Exception e2) {
            e2.printStackTrace();
        }
        com.cmic.sso.sdk.h.f.c(y, "loginClickStart");
    }

    public void k() {
        this.a.removeCallbacksAndMessages(null);
        com.cmic.sso.sdk.widget.a aVar = this.d;
        if (aVar != null && aVar.isShowing()) {
            this.d.dismiss();
        }
        com.cmic.sso.sdk.widget.a aVar2 = this.e;
        if (aVar2 != null && aVar2.isShowing()) {
            this.e.dismiss();
        }
        i();
        this.x = null;
        finish();
        if (this.t.getAuthPageActOut() != null && this.t.getActivityIn() != null) {
            overridePendingTransition(n.a(this, this.t.getActivityIn()), n.a(this, this.t.getAuthPageActOut()));
        }
    }

    public void onClick(View view) {
        try {
            int id = view.getId();
            if (id != 17476) {
                if (id == 26214) {
                    a(false);
                } else if (id == 34952) {
                    if (this.j.isChecked()) {
                        this.j.setChecked(false);
                    } else {
                        this.j.setChecked(true);
                    }
                }
            } else if (this.j.isChecked() || TextUtils.isEmpty(this.t.getCheckTipText())) {
                this.n++;
                a();
            } else {
                Toast.makeText(this.b, this.t.getCheckTipText(), 1).show();
            }
        } catch (Exception e2) {
            com.cmic.sso.sdk.g.a.I.add(e2);
            e2.printStackTrace();
        }
    }

    /* access modifiers changed from: protected */
    public void onCreate(Bundle bundle) {
        try {
            super.onCreate(bundle);
            if (bundle != null) {
                finish();
            }
            this.b = this;
            AuthThemeConfig authThemeConfig = AuthnHelper.getInstance(this).getAuthThemeConfig();
            this.t = authThemeConfig;
            if (authThemeConfig != null) {
                if (authThemeConfig.getThemeId() != -1) {
                    setTheme(this.t.getThemeId());
                }
                if (!(this.t.getAuthPageActIn() == null || this.t.getActivityOut() == null)) {
                    overridePendingTransition(n.a(this, this.t.getAuthPageActIn()), n.a(this, this.t.getActivityOut()));
                }
            }
            com.cmic.sso.sdk.h.c.a("authPageIn");
            this.m = System.currentTimeMillis();
            this.h = com.cmic.sso.sdk.auth.a.a(this);
            e();
            h();
        } catch (Exception e2) {
            com.cmic.sso.sdk.g.a.I.add(e2);
            com.cmic.sso.sdk.h.f.c(y, e2.toString());
            e2.printStackTrace();
            a("200025", "发生未知错误", this.g, null);
        }
    }

    /* access modifiers changed from: protected */
    public void onDestroy() {
        try {
            this.a.removeCallbacksAndMessages(null);
            com.cmic.sso.sdk.h.c.a("timeOnAuthPage", (System.currentTimeMillis() - this.m) + "");
            com.cmic.sso.sdk.h.c.a("authPrivacyState", this.j.isChecked() ? "1" : SessionDescription.SUPPORTED_SDP_VERSION);
            if (!this.g.a("isLoginSwitch", false)) {
                com.cmic.sso.sdk.h.c.a("timeOnAuthPage", (System.currentTimeMillis() - this.m) + "");
                com.cmic.sso.sdk.h.c.a(this.b.getApplicationContext(), this.g);
                com.cmic.sso.sdk.h.c.a();
            }
            this.x = null;
            com.cmic.sso.sdk.h.g.a().c();
            this.o.removeCallbacksAndMessages(null);
        } catch (Exception e2) {
            com.cmic.sso.sdk.h.f.c(y, "LoginAuthActivity clear failed");
            com.cmic.sso.sdk.g.a.I.add(e2);
            e2.printStackTrace();
        }
        super.onDestroy();
    }

    public boolean onKeyUp(int i2, KeyEvent keyEvent) {
        if (i2 != 4 || keyEvent.isCanceled() || keyEvent.getRepeatCount() != 0) {
            return true;
        }
        if (this.t.getBackPressedListener() != null) {
            this.t.getBackPressedListener().onBackPressed();
        }
        a(false);
        return true;
    }

    /* access modifiers changed from: protected */
    public void onResume() {
        super.onResume();
        try {
            com.cmic.sso.sdk.a aVar = this.g;
            if (aVar != null) {
                aVar.b("loginMethod", "loginAuth");
            }
            AuthnHelper.getInstance(this).loginPageInCallBack("200087", null);
        } catch (Exception e2) {
            com.cmic.sso.sdk.g.a.I.add(e2);
            a("200025", "发生未知错误", this.g, null);
        }
    }
}