320 lines
14 KiB
Java
320 lines
14 KiB
Java
package com.discord.widgets.servers;
|
|
|
|
import a0.a.a.b;
|
|
import android.content.Context;
|
|
import android.content.DialogInterface;
|
|
import android.content.Intent;
|
|
import android.content.res.ColorStateList;
|
|
import android.os.Bundle;
|
|
import android.view.View;
|
|
import android.widget.LinearLayout;
|
|
import android.widget.TextView;
|
|
import androidx.fragment.app.Fragment;
|
|
import androidx.fragment.app.FragmentManager;
|
|
import c.a.d.l;
|
|
import c.d.b.a.a;
|
|
import com.discord.app.AppActivity;
|
|
import com.discord.app.AppDialog;
|
|
import com.discord.app.AppFragment;
|
|
import com.discord.databinding.WidgetServerSettingsSecurityBinding;
|
|
import com.discord.databinding.WidgetServerSettingsSecurityDialogBinding;
|
|
import com.discord.stores.StoreStream;
|
|
import com.discord.stores.StoreUser;
|
|
import com.discord.utilities.color.ColorCompat;
|
|
import com.discord.utilities.rx.ObservableExtensionsKt;
|
|
import com.discord.utilities.viewbinding.FragmentViewBindingDelegate;
|
|
import com.discord.utilities.viewbinding.FragmentViewBindingDelegateKt;
|
|
import com.google.android.material.button.MaterialButton;
|
|
import d0.g;
|
|
import d0.z.d.m;
|
|
import kotlin.Lazy;
|
|
import kotlin.jvm.functions.Function0;
|
|
import kotlin.jvm.functions.Function1;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
import kotlin.reflect.KProperty;
|
|
import rx.Observable;
|
|
/* compiled from: WidgetServerSettingsSecurity.kt */
|
|
public final class WidgetServerSettingsSecurity extends AppFragment {
|
|
public static final /* synthetic */ KProperty[] $$delegatedProperties = {a.W(WidgetServerSettingsSecurity.class, "binding", "getBinding()Lcom/discord/databinding/WidgetServerSettingsSecurityBinding;", 0)};
|
|
public static final Companion Companion = new Companion(null);
|
|
private static final String INTENT_EXTRA_GUILD_ID = "INTENT_EXTRA_GUILD_ID";
|
|
private static final String TAG_TOGGLE_MFA_DIALOG = "TAG_TOGGLE_MFA_DIALOG";
|
|
private final FragmentViewBindingDelegate binding$delegate = FragmentViewBindingDelegateKt.viewBinding$default(this, WidgetServerSettingsSecurity$binding$2.INSTANCE, null, 2, null);
|
|
private final Lazy guildId$delegate = g.lazy(new WidgetServerSettingsSecurity$guildId$2(this));
|
|
|
|
/* compiled from: WidgetServerSettingsSecurity.kt */
|
|
public static final class Companion {
|
|
private Companion() {
|
|
}
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
|
|
public final void create(Context context, long j) {
|
|
m.checkNotNullParameter(context, "context");
|
|
StoreStream.Companion.getAnalytics().onGuildSettingsPaneViewed("SECURITY", j);
|
|
Intent putExtra = new Intent().putExtra("INTENT_EXTRA_GUILD_ID", j);
|
|
m.checkNotNullExpressionValue(putExtra, "Intent().putExtra(INTENT_EXTRA_GUILD_ID, guildId)");
|
|
l.d(context, WidgetServerSettingsSecurity.class, putExtra);
|
|
}
|
|
}
|
|
|
|
/* compiled from: WidgetServerSettingsSecurity.kt */
|
|
public static final class Model {
|
|
public static final Companion Companion = new Companion(null);
|
|
private final long guildId;
|
|
private final String guildName;
|
|
private final boolean isMfaEnabled;
|
|
|
|
/* compiled from: WidgetServerSettingsSecurity.kt */
|
|
public static final class Companion {
|
|
private Companion() {
|
|
}
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
|
|
public final Observable<Model> get(long j) {
|
|
StoreStream.Companion companion = StoreStream.Companion;
|
|
Observable j2 = Observable.j(StoreUser.observeMe$default(companion.getUsers(), false, 1, null), companion.getGuilds().observeGuild(j), WidgetServerSettingsSecurity$Model$Companion$get$1.INSTANCE);
|
|
m.checkNotNullExpressionValue(j2, "Observable\n … )\n }");
|
|
Observable<Model> r = ObservableExtensionsKt.computationLatest(j2).r();
|
|
m.checkNotNullExpressionValue(r, "Observable\n … .distinctUntilChanged()");
|
|
return r;
|
|
}
|
|
}
|
|
|
|
public Model(long j, String str, boolean z2) {
|
|
this.guildId = j;
|
|
this.guildName = str;
|
|
this.isMfaEnabled = z2;
|
|
}
|
|
|
|
public static /* synthetic */ Model copy$default(Model model, long j, String str, boolean z2, int i, Object obj) {
|
|
if ((i & 1) != 0) {
|
|
j = model.guildId;
|
|
}
|
|
if ((i & 2) != 0) {
|
|
str = model.guildName;
|
|
}
|
|
if ((i & 4) != 0) {
|
|
z2 = model.isMfaEnabled;
|
|
}
|
|
return model.copy(j, str, z2);
|
|
}
|
|
|
|
public final long component1() {
|
|
return this.guildId;
|
|
}
|
|
|
|
public final String component2() {
|
|
return this.guildName;
|
|
}
|
|
|
|
public final boolean component3() {
|
|
return this.isMfaEnabled;
|
|
}
|
|
|
|
public final Model copy(long j, String str, boolean z2) {
|
|
return new Model(j, str, z2);
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (this == obj) {
|
|
return true;
|
|
}
|
|
if (!(obj instanceof Model)) {
|
|
return false;
|
|
}
|
|
Model model = (Model) obj;
|
|
return this.guildId == model.guildId && m.areEqual(this.guildName, model.guildName) && this.isMfaEnabled == model.isMfaEnabled;
|
|
}
|
|
|
|
public final long getGuildId() {
|
|
return this.guildId;
|
|
}
|
|
|
|
public final String getGuildName() {
|
|
return this.guildName;
|
|
}
|
|
|
|
public int hashCode() {
|
|
int a = b.a(this.guildId) * 31;
|
|
String str = this.guildName;
|
|
int hashCode = (a + (str != null ? str.hashCode() : 0)) * 31;
|
|
boolean z2 = this.isMfaEnabled;
|
|
if (z2) {
|
|
z2 = true;
|
|
}
|
|
int i = z2 ? 1 : 0;
|
|
int i2 = z2 ? 1 : 0;
|
|
int i3 = z2 ? 1 : 0;
|
|
return hashCode + i;
|
|
}
|
|
|
|
public final boolean isMfaEnabled() {
|
|
return this.isMfaEnabled;
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder L = a.L("Model(guildId=");
|
|
L.append(this.guildId);
|
|
L.append(", guildName=");
|
|
L.append(this.guildName);
|
|
L.append(", isMfaEnabled=");
|
|
return a.G(L, this.isMfaEnabled, ")");
|
|
}
|
|
}
|
|
|
|
/* compiled from: WidgetServerSettingsSecurity.kt */
|
|
public static final class ToggleMfaDialog extends AppDialog {
|
|
public static final /* synthetic */ KProperty[] $$delegatedProperties = {a.W(ToggleMfaDialog.class, "binding", "getBinding()Lcom/discord/databinding/WidgetServerSettingsSecurityDialogBinding;", 0)};
|
|
private static final String ARG_GUILD_ID = "ARG_GUILD_ID";
|
|
private static final String ARG_MFA_ENABLED = "ARG_MFA_ENABLED";
|
|
public static final Companion Companion = new Companion(null);
|
|
private final FragmentViewBindingDelegate binding$delegate = FragmentViewBindingDelegateKt.viewBinding$default(this, WidgetServerSettingsSecurity$ToggleMfaDialog$binding$2.INSTANCE, null, 2, null);
|
|
private final Lazy guildId$delegate = g.lazy(new WidgetServerSettingsSecurity$ToggleMfaDialog$guildId$2(this));
|
|
private final Lazy mfaEnabled$delegate = g.lazy(new WidgetServerSettingsSecurity$ToggleMfaDialog$mfaEnabled$2(this));
|
|
|
|
/* compiled from: WidgetServerSettingsSecurity.kt */
|
|
public static final class Companion {
|
|
private Companion() {
|
|
}
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
|
|
public final void show(FragmentManager fragmentManager, long j, boolean z2) {
|
|
m.checkNotNullParameter(fragmentManager, "fragmentManager");
|
|
ToggleMfaDialog toggleMfaDialog = new ToggleMfaDialog();
|
|
Bundle bundle = new Bundle();
|
|
bundle.putLong("ARG_GUILD_ID", j);
|
|
bundle.putBoolean("ARG_MFA_ENABLED", z2);
|
|
toggleMfaDialog.setArguments(bundle);
|
|
toggleMfaDialog.show(fragmentManager, "TAG_TOGGLE_MFA_DIALOG");
|
|
}
|
|
}
|
|
|
|
public ToggleMfaDialog() {
|
|
super(2131559200);
|
|
}
|
|
|
|
public static final /* synthetic */ Bundle access$getArgumentsOrDefault$p(ToggleMfaDialog toggleMfaDialog) {
|
|
return toggleMfaDialog.getArgumentsOrDefault();
|
|
}
|
|
|
|
public static final /* synthetic */ WidgetServerSettingsSecurityDialogBinding access$getBinding$p(ToggleMfaDialog toggleMfaDialog) {
|
|
return toggleMfaDialog.getBinding();
|
|
}
|
|
|
|
private final WidgetServerSettingsSecurityDialogBinding getBinding() {
|
|
return (WidgetServerSettingsSecurityDialogBinding) this.binding$delegate.getValue((Fragment) this, $$delegatedProperties[0]);
|
|
}
|
|
|
|
private final long getGuildId() {
|
|
return ((Number) this.guildId$delegate.getValue()).longValue();
|
|
}
|
|
|
|
private final boolean getMfaEnabled() {
|
|
return ((Boolean) this.mfaEnabled$delegate.getValue()).booleanValue();
|
|
}
|
|
|
|
public final void configure(long j, boolean z2) {
|
|
if (j <= 0) {
|
|
dismiss();
|
|
}
|
|
getBinding().f1913c.setText(z2 ? 2131888123 : 2131888325);
|
|
MaterialButton materialButton = getBinding().f1913c;
|
|
m.checkNotNullExpressionValue(materialButton, "binding.serverSettingsSecurityDialogConfirm");
|
|
WidgetServerSettingsSecurityDialogBinding binding = getBinding();
|
|
m.checkNotNullExpressionValue(binding, "binding");
|
|
LinearLayout linearLayout = binding.a;
|
|
m.checkNotNullExpressionValue(linearLayout, "binding.root");
|
|
materialButton.setBackgroundTintList(ColorStateList.valueOf(ColorCompat.getColor(linearLayout.getContext(), z2 ? 2131100324 : 2131100249)));
|
|
getBinding().f1913c.setOnClickListener(new WidgetServerSettingsSecurity$ToggleMfaDialog$configure$1(this, z2, j));
|
|
getBinding().b.setOnClickListener(new WidgetServerSettingsSecurity$ToggleMfaDialog$configure$2(this));
|
|
}
|
|
|
|
@Override // androidx.fragment.app.DialogFragment, android.content.DialogInterface.OnDismissListener
|
|
public void onDismiss(DialogInterface dialogInterface) {
|
|
m.checkNotNullParameter(dialogInterface, "dialog");
|
|
super.onDismiss(dialogInterface);
|
|
AppDialog.hideKeyboard$default(this, null, 1, null);
|
|
}
|
|
|
|
@Override // com.discord.app.AppDialog
|
|
public void onViewBoundOrOnResume() {
|
|
super.onViewBoundOrOnResume();
|
|
configure(getGuildId(), getMfaEnabled());
|
|
}
|
|
}
|
|
|
|
public WidgetServerSettingsSecurity() {
|
|
super(2131559199);
|
|
}
|
|
|
|
public static final /* synthetic */ void access$configureUI(WidgetServerSettingsSecurity widgetServerSettingsSecurity, Model model) {
|
|
widgetServerSettingsSecurity.configureUI(model);
|
|
}
|
|
|
|
private final void configureUI(Model model) {
|
|
if (model == null) {
|
|
AppActivity appActivity = getAppActivity();
|
|
if (appActivity != null) {
|
|
appActivity.onBackPressed();
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
setActionBarTitle(2131893290);
|
|
setActionBarSubtitle(model.getGuildName());
|
|
if (model.isMfaEnabled()) {
|
|
getBinding().f1912c.setText(2131889389);
|
|
MaterialButton materialButton = getBinding().f1912c;
|
|
m.checkNotNullExpressionValue(materialButton, "binding.serverSettingsSecurityToggleMfaButton");
|
|
materialButton.setBackgroundTintList(ColorStateList.valueOf(ColorCompat.getColor(requireContext(), 2131100324)));
|
|
} else {
|
|
getBinding().f1912c.setText(2131889390);
|
|
MaterialButton materialButton2 = getBinding().f1912c;
|
|
m.checkNotNullExpressionValue(materialButton2, "binding.serverSettingsSecurityToggleMfaButton");
|
|
materialButton2.setBackgroundTintList(ColorStateList.valueOf(ColorCompat.getColor(requireContext(), 2131100249)));
|
|
}
|
|
Fragment findFragmentByTag = getParentFragmentManager().findFragmentByTag("TAG_TOGGLE_MFA_DIALOG");
|
|
if (findFragmentByTag != null) {
|
|
((ToggleMfaDialog) findFragmentByTag).configure(model.getGuildId(), model.isMfaEnabled());
|
|
}
|
|
getBinding().f1912c.setOnClickListener(new WidgetServerSettingsSecurity$configureUI$1(this, model));
|
|
}
|
|
|
|
private final WidgetServerSettingsSecurityBinding getBinding() {
|
|
return (WidgetServerSettingsSecurityBinding) this.binding$delegate.getValue((Fragment) this, $$delegatedProperties[0]);
|
|
}
|
|
|
|
private final long getGuildId() {
|
|
return ((Number) this.guildId$delegate.getValue()).longValue();
|
|
}
|
|
|
|
@Override // com.discord.app.AppFragment
|
|
public void onViewBound(View view) {
|
|
m.checkNotNullParameter(view, "view");
|
|
super.onViewBound(view);
|
|
AppFragment.setActionBarDisplayHomeAsUpEnabled$default(this, false, 1, null);
|
|
Fragment findFragmentByTag = getParentFragmentManager().findFragmentByTag("TAG_TOGGLE_MFA_DIALOG");
|
|
if (findFragmentByTag != null) {
|
|
getParentFragmentManager().beginTransaction().remove(findFragmentByTag).commitAllowingStateLoss();
|
|
}
|
|
TextView textView = getBinding().b;
|
|
m.checkNotNullExpressionValue(textView, "binding.mfaDescriptionText");
|
|
c.a.l.b.m(textView, 2131889384, new Object[0], null, 4);
|
|
}
|
|
|
|
@Override // com.discord.app.AppFragment
|
|
public void onViewBoundOrOnResume() {
|
|
super.onViewBoundOrOnResume();
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(Model.Companion.get(getGuildId()), this, null, 2, null), WidgetServerSettingsSecurity.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetServerSettingsSecurity$onViewBoundOrOnResume$1(this), 62, (Object) null);
|
|
}
|
|
}
|