package com.discord.widgets.settings.account; import android.content.Context; import android.content.Intent; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import androidx.annotation.LayoutRes; import androidx.fragment.app.Fragment; import androidx.recyclerview.widget.RecyclerView; import b.a.d.j; import b.a.d.o; import b.a.k.b; import b.d.b.a.a; import com.discord.R; import com.discord.api.auth.mfa.BackupCode; import com.discord.api.auth.mfa.GetBackupCodesSendVerificationKeyRequestBody; import com.discord.api.auth.mfa.GetBackupCodesVerificationRequestBody; import com.discord.app.AppActivity; import com.discord.app.AppFragment; import com.discord.databinding.WidgetSettingsAccountBackupCodesBinding; import com.discord.databinding.WidgetSettingsItemBackupCodeBinding; import com.discord.databinding.WidgetSettingsItemBackupCodeHeaderBinding; import com.discord.stores.StoreNotices; import com.discord.utilities.mg_recycler.MGRecyclerAdapter; import com.discord.utilities.mg_recycler.MGRecyclerAdapterSimple; import com.discord.utilities.mg_recycler.MGRecyclerDataPayload; import com.discord.utilities.mg_recycler.MGRecyclerViewHolder; import com.discord.utilities.rest.RestAPI; import com.discord.utilities.rx.ObservableExtensionsKt; import com.discord.utilities.viewbinding.FragmentViewBindingDelegate; import com.discord.utilities.viewbinding.FragmentViewBindingDelegateKt; import com.discord.widgets.notice.WidgetNoticeDialog; import d0.z.d.m; import java.util.List; import java.util.Objects; import kotlin.jvm.internal.DefaultConstructorMarker; import kotlin.reflect.KProperty; /* compiled from: WidgetSettingsAccountBackupCodes.kt */ /* loaded from: classes2.dex */ public final class WidgetSettingsAccountBackupCodes extends AppFragment { public static final /* synthetic */ KProperty[] $$delegatedProperties = {a.c0(WidgetSettingsAccountBackupCodes.class, "binding", "getBinding()Lcom/discord/databinding/WidgetSettingsAccountBackupCodesBinding;", 0)}; public static final Companion Companion = new Companion(null); private Adapter backupCodesAdapter; private final FragmentViewBindingDelegate binding$delegate = FragmentViewBindingDelegateKt.viewBinding$default(this, WidgetSettingsAccountBackupCodes$binding$2.INSTANCE, null, 2, null); private String password = ""; private String nonce = ""; private String regenerateNonce = ""; private String verificationKey = ""; /* compiled from: WidgetSettingsAccountBackupCodes.kt */ /* loaded from: classes2.dex */ public static final class Adapter extends MGRecyclerAdapterSimple { /* compiled from: WidgetSettingsAccountBackupCodes.kt */ /* loaded from: classes2.dex */ public static final class BackupCodeHeaderViewHolder extends MGRecyclerViewHolder { private final WidgetSettingsItemBackupCodeHeaderBinding binding; /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */ public BackupCodeHeaderViewHolder(@LayoutRes int i, Adapter adapter) { super(i, adapter); m.checkNotNullParameter(adapter, "adapter"); View view = this.itemView; Objects.requireNonNull(view, "rootView"); TextView textView = (TextView) view; WidgetSettingsItemBackupCodeHeaderBinding widgetSettingsItemBackupCodeHeaderBinding = new WidgetSettingsItemBackupCodeHeaderBinding(textView, textView); m.checkNotNullExpressionValue(widgetSettingsItemBackupCodeHeaderBinding, "WidgetSettingsItemBackup…derBinding.bind(itemView)"); this.binding = widgetSettingsItemBackupCodeHeaderBinding; } public void onConfigure(int i, MGRecyclerDataPayload mGRecyclerDataPayload) { m.checkNotNullParameter(mGRecyclerDataPayload, "data"); super.onConfigure(i, (int) mGRecyclerDataPayload); TextView textView = this.binding.f2602b; m.checkNotNullExpressionValue(textView, "binding.itemHeader"); textView.setText(((BackupCodeItemHeader) mGRecyclerDataPayload).getHeaderText()); } } /* compiled from: WidgetSettingsAccountBackupCodes.kt */ /* loaded from: classes2.dex */ public static final class BackupCodeViewHolder extends MGRecyclerViewHolder { private final WidgetSettingsItemBackupCodeBinding binding; /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */ public BackupCodeViewHolder(@LayoutRes int i, Adapter adapter) { super(i, adapter); m.checkNotNullParameter(adapter, "adapter"); View view = this.itemView; Objects.requireNonNull(view, "rootView"); TextView textView = (TextView) view; WidgetSettingsItemBackupCodeBinding widgetSettingsItemBackupCodeBinding = new WidgetSettingsItemBackupCodeBinding(textView, textView); m.checkNotNullExpressionValue(widgetSettingsItemBackupCodeBinding, "WidgetSettingsItemBackupCodeBinding.bind(itemView)"); this.binding = widgetSettingsItemBackupCodeBinding; } public void onConfigure(int i, MGRecyclerDataPayload mGRecyclerDataPayload) { m.checkNotNullParameter(mGRecyclerDataPayload, "data"); super.onConfigure(i, (int) mGRecyclerDataPayload); BackupCodeItem backupCodeItem = (BackupCodeItem) mGRecyclerDataPayload; TextView textView = this.binding.f2601b; m.checkNotNullExpressionValue(textView, "binding.itemBackupCodeTv"); String a = backupCodeItem.getBackupCode().a(); Objects.requireNonNull(a, "null cannot be cast to non-null type java.lang.String"); String substring = a.substring(0, 4); m.checkNotNullExpressionValue(substring, "(this as java.lang.Strin…ing(startIndex, endIndex)"); String a2 = backupCodeItem.getBackupCode().a(); Objects.requireNonNull(a2, "null cannot be cast to non-null type java.lang.String"); String substring2 = a2.substring(4); m.checkNotNullExpressionValue(substring2, "(this as java.lang.String).substring(startIndex)"); b.n(textView, R.string.backup_codes_dash, new Object[]{substring, substring2}, null, 4); if (backupCodeItem.getBackupCode().b()) { this.binding.f2601b.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_check_brand_24dp, 0); this.binding.f2601b.setOnClickListener(null); return; } this.binding.f2601b.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0); this.binding.f2601b.setOnClickListener(new WidgetSettingsAccountBackupCodes$Adapter$BackupCodeViewHolder$onConfigure$1(mGRecyclerDataPayload)); } } /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */ public Adapter(RecyclerView recyclerView) { super(recyclerView, false, 2, null); m.checkNotNullParameter(recyclerView, "recyclerView"); } @Override // androidx.recyclerview.widget.RecyclerView.Adapter public MGRecyclerViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) { m.checkNotNullParameter(viewGroup, "parent"); return i != 0 ? i != 1 ? new MGRecyclerViewHolder<>(0, this) : new BackupCodeViewHolder(R.layout.widget_settings_item_backup_code, this) : new BackupCodeHeaderViewHolder(R.layout.widget_settings_item_backup_code_header, this); } } /* compiled from: WidgetSettingsAccountBackupCodes.kt */ /* loaded from: classes2.dex */ public static final class BackupCodeItem implements MGRecyclerDataPayload { private final BackupCode backupCode; private final String key; private final int type = 1; public BackupCodeItem(BackupCode backupCode) { m.checkNotNullParameter(backupCode, "backupCode"); this.backupCode = backupCode; this.key = backupCode.a(); } public static /* synthetic */ BackupCodeItem copy$default(BackupCodeItem backupCodeItem, BackupCode backupCode, int i, Object obj) { if ((i & 1) != 0) { backupCode = backupCodeItem.backupCode; } return backupCodeItem.copy(backupCode); } public final BackupCode component1() { return this.backupCode; } public final BackupCodeItem copy(BackupCode backupCode) { m.checkNotNullParameter(backupCode, "backupCode"); return new BackupCodeItem(backupCode); } public boolean equals(Object obj) { if (this != obj) { return (obj instanceof BackupCodeItem) && m.areEqual(this.backupCode, ((BackupCodeItem) obj).backupCode); } return true; } public final BackupCode getBackupCode() { return this.backupCode; } @Override // com.discord.utilities.mg_recycler.MGRecyclerDataPayload, com.discord.utilities.recycler.DiffKeyProvider public String getKey() { return this.key; } @Override // com.discord.utilities.mg_recycler.MGRecyclerDataPayload public int getType() { return this.type; } public int hashCode() { BackupCode backupCode = this.backupCode; if (backupCode != null) { return backupCode.hashCode(); } return 0; } public String toString() { StringBuilder S = a.S("BackupCodeItem(backupCode="); S.append(this.backupCode); S.append(")"); return S.toString(); } } /* compiled from: WidgetSettingsAccountBackupCodes.kt */ /* loaded from: classes2.dex */ public static final class BackupCodeItemHeader implements MGRecyclerDataPayload { private final CharSequence headerText; private final String key; private final int type; public BackupCodeItemHeader(CharSequence charSequence) { m.checkNotNullParameter(charSequence, "headerText"); this.headerText = charSequence; this.key = charSequence.toString(); } public static /* synthetic */ BackupCodeItemHeader copy$default(BackupCodeItemHeader backupCodeItemHeader, CharSequence charSequence, int i, Object obj) { if ((i & 1) != 0) { charSequence = backupCodeItemHeader.headerText; } return backupCodeItemHeader.copy(charSequence); } public final CharSequence component1() { return this.headerText; } public final BackupCodeItemHeader copy(CharSequence charSequence) { m.checkNotNullParameter(charSequence, "headerText"); return new BackupCodeItemHeader(charSequence); } public boolean equals(Object obj) { if (this != obj) { return (obj instanceof BackupCodeItemHeader) && m.areEqual(this.headerText, ((BackupCodeItemHeader) obj).headerText); } return true; } public final CharSequence getHeaderText() { return this.headerText; } @Override // com.discord.utilities.mg_recycler.MGRecyclerDataPayload, com.discord.utilities.recycler.DiffKeyProvider public String getKey() { return this.key; } @Override // com.discord.utilities.mg_recycler.MGRecyclerDataPayload public int getType() { return this.type; } public int hashCode() { CharSequence charSequence = this.headerText; if (charSequence != null) { return charSequence.hashCode(); } return 0; } public String toString() { return a.D(a.S("BackupCodeItemHeader(headerText="), this.headerText, ")"); } } /* compiled from: WidgetSettingsAccountBackupCodes.kt */ /* loaded from: classes2.dex */ public static final class Companion { private Companion() { } public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) { this(); } public final void launch(Context context) { m.checkNotNullParameter(context, "context"); j.d(context, WidgetSettingsAccountBackupCodes.class, new Intent()); } } public WidgetSettingsAccountBackupCodes() { super(R.layout.widget_settings_account_backup_codes); } public static final /* synthetic */ void access$configureUI(WidgetSettingsAccountBackupCodes widgetSettingsAccountBackupCodes, List list) { widgetSettingsAccountBackupCodes.configureUI(list); } public static final /* synthetic */ void access$getBackupCodes(WidgetSettingsAccountBackupCodes widgetSettingsAccountBackupCodes, boolean z2) { widgetSettingsAccountBackupCodes.getBackupCodes(z2); } public static final /* synthetic */ String access$getNonce$p(WidgetSettingsAccountBackupCodes widgetSettingsAccountBackupCodes) { return widgetSettingsAccountBackupCodes.nonce; } public static final /* synthetic */ String access$getPassword$p(WidgetSettingsAccountBackupCodes widgetSettingsAccountBackupCodes) { return widgetSettingsAccountBackupCodes.password; } public static final /* synthetic */ String access$getRegenerateNonce$p(WidgetSettingsAccountBackupCodes widgetSettingsAccountBackupCodes) { return widgetSettingsAccountBackupCodes.regenerateNonce; } public static final /* synthetic */ String access$getVerificationKey$p(WidgetSettingsAccountBackupCodes widgetSettingsAccountBackupCodes) { return widgetSettingsAccountBackupCodes.verificationKey; } public static final /* synthetic */ void access$sendVerificationKey(WidgetSettingsAccountBackupCodes widgetSettingsAccountBackupCodes) { widgetSettingsAccountBackupCodes.sendVerificationKey(); } public static final /* synthetic */ void access$setNonce$p(WidgetSettingsAccountBackupCodes widgetSettingsAccountBackupCodes, String str) { widgetSettingsAccountBackupCodes.nonce = str; } public static final /* synthetic */ void access$setPassword$p(WidgetSettingsAccountBackupCodes widgetSettingsAccountBackupCodes, String str) { widgetSettingsAccountBackupCodes.password = str; } public static final /* synthetic */ void access$setRegenerateNonce$p(WidgetSettingsAccountBackupCodes widgetSettingsAccountBackupCodes, String str) { widgetSettingsAccountBackupCodes.regenerateNonce = str; } public static final /* synthetic */ void access$setVerificationKey$p(WidgetSettingsAccountBackupCodes widgetSettingsAccountBackupCodes, String str) { widgetSettingsAccountBackupCodes.verificationKey = str; } public static final /* synthetic */ void access$showPasswordModal(WidgetSettingsAccountBackupCodes widgetSettingsAccountBackupCodes) { widgetSettingsAccountBackupCodes.showPasswordModal(); } public static final /* synthetic */ void access$showVerificationKeyModal(WidgetSettingsAccountBackupCodes widgetSettingsAccountBackupCodes) { widgetSettingsAccountBackupCodes.showVerificationKeyModal(); } private final void configureUI(List list) { Adapter adapter = this.backupCodesAdapter; if (adapter == null) { m.throwUninitializedPropertyAccessException("backupCodesAdapter"); } adapter.setData(list); } private final void getBackupCodes(boolean z2) { ObservableExtensionsKt.restSubscribeOn$default(ObservableExtensionsKt.withDimmer(ObservableExtensionsKt.ui$default(RestAPI.Companion.getApi().getBackupCodesVerification(new GetBackupCodesVerificationRequestBody(this.verificationKey, z2 ? this.regenerateNonce : this.nonce, z2)), this, null, 2, null), getBinding().f2568b, 100L), false, 1, null).k(o.a.g(getContext(), new WidgetSettingsAccountBackupCodes$getBackupCodes$1(this), null)); } public static /* synthetic */ void getBackupCodes$default(WidgetSettingsAccountBackupCodes widgetSettingsAccountBackupCodes, boolean z2, int i, Object obj) { if ((i & 1) != 0) { z2 = false; } widgetSettingsAccountBackupCodes.getBackupCodes(z2); } private final WidgetSettingsAccountBackupCodesBinding getBinding() { return (WidgetSettingsAccountBackupCodesBinding) this.binding$delegate.getValue((Fragment) this, $$delegatedProperties[0]); } private final void sendVerificationKey() { ObservableExtensionsKt.restSubscribeOn$default(ObservableExtensionsKt.ui$default(RestAPI.Companion.getApi().getBackupCodesSendVerificationKey(new GetBackupCodesSendVerificationKeyRequestBody(this.password)), this, null, 2, null), false, 1, null).k(o.a.g(getContext(), new WidgetSettingsAccountBackupCodes$sendVerificationKey$1(this), new WidgetSettingsAccountBackupCodes$sendVerificationKey$2(this))); } private final void showPasswordModal() { AppActivity appActivity = getAppActivity(); if (appActivity != null) { WidgetNoticeDialog.Companion companion = WidgetNoticeDialog.Companion; CharSequence h = b.h(requireContext(), R.string.user_settings_enter_password_view_codes, new Object[0], null, 4); CharSequence h2 = b.h(requireContext(), R.string.form_label_password, new Object[0], null, 4); WidgetNoticeDialog.Companion.showInputModal$default(companion, appActivity, b.h(requireContext(), R.string.two_fa_backup_codes_label, new Object[0], null, 4), h, h2, new WidgetSettingsAccountBackupCodes$showPasswordModal$$inlined$let$lambda$1(this), new WidgetSettingsAccountBackupCodes$showPasswordModal$$inlined$let$lambda$2(this), Boolean.FALSE, null, b.h(requireContext(), R.string.two_fa_backup_codes_next_action, new Object[0], null, 4), false, 640, null); } } private final void showVerificationKeyModal() { AppActivity appActivity = getAppActivity(); if (appActivity != null) { WidgetNoticeDialog.Companion.showInputModal$default(WidgetNoticeDialog.Companion, appActivity, b.h(requireContext(), R.string.two_fa_confirm_view_backup_codes_label, new Object[0], null, 4), b.h(requireContext(), R.string.two_fa_confirm_view_backup_codes_body, new Object[0], null, 4), b.h(requireContext(), R.string.two_fa_confirm_view_backup_codes_input_label, new Object[0], null, 4), new WidgetSettingsAccountBackupCodes$showVerificationKeyModal$$inlined$let$lambda$1(this), new WidgetSettingsAccountBackupCodes$showVerificationKeyModal$$inlined$let$lambda$2(this), Boolean.FALSE, StoreNotices.InputDialog.Type.TEXT_NO_SUGGESTIONS, null, true, 256, null); } } @Override // com.discord.app.AppFragment public void onViewBound(View view) { m.checkNotNullParameter(view, "view"); super.onViewBound(view); setActionBarSubtitle(R.string.user_settings); setActionBarTitle(R.string.two_fa_backup_codes_label); AppFragment.setActionBarDisplayHomeAsUpEnabled$default(this, false, 1, null); TextView textView = getBinding().d; m.checkNotNullExpressionValue(textView, "binding.settingsBackupCodesInfo"); b.n(textView, R.string.two_fa_backup_codes_body, new Object[0], null, 4); RecyclerView recyclerView = getBinding().e; m.checkNotNullExpressionValue(recyclerView, "binding.settingsBackupCodesRv"); this.backupCodesAdapter = new Adapter(recyclerView); if (e() != null) { MGRecyclerAdapter.Companion companion = MGRecyclerAdapter.Companion; RecyclerView recyclerView2 = getBinding().e; m.checkNotNullExpressionValue(recyclerView2, "binding.settingsBackupCodesRv"); this.backupCodesAdapter = (Adapter) companion.configure(new Adapter(recyclerView2)); } getBinding().c.setOnClickListener(new WidgetSettingsAccountBackupCodes$onViewBound$2(this)); getBinding().f2568b.setDimmed(true, true); showPasswordModal(); } }