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

368 lines
16 KiB
Java

package com.discord.widgets.servers;
import a0.a.a.b;
import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.widget.ProgressBar;
import android.widget.TextView;
import androidx.fragment.app.Fragment;
import c.a.d.l;
import c.d.b.a.a;
import com.discord.app.AppActivity;
import com.discord.app.AppFragment;
import com.discord.databinding.WidgetServerSettingsVanityUrlBinding;
import com.discord.restapi.RestAPIParams;
import com.discord.stores.StoreStream;
import com.discord.stores.StoreUser;
import com.discord.utilities.resources.StringResourceUtilsKt;
import com.discord.utilities.rest.RestAPI;
import com.discord.utilities.rx.ObservableExtensionsKt;
import com.discord.utilities.stateful.StatefulViews;
import com.discord.utilities.view.extensions.ViewExtensions;
import com.discord.utilities.viewbinding.FragmentViewBindingDelegate;
import com.discord.utilities.viewbinding.FragmentViewBindingDelegateKt;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.textfield.TextInputLayout;
import d0.g;
import d0.z.d.m;
import kotlin.Lazy;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.reflect.KProperty;
import rx.Observable;
/* compiled from: WidgetServerSettingsVanityUrl.kt */
public final class WidgetServerSettingsVanityUrl extends AppFragment {
public static final /* synthetic */ KProperty[] $$delegatedProperties = {a.V(WidgetServerSettingsVanityUrl.class, "binding", "getBinding()Lcom/discord/databinding/WidgetServerSettingsVanityUrlBinding;", 0)};
private static final long ANIMATION_DURATION = 250;
public static final Companion Companion = new Companion(null);
private static final String INTENT_EXTRA_GUILD_ID = "INTENT_EXTRA_GUILD_ID";
private final FragmentViewBindingDelegate binding$delegate = FragmentViewBindingDelegateKt.viewBinding$default(this, WidgetServerSettingsVanityUrl$binding$2.INSTANCE, null, 2, null);
private final Lazy guildId$delegate = g.lazy(new WidgetServerSettingsVanityUrl$guildId$2(this));
private final StatefulViews state = new StatefulViews(2131364819);
/* compiled from: WidgetServerSettingsVanityUrl.kt */
public static final class Companion {
private Companion() {
}
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
public static final /* synthetic */ void access$translateLeft(Companion companion, View view, int i) {
companion.translateLeft(view, i);
}
public static final /* synthetic */ void access$translateToOriginX(Companion companion, View view) {
companion.translateToOriginX(view);
}
private final void translateLeft(View view, int i) {
view.animate().translationXBy(-((float) i)).setDuration(250).setInterpolator(new AccelerateDecelerateInterpolator()).start();
}
private final void translateToOriginX(View view) {
view.animate().translationX(0.0f).setDuration(250).setInterpolator(new AccelerateDecelerateInterpolator()).start();
}
public final void create(Context context, long j) {
m.checkNotNullParameter(context, "context");
StoreStream.Companion.getAnalytics().onGuildSettingsPaneViewed("VANITY_URL", j);
Intent putExtra = new Intent().putExtra("INTENT_EXTRA_GUILD_ID", j);
m.checkNotNullExpressionValue(putExtra, "Intent()\n .putE…_EXTRA_GUILD_ID, guildId)");
l.d(context, WidgetServerSettingsVanityUrl.class, putExtra);
}
}
/* compiled from: WidgetServerSettingsVanityUrl.kt */
public static final class Model {
public static final Companion Companion = new Companion(null);
private final long guildId;
private final String guildName;
private final String vanityUrl;
private final int vanityUrlUses;
/* compiled from: WidgetServerSettingsVanityUrl.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<Model> h = Observable.h(StoreUser.observeMe$default(companion.getUsers(), false, 1, null), companion.getPermissions().observePermissionsForGuild(j), companion.getGuilds().observeGuild(j), ObservableExtensionsKt.restSubscribeOn$default(RestAPI.Companion.getApi().getVanityUrl(j), false, 1, null), new WidgetServerSettingsVanityUrl$Model$Companion$get$1(j));
m.checkNotNullExpressionValue(h, "Observable.combineLatest…ull\n }\n }");
return h;
}
}
public Model(long j, String str, String str2, int i) {
this.guildId = j;
this.guildName = str;
this.vanityUrl = str2;
this.vanityUrlUses = i;
}
public static /* synthetic */ Model copy$default(Model model, long j, String str, String str2, int i, int i2, Object obj) {
if ((i2 & 1) != 0) {
j = model.guildId;
}
if ((i2 & 2) != 0) {
str = model.guildName;
}
if ((i2 & 4) != 0) {
str2 = model.vanityUrl;
}
if ((i2 & 8) != 0) {
i = model.vanityUrlUses;
}
return model.copy(j, str, str2, i);
}
public final long component1() {
return this.guildId;
}
public final String component2() {
return this.guildName;
}
public final String component3() {
return this.vanityUrl;
}
public final int component4() {
return this.vanityUrlUses;
}
public final Model copy(long j, String str, String str2, int i) {
return new Model(j, str, str2, i);
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof Model)) {
return false;
}
Model model = (Model) obj;
return this.guildId == model.guildId && m.areEqual(this.guildName, model.guildName) && m.areEqual(this.vanityUrl, model.vanityUrl) && this.vanityUrlUses == model.vanityUrlUses;
}
public final long getGuildId() {
return this.guildId;
}
public final String getGuildName() {
return this.guildName;
}
public final String getVanityUrl() {
return this.vanityUrl;
}
public final int getVanityUrlUses() {
return this.vanityUrlUses;
}
public int hashCode() {
int a = b.a(this.guildId) * 31;
String str = this.guildName;
int i = 0;
int hashCode = (a + (str != null ? str.hashCode() : 0)) * 31;
String str2 = this.vanityUrl;
if (str2 != null) {
i = str2.hashCode();
}
return ((hashCode + i) * 31) + this.vanityUrlUses;
}
public String toString() {
StringBuilder K = a.K("Model(guildId=");
K.append(this.guildId);
K.append(", guildName=");
K.append(this.guildName);
K.append(", vanityUrl=");
K.append(this.vanityUrl);
K.append(", vanityUrlUses=");
return a.w(K, this.vanityUrlUses, ")");
}
}
public WidgetServerSettingsVanityUrl() {
super(2131559207);
}
public static final /* synthetic */ void access$configureInviteCode(WidgetServerSettingsVanityUrl widgetServerSettingsVanityUrl, String str, int i) {
widgetServerSettingsVanityUrl.configureInviteCode(str, i);
}
public static final /* synthetic */ void access$configureUI(WidgetServerSettingsVanityUrl widgetServerSettingsVanityUrl, Model model) {
widgetServerSettingsVanityUrl.configureUI(model);
}
public static final /* synthetic */ WidgetServerSettingsVanityUrlBinding access$getBinding$p(WidgetServerSettingsVanityUrl widgetServerSettingsVanityUrl) {
return widgetServerSettingsVanityUrl.getBinding();
}
public static final /* synthetic */ StatefulViews access$getState$p(WidgetServerSettingsVanityUrl widgetServerSettingsVanityUrl) {
return widgetServerSettingsVanityUrl.state;
}
public static final /* synthetic */ void access$showLoadingUI(WidgetServerSettingsVanityUrl widgetServerSettingsVanityUrl, boolean z2) {
widgetServerSettingsVanityUrl.showLoadingUI(z2);
}
public static final /* synthetic */ void access$updateVanityUrl(WidgetServerSettingsVanityUrl widgetServerSettingsVanityUrl, long j, String str) {
widgetServerSettingsVanityUrl.updateVanityUrl(j, str);
}
/* JADX WARNING: Removed duplicated region for block: B:19:0x0075 */
/* JADX WARNING: Removed duplicated region for block: B:20:0x0077 */
/* JADX WARNING: Removed duplicated region for block: B:23:0x0089 */
/* JADX WARNING: Removed duplicated region for block: B:31:0x0099 */
/* JADX WARNING: Removed duplicated region for block: B:34:0x009f */
/* JADX WARNING: Removed duplicated region for block: B:35:0x00c8 */
private final void configureInviteCode(String str, int i) {
boolean z2;
boolean z3;
TextInputLayout textInputLayout = getBinding().b;
m.checkNotNullExpressionValue(textInputLayout, "binding.serverSettingsVanityInput");
StatefulViews statefulViews = this.state;
TextInputLayout textInputLayout2 = getBinding().b;
m.checkNotNullExpressionValue(textInputLayout2, "binding.serverSettingsVanityInput");
ViewExtensions.setText(textInputLayout, (CharSequence) statefulViews.get(textInputLayout2.getId(), str));
getBinding().b.clearFocus();
if (str != null) {
if (str.length() > 0) {
String s2 = a.s("https://discord.gg/", str);
TextView textView = getBinding().f1919c;
m.checkNotNullExpressionValue(textView, "binding.serverSettingsVanityUrlCurrentUrl");
c.a.k.b.m(textView, 2131894675, new Object[]{s2}, null, 4);
}
}
TextView textView2 = getBinding().f1919c;
m.checkNotNullExpressionValue(textView2, "binding.serverSettingsVanityUrlCurrentUrl");
if (str != null) {
if (str.length() > 0) {
z2 = true;
int i2 = 8;
textView2.setVisibility(!z2 ? 0 : 8);
TextView textView3 = getBinding().i;
m.checkNotNullExpressionValue(textView3, "binding.serverSettingsVanityUrlRemove");
if (str != null) {
if (str.length() > 0) {
z3 = true;
if (z3) {
i2 = 0;
}
textView3.setVisibility(i2);
if (str != null) {
CharSequence i18nPluralString = StringResourceUtilsKt.getI18nPluralString(requireContext(), 2131755359, i, Integer.valueOf(i));
TextView textView4 = getBinding().e;
m.checkNotNullExpressionValue(textView4, "binding.serverSettingsVanityUrlHeader");
c.a.k.b.m(textView4, 2131894672, new Object[]{i18nPluralString}, null, 4);
return;
}
getBinding().e.setText(2131894671);
return;
}
}
z3 = false;
if (z3) {
}
textView3.setVisibility(i2);
if (str != null) {
}
}
}
z2 = false;
int i2 = 8;
textView2.setVisibility(!z2 ? 0 : 8);
TextView textView3 = getBinding().i;
m.checkNotNullExpressionValue(textView3, "binding.serverSettingsVanityUrlRemove");
if (str != null) {
}
z3 = false;
if (z3) {
}
textView3.setVisibility(i2);
if (str != null) {
}
}
private final void configureUI(Model model) {
if (model == null) {
AppActivity appActivity = getAppActivity();
if (appActivity != null) {
appActivity.finish();
return;
}
return;
}
showLoadingUI(false);
setActionBarTitle(2131894671);
setActionBarSubtitle(model.getGuildName());
configureInviteCode(model.getVanityUrl(), model.getVanityUrlUses());
this.state.configureSaveActionView(getBinding().j);
getBinding().j.setOnClickListener(new WidgetServerSettingsVanityUrl$configureUI$1(this, model));
getBinding().i.setOnClickListener(new WidgetServerSettingsVanityUrl$configureUI$2(this, model));
}
private final WidgetServerSettingsVanityUrlBinding getBinding() {
return (WidgetServerSettingsVanityUrlBinding) this.binding$delegate.getValue((Fragment) this, $$delegatedProperties[0]);
}
private final long getGuildId() {
return ((Number) this.guildId$delegate.getValue()).longValue();
}
private final void showLoadingUI(boolean z2) {
ProgressBar progressBar = getBinding().g;
m.checkNotNullExpressionValue(progressBar, "binding.serverSettingsVanityUrlLoadingIndicator");
progressBar.setVisibility(z2 ? 0 : 8);
TextView textView = getBinding().d;
m.checkNotNullExpressionValue(textView, "binding.serverSettingsVanityUrlErrorText");
textView.setVisibility(8);
TextView textView2 = getBinding().i;
m.checkNotNullExpressionValue(textView2, "binding.serverSettingsVanityUrlRemove");
textView2.setEnabled(!z2);
}
private final void updateVanityUrl(long j, String str) {
showLoadingUI(true);
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(ObservableExtensionsKt.restSubscribeOn$default(RestAPI.Companion.getApi().updateVanityUrl(j, new RestAPIParams.VanityUrl(str)), false, 1, null), this, null, 2, null), WidgetServerSettingsVanityUrl.class, getContext(), (Function1) null, new WidgetServerSettingsVanityUrl$updateVanityUrl$2(this), (Function0) null, (Function0) null, new WidgetServerSettingsVanityUrl$updateVanityUrl$1(this), 52, (Object) null);
}
@Override // com.discord.app.AppFragment, androidx.fragment.app.Fragment
public void onResume() {
super.onResume();
showLoadingUI(true);
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(Model.Companion.get(getGuildId()), this, null, 2, null), WidgetServerSettingsVanityUrl.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetServerSettingsVanityUrl$onResume$1(this), 62, (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);
TextInputLayout textInputLayout = getBinding().b;
m.checkNotNullExpressionValue(textInputLayout, "binding.serverSettingsVanityInput");
ViewExtensions.setOnEditTextFocusChangeListener(textInputLayout, new WidgetServerSettingsVanityUrl$onViewBound$1(this));
getBinding().f.setOnClickListener(new WidgetServerSettingsVanityUrl$onViewBound$2(this));
this.state.setupUnsavedChangesConfirmation(this);
StatefulViews statefulViews = this.state;
FloatingActionButton floatingActionButton = getBinding().j;
TextInputLayout textInputLayout2 = getBinding().b;
m.checkNotNullExpressionValue(textInputLayout2, "binding.serverSettingsVanityInput");
statefulViews.setupTextWatcherWithSaveAction(this, floatingActionButton, textInputLayout2);
}
}