255 lines
13 KiB
Java
255 lines
13 KiB
Java
package com.discord.widgets.servers;
|
|
|
|
import android.content.Context;
|
|
import android.content.Intent;
|
|
import android.view.View;
|
|
import android.widget.TextView;
|
|
import androidx.fragment.app.Fragment;
|
|
import c.a.d.l;
|
|
import c.a.l.b;
|
|
import c.d.b.a.a;
|
|
import com.discord.api.guild.GuildExplicitContentFilter;
|
|
import com.discord.api.guild.GuildFeature;
|
|
import com.discord.api.guild.GuildVerificationLevel;
|
|
import com.discord.app.AppActivity;
|
|
import com.discord.app.AppFragment;
|
|
import com.discord.databinding.WidgetServerSettingsModerationBinding;
|
|
import com.discord.models.guild.Guild;
|
|
import com.discord.restapi.RestAPIParams;
|
|
import com.discord.stores.StoreStream;
|
|
import com.discord.stores.StoreUser;
|
|
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.views.CheckedSetting;
|
|
import com.discord.views.RadioManager;
|
|
import d0.g;
|
|
import d0.t.n;
|
|
import d0.z.d.m;
|
|
import java.util.List;
|
|
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: WidgetServerSettingsModeration.kt */
|
|
public final class WidgetServerSettingsModeration extends AppFragment {
|
|
public static final /* synthetic */ KProperty[] $$delegatedProperties = {a.W(WidgetServerSettingsModeration.class, "binding", "getBinding()Lcom/discord/databinding/WidgetServerSettingsModerationBinding;", 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 VERIFICATION_LEVEL_HIGH_MINUTES = "10";
|
|
private static final String VERIFICATION_LEVEL_MEDIUM_MINUTES = "5";
|
|
private final FragmentViewBindingDelegate binding$delegate = FragmentViewBindingDelegateKt.viewBinding$default(this, WidgetServerSettingsModeration$binding$2.INSTANCE, null, 2, null);
|
|
private final Lazy guildId$delegate = g.lazy(new WidgetServerSettingsModeration$guildId$2(this));
|
|
private RadioManager radioManagerExplicit;
|
|
private RadioManager radioManagerVerification;
|
|
|
|
/* compiled from: WidgetServerSettingsModeration.kt */
|
|
public static final class Companion {
|
|
private Companion() {
|
|
}
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
|
|
public final void launch(Context context, long j) {
|
|
m.checkNotNullParameter(context, "context");
|
|
StoreStream.Companion.getAnalytics().onGuildSettingsPaneViewed("MODERATION", j);
|
|
Intent putExtra = new Intent().putExtra("INTENT_EXTRA_GUILD_ID", j);
|
|
m.checkNotNullExpressionValue(putExtra, "Intent().putExtra(INTENT_EXTRA_GUILD_ID, guildId)");
|
|
l.d(context, WidgetServerSettingsModeration.class, putExtra);
|
|
}
|
|
}
|
|
|
|
/* compiled from: WidgetServerSettingsModeration.kt */
|
|
public static final class Model {
|
|
public static final Companion Companion = new Companion(null);
|
|
private final Guild guild;
|
|
|
|
/* compiled from: WidgetServerSettingsModeration.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 i = Observable.i(companion.getGuilds().observeGuild(j), StoreUser.observeMe$default(companion.getUsers(), false, 1, null), companion.getPermissions().observePermissionsForGuild(j), WidgetServerSettingsModeration$Model$Companion$get$1.INSTANCE);
|
|
m.checkNotNullExpressionValue(i, "Observable\n … }\n }");
|
|
Observable<Model> r = ObservableExtensionsKt.computationLatest(i).r();
|
|
m.checkNotNullExpressionValue(r, "Observable\n … .distinctUntilChanged()");
|
|
return r;
|
|
}
|
|
}
|
|
|
|
public Model(Guild guild) {
|
|
m.checkNotNullParameter(guild, "guild");
|
|
this.guild = guild;
|
|
}
|
|
|
|
public static /* synthetic */ Model copy$default(Model model, Guild guild, int i, Object obj) {
|
|
if ((i & 1) != 0) {
|
|
guild = model.guild;
|
|
}
|
|
return model.copy(guild);
|
|
}
|
|
|
|
public final Guild component1() {
|
|
return this.guild;
|
|
}
|
|
|
|
public final Model copy(Guild guild) {
|
|
m.checkNotNullParameter(guild, "guild");
|
|
return new Model(guild);
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (this != obj) {
|
|
return (obj instanceof Model) && m.areEqual(this.guild, ((Model) obj).guild);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public final Guild getGuild() {
|
|
return this.guild;
|
|
}
|
|
|
|
public int hashCode() {
|
|
Guild guild = this.guild;
|
|
if (guild != null) {
|
|
return guild.hashCode();
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder L = a.L("Model(guild=");
|
|
L.append(this.guild);
|
|
L.append(")");
|
|
return L.toString();
|
|
}
|
|
}
|
|
|
|
public WidgetServerSettingsModeration() {
|
|
super(2131559191);
|
|
}
|
|
|
|
public static final /* synthetic */ void access$configureUI(WidgetServerSettingsModeration widgetServerSettingsModeration, Model model) {
|
|
widgetServerSettingsModeration.configureUI(model);
|
|
}
|
|
|
|
public static final /* synthetic */ void access$updateGuild(WidgetServerSettingsModeration widgetServerSettingsModeration, long j, RestAPIParams.UpdateGuild updateGuild) {
|
|
widgetServerSettingsModeration.updateGuild(j, updateGuild);
|
|
}
|
|
|
|
private final void configureExplicitContentRadio(Model model, CheckedSetting checkedSetting, GuildExplicitContentFilter guildExplicitContentFilter) {
|
|
RadioManager radioManager;
|
|
if (!model.getGuild().getFeatures().contains(GuildFeature.COMMUNITY) || guildExplicitContentFilter.compareTo(GuildExplicitContentFilter.ALL) >= 0) {
|
|
checkedSetting.e(new WidgetServerSettingsModeration$configureExplicitContentRadio$1(this, model, guildExplicitContentFilter));
|
|
} else {
|
|
checkedSetting.b(2131894159);
|
|
}
|
|
if (this.radioManagerExplicit != null && model.getGuild().getExplicitContentFilter() == guildExplicitContentFilter && (radioManager = this.radioManagerExplicit) != null) {
|
|
radioManager.a(checkedSetting);
|
|
}
|
|
}
|
|
|
|
private final void configureUI(Model model) {
|
|
if (model == null) {
|
|
AppActivity appActivity = getAppActivity();
|
|
if (appActivity != null) {
|
|
appActivity.finish();
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
setActionBarSubtitle(model.getGuild().getName());
|
|
configureVerificationLevelRadio(model, getVerificationViews().get(0), GuildVerificationLevel.NONE);
|
|
configureVerificationLevelRadio(model, getVerificationViews().get(1), GuildVerificationLevel.LOW);
|
|
configureVerificationLevelRadio(model, getVerificationViews().get(2), GuildVerificationLevel.MEDIUM);
|
|
configureVerificationLevelRadio(model, getVerificationViews().get(3), GuildVerificationLevel.HIGH);
|
|
configureVerificationLevelRadio(model, getVerificationViews().get(4), GuildVerificationLevel.HIGHEST);
|
|
configureExplicitContentRadio(model, getExplicitContentViews().get(0), GuildExplicitContentFilter.NONE);
|
|
configureExplicitContentRadio(model, getExplicitContentViews().get(1), GuildExplicitContentFilter.SOME);
|
|
configureExplicitContentRadio(model, getExplicitContentViews().get(2), GuildExplicitContentFilter.ALL);
|
|
}
|
|
|
|
private final void configureVerificationLevelRadio(Model model, CheckedSetting checkedSetting, GuildVerificationLevel guildVerificationLevel) {
|
|
RadioManager radioManager;
|
|
if (!model.getGuild().getFeatures().contains(GuildFeature.COMMUNITY) || guildVerificationLevel != GuildVerificationLevel.NONE) {
|
|
checkedSetting.e(new WidgetServerSettingsModeration$configureVerificationLevelRadio$1(this, model, guildVerificationLevel));
|
|
} else {
|
|
checkedSetting.b(2131894159);
|
|
}
|
|
if (this.radioManagerVerification != null && model.getGuild().getVerificationLevel() == guildVerificationLevel && (radioManager = this.radioManagerVerification) != null) {
|
|
radioManager.a(checkedSetting);
|
|
}
|
|
}
|
|
|
|
private final WidgetServerSettingsModerationBinding getBinding() {
|
|
return (WidgetServerSettingsModerationBinding) this.binding$delegate.getValue((Fragment) this, $$delegatedProperties[0]);
|
|
}
|
|
|
|
private final List<CheckedSetting> getExplicitContentViews() {
|
|
CheckedSetting checkedSetting = getBinding().b;
|
|
m.checkNotNullExpressionValue(checkedSetting, "binding.serverSettingsModerationExplicit1");
|
|
CheckedSetting checkedSetting2 = getBinding().f1906c;
|
|
m.checkNotNullExpressionValue(checkedSetting2, "binding.serverSettingsModerationExplicit2");
|
|
CheckedSetting checkedSetting3 = getBinding().d;
|
|
m.checkNotNullExpressionValue(checkedSetting3, "binding.serverSettingsModerationExplicit3");
|
|
return n.listOf((Object[]) new CheckedSetting[]{checkedSetting, checkedSetting2, checkedSetting3});
|
|
}
|
|
|
|
private final long getGuildId() {
|
|
return ((Number) this.guildId$delegate.getValue()).longValue();
|
|
}
|
|
|
|
private final List<CheckedSetting> getVerificationViews() {
|
|
CheckedSetting checkedSetting = getBinding().f;
|
|
m.checkNotNullExpressionValue(checkedSetting, "binding.serverSettingsModerationVerification1");
|
|
CheckedSetting checkedSetting2 = getBinding().g;
|
|
m.checkNotNullExpressionValue(checkedSetting2, "binding.serverSettingsModerationVerification2");
|
|
CheckedSetting checkedSetting3 = getBinding().h;
|
|
m.checkNotNullExpressionValue(checkedSetting3, "binding.serverSettingsModerationVerification3");
|
|
CheckedSetting checkedSetting4 = getBinding().i;
|
|
m.checkNotNullExpressionValue(checkedSetting4, "binding.serverSettingsModerationVerification4");
|
|
CheckedSetting checkedSetting5 = getBinding().j;
|
|
m.checkNotNullExpressionValue(checkedSetting5, "binding.serverSettingsModerationVerification5");
|
|
return n.listOf((Object[]) new CheckedSetting[]{checkedSetting, checkedSetting2, checkedSetting3, checkedSetting4, checkedSetting5});
|
|
}
|
|
|
|
private final void updateGuild(long j, RestAPIParams.UpdateGuild updateGuild) {
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(ObservableExtensionsKt.restSubscribeOn$default(RestAPI.Companion.getApi().updateGuild(j, updateGuild), false, 1, null), this, null, 2, null), WidgetServerSettingsModeration.class, getContext(), (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetServerSettingsModeration$updateGuild$1(this), 60, (Object) null);
|
|
}
|
|
|
|
@Override // com.discord.app.AppFragment
|
|
public void onViewBound(View view) {
|
|
m.checkNotNullParameter(view, "view");
|
|
super.onViewBound(view);
|
|
AppFragment.setActionBarDisplayHomeAsUpEnabled$default(this, false, 1, null);
|
|
setActionBarTitle(2131891381);
|
|
TextView textView = getBinding().k;
|
|
m.checkNotNullExpressionValue(textView, "binding.serverSettingsModerationVerificationHelp");
|
|
b.m(textView, 2131888603, new Object[0], null, 4);
|
|
TextView textView2 = getBinding().e;
|
|
m.checkNotNullExpressionValue(textView2, "binding.serverSettingsModerationExplicitHelp");
|
|
b.m(textView2, 2131888582, new Object[0], null, 4);
|
|
this.radioManagerVerification = new RadioManager(getVerificationViews());
|
|
this.radioManagerExplicit = new RadioManager(getExplicitContentViews());
|
|
CheckedSetting.i(getVerificationViews().get(2), b.j(this, 2131894666, new Object[]{"5"}, null, 4), false, 2);
|
|
CheckedSetting.i(getVerificationViews().get(3), b.j(this, 2131894662, new Object[]{"10"}, null, 4), false, 2);
|
|
}
|
|
|
|
@Override // com.discord.app.AppFragment
|
|
public void onViewBoundOrOnResume() {
|
|
super.onViewBoundOrOnResume();
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(Model.Companion.get(getGuildId()), this, null, 2, null), WidgetServerSettingsModeration.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetServerSettingsModeration$onViewBoundOrOnResume$1(this), 62, (Object) null);
|
|
}
|
|
}
|