discord-jadx/app/src/main/java/com/discord/widgets/servers/WidgetServerSettingsOvervie...

794 lines
45 KiB
Java

package com.discord.widgets.servers;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.net.Uri;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.DrawableRes;
import androidx.annotation.StringRes;
import androidx.core.app.NotificationCompat;
import androidx.exifinterface.media.ExifInterface;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import b.a.d.f;
import b.a.d.j;
import b.a.k.b;
import b.d.b.a.a;
import com.discord.R;
import com.discord.api.channel.Channel;
import com.discord.api.channel.ChannelUtils;
import com.discord.api.guild.GuildFeature;
import com.discord.api.guild.preview.GuildPreview;
import com.discord.app.AppActivity;
import com.discord.app.AppBottomSheet;
import com.discord.app.AppFragment;
import com.discord.app.LoggingConfig;
import com.discord.databinding.WidgetServerSettingsOverviewAfkTimeoutBinding;
import com.discord.databinding.WidgetServerSettingsOverviewBinding;
import com.discord.dialogs.ImageUploadDialog;
import com.discord.models.guild.Guild;
import com.discord.models.user.MeUser;
import com.discord.stores.StoreGuildProfiles;
import com.discord.stores.StoreStream;
import com.discord.utilities.color.ColorCompat;
import com.discord.utilities.drawable.DrawableCompat;
import com.discord.utilities.icon.IconUtils;
import com.discord.utilities.images.MGImages;
import com.discord.utilities.permissions.PermissionUtils;
import com.discord.utilities.premium.GuildBoostUtils;
import com.discord.utilities.premium.PremiumUtils;
import com.discord.utilities.resources.StringResourceUtilsKt;
import com.discord.utilities.rx.ObservableExtensionsKt;
import com.discord.utilities.stateful.StatefulViews;
import com.discord.utilities.view.extensions.ViewExtensions;
import com.discord.utilities.view.text.LinkifiedTextView;
import com.discord.utilities.viewbinding.FragmentViewBindingDelegate;
import com.discord.utilities.viewbinding.FragmentViewBindingDelegateKt;
import com.discord.views.CheckedSetting;
import com.discord.widgets.channels.WidgetChannelSelector;
import com.facebook.drawee.view.SimpleDraweeView;
import com.google.android.material.button.MaterialButton;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.textfield.TextInputLayout;
import d0.g0.t;
import d0.t.n;
import d0.z.d.m;
import java.util.List;
import java.util.Objects;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.reflect.KProperty;
import rx.Observable;
import rx.functions.Action1;
/* compiled from: WidgetServerSettingsOverview.kt */
public final class WidgetServerSettingsOverview extends AppFragment {
public static final /* synthetic */ KProperty[] $$delegatedProperties = {a.b0(WidgetServerSettingsOverview.class, "binding", "getBinding()Lcom/discord/databinding/WidgetServerSettingsOverviewBinding;", 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 INTENT_EXTRA_OPEN_AVATAR_PICKER = "INTENT_EXTRA_OPEN_AVATAR_PICKER";
private static final String REQUEST_KEY_AFK_CHANNEL = "REQUEST_KEY_AFK_CHANNEL";
private static final String REQUEST_KEY_SYSTEM_CHANNEL = "REQUEST_KEY_SYSTEM_CHANNEL";
private static final int STATE_ID_NOTIFICATION_DEFAULT = 90001;
private final FragmentViewBindingDelegate binding$delegate = FragmentViewBindingDelegateKt.viewBinding$default(this, WidgetServerSettingsOverview$binding$2.INSTANCE, null, 2, null);
private boolean hasOpenedAvatarPicker;
private Action1<String> imageSelectedResult;
private final LoggingConfig loggingConfig = new LoggingConfig(false, null, WidgetServerSettingsOverview$loggingConfig$1.INSTANCE, 3);
private final StatefulViews state = new StatefulViews(R.id.server_settings_overview_icon, R.id.overview_name, R.id.afk_channel, R.id.afk_timeout, R.id.afk_timeout_wrap, R.id.system_channel, R.id.upload_splash, R.id.upload_banner, R.id.system_channel_join, R.id.system_channel_join_replies, R.id.system_channel_boost, STATE_ID_NOTIFICATION_DEFAULT);
/* compiled from: WidgetServerSettingsOverview.kt */
public static final class AfkBottomSheet extends AppBottomSheet {
public static final /* synthetic */ KProperty[] $$delegatedProperties = {a.b0(AfkBottomSheet.class, "binding", "getBinding()Lcom/discord/databinding/WidgetServerSettingsOverviewAfkTimeoutBinding;", 0)};
private final FragmentViewBindingDelegate binding$delegate = FragmentViewBindingDelegateKt.viewBinding$default(this, WidgetServerSettingsOverview$AfkBottomSheet$binding$2.INSTANCE, null, 2, null);
public AfkBottomSheet() {
super(false, 1, null);
}
private final WidgetServerSettingsOverviewAfkTimeoutBinding getBinding() {
return (WidgetServerSettingsOverviewAfkTimeoutBinding) this.binding$delegate.getValue((Fragment) this, $$delegatedProperties[0]);
}
private final List<TextView> getTimeouts() {
TextView textView = getBinding().f2556b;
m.checkNotNullExpressionValue(textView, "binding.serverSettingsOverviewAfkTimeout01");
TextView textView2 = getBinding().c;
m.checkNotNullExpressionValue(textView2, "binding.serverSettingsOverviewAfkTimeout05");
TextView textView3 = getBinding().d;
m.checkNotNullExpressionValue(textView3, "binding.serverSettingsOverviewAfkTimeout15");
TextView textView4 = getBinding().e;
m.checkNotNullExpressionValue(textView4, "binding.serverSettingsOverviewAfkTimeout30");
TextView textView5 = getBinding().f;
m.checkNotNullExpressionValue(textView5, "binding.serverSettingsOverviewAfkTimeout60");
return n.listOf((Object[]) new TextView[]{textView, textView2, textView3, textView4, textView5});
}
@Override // com.discord.app.AppBottomSheet
public int getContentViewResId() {
return R.layout.widget_server_settings_overview_afk_timeout;
}
@Override // com.discord.app.AppBottomSheet, androidx.fragment.app.Fragment
public void onViewCreated(View view, Bundle bundle) {
m.checkNotNullParameter(view, "view");
super.onViewCreated(view, bundle);
Fragment parentFragment = getParentFragment();
if (!(parentFragment instanceof WidgetServerSettingsOverview)) {
parentFragment = null;
}
WidgetServerSettingsOverview widgetServerSettingsOverview = (WidgetServerSettingsOverview) parentFragment;
if (widgetServerSettingsOverview == null) {
dismiss();
return;
}
for (TextView textView : getTimeouts()) {
Object tag = textView.getTag();
Objects.requireNonNull(tag, "null cannot be cast to non-null type kotlin.String");
int parseInt = Integer.parseInt((String) tag);
Model.Companion companion = Model.Companion;
Context context = textView.getContext();
m.checkNotNullExpressionValue(context, "it.context");
CharSequence afkTimeout = companion.getAfkTimeout(context, parseInt);
textView.setText(afkTimeout);
textView.setOnClickListener(new WidgetServerSettingsOverview$AfkBottomSheet$onViewCreated$$inlined$forEach$lambda$1(afkTimeout, parseInt, this, widgetServerSettingsOverview));
}
}
}
/* compiled from: WidgetServerSettingsOverview.kt */
public static final class Companion {
private Companion() {
}
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
public static /* synthetic */ void create$default(Companion companion, Context context, long j, boolean z2, int i, Object obj) {
if ((i & 4) != 0) {
z2 = false;
}
companion.create(context, j, z2);
}
public final void create(Context context, long j, boolean z2) {
m.checkNotNullParameter(context, "context");
StoreStream.Companion.getAnalytics().onGuildSettingsPaneViewed("OVERVIEW", j);
Intent putExtra = new Intent().putExtra("INTENT_EXTRA_GUILD_ID", j).putExtra(WidgetServerSettingsOverview.INTENT_EXTRA_OPEN_AVATAR_PICKER, z2);
m.checkNotNullExpressionValue(putExtra, "Intent()\n .putE…PICKER, openAvatarPicker)");
j.d(context, WidgetServerSettingsOverview.class, putExtra);
}
}
/* compiled from: WidgetServerSettingsOverview.kt */
public static final class Model {
public static final Companion Companion = new Companion(null);
private final Channel afkChannelModel;
private final Integer approximateMemberCount;
private final boolean canManage;
private final Guild guild;
private final boolean isAboveNotifyAllSize;
private final boolean isOwner;
private final Channel systemChannelModel;
/* compiled from: WidgetServerSettingsOverview.kt */
public static final class Companion {
private Companion() {
}
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
public final Observable<Model> get(long j) {
Observable<R> Y = StoreStream.Companion.getGuilds().observeGuild(j).Y(new WidgetServerSettingsOverview$Model$Companion$get$1(j));
m.checkNotNullExpressionValue(Y, "StoreStream\n … }\n }");
Observable<Model> q = ObservableExtensionsKt.computationLatest(Y).q();
m.checkNotNullExpressionValue(q, "StoreStream\n … .distinctUntilChanged()");
return q;
}
public final CharSequence getAfkTimeout(Context context, int i) {
m.checkNotNullParameter(context, "context");
if (i == 60) {
Resources resources = context.getResources();
m.checkNotNullExpressionValue(resources, "context.resources");
return StringResourceUtilsKt.getQuantityString(resources, context, (int) R.plurals.duration_minutes_minutes, 1, 1);
} else if (i == 300) {
Resources resources2 = context.getResources();
m.checkNotNullExpressionValue(resources2, "context.resources");
return StringResourceUtilsKt.getQuantityString(resources2, context, (int) R.plurals.duration_minutes_minutes, 5, 5);
} else if (i == 900) {
Resources resources3 = context.getResources();
m.checkNotNullExpressionValue(resources3, "context.resources");
return StringResourceUtilsKt.getQuantityString(resources3, context, (int) R.plurals.duration_minutes_minutes, 15, 15);
} else if (i == 1800) {
Resources resources4 = context.getResources();
m.checkNotNullExpressionValue(resources4, "context.resources");
return StringResourceUtilsKt.getQuantityString(resources4, context, (int) R.plurals.duration_minutes_minutes, 30, 30);
} else if (i != 3600) {
return "";
} else {
Resources resources5 = context.getResources();
m.checkNotNullExpressionValue(resources5, "context.resources");
return StringResourceUtilsKt.getQuantityString(resources5, context, (int) R.plurals.duration_hours_hours, 1, 1);
}
}
}
public Model(Guild guild, MeUser meUser, Channel channel, Channel channel2, Long l, StoreGuildProfiles.GuildProfileData guildProfileData) {
GuildPreview data;
m.checkNotNullParameter(guild, "guild");
m.checkNotNullParameter(meUser, "me");
this.guild = guild;
this.afkChannelModel = channel;
this.systemChannelModel = channel2;
boolean isOwner = guild.isOwner(meUser.getId());
this.isOwner = isOwner;
boolean z2 = false;
this.canManage = isOwner || PermissionUtils.canAndIsElevated(32, l, meUser.getMfaEnabled(), guild.getMfaLevel());
Integer a = (guildProfileData == null || (data = guildProfileData.getData()) == null) ? null : data.a();
this.approximateMemberCount = a;
if (a != null && a.intValue() > 2500) {
z2 = true;
}
this.isAboveNotifyAllSize = z2;
}
public final Channel getAfkChannelModel() {
return this.afkChannelModel;
}
public final boolean getCanManage() {
return this.canManage;
}
public final Guild getGuild() {
return this.guild;
}
public final Channel getSystemChannelModel() {
return this.systemChannelModel;
}
public final boolean isAboveNotifyAllSize() {
return this.isAboveNotifyAllSize;
}
public final boolean isOwner() {
return this.isOwner;
}
}
public WidgetServerSettingsOverview() {
super(R.layout.widget_server_settings_overview);
}
public static final /* synthetic */ void access$configureAfkChannel(WidgetServerSettingsOverview widgetServerSettingsOverview, Channel channel) {
widgetServerSettingsOverview.configureAfkChannel(channel);
}
public static final /* synthetic */ void access$configureBannerImage(WidgetServerSettingsOverview widgetServerSettingsOverview, String str, String str2, boolean z2) {
widgetServerSettingsOverview.configureBannerImage(str, str2, z2);
}
public static final /* synthetic */ void access$configureIcon(WidgetServerSettingsOverview widgetServerSettingsOverview, String str, String str2, String str3, boolean z2) {
widgetServerSettingsOverview.configureIcon(str, str2, str3, z2);
}
public static final /* synthetic */ void access$configureRadios(WidgetServerSettingsOverview widgetServerSettingsOverview, int i, int i2, boolean z2, boolean z3) {
widgetServerSettingsOverview.configureRadios(i, i2, z2, z3);
}
public static final /* synthetic */ void access$configureSplashImage(WidgetServerSettingsOverview widgetServerSettingsOverview, String str, String str2, boolean z2) {
widgetServerSettingsOverview.configureSplashImage(str, str2, z2);
}
public static final /* synthetic */ void access$configureSystemChannel(WidgetServerSettingsOverview widgetServerSettingsOverview, Channel channel) {
widgetServerSettingsOverview.configureSystemChannel(channel);
}
public static final /* synthetic */ void access$configureUI(WidgetServerSettingsOverview widgetServerSettingsOverview, Model model) {
widgetServerSettingsOverview.configureUI(model);
}
public static final /* synthetic */ void access$configureUpdatedGuild(WidgetServerSettingsOverview widgetServerSettingsOverview, Model model) {
widgetServerSettingsOverview.configureUpdatedGuild(model);
}
public static final /* synthetic */ WidgetServerSettingsOverviewBinding access$getBinding$p(WidgetServerSettingsOverview widgetServerSettingsOverview) {
return widgetServerSettingsOverview.getBinding();
}
public static final /* synthetic */ Action1 access$getImageSelectedResult$p(WidgetServerSettingsOverview widgetServerSettingsOverview) {
return widgetServerSettingsOverview.imageSelectedResult;
}
public static final /* synthetic */ StatefulViews access$getState$p(WidgetServerSettingsOverview widgetServerSettingsOverview) {
return widgetServerSettingsOverview.state;
}
public static final /* synthetic */ void access$openAvatarPicker(WidgetServerSettingsOverview widgetServerSettingsOverview, String str, String str2) {
widgetServerSettingsOverview.openAvatarPicker(str, str2);
}
public static final /* synthetic */ void access$setImageSelectedResult$p(WidgetServerSettingsOverview widgetServerSettingsOverview, Action1 action1) {
widgetServerSettingsOverview.imageSelectedResult = action1;
}
private final void configureAfkChannel(Channel channel) {
TextView textView = getBinding().f2557b.f209b;
m.checkNotNullExpressionValue(textView, "binding.afk.afkChannel");
configureChannel(textView, channel, R.string.no_afk_channel, R.drawable.ic_channel_voice_16dp);
}
private final void configureAnimatedBannerUpsellSection(Guild guild) {
int premiumTier = guild.getPremiumTier();
Integer minimumBoostTierForGuildFeature = PremiumUtils.INSTANCE.getMinimumBoostTierForGuildFeature(GuildFeature.ANIMATED_BANNER);
boolean z2 = false;
boolean z3 = premiumTier == (minimumBoostTierForGuildFeature != null ? minimumBoostTierForGuildFeature.intValue() : 0) - 1;
boolean canHaveAnimatedBanner = guild.canHaveAnimatedBanner();
LinearLayout linearLayout = getBinding().h.f137b.c;
m.checkNotNullExpressionValue(linearLayout, "binding.uploadBanner.ani…atedBannerUpsellContainer");
int i = 8;
linearLayout.setVisibility(canHaveAnimatedBanner || z3 ? 0 : 8);
MaterialButton materialButton = getBinding().h.f137b.f130b;
m.checkNotNullExpressionValue(materialButton, "binding.uploadBanner.ani…nimatedBannerUpsellButton");
if (z3) {
i = 0;
}
materialButton.setVisibility(i);
TextView textView = getBinding().h.f137b.d;
m.checkNotNullExpressionValue(textView, "binding.uploadBanner.ani….animatedBannerUpsellText");
b.n(textView, canHaveAnimatedBanner ? R.string.guild_settings_animated_banner_try_it : R.string.guild_settings_animated_banner_upsell, new Object[0], null, 4);
MaterialButton materialButton2 = getBinding().h.f137b.f130b;
m.checkNotNullExpressionValue(materialButton2, "binding.uploadBanner.ani…nimatedBannerUpsellButton");
if (materialButton2.getVisibility() == 0) {
z2 = true;
}
if (z2) {
getBinding().h.f137b.f130b.setOnClickListener(new WidgetServerSettingsOverview$configureAnimatedBannerUpsellSection$1(guild));
}
}
private final void configureBannerImage(String str, String str2, boolean z2) {
if (z2) {
StatefulViews statefulViews = this.state;
SimpleDraweeView simpleDraweeView = getBinding().h.e;
m.checkNotNullExpressionValue(simpleDraweeView, "binding.uploadBanner.uploadBanner");
statefulViews.put(simpleDraweeView.getId(), str2 != null ? str2 : "");
} else {
StatefulViews statefulViews2 = this.state;
SimpleDraweeView simpleDraweeView2 = getBinding().h.e;
m.checkNotNullExpressionValue(simpleDraweeView2, "binding.uploadBanner.uploadBanner");
str2 = (String) statefulViews2.get(simpleDraweeView2.getId(), str);
}
getBinding().h.c.setOnClickListener(new WidgetServerSettingsOverview$configureBannerImage$1(this, str));
SimpleDraweeView simpleDraweeView3 = getBinding().h.e;
m.checkNotNullExpressionValue(simpleDraweeView3, "binding.uploadBanner.uploadBanner");
IconUtils.setIcon$default(simpleDraweeView3, str2, 0, (Function1) null, (MGImages.ChangeDetector) null, 28, (Object) null);
TextView textView = getBinding().h.d;
m.checkNotNullExpressionValue(textView, "binding.uploadBanner.ser…verviewUploadBannerRemove");
int i = 0;
if (!(!(str2 == null || t.isBlank(str2)))) {
i = 8;
}
textView.setVisibility(i);
getBinding().h.d.setOnClickListener(new WidgetServerSettingsOverview$configureBannerImage$2(this, str));
this.state.configureSaveActionView(getBinding().e);
}
private final void configureBannerSection(Guild guild) {
boolean z2 = true;
if (guild.canHaveBanner()) {
getBinding().h.e.setBackgroundResource(R.drawable.drawable_bg_nitro_gradient);
TextView textView = getBinding().h.h;
m.checkNotNullExpressionValue(textView, "binding.uploadBanner.uploadBannerNitroTier");
int i = 8;
textView.setVisibility(8);
TextView textView2 = getBinding().h.i;
m.checkNotNullExpressionValue(textView2, "binding.uploadBanner.uploadBannerUnlock");
b.n(textView2, R.string.guild_settings_overview_boost_unlocked, new Object[]{ExifInterface.GPS_MEASUREMENT_2D}, null, 4);
TextView textView3 = getBinding().h.i;
m.checkNotNullExpressionValue(textView3, "binding.uploadBanner.uploadBannerUnlock");
DrawableCompat.setCompoundDrawablesCompat$default(textView3, 0, (int) R.drawable.ic_perk_tier_1_boosted, 0, 0, 13, (Object) null);
getBinding().h.i.setTextColor(ColorCompat.getColor(requireContext(), (int) R.color.white));
TextView textView4 = getBinding().h.i;
m.checkNotNullExpressionValue(textView4, "binding.uploadBanner.uploadBannerUnlock");
String banner = guild.getBanner();
if (!(banner == null || banner.length() == 0)) {
z2 = false;
}
if (z2) {
i = 0;
}
textView4.setVisibility(i);
IconUtils iconUtils = IconUtils.INSTANCE;
Resources resources = getResources();
m.checkNotNullExpressionValue(resources, "resources");
DisplayMetrics displayMetrics = resources.getDisplayMetrics();
configureBannerImage(IconUtils.getBannerForGuild$default(iconUtils, guild, displayMetrics != null ? Integer.valueOf(displayMetrics.widthPixels) : null, false, 4, null), null, false);
return;
}
TextView textView5 = getBinding().h.h;
m.checkNotNullExpressionValue(textView5, "binding.uploadBanner.uploadBannerNitroTier");
b.m(textView5, R.string.guild_settings_overview_tier_info, new Object[]{ExifInterface.GPS_MEASUREMENT_2D, "tierStatus"}, new WidgetServerSettingsOverview$configureBannerSection$1(guild));
TextView textView6 = getBinding().h.h;
m.checkNotNullExpressionValue(textView6, "binding.uploadBanner.uploadBannerNitroTier");
textView6.setVisibility(0);
FloatingActionButton floatingActionButton = getBinding().h.f;
m.checkNotNullExpressionValue(floatingActionButton, "binding.uploadBanner.uploadBannerFab");
ViewExtensions.setEnabledAlpha$default(floatingActionButton, false, 0.0f, 2, null);
int boostsRequiredForTier$default = GuildBoostUtils.getBoostsRequiredForTier$default(GuildBoostUtils.INSTANCE, guild.getId(), 2, null, null, 12, null) - guild.getPremiumSubscriptionCount();
Resources resources2 = getResources();
m.checkNotNullExpressionValue(resources2, "resources");
CharSequence quantityString = StringResourceUtilsKt.getQuantityString(resources2, requireContext(), (int) R.plurals.guild_settings_overview_boost_unlock_boosts, boostsRequiredForTier$default, Integer.valueOf(boostsRequiredForTier$default));
TextView textView7 = getBinding().h.i;
m.checkNotNullExpressionValue(textView7, "binding.uploadBanner.uploadBannerUnlock");
ViewExtensions.setTextAndVisibilityBy(textView7, b.k(this, R.string.guild_settings_overview_boost_unlock, new Object[]{quantityString}, null, 4));
TextView textView8 = getBinding().h.i;
m.checkNotNullExpressionValue(textView8, "binding.uploadBanner.uploadBannerUnlock");
DrawableCompat.setCompoundDrawablesCompat$default(textView8, 0, (int) R.drawable.ic_perk_lock, 0, 0, 13, (Object) null);
getBinding().h.i.setTextColor(ColorCompat.getThemedColor(requireContext(), (int) R.attr.primary_300));
getBinding().h.e.setBackgroundColor(ColorCompat.getThemedColor(requireContext(), (int) R.attr.primary_630));
getBinding().h.h.setOnClickListener(new WidgetServerSettingsOverview$configureBannerSection$2(guild));
}
private final void configureChannel(TextView textView, Channel channel, @StringRes int i, @DrawableRes int i2) {
CharSequence charSequence;
if (channel != null) {
charSequence = ChannelUtils.c(channel);
} else {
Context context = textView.getContext();
m.checkNotNullExpressionValue(context, "context");
charSequence = b.h(context, i, new Object[0], null, 4);
}
textView.setText(charSequence);
DrawableCompat.setCompoundDrawablesCompat$default(textView, channel == null ? 0 : i2, 0, 0, 0, 14, (Object) null);
}
private final void configureIcon(String str, String str2, String str3, boolean z2) {
boolean z3 = true;
int i = 0;
if (!this.hasOpenedAvatarPicker && getMostRecentIntent().getBooleanExtra(INTENT_EXTRA_OPEN_AVATAR_PICKER, false)) {
openAvatarPicker(str, str2);
}
if (z2) {
StatefulViews statefulViews = this.state;
SimpleDraweeView simpleDraweeView = getBinding().c.d;
m.checkNotNullExpressionValue(simpleDraweeView, "binding.header.serverSettingsOverviewIcon");
statefulViews.put(simpleDraweeView.getId(), str3 != null ? str3 : "");
} else {
StatefulViews statefulViews2 = this.state;
SimpleDraweeView simpleDraweeView2 = getBinding().c.d;
m.checkNotNullExpressionValue(simpleDraweeView2, "binding.header.serverSettingsOverviewIcon");
str3 = (String) statefulViews2.get(simpleDraweeView2.getId(), str2);
}
getBinding().c.d.setOnClickListener(new WidgetServerSettingsOverview$configureIcon$1(this, str, str2));
SimpleDraweeView simpleDraweeView3 = getBinding().c.d;
m.checkNotNullExpressionValue(simpleDraweeView3, "binding.header.serverSettingsOverviewIcon");
IconUtils.setIcon$default(simpleDraweeView3, str3, (int) R.dimen.avatar_size_extra_large, (Function1) null, (MGImages.ChangeDetector) null, 24, (Object) null);
if (str3 != null && !t.isBlank(str3)) {
z3 = false;
}
TextView textView = getBinding().c.f110b;
m.checkNotNullExpressionValue(textView, "binding.header.iconLabel");
textView.setVisibility(z3 ? 0 : 8);
TextView textView2 = getBinding().c.e;
m.checkNotNullExpressionValue(textView2, "binding.header.serverSettingsOverviewIconRemove");
textView2.setVisibility(z3 ^ true ? 0 : 8);
getBinding().c.e.setOnClickListener(new WidgetServerSettingsOverview$configureIcon$2(this, str, str2));
TextView textView3 = getBinding().c.f;
m.checkNotNullExpressionValue(textView3, "binding.header.serverSettingsOverviewIconText");
if (!z3) {
i = 8;
}
textView3.setVisibility(i);
TextView textView4 = getBinding().c.f;
m.checkNotNullExpressionValue(textView4, "binding.header.serverSettingsOverviewIconText");
textView4.setText(str);
this.state.configureSaveActionView(getBinding().e);
}
private final void configureRadios(int i, int i2, boolean z2, boolean z3) {
if (z3) {
this.state.put(i, Integer.valueOf(i2));
}
int i3 = 0;
for (Object obj : n.listOf((Object[]) new CheckedSetting[]{getBinding().d.f116b, getBinding().d.c})) {
int i4 = i3 + 1;
if (i3 < 0) {
n.throwIndexOverflow();
}
CheckedSetting checkedSetting = (CheckedSetting) obj;
m.checkNotNullExpressionValue(checkedSetting, "checkedSetting");
checkedSetting.setChecked(i3 == i2);
if (!z2 || checkedSetting.getId() != R.id.server_settings_overview_notification_all) {
checkedSetting.h(null, false);
} else {
checkedSetting.h(b.k(this, R.string.guild_settings_default_notifications_large_guild_notify_all, new Object[0], null, 4), false);
}
checkedSetting.setOnCheckedListener(new WidgetServerSettingsOverview$configureRadios$$inlined$forEachIndexed$lambda$1(i3, this, i2, z2, i));
i3 = i4;
}
this.state.configureSaveActionView(getBinding().e);
}
private final void configureSplashImage(String str, String str2, boolean z2) {
if (z2) {
StatefulViews statefulViews = this.state;
SimpleDraweeView simpleDraweeView = getBinding().i.e;
m.checkNotNullExpressionValue(simpleDraweeView, "binding.uploadSplash.uploadSplash");
statefulViews.put(simpleDraweeView.getId(), str2 != null ? str2 : "");
} else {
StatefulViews statefulViews2 = this.state;
SimpleDraweeView simpleDraweeView2 = getBinding().i.e;
m.checkNotNullExpressionValue(simpleDraweeView2, "binding.uploadSplash.uploadSplash");
str2 = (String) statefulViews2.get(simpleDraweeView2.getId(), str);
}
getBinding().i.f144b.setOnClickListener(new WidgetServerSettingsOverview$configureSplashImage$1(this, str));
SimpleDraweeView simpleDraweeView3 = getBinding().i.e;
m.checkNotNullExpressionValue(simpleDraweeView3, "binding.uploadSplash.uploadSplash");
IconUtils.setIcon$default(simpleDraweeView3, str2, 0, (Function1) null, (MGImages.ChangeDetector) null, 28, (Object) null);
TextView textView = getBinding().i.d;
m.checkNotNullExpressionValue(textView, "binding.uploadSplash.ser…verviewUploadSplashRemove");
int i = 0;
if (!(!(str2 == null || t.isBlank(str2)))) {
i = 8;
}
textView.setVisibility(i);
getBinding().i.d.setOnClickListener(new WidgetServerSettingsOverview$configureSplashImage$2(this, str));
this.state.configureSaveActionView(getBinding().e);
}
private final void configureSplashSection(Guild guild) {
boolean z2 = true;
if (guild.canHaveSplash()) {
TextView textView = getBinding().i.g;
m.checkNotNullExpressionValue(textView, "binding.uploadSplash.uploadSplashNitroTier");
int i = 8;
textView.setVisibility(8);
getBinding().i.e.setBackgroundResource(R.drawable.drawable_bg_nitro_gradient);
TextView textView2 = getBinding().i.h;
m.checkNotNullExpressionValue(textView2, "binding.uploadSplash.uploadSplashUnlock");
b.n(textView2, R.string.guild_settings_overview_boost_unlocked, new Object[]{"1"}, null, 4);
TextView textView3 = getBinding().i.h;
m.checkNotNullExpressionValue(textView3, "binding.uploadSplash.uploadSplashUnlock");
DrawableCompat.setCompoundDrawablesCompat$default(textView3, 0, (int) R.drawable.ic_perk_tier_1_boosted, 0, 0, 13, (Object) null);
getBinding().i.h.setTextColor(ColorCompat.getColor(requireContext(), (int) R.color.white));
TextView textView4 = getBinding().i.h;
m.checkNotNullExpressionValue(textView4, "binding.uploadSplash.uploadSplashUnlock");
String splash = guild.getSplash();
if (!(splash == null || splash.length() == 0)) {
z2 = false;
}
if (z2) {
i = 0;
}
textView4.setVisibility(i);
IconUtils iconUtils = IconUtils.INSTANCE;
Resources resources = getResources();
m.checkNotNullExpressionValue(resources, "resources");
DisplayMetrics displayMetrics = resources.getDisplayMetrics();
configureSplashImage(iconUtils.getGuildSplashUrl(guild, displayMetrics != null ? Integer.valueOf(displayMetrics.widthPixels) : null), null, false);
return;
}
TextView textView5 = getBinding().i.g;
m.checkNotNullExpressionValue(textView5, "binding.uploadSplash.uploadSplashNitroTier");
b.m(textView5, R.string.guild_settings_overview_tier_info, new Object[]{"1", "tierInfo"}, new WidgetServerSettingsOverview$configureSplashSection$1(guild));
TextView textView6 = getBinding().i.g;
m.checkNotNullExpressionValue(textView6, "binding.uploadSplash.uploadSplashNitroTier");
textView6.setVisibility(0);
FloatingActionButton floatingActionButton = getBinding().i.c;
m.checkNotNullExpressionValue(floatingActionButton, "binding.uploadSplash.ser…gsOverviewUploadSplashFab");
ViewExtensions.setEnabledAlpha$default(floatingActionButton, false, 0.0f, 2, null);
int boostsRequiredForTier$default = GuildBoostUtils.getBoostsRequiredForTier$default(GuildBoostUtils.INSTANCE, guild.getId(), 1, null, null, 12, null) - guild.getPremiumSubscriptionCount();
Resources resources2 = getResources();
m.checkNotNullExpressionValue(resources2, "resources");
CharSequence quantityString = StringResourceUtilsKt.getQuantityString(resources2, requireContext(), (int) R.plurals.guild_settings_overview_boost_unlock_boosts, boostsRequiredForTier$default, Integer.valueOf(boostsRequiredForTier$default));
TextView textView7 = getBinding().i.h;
m.checkNotNullExpressionValue(textView7, "binding.uploadSplash.uploadSplashUnlock");
ViewExtensions.setTextAndVisibilityBy(textView7, b.k(this, R.string.guild_settings_overview_boost_unlock, new Object[]{quantityString}, null, 4));
TextView textView8 = getBinding().i.h;
m.checkNotNullExpressionValue(textView8, "binding.uploadSplash.uploadSplashUnlock");
DrawableCompat.setCompoundDrawablesCompat$default(textView8, 0, (int) R.drawable.ic_perk_lock, 0, 0, 13, (Object) null);
getBinding().i.h.setTextColor(ColorCompat.getThemedColor(requireContext(), (int) R.attr.primary_300));
getBinding().i.e.setBackgroundColor(ColorCompat.getThemedColor(requireContext(), (int) R.attr.primary_630));
getBinding().i.g.setOnClickListener(new WidgetServerSettingsOverview$configureSplashSection$2(guild));
}
private final void configureSystemChannel(Channel channel) {
TextView textView = getBinding().g.f123b;
m.checkNotNullExpressionValue(textView, "binding.systemChannel.systemChannel");
configureChannel(textView, channel, R.string.no_system_channel, R.drawable.ic_channel_text_16dp);
}
private final void configureUI(Model model) {
if (model == null || !model.getCanManage()) {
AppActivity appActivity = getAppActivity();
if (appActivity != null) {
appActivity.finish();
return;
}
return;
}
boolean z2 = false;
configureIcon(model.getGuild().getShortName(), IconUtils.getForGuild$default(model.getGuild(), null, true, null, 10, null), null, false);
TextInputLayout textInputLayout = getBinding().c.c;
m.checkNotNullExpressionValue(textInputLayout, "binding.header.overviewName");
StatefulViews statefulViews = this.state;
TextInputLayout textInputLayout2 = getBinding().c.c;
m.checkNotNullExpressionValue(textInputLayout2, "binding.header.overviewName");
ViewExtensions.setText(textInputLayout, (CharSequence) statefulViews.get(textInputLayout2.getId(), model.getGuild().getName()));
StatefulViews statefulViews2 = this.state;
TextView textView = getBinding().f2557b.f209b;
m.checkNotNullExpressionValue(textView, "binding.afk.afkChannel");
configureAfkChannel((Channel) statefulViews2.get(textView.getId(), model.getAfkChannelModel()));
getBinding().f2557b.c.setOnClickListener(new WidgetServerSettingsOverview$configureUI$1(this, model));
TextView textView2 = getBinding().f2557b.d;
m.checkNotNullExpressionValue(textView2, "binding.afk.afkTimeout");
StatefulViews statefulViews3 = this.state;
TextView textView3 = getBinding().f2557b.d;
m.checkNotNullExpressionValue(textView3, "binding.afk.afkTimeout");
int id2 = textView3.getId();
Model.Companion companion = Model.Companion;
TextView textView4 = getBinding().f2557b.d;
m.checkNotNullExpressionValue(textView4, "binding.afk.afkTimeout");
Context context = textView4.getContext();
m.checkNotNullExpressionValue(context, "binding.afk.afkTimeout.context");
textView2.setText((CharSequence) statefulViews3.get(id2, companion.getAfkTimeout(context, model.getGuild().getAfkTimeout())));
getBinding().f2557b.e.setOnClickListener(new WidgetServerSettingsOverview$configureUI$2(this));
LinearLayout linearLayout = getBinding().f2557b.e;
m.checkNotNullExpressionValue(linearLayout, "binding.afk.afkTimeoutWrap");
linearLayout.setTag(Integer.valueOf(model.getGuild().getAfkTimeout()));
StatefulViews statefulViews4 = this.state;
TextView textView5 = getBinding().g.f123b;
m.checkNotNullExpressionValue(textView5, "binding.systemChannel.systemChannel");
configureSystemChannel((Channel) statefulViews4.get(textView5.getId(), model.getSystemChannelModel()));
getBinding().g.f.setOnClickListener(new WidgetServerSettingsOverview$configureUI$3(this, model));
LinearLayout linearLayout2 = getBinding().g.f;
m.checkNotNullExpressionValue(linearLayout2, "binding.systemChannel.systemChannelWrap");
StatefulViews statefulViews5 = this.state;
LinearLayout linearLayout3 = getBinding().g.f;
m.checkNotNullExpressionValue(linearLayout3, "binding.systemChannel.systemChannelWrap");
linearLayout2.setTag(statefulViews5.get(linearLayout3.getId(), model.getGuild().getSystemChannelId()));
configureRadios(STATE_ID_NOTIFICATION_DEFAULT, ((Number) this.state.get(STATE_ID_NOTIFICATION_DEFAULT, Integer.valueOf(model.getGuild().getDefaultMessageNotifications()))).intValue(), model.isAboveNotifyAllSize(), false);
configureSplashSection(model.getGuild());
configureBannerSection(model.getGuild());
configureAnimatedBannerUpsellSection(model.getGuild());
boolean z3 = (model.getGuild().getSystemChannelFlags() & 1) == 0;
CheckedSetting checkedSetting = getBinding().g.d;
m.checkNotNullExpressionValue(checkedSetting, "binding.systemChannel.systemChannelJoin");
StatefulViews statefulViews6 = this.state;
CheckedSetting checkedSetting2 = getBinding().g.d;
m.checkNotNullExpressionValue(checkedSetting2, "binding.systemChannel.systemChannelJoin");
checkedSetting.setChecked(((Boolean) statefulViews6.get(checkedSetting2.getId(), Boolean.valueOf(z3))).booleanValue());
if (model.getSystemChannelModel() != null) {
getBinding().g.d.e(new WidgetServerSettingsOverview$configureUI$4(this));
} else {
CheckedSetting.d(getBinding().g.d, null, 1);
}
boolean z4 = (model.getGuild().getSystemChannelFlags() & 2) == 0;
CheckedSetting checkedSetting3 = getBinding().g.c;
m.checkNotNullExpressionValue(checkedSetting3, "binding.systemChannel.systemChannelBoost");
StatefulViews statefulViews7 = this.state;
CheckedSetting checkedSetting4 = getBinding().g.c;
m.checkNotNullExpressionValue(checkedSetting4, "binding.systemChannel.systemChannelBoost");
checkedSetting3.setChecked(((Boolean) statefulViews7.get(checkedSetting4.getId(), Boolean.valueOf(z4))).booleanValue());
if (model.getSystemChannelModel() != null) {
getBinding().g.c.e(new WidgetServerSettingsOverview$configureUI$5(this));
} else {
CheckedSetting.d(getBinding().g.c, null, 1);
}
if ((model.getGuild().getSystemChannelFlags() & 8) == 0) {
z2 = true;
}
CheckedSetting checkedSetting5 = getBinding().g.e;
m.checkNotNullExpressionValue(checkedSetting5, "binding.systemChannel.systemChannelJoinReplies");
StatefulViews statefulViews8 = this.state;
CheckedSetting checkedSetting6 = getBinding().g.e;
m.checkNotNullExpressionValue(checkedSetting6, "binding.systemChannel.systemChannelJoinReplies");
checkedSetting5.setChecked(((Boolean) statefulViews8.get(checkedSetting6.getId(), Boolean.valueOf(z2))).booleanValue());
if (model.getSystemChannelModel() != null) {
getBinding().g.e.e(new WidgetServerSettingsOverview$configureUI$6(this));
} else {
CheckedSetting.d(getBinding().g.e, null, 1);
}
this.state.configureSaveActionView(getBinding().e);
getBinding().e.setOnClickListener(new WidgetServerSettingsOverview$configureUI$7(this, model));
}
private final void configureUpdatedGuild(Model model) {
StatefulViews.clear$default(this.state, false, 1, null);
AppFragment.hideKeyboard$default(this, null, 1, null);
getBinding().f.fullScroll(33);
configureUI(model);
b.a.d.m.i(this, R.string.server_settings_updated, 0, 4);
}
public static final void create(Context context, long j, boolean z2) {
Companion.create(context, j, z2);
}
private final WidgetServerSettingsOverviewBinding getBinding() {
return (WidgetServerSettingsOverviewBinding) this.binding$delegate.getValue((Fragment) this, $$delegatedProperties[0]);
}
private final void openAvatarPicker(String str, String str2) {
this.hasOpenedAvatarPicker = true;
this.imageSelectedResult = new WidgetServerSettingsOverview$openAvatarPicker$1(this, str, str2);
openMediaChooser();
}
@Override // com.discord.app.AppFragment, com.discord.app.AppLogger.a
public LoggingConfig getLoggingConfig() {
return this.loggingConfig;
}
@Override // com.discord.app.AppFragment
public void onImageChosen(Uri uri, String str) {
m.checkNotNullParameter(uri, NotificationCompat.MessagingStyle.Message.KEY_DATA_URI);
m.checkNotNullParameter(str, "mimeType");
super.onImageChosen(uri, str);
FragmentManager parentFragmentManager = getParentFragmentManager();
m.checkNotNullExpressionValue(parentFragmentManager, "parentFragmentManager");
MGImages.prepareImageUpload(uri, str, parentFragmentManager, this, this.imageSelectedResult, ImageUploadDialog.PreviewType.GUILD_AVATAR);
}
@Override // com.discord.app.AppFragment
public void onImageCropped(Uri uri, String str) {
m.checkNotNullParameter(uri, NotificationCompat.MessagingStyle.Message.KEY_DATA_URI);
m.checkNotNullParameter(str, "mimeType");
super.onImageCropped(uri, str);
MGImages.requestDataUrl(getContext(), uri, str, this.imageSelectedResult);
}
@Override // com.discord.app.AppFragment
public void onViewBound(View view) {
m.checkNotNullParameter(view, "view");
super.onViewBound(view);
AppFragment.setActionBarDisplayHomeAsUpEnabled$default(this, false, 1, null);
setRetainInstance(true);
this.state.setupUnsavedChangesConfirmation(this);
StatefulViews statefulViews = this.state;
FloatingActionButton floatingActionButton = getBinding().e;
TextInputLayout textInputLayout = getBinding().c.c;
m.checkNotNullExpressionValue(textInputLayout, "binding.header.overviewName");
TextView textView = getBinding().f2557b.d;
m.checkNotNullExpressionValue(textView, "binding.afk.afkTimeout");
statefulViews.setupTextWatcherWithSaveAction(this, floatingActionButton, textInputLayout, textView);
StatefulViews statefulViews2 = this.state;
TextView textView2 = getBinding().f2557b.f209b;
m.checkNotNullExpressionValue(textView2, "binding.afk.afkChannel");
TextView textView3 = getBinding().g.f123b;
m.checkNotNullExpressionValue(textView3, "binding.systemChannel.systemChannel");
statefulViews2.addOptionalFields(textView2, textView3);
TextView textView4 = getBinding().c.f110b;
m.checkNotNullExpressionValue(textView4, "binding.header.iconLabel");
b.n(textView4, R.string.minimum_size, new Object[]{"128", "128"}, null, 4);
LinkifiedTextView linkifiedTextView = getBinding().i.f;
m.checkNotNullExpressionValue(linkifiedTextView, "binding.uploadSplash.uploadSplashLearnMore");
f fVar = f.a;
b.n(linkifiedTextView, R.string.guild_settings_splash_recommend, new Object[]{fVar.a(4415841146391L, null)}, null, 4);
LinkifiedTextView linkifiedTextView2 = getBinding().h.g;
m.checkNotNullExpressionValue(linkifiedTextView2, "binding.uploadBanner.uploadBannerLearnMore");
b.n(linkifiedTextView2, R.string.guild_settings_banner_recommend, new Object[]{fVar.a(360028716472L, null)}, null, 4);
getBinding().e.hide();
WidgetChannelSelector.Companion companion = WidgetChannelSelector.Companion;
companion.registerForResult(this, REQUEST_KEY_AFK_CHANNEL, true, new WidgetServerSettingsOverview$onViewBound$1(this));
companion.registerForResult(this, REQUEST_KEY_SYSTEM_CHANNEL, true, new WidgetServerSettingsOverview$onViewBound$2(this));
}
@Override // com.discord.app.AppFragment
public void onViewBoundOrOnResume() {
super.onViewBoundOrOnResume();
setActionBarTitle(R.string.overview);
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(Model.Companion.get(getMostRecentIntent().getLongExtra("INTENT_EXTRA_GUILD_ID", -1)), this, null, 2, null), WidgetServerSettingsOverview.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetServerSettingsOverview$onViewBoundOrOnResume$1(this), 62, (Object) null);
}
}