package com.lantern.conn.sdk.ui.widget; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.graphics.Color; import android.net.Uri; import android.os.Bundle; import android.text.SpannableStringBuilder; import android.text.TextPaint; import android.text.TextUtils; import android.text.method.LinkMovementMethod; import android.text.style.AbsoluteSizeSpan; import android.text.style.ClickableSpan; import android.text.style.ForegroundColorSpan; import android.view.KeyEvent; import android.view.View; import android.view.ViewGroup; import android.view.inputmethod.InputMethodManager; import android.widget.Button; import android.widget.CheckBox; import android.widget.CompoundButton; import android.widget.TextView; import com.appara.feed.model.TagTemplateItem; import com.lantern.conn.sdk.R; import com.lantern.conn.sdk.WkApplication; import com.lantern.conn.sdk.analytics.AnalyticsAgent; import com.lantern.conn.sdk.config.d; import com.lantern.conn.sdk.connect.query.a.b; import com.lantern.conn.sdk.connect.query.model.AccessPoint; import com.lantern.conn.sdk.connect.query.model.AccessPointApLevel; import com.lantern.conn.sdk.core.common.BLLog; import com.lantern.conn.sdk.core.common.l; import com.xiaomi.mipush.sdk.Constants; import org.json.JSONObject; import wksdk_bluefay.a.c; /* compiled from: WkSdkWifiDialog */ public class i extends c implements d { /* renamed from: a reason: collision with root package name */ private final a f5734a; /* renamed from: b reason: collision with root package name */ private final AccessPoint f5735b; private View c; private c d; private boolean e; private boolean f; private boolean g; private boolean h; private Context i; private DialogInterface.OnClickListener j = new DialogInterface.OnClickListener() { /* class com.lantern.conn.sdk.ui.widget.i.AnonymousClass1 */ public void onClick(DialogInterface dialogInterface, int i) { if (i == -2) { AnalyticsAgent.getInstance().onEvent("passwordcan"); } else if (i == -1 && i.this.f5734a != null) { AnalyticsAgent.getInstance().onEvent("passwordcon"); boolean isChecked = ((CheckBox) i.this.c.findViewById(R.id.share_password)).isChecked(); if (isChecked) { AnalyticsAgent.getInstance().onEvent("passwordsel"); } else { AnalyticsAgent.getInstance().onEvent("passwordunsel"); } if (!i.this.f) { if (isChecked) { AnalyticsAgent.getInstance().onEvent("consharestat"); } else { AnalyticsAgent.getInstance().onEvent("consharestaf"); } } i.this.f5735b.b(i.this.d.c()); i.this.f5735b.a(i.this.d.b()); if (i.this.i != null) { ((InputMethodManager) i.this.i.getSystemService("input_method")).hideSoftInputFromWindow(i.this.getCurrentFocus().getWindowToken(), 2); } i.this.f5734a.a(isChecked, i.this.f5735b); } } }; /* compiled from: WkSdkWifiDialog */ public interface a { void a(boolean z, AccessPoint accessPoint); } public i(Context context, a aVar, AccessPoint accessPoint, boolean z, boolean z2, boolean z3) { super(context); this.i = context; this.e = z; this.f5734a = aVar; this.f5735b = accessPoint; this.f = z2; this.h = z3; } /* access modifiers changed from: private */ /* access modifiers changed from: public */ private SpannableStringBuilder b(boolean z) { String str; SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(); Context context = this.i; if (context == null) { return null; } String string = context.getResources().getString(R.string.connect_sh_can_click_title); if (z) { str = string + this.i.getResources().getString(R.string.wksdk_connect_sh_cannot_click_title_b); } else { str = string; } spannableStringBuilder.append((CharSequence) str); int length = !TextUtils.isEmpty(str) ? str.length() : 0; if (!TextUtils.isEmpty(string)) { string.length(); } spannableStringBuilder.setSpan(new ForegroundColorSpan((int) TagTemplateItem.COLOR_TEXT_DEFAULT), 0, length, 34); if (z) { String string2 = this.i.getResources().getString(R.string.connect_sh_selected_plan); spannableStringBuilder.append((CharSequence) string2); int length2 = (!TextUtils.isEmpty(string2) ? string2.length() : 0) + length; spannableStringBuilder.setSpan(new ForegroundColorSpan(-10716268), length, length2, 33); spannableStringBuilder.setSpan(new ClickableSpan() { /* class com.lantern.conn.sdk.ui.widget.i.AnonymousClass2 */ public void onClick(View view) { Intent intent = new Intent("android.intent.action.VIEW"); intent.setData(Uri.parse("https://cn.wifi.com/app_h5/connect_sdk/share_plan/")); intent.addFlags(268435456); l.a(i.this.i, intent); } public void updateDrawState(TextPaint textPaint) { textPaint.setColor(Color.parseColor("#61ABE8")); textPaint.setUnderlineText(false); } }, length, length2, 33); } spannableStringBuilder.setSpan(new AbsoluteSizeSpan(11, true), 0, spannableStringBuilder.length(), 33); return spannableStringBuilder; } @Override // wksdk_bluefay.a.c public void onCreate(Bundle bundle) { String str = null; this.c = getLayoutInflater().inflate(R.layout.wksdk_connect_wifi_dialog_b, (ViewGroup) null); this.c.setLayerType(2, null); a(this.c); if ("B".equals(d())) { this.g = false; } else { if (b.a().b(this.f5735b)) { AccessPointApLevel a2 = b.a().a(this.f5735b); if ("0".equals(a2.f5459a) || "1".equals(a2.f5459a)) { this.g = true; } else { this.g = false; } BLLog.d("aplevel apssid " + a2.getSSID() + " mShareSelected " + this.g + " securitylevel " + a2.getSecurity() + " mApLevel " + a2.f5459a, new Object[0]); } else { this.g = false; try { JSONObject a3 = d.a(this.i).a("wksdk_sas_def"); if (a3 != null) { str = a3.optString("check"); } if (!TextUtils.isEmpty(str) && "1".equals(str)) { this.g = true; } } catch (Exception e2) { BLLog.e(e2); this.g = false; } } BLLog.d("aplevel mShareSelected" + this.g, new Object[0]); } CheckBox checkBox = (CheckBox) this.c.findViewById(R.id.share_password); checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { /* class com.lantern.conn.sdk.ui.widget.i.AnonymousClass3 */ public void onCheckedChanged(CompoundButton compoundButton, boolean z) { SpannableStringBuilder b2 = i.this.b((i) z); if (b2 != null) { ((TextView) i.this.c.findViewById(R.id.sh_checkbox_selected_title)).setText(b2); if (z) { ((TextView) i.this.c.findViewById(R.id.sh_checkbox_selected_title)).setMovementMethod(LinkMovementMethod.getInstance()); } } } }); checkBox.setChecked(this.g); SpannableStringBuilder b2 = b(this.g); if (b2 != null) { ((TextView) this.c.findViewById(R.id.sh_checkbox_selected_title)).setText(b2); if (this.g) { ((TextView) this.c.findViewById(R.id.sh_checkbox_selected_title)).setMovementMethod(LinkMovementMethod.getInstance()); } } checkBox.setChecked(this.g); this.c.findViewById(R.id.share_password_layout).setVisibility(0); if (this.f) { checkBox.setChecked(true); SpannableStringBuilder b3 = b(true); if (b3 != null) { ((TextView) this.c.findViewById(R.id.sh_checkbox_selected_title)).setVisibility(8); ((TextView) this.c.findViewById(R.id.sh_title)).setVisibility(0); ((TextView) this.c.findViewById(R.id.sh_title)).setText(b3); ((TextView) this.c.findViewById(R.id.sh_title)).setMovementMethod(LinkMovementMethod.getInstance()); } checkBox.setVisibility(8); } a(true); this.d = new c(this, this.c, this.f5735b, this.e, this.f, this.h); super.onCreate(bundle); this.d.a(); b(); setOnKeyListener(new DialogInterface.OnKeyListener() { /* class com.lantern.conn.sdk.ui.widget.i.AnonymousClass4 */ public boolean onKey(DialogInterface dialogInterface, int i, KeyEvent keyEvent) { if (i != 66) { return false; } i.this.c(); return true; } }); } private void b() { View view = this.c; if (view != null) { view.postDelayed(new Runnable() { /* class com.lantern.conn.sdk.ui.widget.i.AnonymousClass5 */ public void run() { i.this.c(); } }, 180); } } /* access modifiers changed from: private */ /* access modifiers changed from: public */ private void c() { Context context = this.i; if (context != null) { try { ((InputMethodManager) context.getSystemService("input_method")).toggleSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0, 2); } catch (Exception unused) { } } } @Override // com.lantern.conn.sdk.ui.widget.d public Button a() { return b(-1); } @Override // com.lantern.conn.sdk.ui.widget.d public void a(CharSequence charSequence) { a(-1, charSequence, this.j); } @Override // com.lantern.conn.sdk.ui.widget.d public void b(CharSequence charSequence) { a(-3, charSequence, this.j); } @Override // com.lantern.conn.sdk.ui.widget.d public void c(CharSequence charSequence) { a(-2, charSequence, this.j); } private String d() { String str = "A"; try { JSONObject a2 = d.a(WkApplication.getAppContext()).a("wksdk_sh_we_selected"); String[] split = (a2 != null ? a2.optString("abtest", "A,A") : "A,A").split(Constants.ACCEPT_TIME_SEPARATOR_SP); String str2 = split[Math.abs(WkApplication.getServer().a().hashCode()) % split.length]; if ("A".equals(str2) || "B".equals(str2)) { str = str2; } } catch (Exception e2) { BLLog.e(e2); str = "A"; } BLLog.d("getShareABTest:".concat(String.valueOf(str)), new Object[0]); return str; } }