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

937 lines
50 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.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.DrawableRes;
import androidx.annotation.StringRes;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import c.a.d.f;
import c.a.d.l;
import c.a.d.o;
import c.a.k.b;
import c.d.b.a.a;
import com.airbnb.lottie.parser.AnimatableValueParser;
import com.discord.api.channel.Channel;
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.databinding.WidgetServerSettingsOverviewAfkTimeoutBinding;
import com.discord.databinding.WidgetServerSettingsOverviewBinding;
import com.discord.dialogs.ImageUploadDialog;
import com.discord.models.domain.ModelVoiceRegion;
import com.discord.models.experiments.domain.Experiment;
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.mg_recycler.MGRecyclerDataPayload;
import com.discord.utilities.permissions.PermissionUtils;
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.discord.widgets.servers.WidgetServerRegionSelectDialog;
import com.facebook.drawee.view.SimpleDraweeView;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.textfield.TextInputLayout;
import d0.g0.t;
import d0.t.n;
import d0.t.u;
import d0.z.d.d0;
import d0.z.d.m;
import java.util.ArrayList;
import java.util.Iterator;
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.V(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 StatefulViews state = new StatefulViews(2131364784, 2131364225, 2131364226, 2131364227, 2131364228, 2131361931, 2131361933, 2131361934, 2131365284, 2131365501, 2131365492, 2131365286, 2131365285, 90001);
/* compiled from: WidgetServerSettingsOverview.kt */
public static final class AfkBottomSheet extends AppBottomSheet {
public static final /* synthetic */ KProperty[] $$delegatedProperties = {a.V(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().b;
m.checkNotNullExpressionValue(textView, "binding.serverSettingsOverviewAfkTimeout01");
TextView textView2 = getBinding().f1912c;
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 2131559199;
}
@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("INTENT_EXTRA_OPEN_AVATAR_PICKER", z2);
m.checkNotNullExpressionValue(putExtra, "Intent()\n .putE…PICKER, openAvatarPicker)");
l.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 hideRegionOverride;
private final boolean isAboveNotifyAllSize;
private final boolean isOwner;
private final String selectedVoiceRegionName;
private final Channel systemChannelModel;
private final List<VoiceRegion> voiceRegions;
/* 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> r = ObservableExtensionsKt.computationLatest(Y).r();
m.checkNotNullExpressionValue(r, "StoreStream\n … .distinctUntilChanged()");
return r;
}
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, 2131755068, 1, 1);
} else if (i == 300) {
Resources resources2 = context.getResources();
m.checkNotNullExpressionValue(resources2, "context.resources");
return StringResourceUtilsKt.getQuantityString(resources2, context, 2131755068, 5, 5);
} else if (i == 900) {
Resources resources3 = context.getResources();
m.checkNotNullExpressionValue(resources3, "context.resources");
return StringResourceUtilsKt.getQuantityString(resources3, context, 2131755068, 15, 15);
} else if (i == 1800) {
Resources resources4 = context.getResources();
m.checkNotNullExpressionValue(resources4, "context.resources");
return StringResourceUtilsKt.getQuantityString(resources4, context, 2131755068, 30, 30);
} else if (i != 3600) {
return "";
} else {
Resources resources5 = context.getResources();
m.checkNotNullExpressionValue(resources5, "context.resources");
return StringResourceUtilsKt.getQuantityString(resources5, context, 2131755065, 1, 1);
}
}
}
/* compiled from: WidgetServerSettingsOverview.kt */
public static final class VoiceRegion implements MGRecyclerDataPayload {
/* renamed from: id reason: collision with root package name */
private final String f2164id;
private final String key;
private final String name;
private final int type;
public VoiceRegion(String str, String str2) {
m.checkNotNullParameter(str, "id");
m.checkNotNullParameter(str2, "name");
this.f2164id = str;
this.name = str2;
this.key = str;
}
public static /* synthetic */ VoiceRegion copy$default(VoiceRegion voiceRegion, String str, String str2, int i, Object obj) {
if ((i & 1) != 0) {
str = voiceRegion.f2164id;
}
if ((i & 2) != 0) {
str2 = voiceRegion.name;
}
return voiceRegion.copy(str, str2);
}
public final String component1() {
return this.f2164id;
}
public final String component2() {
return this.name;
}
public final VoiceRegion copy(String str, String str2) {
m.checkNotNullParameter(str, "id");
m.checkNotNullParameter(str2, "name");
return new VoiceRegion(str, str2);
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof VoiceRegion)) {
return false;
}
VoiceRegion voiceRegion = (VoiceRegion) obj;
return m.areEqual(this.f2164id, voiceRegion.f2164id) && m.areEqual(this.name, voiceRegion.name);
}
public final String getId() {
return this.f2164id;
}
@Override // com.discord.utilities.mg_recycler.MGRecyclerDataPayload, com.discord.utilities.recycler.DiffKeyProvider
public String getKey() {
return this.key;
}
public final String getName() {
return this.name;
}
@Override // com.discord.utilities.mg_recycler.MGRecyclerDataPayload
public int getType() {
return this.type;
}
public int hashCode() {
String str = this.f2164id;
int i = 0;
int hashCode = (str != null ? str.hashCode() : 0) * 31;
String str2 = this.name;
if (str2 != null) {
i = str2.hashCode();
}
return hashCode + i;
}
public String toString() {
StringBuilder K = a.K("VoiceRegion(id=");
K.append(this.f2164id);
K.append(", name=");
return a.C(K, this.name, ")");
}
}
public Model(Guild guild, MeUser meUser, List<? extends ModelVoiceRegion> list, Channel channel, Channel channel2, Long l, StoreGuildProfiles.GuildProfileData guildProfileData) {
Object obj;
VoiceRegion voiceRegion;
GuildPreview data;
m.checkNotNullParameter(guild, "guild");
m.checkNotNullParameter(meUser, "me");
m.checkNotNullParameter(list, "regions");
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());
this.approximateMemberCount = (guildProfileData == null || (data = guildProfileData.getData()) == null) ? null : data.a();
Iterator<T> it = list.iterator();
while (true) {
if (!it.hasNext()) {
obj = null;
break;
}
obj = it.next();
if (m.areEqual(((ModelVoiceRegion) obj).getId(), this.guild.getRegion())) {
break;
}
}
ModelVoiceRegion modelVoiceRegion = (ModelVoiceRegion) obj;
this.selectedVoiceRegionName = modelVoiceRegion != null ? modelVoiceRegion.getName() : null;
ArrayList arrayList = new ArrayList();
for (ModelVoiceRegion modelVoiceRegion2 : list) {
if (!modelVoiceRegion2.isDeprecated()) {
String id2 = modelVoiceRegion2.getId();
m.checkNotNullExpressionValue(id2, "it.id");
String name = modelVoiceRegion2.getName();
m.checkNotNullExpressionValue(name, "it.name");
voiceRegion = new VoiceRegion(id2, name);
} else {
voiceRegion = null;
}
if (voiceRegion != null) {
arrayList.add(voiceRegion);
}
}
this.voiceRegions = u.sortedWith(arrayList, new WidgetServerSettingsOverview$Model$$special$$inlined$compareBy$1(t.getCASE_INSENSITIVE_ORDER(d0.a)));
Integer num = this.approximateMemberCount;
this.isAboveNotifyAllSize = num != null && num.intValue() > 2500;
Experiment guildExperiment = StoreStream.Companion.getExperiments().getGuildExperiment("2020-09_guild_voice_channel_latency_routing", this.guild.getId(), false);
if (guildExperiment != null && guildExperiment.getBucket() == 1) {
z2 = true;
}
this.hideRegionOverride = z2;
}
public final Channel getAfkChannelModel() {
return this.afkChannelModel;
}
public final boolean getCanManage() {
return this.canManage;
}
public final Guild getGuild() {
return this.guild;
}
public final boolean getHideRegionOverride() {
return this.hideRegionOverride;
}
public final Channel getSystemChannelModel() {
return this.systemChannelModel;
}
public final String getVoiceRegion() {
return this.selectedVoiceRegionName;
}
public final List<VoiceRegion> getVoiceRegions() {
return this.voiceRegions;
}
public final boolean isAboveNotifyAllSize() {
return this.isAboveNotifyAllSize;
}
public final boolean isOwner() {
return this.isOwner;
}
}
public WidgetServerSettingsOverview() {
super(2131559198);
}
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;
}
public static final /* synthetic */ void access$showRegionDialog(WidgetServerSettingsOverview widgetServerSettingsOverview, Model model) {
widgetServerSettingsOverview.showRegionDialog(model);
}
private final void configureAfkChannel(Channel channel) {
TextView textView = getBinding().b.b;
m.checkNotNullExpressionValue(textView, "binding.afk.afkChannel");
configureChannel(textView, channel, 2131891526, 2131231508);
}
private final void configureBannerImage(String str, String str2, boolean z2) {
if (z2) {
StatefulViews statefulViews = this.state;
SimpleDraweeView simpleDraweeView = getBinding().j.d;
m.checkNotNullExpressionValue(simpleDraweeView, "binding.uploadBanner.uploadBanner");
statefulViews.put(simpleDraweeView.getId(), str2 != null ? str2 : "");
} else {
StatefulViews statefulViews2 = this.state;
SimpleDraweeView simpleDraweeView2 = getBinding().j.d;
m.checkNotNullExpressionValue(simpleDraweeView2, "binding.uploadBanner.uploadBanner");
str2 = (String) statefulViews2.get(simpleDraweeView2.getId(), str);
}
getBinding().j.b.setOnClickListener(new WidgetServerSettingsOverview$configureBannerImage$1(this, str));
SimpleDraweeView simpleDraweeView3 = getBinding().j.d;
m.checkNotNullExpressionValue(simpleDraweeView3, "binding.uploadBanner.uploadBanner");
IconUtils.setIcon$default(simpleDraweeView3, str2, 0, (Function1) null, (MGImages.ChangeDetector) null, 28, (Object) null);
TextView textView = getBinding().j.f84c;
m.checkNotNullExpressionValue(textView, "binding.uploadBanner.ser…verviewUploadBannerRemove");
int i = 0;
if (!(!(str2 == null || t.isBlank(str2)))) {
i = 8;
}
textView.setVisibility(i);
getBinding().j.f84c.setOnClickListener(new WidgetServerSettingsOverview$configureBannerImage$2(this, str));
this.state.configureSaveActionView(getBinding().g);
}
private final void configureBannerSection(Guild guild) {
boolean z2 = true;
if (guild.canHaveBanner()) {
getBinding().k.e.setBackgroundResource(2131231025);
TextView textView = getBinding().j.g;
m.checkNotNullExpressionValue(textView, "binding.uploadBanner.uploadBannerNitroTier");
int i = 8;
textView.setVisibility(8);
TextView textView2 = getBinding().j.h;
m.checkNotNullExpressionValue(textView2, "binding.uploadBanner.uploadBannerUnlock");
b.m(textView2, 2131889867, new Object[]{"2"}, null, 4);
TextView textView3 = getBinding().j.h;
m.checkNotNullExpressionValue(textView3, "binding.uploadBanner.uploadBannerUnlock");
DrawableCompat.setCompoundDrawablesCompat$default(textView3, 0, 2131231842, 0, 0, 13, (Object) null);
getBinding().j.h.setTextColor(ColorCompat.getColor(requireContext(), 2131100428));
TextView textView4 = getBinding().j.h;
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(guild, displayMetrics != null ? Integer.valueOf(displayMetrics.widthPixels) : null), null, false);
return;
}
TextView textView5 = getBinding().j.g;
m.checkNotNullExpressionValue(textView5, "binding.uploadBanner.uploadBannerNitroTier");
b.l(textView5, 2131889868, new Object[]{"2", "tierStatus"}, new WidgetServerSettingsOverview$configureBannerSection$1(guild));
TextView textView6 = getBinding().j.g;
m.checkNotNullExpressionValue(textView6, "binding.uploadBanner.uploadBannerNitroTier");
textView6.setVisibility(0);
FloatingActionButton floatingActionButton = getBinding().j.e;
m.checkNotNullExpressionValue(floatingActionButton, "binding.uploadBanner.uploadBannerFab");
ViewExtensions.setEnabledAlpha$default(floatingActionButton, false, 0.0f, 2, null);
int premiumSubscriptionCount = 15 - guild.getPremiumSubscriptionCount();
Resources resources2 = getResources();
m.checkNotNullExpressionValue(resources2, "resources");
CharSequence quantityString = StringResourceUtilsKt.getQuantityString(resources2, requireContext(), 2131755162, premiumSubscriptionCount, Integer.valueOf(premiumSubscriptionCount));
TextView textView7 = getBinding().j.h;
m.checkNotNullExpressionValue(textView7, "binding.uploadBanner.uploadBannerUnlock");
ViewExtensions.setTextAndVisibilityBy(textView7, b.j(this, 2131889866, new Object[]{quantityString}, null, 4));
TextView textView8 = getBinding().j.h;
m.checkNotNullExpressionValue(textView8, "binding.uploadBanner.uploadBannerUnlock");
DrawableCompat.setCompoundDrawablesCompat$default(textView8, 0, 2131231841, 0, 0, 13, (Object) null);
getBinding().j.h.setTextColor(ColorCompat.getThemedColor(requireContext(), 2130969880));
getBinding().j.d.setBackgroundColor(ColorCompat.getThemedColor(requireContext(), 2130969893));
getBinding().j.g.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 = AnimatableValueParser.y0(channel);
} else {
Context context = textView.getContext();
m.checkNotNullExpressionValue(context, "context");
charSequence = b.g(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().f1913c.d;
m.checkNotNullExpressionValue(simpleDraweeView, "binding.header.serverSettingsOverviewIcon");
statefulViews.put(simpleDraweeView.getId(), str3 != null ? str3 : "");
} else {
StatefulViews statefulViews2 = this.state;
SimpleDraweeView simpleDraweeView2 = getBinding().f1913c.d;
m.checkNotNullExpressionValue(simpleDraweeView2, "binding.header.serverSettingsOverviewIcon");
str3 = (String) statefulViews2.get(simpleDraweeView2.getId(), str2);
}
getBinding().f1913c.d.setOnClickListener(new WidgetServerSettingsOverview$configureIcon$1(this, str, str2));
SimpleDraweeView simpleDraweeView3 = getBinding().f1913c.d;
m.checkNotNullExpressionValue(simpleDraweeView3, "binding.header.serverSettingsOverviewIcon");
IconUtils.setIcon$default(simpleDraweeView3, str3, 2131165286, (Function1) null, (MGImages.ChangeDetector) null, 24, (Object) null);
if (str3 != null && !t.isBlank(str3)) {
z3 = false;
}
TextView textView = getBinding().f1913c.b;
m.checkNotNullExpressionValue(textView, "binding.header.iconLabel");
textView.setVisibility(z3 ? 0 : 8);
TextView textView2 = getBinding().f1913c.e;
m.checkNotNullExpressionValue(textView2, "binding.header.serverSettingsOverviewIconRemove");
textView2.setVisibility(z3 ^ true ? 0 : 8);
getBinding().f1913c.e.setOnClickListener(new WidgetServerSettingsOverview$configureIcon$2(this, str, str2));
TextView textView3 = getBinding().f1913c.f;
m.checkNotNullExpressionValue(textView3, "binding.header.serverSettingsOverviewIconText");
if (!z3) {
i = 8;
}
textView3.setVisibility(i);
TextView textView4 = getBinding().f1913c.f;
m.checkNotNullExpressionValue(textView4, "binding.header.serverSettingsOverviewIconText");
textView4.setText(str);
this.state.configureSaveActionView(getBinding().g);
}
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.b, getBinding().d.f62c})) {
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() != 2131364788) {
checkedSetting.h(null, false);
} else {
checkedSetting.h(b.j(this, 2131889676, 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().g);
}
private final void configureSplashImage(String str, String str2, boolean z2) {
if (z2) {
StatefulViews statefulViews = this.state;
SimpleDraweeView simpleDraweeView = getBinding().k.e;
m.checkNotNullExpressionValue(simpleDraweeView, "binding.uploadSplash.uploadSplash");
statefulViews.put(simpleDraweeView.getId(), str2 != null ? str2 : "");
} else {
StatefulViews statefulViews2 = this.state;
SimpleDraweeView simpleDraweeView2 = getBinding().k.e;
m.checkNotNullExpressionValue(simpleDraweeView2, "binding.uploadSplash.uploadSplash");
str2 = (String) statefulViews2.get(simpleDraweeView2.getId(), str);
}
getBinding().k.b.setOnClickListener(new WidgetServerSettingsOverview$configureSplashImage$1(this, str));
SimpleDraweeView simpleDraweeView3 = getBinding().k.e;
m.checkNotNullExpressionValue(simpleDraweeView3, "binding.uploadSplash.uploadSplash");
IconUtils.setIcon$default(simpleDraweeView3, str2, 0, (Function1) null, (MGImages.ChangeDetector) null, 28, (Object) null);
TextView textView = getBinding().k.d;
m.checkNotNullExpressionValue(textView, "binding.uploadSplash.ser…verviewUploadSplashRemove");
int i = 0;
if (!(!(str2 == null || t.isBlank(str2)))) {
i = 8;
}
textView.setVisibility(i);
getBinding().k.d.setOnClickListener(new WidgetServerSettingsOverview$configureSplashImage$2(this, str));
this.state.configureSaveActionView(getBinding().g);
}
private final void configureSplashSection(Guild guild) {
boolean z2 = true;
if (guild.canHaveSplash()) {
TextView textView = getBinding().k.g;
m.checkNotNullExpressionValue(textView, "binding.uploadSplash.uploadSplashNitroTier");
int i = 8;
textView.setVisibility(8);
getBinding().k.e.setBackgroundResource(2131231025);
TextView textView2 = getBinding().k.h;
m.checkNotNullExpressionValue(textView2, "binding.uploadSplash.uploadSplashUnlock");
b.m(textView2, 2131889867, new Object[]{"1"}, null, 4);
TextView textView3 = getBinding().k.h;
m.checkNotNullExpressionValue(textView3, "binding.uploadSplash.uploadSplashUnlock");
DrawableCompat.setCompoundDrawablesCompat$default(textView3, 0, 2131231842, 0, 0, 13, (Object) null);
getBinding().k.h.setTextColor(ColorCompat.getColor(requireContext(), 2131100428));
TextView textView4 = getBinding().k.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().k.g;
m.checkNotNullExpressionValue(textView5, "binding.uploadSplash.uploadSplashNitroTier");
b.l(textView5, 2131889868, new Object[]{"1", "tierInfo"}, new WidgetServerSettingsOverview$configureSplashSection$1(guild));
TextView textView6 = getBinding().k.g;
m.checkNotNullExpressionValue(textView6, "binding.uploadSplash.uploadSplashNitroTier");
textView6.setVisibility(0);
FloatingActionButton floatingActionButton = getBinding().k.f89c;
m.checkNotNullExpressionValue(floatingActionButton, "binding.uploadSplash.ser…gsOverviewUploadSplashFab");
ViewExtensions.setEnabledAlpha$default(floatingActionButton, false, 0.0f, 2, null);
int premiumSubscriptionCount = 2 - guild.getPremiumSubscriptionCount();
Resources resources2 = getResources();
m.checkNotNullExpressionValue(resources2, "resources");
CharSequence quantityString = StringResourceUtilsKt.getQuantityString(resources2, requireContext(), 2131755162, premiumSubscriptionCount, Integer.valueOf(premiumSubscriptionCount));
TextView textView7 = getBinding().k.h;
m.checkNotNullExpressionValue(textView7, "binding.uploadSplash.uploadSplashUnlock");
ViewExtensions.setTextAndVisibilityBy(textView7, b.j(this, 2131889866, new Object[]{quantityString}, null, 4));
TextView textView8 = getBinding().k.h;
m.checkNotNullExpressionValue(textView8, "binding.uploadSplash.uploadSplashUnlock");
DrawableCompat.setCompoundDrawablesCompat$default(textView8, 0, 2131231841, 0, 0, 13, (Object) null);
getBinding().k.h.setTextColor(ColorCompat.getThemedColor(requireContext(), 2130969880));
getBinding().k.e.setBackgroundColor(ColorCompat.getThemedColor(requireContext(), 2130969893));
getBinding().k.g.setOnClickListener(new WidgetServerSettingsOverview$configureSplashSection$2(guild));
}
private final void configureSystemChannel(Channel channel) {
TextView textView = getBinding().i.b;
m.checkNotNullExpressionValue(textView, "binding.systemChannel.systemChannel");
configureChannel(textView, channel, 2131891579, 2131231499);
}
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().f1913c.f194c;
m.checkNotNullExpressionValue(textInputLayout, "binding.header.overviewName");
StatefulViews statefulViews = this.state;
TextInputLayout textInputLayout2 = getBinding().f1913c.f194c;
m.checkNotNullExpressionValue(textInputLayout2, "binding.header.overviewName");
ViewExtensions.setText(textInputLayout, (CharSequence) statefulViews.get(textInputLayout2.getId(), model.getGuild().getName()));
getBinding().e.d.setOnClickListener(new WidgetServerSettingsOverview$configureUI$1(this, model));
LinearLayout linearLayout = getBinding().e.d;
m.checkNotNullExpressionValue(linearLayout, "binding.region.overviewRegionWrap");
StatefulViews statefulViews2 = this.state;
LinearLayout linearLayout2 = getBinding().e.d;
m.checkNotNullExpressionValue(linearLayout2, "binding.region.overviewRegionWrap");
linearLayout.setTag(statefulViews2.get(linearLayout2.getId(), model.getGuild().getRegion()));
LinearLayout linearLayout3 = getBinding().e.d;
m.checkNotNullExpressionValue(linearLayout3, "binding.region.overviewRegionWrap");
int i = 8;
linearLayout3.setVisibility(model.getHideRegionOverride() ^ true ? 0 : 8);
TextView textView = getBinding().e.b;
m.checkNotNullExpressionValue(textView, "binding.region.overviewRegion");
StatefulViews statefulViews3 = this.state;
TextView textView2 = getBinding().e.b;
m.checkNotNullExpressionValue(textView2, "binding.region.overviewRegion");
CharSequence charSequence = (String) statefulViews3.get(textView2.getId(), model.getVoiceRegion());
if (charSequence == null) {
charSequence = b.j(this, 2131893362, new Object[0], null, 4);
}
textView.setText(charSequence);
LinearLayout linearLayout4 = getBinding().f.f73c;
m.checkNotNullExpressionValue(linearLayout4, "binding.regionHelp.overviewRegionWrapHelp");
if (model.getHideRegionOverride()) {
i = 0;
}
linearLayout4.setVisibility(i);
LinkifiedTextView linkifiedTextView = getBinding().f.b;
m.checkNotNullExpressionValue(linkifiedTextView, "binding.regionHelp.guildRegionHelp");
b.m(linkifiedTextView, 2131889361, new Object[]{f.a.a(360060570993L, null)}, null, 4);
int voiceRegionIconResourceId = IconUtils.INSTANCE.getVoiceRegionIconResourceId(model.getGuild().getRegion());
StatefulViews statefulViews4 = this.state;
ImageView imageView = getBinding().e.f66c;
m.checkNotNullExpressionValue(imageView, "binding.region.overviewRegionFlag");
getBinding().e.f66c.setImageResource(((Number) statefulViews4.get(imageView.getId(), Integer.valueOf(voiceRegionIconResourceId))).intValue());
StatefulViews statefulViews5 = this.state;
TextView textView3 = getBinding().b.b;
m.checkNotNullExpressionValue(textView3, "binding.afk.afkChannel");
configureAfkChannel((Channel) statefulViews5.get(textView3.getId(), model.getAfkChannelModel()));
getBinding().b.f132c.setOnClickListener(new WidgetServerSettingsOverview$configureUI$2(this, model));
TextView textView4 = getBinding().b.d;
m.checkNotNullExpressionValue(textView4, "binding.afk.afkTimeout");
StatefulViews statefulViews6 = this.state;
TextView textView5 = getBinding().b.d;
m.checkNotNullExpressionValue(textView5, "binding.afk.afkTimeout");
int id2 = textView5.getId();
Model.Companion companion = Model.Companion;
TextView textView6 = getBinding().b.d;
m.checkNotNullExpressionValue(textView6, "binding.afk.afkTimeout");
Context context = textView6.getContext();
m.checkNotNullExpressionValue(context, "binding.afk.afkTimeout.context");
textView4.setText((CharSequence) statefulViews6.get(id2, companion.getAfkTimeout(context, model.getGuild().getAfkTimeout())));
getBinding().b.e.setOnClickListener(new WidgetServerSettingsOverview$configureUI$3(this));
LinearLayout linearLayout5 = getBinding().b.e;
m.checkNotNullExpressionValue(linearLayout5, "binding.afk.afkTimeoutWrap");
linearLayout5.setTag(Integer.valueOf(model.getGuild().getAfkTimeout()));
StatefulViews statefulViews7 = this.state;
TextView textView7 = getBinding().i.b;
m.checkNotNullExpressionValue(textView7, "binding.systemChannel.systemChannel");
configureSystemChannel((Channel) statefulViews7.get(textView7.getId(), model.getSystemChannelModel()));
getBinding().i.e.setOnClickListener(new WidgetServerSettingsOverview$configureUI$4(this, model));
LinearLayout linearLayout6 = getBinding().i.e;
m.checkNotNullExpressionValue(linearLayout6, "binding.systemChannel.systemChannelWrap");
StatefulViews statefulViews8 = this.state;
LinearLayout linearLayout7 = getBinding().i.e;
m.checkNotNullExpressionValue(linearLayout7, "binding.systemChannel.systemChannelWrap");
linearLayout6.setTag(statefulViews8.get(linearLayout7.getId(), model.getGuild().getSystemChannelId()));
configureRadios(90001, ((Number) this.state.get(90001, Integer.valueOf(model.getGuild().getDefaultMessageNotifications()))).intValue(), model.isAboveNotifyAllSize(), false);
configureSplashSection(model.getGuild());
configureBannerSection(model.getGuild());
boolean z3 = (model.getGuild().getSystemChannelFlags() & 1) == 0;
CheckedSetting checkedSetting = getBinding().i.d;
m.checkNotNullExpressionValue(checkedSetting, "binding.systemChannel.systemChannelJoin");
StatefulViews statefulViews9 = this.state;
CheckedSetting checkedSetting2 = getBinding().i.d;
m.checkNotNullExpressionValue(checkedSetting2, "binding.systemChannel.systemChannelJoin");
checkedSetting.setChecked(((Boolean) statefulViews9.get(checkedSetting2.getId(), Boolean.valueOf(z3))).booleanValue());
if (model.getSystemChannelModel() != null) {
getBinding().i.d.e(new WidgetServerSettingsOverview$configureUI$5(this));
} else {
CheckedSetting.d(getBinding().i.d, null, 1);
}
if ((model.getGuild().getSystemChannelFlags() & 2) == 0) {
z2 = true;
}
CheckedSetting checkedSetting3 = getBinding().i.f79c;
m.checkNotNullExpressionValue(checkedSetting3, "binding.systemChannel.systemChannelBoost");
StatefulViews statefulViews10 = this.state;
CheckedSetting checkedSetting4 = getBinding().i.f79c;
m.checkNotNullExpressionValue(checkedSetting4, "binding.systemChannel.systemChannelBoost");
checkedSetting3.setChecked(((Boolean) statefulViews10.get(checkedSetting4.getId(), Boolean.valueOf(z2))).booleanValue());
if (model.getSystemChannelModel() != null) {
getBinding().i.f79c.e(new WidgetServerSettingsOverview$configureUI$6(this));
} else {
CheckedSetting.d(getBinding().i.f79c, null, 1);
}
this.state.configureSaveActionView(getBinding().g);
getBinding().g.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().h.fullScroll(33);
configureUI(model);
o.i(this, 2131893364, 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();
}
private final void showRegionDialog(Model model) {
StatefulViews statefulViews = this.state;
LinearLayout linearLayout = getBinding().e.d;
m.checkNotNullExpressionValue(linearLayout, "binding.region.overviewRegionWrap");
WidgetServerRegionSelectDialog.Companion companion = WidgetServerRegionSelectDialog.Companion;
FragmentManager childFragmentManager = getChildFragmentManager();
m.checkNotNullExpressionValue(childFragmentManager, "childFragmentManager");
companion.show(childFragmentManager, model.getGuild().getId(), (String) statefulViews.get(linearLayout.getId(), model.getGuild().getRegion())).setOnSubmitListener(new WidgetServerSettingsOverview$showRegionDialog$$inlined$apply$lambda$1(this));
}
@Override // com.discord.app.AppFragment
public void onImageChosen(Uri uri, String str) {
m.checkNotNullParameter(uri, "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, "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().g;
TextInputLayout textInputLayout = getBinding().f1913c.f194c;
m.checkNotNullExpressionValue(textInputLayout, "binding.header.overviewName");
TextView textView = getBinding().e.b;
m.checkNotNullExpressionValue(textView, "binding.region.overviewRegion");
TextView textView2 = getBinding().b.d;
m.checkNotNullExpressionValue(textView2, "binding.afk.afkTimeout");
statefulViews.setupTextWatcherWithSaveAction(this, floatingActionButton, textInputLayout, textView, textView2);
StatefulViews statefulViews2 = this.state;
TextView textView3 = getBinding().b.b;
m.checkNotNullExpressionValue(textView3, "binding.afk.afkChannel");
TextView textView4 = getBinding().i.b;
m.checkNotNullExpressionValue(textView4, "binding.systemChannel.systemChannel");
statefulViews2.addOptionalFields(textView3, textView4);
TextView textView5 = getBinding().f1913c.b;
m.checkNotNullExpressionValue(textView5, "binding.header.iconLabel");
b.m(textView5, 2131891361, new Object[]{"128", "128"}, null, 4);
LinkifiedTextView linkifiedTextView = getBinding().k.f;
m.checkNotNullExpressionValue(linkifiedTextView, "binding.uploadSplash.uploadSplashLearnMore");
f fVar = f.a;
b.m(linkifiedTextView, 2131889968, new Object[]{fVar.a(360028716472L, null)}, null, 4);
LinkifiedTextView linkifiedTextView2 = getBinding().j.f;
m.checkNotNullExpressionValue(linkifiedTextView2, "binding.uploadBanner.uploadBannerLearnMore");
b.m(linkifiedTextView2, 2131889637, new Object[]{fVar.a(360028716472L, null)}, null, 4);
getBinding().g.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(2131891914);
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);
}
}