2021-06-27 20:44:35 +00:00
|
|
|
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 c.a.d.l;
|
|
|
|
import c.a.d.q;
|
|
|
|
import c.a.l.b;
|
|
|
|
import c.d.b.a.a;
|
|
|
|
import com.discord.api.auth.mfa.BackupCode;
|
|
|
|
import com.discord.api.auth.mfa.GetBackupCodesRequestBody;
|
|
|
|
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.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 */
|
|
|
|
public final class WidgetSettingsAccountBackupCodes extends AppFragment {
|
|
|
|
public static final /* synthetic */ KProperty[] $$delegatedProperties = {a.W(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 = "";
|
|
|
|
|
|
|
|
/* compiled from: WidgetSettingsAccountBackupCodes.kt */
|
|
|
|
public static final class Adapter extends MGRecyclerAdapterSimple<MGRecyclerDataPayload> {
|
|
|
|
|
|
|
|
/* compiled from: WidgetSettingsAccountBackupCodes.kt */
|
|
|
|
public static final class BackupCodeHeaderViewHolder extends MGRecyclerViewHolder<Adapter, MGRecyclerDataPayload> {
|
|
|
|
private final WidgetSettingsItemBackupCodeHeaderBinding binding;
|
|
|
|
|
|
|
|
/* JADX INFO: 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.b;
|
|
|
|
m.checkNotNullExpressionValue(textView, "binding.itemHeader");
|
|
|
|
textView.setText(((BackupCodeItemHeader) mGRecyclerDataPayload).getHeaderText());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* compiled from: WidgetSettingsAccountBackupCodes.kt */
|
|
|
|
public static final class BackupCodeViewHolder extends MGRecyclerViewHolder<Adapter, MGRecyclerDataPayload> {
|
|
|
|
private final WidgetSettingsItemBackupCodeBinding binding;
|
|
|
|
|
|
|
|
/* JADX INFO: 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.b;
|
|
|
|
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, 2131886813, new Object[]{substring, substring2}, null, 4);
|
|
|
|
if (backupCodeItem.getBackupCode().b()) {
|
|
|
|
this.binding.b.setCompoundDrawablesWithIntrinsicBounds(0, 0, 2131231501, 0);
|
|
|
|
this.binding.b.setOnClickListener(null);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
this.binding.b.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
|
|
|
|
this.binding.b.setOnClickListener(new WidgetSettingsAccountBackupCodes$Adapter$BackupCodeViewHolder$onConfigure$1(mGRecyclerDataPayload));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* JADX INFO: 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<Adapter, MGRecyclerDataPayload> onCreateViewHolder(ViewGroup viewGroup, int i) {
|
|
|
|
m.checkNotNullParameter(viewGroup, "parent");
|
2021-06-27 20:53:42 +00:00
|
|
|
return i != 0 ? i != 1 ? new MGRecyclerViewHolder<>(0, this) : new BackupCodeViewHolder(2131559205, this) : new BackupCodeHeaderViewHolder(2131559206, this);
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* compiled from: WidgetSettingsAccountBackupCodes.kt */
|
|
|
|
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 L = a.L("BackupCodeItem(backupCode=");
|
|
|
|
L.append(this.backupCode);
|
|
|
|
L.append(")");
|
|
|
|
return L.toString();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* compiled from: WidgetSettingsAccountBackupCodes.kt */
|
|
|
|
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() {
|
|
|
|
StringBuilder L = a.L("BackupCodeItemHeader(headerText=");
|
|
|
|
L.append(this.headerText);
|
|
|
|
L.append(")");
|
|
|
|
return L.toString();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* compiled from: WidgetSettingsAccountBackupCodes.kt */
|
|
|
|
public static final class Companion {
|
|
|
|
private Companion() {
|
|
|
|
}
|
|
|
|
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
|
|
this();
|
|
|
|
}
|
|
|
|
|
|
|
|
public final void launch(Context context) {
|
|
|
|
m.checkNotNullParameter(context, "context");
|
|
|
|
l.d(context, WidgetSettingsAccountBackupCodes.class, new Intent());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public WidgetSettingsAccountBackupCodes() {
|
2021-06-27 20:53:42 +00:00
|
|
|
super(2131559184);
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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$getPassword$p(WidgetSettingsAccountBackupCodes widgetSettingsAccountBackupCodes) {
|
|
|
|
return widgetSettingsAccountBackupCodes.password;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final /* synthetic */ void access$setPassword$p(WidgetSettingsAccountBackupCodes widgetSettingsAccountBackupCodes, String str) {
|
|
|
|
widgetSettingsAccountBackupCodes.password = str;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final /* synthetic */ void access$showPasswordModal(WidgetSettingsAccountBackupCodes widgetSettingsAccountBackupCodes) {
|
|
|
|
widgetSettingsAccountBackupCodes.showPasswordModal();
|
|
|
|
}
|
|
|
|
|
|
|
|
private final void configureUI(List<? extends MGRecyclerDataPayload> 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().getBackupCodes(new GetBackupCodesRequestBody(this.password, z2)), this, null, 2, null), getBinding().b, 100), false, 1, null).k(q.a.g(getContext(), new WidgetSettingsAccountBackupCodes$getBackupCodes$1(this), new WidgetSettingsAccountBackupCodes$getBackupCodes$2(this)));
|
|
|
|
}
|
|
|
|
|
|
|
|
private final WidgetSettingsAccountBackupCodesBinding getBinding() {
|
|
|
|
return (WidgetSettingsAccountBackupCodesBinding) this.binding$delegate.getValue((Fragment) this, $$delegatedProperties[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
private final void showPasswordModal() {
|
|
|
|
AppActivity appActivity = getAppActivity();
|
|
|
|
if (appActivity != null) {
|
|
|
|
getBinding().b.setDimmed(true, true);
|
2021-06-27 20:53:42 +00:00
|
|
|
WidgetNoticeDialog.Companion.showInputModal(appActivity, b.g(requireContext(), 2131893985, new Object[0], null, 4), b.g(requireContext(), 2131894312, new Object[0], null, 4), b.g(requireContext(), 2131888715, new Object[0], null, 4), new WidgetSettingsAccountBackupCodes$showPasswordModal$$inlined$let$lambda$1(this), new WidgetSettingsAccountBackupCodes$showPasswordModal$$inlined$let$lambda$2(this), Boolean.FALSE);
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // com.discord.app.AppFragment
|
|
|
|
public void onViewBound(View view) {
|
|
|
|
m.checkNotNullParameter(view, "view");
|
|
|
|
super.onViewBound(view);
|
2021-06-27 20:53:42 +00:00
|
|
|
setActionBarSubtitle(2131894256);
|
|
|
|
setActionBarTitle(2131893985);
|
2021-06-27 20:44:35 +00:00
|
|
|
AppFragment.setActionBarDisplayHomeAsUpEnabled$default(this, false, 1, null);
|
|
|
|
TextView textView = getBinding().d;
|
|
|
|
m.checkNotNullExpressionValue(textView, "binding.settingsBackupCodesInfo");
|
2021-06-27 20:53:42 +00:00
|
|
|
b.n(textView, 2131893984, new Object[0], null, 4);
|
2021-06-27 20:44:35 +00:00
|
|
|
RecyclerView recyclerView = getBinding().e;
|
|
|
|
m.checkNotNullExpressionValue(recyclerView, "binding.settingsBackupCodesRv");
|
|
|
|
this.backupCodesAdapter = new Adapter(recyclerView);
|
|
|
|
if (getActivity() != null) {
|
|
|
|
MGRecyclerAdapter.Companion companion = MGRecyclerAdapter.Companion;
|
|
|
|
RecyclerView recyclerView2 = getBinding().e;
|
|
|
|
m.checkNotNullExpressionValue(recyclerView2, "binding.settingsBackupCodesRv");
|
|
|
|
this.backupCodesAdapter = (Adapter) companion.configure(new Adapter(recyclerView2));
|
|
|
|
}
|
2021-06-27 20:53:42 +00:00
|
|
|
getBinding().f1903c.setOnClickListener(new WidgetSettingsAccountBackupCodes$onViewBound$2(this));
|
2021-06-27 20:44:35 +00:00
|
|
|
showPasswordModal();
|
|
|
|
}
|
|
|
|
}
|