forked from Juby210/discord-jadx
476 lines
21 KiB
Java
476 lines
21 KiB
Java
package com.discord.widgets.guilds.create;
|
|
|
|
import a0.a.a.b;
|
|
import android.content.Context;
|
|
import android.content.Intent;
|
|
import android.net.Uri;
|
|
import android.os.Bundle;
|
|
import android.os.Parcel;
|
|
import android.os.Parcelable;
|
|
import android.widget.EditText;
|
|
import androidx.annotation.LayoutRes;
|
|
import androidx.constraintlayout.widget.Group;
|
|
import androidx.core.app.NotificationCompat;
|
|
import androidx.fragment.app.Fragment;
|
|
import androidx.fragment.app.FragmentActivity;
|
|
import androidx.fragment.app.FragmentManager;
|
|
import androidx.fragment.app.FragmentViewModelLazyKt;
|
|
import b.a.d.f0;
|
|
import b.a.d.h0;
|
|
import b.a.d.j;
|
|
import b.c.a.a0.d;
|
|
import b.d.b.a.a;
|
|
import com.discord.R;
|
|
import com.discord.app.AppFragment;
|
|
import com.discord.app.LoggingConfig;
|
|
import com.discord.databinding.WidgetGuildCreateBinding;
|
|
import com.discord.dialogs.ImageUploadDialog;
|
|
import com.discord.utilities.icon.IconUtils;
|
|
import com.discord.utilities.images.MGImages;
|
|
import com.discord.utilities.rx.ObservableExtensionsKt;
|
|
import com.discord.utilities.view.extensions.ViewExtensions;
|
|
import com.discord.utilities.view.text.TextWatcherKt;
|
|
import com.discord.utilities.viewbinding.FragmentViewBindingDelegate;
|
|
import com.discord.utilities.viewbinding.FragmentViewBindingDelegateKt;
|
|
import com.discord.views.ScreenTitleView;
|
|
import com.discord.widgets.guilds.create.GuildCreateCloneViews;
|
|
import com.discord.widgets.guilds.create.WidgetGuildCreateViewModel;
|
|
import com.discord.widgets.guilds.invite.GuildInviteShareSheetFeatureFlag;
|
|
import com.discord.widgets.guilds.invite.WidgetGuildInviteShare;
|
|
import com.discord.widgets.guilds.invite.WidgetGuildInviteShareSheet;
|
|
import com.discord.widgets.nux.WidgetNuxChannelPrompt;
|
|
import d0.g;
|
|
import d0.z.d.a0;
|
|
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;
|
|
/* compiled from: WidgetGuildCreate.kt */
|
|
public class WidgetGuildCreate extends AppFragment {
|
|
public static final /* synthetic */ KProperty[] $$delegatedProperties = {a.b0(WidgetGuildCreate.class, "binding", "getBinding()Lcom/discord/databinding/WidgetGuildCreateBinding;", 0)};
|
|
public static final String ANALYTICS_SOURCE = "Guild Create";
|
|
public static final Companion Companion = new Companion(null);
|
|
public static final String EXTRA_OPTIONS = "com.discord.intent.extra.EXTRA_OPTIONS";
|
|
private static final String GUIDELINES_URL = "https://discord.com/guidelines";
|
|
private final Lazy args$delegate;
|
|
private final FragmentViewBindingDelegate binding$delegate;
|
|
private String currentImageUri;
|
|
private final LoggingConfig loggingConfig;
|
|
private final Lazy viewModel$delegate;
|
|
|
|
/* compiled from: WidgetGuildCreate.kt */
|
|
public static final class Companion {
|
|
private Companion() {
|
|
}
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
|
|
public final void show(Context context, Options options) {
|
|
m.checkNotNullParameter(context, "context");
|
|
m.checkNotNullParameter(options, "options");
|
|
Intent intent = new Intent();
|
|
intent.putExtra(WidgetGuildCreate.EXTRA_OPTIONS, options);
|
|
j.d(context, WidgetGuildCreate.class, intent);
|
|
}
|
|
|
|
public final void showFragment(AppFragment appFragment, Options options) {
|
|
m.checkNotNullParameter(appFragment, "fragment");
|
|
m.checkNotNullParameter(options, "options");
|
|
Bundle bundle = new Bundle();
|
|
bundle.putParcelable(WidgetGuildCreate.EXTRA_OPTIONS, options);
|
|
j.g(j.g, appFragment.getParentFragmentManager(), appFragment.requireContext(), WidgetGuildCreate.class, 0, true, null, bundle, 40);
|
|
}
|
|
}
|
|
|
|
/* compiled from: WidgetGuildCreate.kt */
|
|
public static final class Options implements Parcelable {
|
|
public static final Parcelable.Creator<Options> CREATOR = new Creator();
|
|
private final String analyticsLocation;
|
|
private final boolean closeWithResult;
|
|
private final String customTitle;
|
|
private final boolean showChannelPrompt;
|
|
private final StockGuildTemplate template;
|
|
|
|
public static class Creator implements Parcelable.Creator<Options> {
|
|
@Override // android.os.Parcelable.Creator
|
|
public final Options createFromParcel(Parcel parcel) {
|
|
m.checkNotNullParameter(parcel, "in");
|
|
return new Options(parcel.readString(), (StockGuildTemplate) Enum.valueOf(StockGuildTemplate.class, parcel.readString()), parcel.readInt() != 0, parcel.readString(), parcel.readInt() != 0);
|
|
}
|
|
|
|
@Override // android.os.Parcelable.Creator
|
|
public final Options[] newArray(int i) {
|
|
return new Options[i];
|
|
}
|
|
}
|
|
|
|
public Options(String str, StockGuildTemplate stockGuildTemplate, boolean z2, String str2, boolean z3) {
|
|
m.checkNotNullParameter(str, "analyticsLocation");
|
|
m.checkNotNullParameter(stockGuildTemplate, "template");
|
|
this.analyticsLocation = str;
|
|
this.template = stockGuildTemplate;
|
|
this.showChannelPrompt = z2;
|
|
this.customTitle = str2;
|
|
this.closeWithResult = z3;
|
|
}
|
|
|
|
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
|
|
public /* synthetic */ Options(String str, StockGuildTemplate stockGuildTemplate, boolean z2, String str2, boolean z3, int i, DefaultConstructorMarker defaultConstructorMarker) {
|
|
this(str, (i & 2) != 0 ? StockGuildTemplate.CREATE : stockGuildTemplate, (i & 4) != 0 ? false : z2, (i & 8) != 0 ? null : str2, (i & 16) != 0 ? false : z3);
|
|
}
|
|
|
|
public static /* synthetic */ Options copy$default(Options options, String str, StockGuildTemplate stockGuildTemplate, boolean z2, String str2, boolean z3, int i, Object obj) {
|
|
if ((i & 1) != 0) {
|
|
str = options.analyticsLocation;
|
|
}
|
|
if ((i & 2) != 0) {
|
|
stockGuildTemplate = options.template;
|
|
}
|
|
if ((i & 4) != 0) {
|
|
z2 = options.showChannelPrompt;
|
|
}
|
|
if ((i & 8) != 0) {
|
|
str2 = options.customTitle;
|
|
}
|
|
if ((i & 16) != 0) {
|
|
z3 = options.closeWithResult;
|
|
}
|
|
return options.copy(str, stockGuildTemplate, z2, str2, z3);
|
|
}
|
|
|
|
public final String component1() {
|
|
return this.analyticsLocation;
|
|
}
|
|
|
|
public final StockGuildTemplate component2() {
|
|
return this.template;
|
|
}
|
|
|
|
public final boolean component3() {
|
|
return this.showChannelPrompt;
|
|
}
|
|
|
|
public final String component4() {
|
|
return this.customTitle;
|
|
}
|
|
|
|
public final boolean component5() {
|
|
return this.closeWithResult;
|
|
}
|
|
|
|
public final Options copy(String str, StockGuildTemplate stockGuildTemplate, boolean z2, String str2, boolean z3) {
|
|
m.checkNotNullParameter(str, "analyticsLocation");
|
|
m.checkNotNullParameter(stockGuildTemplate, "template");
|
|
return new Options(str, stockGuildTemplate, z2, str2, z3);
|
|
}
|
|
|
|
@Override // android.os.Parcelable
|
|
public int describeContents() {
|
|
return 0;
|
|
}
|
|
|
|
@Override // java.lang.Object
|
|
public boolean equals(Object obj) {
|
|
if (this == obj) {
|
|
return true;
|
|
}
|
|
if (!(obj instanceof Options)) {
|
|
return false;
|
|
}
|
|
Options options = (Options) obj;
|
|
return m.areEqual(this.analyticsLocation, options.analyticsLocation) && m.areEqual(this.template, options.template) && this.showChannelPrompt == options.showChannelPrompt && m.areEqual(this.customTitle, options.customTitle) && this.closeWithResult == options.closeWithResult;
|
|
}
|
|
|
|
public final String getAnalyticsLocation() {
|
|
return this.analyticsLocation;
|
|
}
|
|
|
|
public final boolean getCloseWithResult() {
|
|
return this.closeWithResult;
|
|
}
|
|
|
|
public final String getCustomTitle() {
|
|
return this.customTitle;
|
|
}
|
|
|
|
public final boolean getShowChannelPrompt() {
|
|
return this.showChannelPrompt;
|
|
}
|
|
|
|
public final StockGuildTemplate getTemplate() {
|
|
return this.template;
|
|
}
|
|
|
|
@Override // java.lang.Object
|
|
public int hashCode() {
|
|
String str = this.analyticsLocation;
|
|
int i = 0;
|
|
int hashCode = (str != null ? str.hashCode() : 0) * 31;
|
|
StockGuildTemplate stockGuildTemplate = this.template;
|
|
int hashCode2 = (hashCode + (stockGuildTemplate != null ? stockGuildTemplate.hashCode() : 0)) * 31;
|
|
boolean z2 = this.showChannelPrompt;
|
|
int i2 = 1;
|
|
if (z2) {
|
|
z2 = true;
|
|
}
|
|
int i3 = z2 ? 1 : 0;
|
|
int i4 = z2 ? 1 : 0;
|
|
int i5 = z2 ? 1 : 0;
|
|
int i6 = (hashCode2 + i3) * 31;
|
|
String str2 = this.customTitle;
|
|
if (str2 != null) {
|
|
i = str2.hashCode();
|
|
}
|
|
int i7 = (i6 + i) * 31;
|
|
boolean z3 = this.closeWithResult;
|
|
if (!z3) {
|
|
i2 = z3 ? 1 : 0;
|
|
}
|
|
return i7 + i2;
|
|
}
|
|
|
|
@Override // java.lang.Object
|
|
public String toString() {
|
|
StringBuilder R = a.R("Options(analyticsLocation=");
|
|
R.append(this.analyticsLocation);
|
|
R.append(", template=");
|
|
R.append(this.template);
|
|
R.append(", showChannelPrompt=");
|
|
R.append(this.showChannelPrompt);
|
|
R.append(", customTitle=");
|
|
R.append(this.customTitle);
|
|
R.append(", closeWithResult=");
|
|
return a.L(R, this.closeWithResult, ")");
|
|
}
|
|
|
|
@Override // android.os.Parcelable
|
|
public void writeToParcel(Parcel parcel, int i) {
|
|
m.checkNotNullParameter(parcel, "parcel");
|
|
parcel.writeString(this.analyticsLocation);
|
|
parcel.writeString(this.template.name());
|
|
parcel.writeInt(this.showChannelPrompt ? 1 : 0);
|
|
parcel.writeString(this.customTitle);
|
|
parcel.writeInt(this.closeWithResult ? 1 : 0);
|
|
}
|
|
}
|
|
|
|
/* compiled from: WidgetGuildCreate.kt */
|
|
public static final class Result implements Parcelable {
|
|
public static final Parcelable.Creator<Result> CREATOR = new Creator();
|
|
private final long guildId;
|
|
|
|
public static class Creator implements Parcelable.Creator<Result> {
|
|
@Override // android.os.Parcelable.Creator
|
|
public final Result createFromParcel(Parcel parcel) {
|
|
m.checkNotNullParameter(parcel, "in");
|
|
return new Result(parcel.readLong());
|
|
}
|
|
|
|
@Override // android.os.Parcelable.Creator
|
|
public final Result[] newArray(int i) {
|
|
return new Result[i];
|
|
}
|
|
}
|
|
|
|
public Result(long j) {
|
|
this.guildId = j;
|
|
}
|
|
|
|
public static /* synthetic */ Result copy$default(Result result, long j, int i, Object obj) {
|
|
if ((i & 1) != 0) {
|
|
j = result.guildId;
|
|
}
|
|
return result.copy(j);
|
|
}
|
|
|
|
public final long component1() {
|
|
return this.guildId;
|
|
}
|
|
|
|
public final Result copy(long j) {
|
|
return new Result(j);
|
|
}
|
|
|
|
@Override // android.os.Parcelable
|
|
public int describeContents() {
|
|
return 0;
|
|
}
|
|
|
|
@Override // java.lang.Object
|
|
public boolean equals(Object obj) {
|
|
if (this != obj) {
|
|
return (obj instanceof Result) && this.guildId == ((Result) obj).guildId;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public final long getGuildId() {
|
|
return this.guildId;
|
|
}
|
|
|
|
@Override // java.lang.Object
|
|
public int hashCode() {
|
|
return b.a(this.guildId);
|
|
}
|
|
|
|
@Override // java.lang.Object
|
|
public String toString() {
|
|
return a.B(a.R("Result(guildId="), this.guildId, ")");
|
|
}
|
|
|
|
@Override // android.os.Parcelable
|
|
public void writeToParcel(Parcel parcel, int i) {
|
|
m.checkNotNullParameter(parcel, "parcel");
|
|
parcel.writeLong(this.guildId);
|
|
}
|
|
}
|
|
|
|
public WidgetGuildCreate() {
|
|
this(0, 1, null);
|
|
}
|
|
|
|
public WidgetGuildCreate(@LayoutRes int i) {
|
|
super(i);
|
|
this.args$delegate = g.lazy(new WidgetGuildCreate$$special$$inlined$args$1(this, EXTRA_OPTIONS));
|
|
WidgetGuildCreate$viewModel$2 widgetGuildCreate$viewModel$2 = new WidgetGuildCreate$viewModel$2(this);
|
|
f0 f0Var = new f0(this);
|
|
this.viewModel$delegate = FragmentViewModelLazyKt.createViewModelLazy(this, a0.getOrCreateKotlinClass(WidgetGuildCreateViewModel.class), new WidgetGuildCreate$appViewModels$$inlined$viewModels$1(f0Var), new h0(widgetGuildCreate$viewModel$2));
|
|
this.binding$delegate = FragmentViewBindingDelegateKt.viewBinding$default(this, WidgetGuildCreate$binding$2.INSTANCE, null, 2, null);
|
|
this.loggingConfig = new LoggingConfig(false, null, new WidgetGuildCreate$loggingConfig$1(this), 3);
|
|
}
|
|
|
|
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
|
|
public /* synthetic */ WidgetGuildCreate(int i, int i2, DefaultConstructorMarker defaultConstructorMarker) {
|
|
this((i2 & 1) != 0 ? R.layout.widget_guild_create : i);
|
|
}
|
|
|
|
public static final /* synthetic */ WidgetGuildCreateViewModel access$getViewModel$p(WidgetGuildCreate widgetGuildCreate) {
|
|
return widgetGuildCreate.getViewModel();
|
|
}
|
|
|
|
public static final /* synthetic */ void access$handleEvent(WidgetGuildCreate widgetGuildCreate, WidgetGuildCreateViewModel.Event event) {
|
|
widgetGuildCreate.handleEvent(event);
|
|
}
|
|
|
|
private final WidgetGuildCreateBinding getBinding() {
|
|
return (WidgetGuildCreateBinding) this.binding$delegate.getValue((Fragment) this, $$delegatedProperties[0]);
|
|
}
|
|
|
|
private final WidgetGuildCreateViewModel getViewModel() {
|
|
return (WidgetGuildCreateViewModel) this.viewModel$delegate.getValue();
|
|
}
|
|
|
|
private final void handleEvent(WidgetGuildCreateViewModel.Event event) {
|
|
if (event instanceof WidgetGuildCreateViewModel.Event.ShowToast) {
|
|
b.a.d.m.i(this, ((WidgetGuildCreateViewModel.Event.ShowToast) event).getStringResId(), 0, 4);
|
|
} else if (event instanceof WidgetGuildCreateViewModel.Event.LaunchChannelPrompt) {
|
|
WidgetNuxChannelPrompt.Companion.launch(requireContext(), ((WidgetGuildCreateViewModel.Event.LaunchChannelPrompt) event).getGuildId());
|
|
requireActivity().finish();
|
|
} else if (event instanceof WidgetGuildCreateViewModel.Event.CloseWithResult) {
|
|
FragmentActivity activity = getActivity();
|
|
if (activity != null) {
|
|
activity.setResult(-1, d.e2(new Result(((WidgetGuildCreateViewModel.Event.CloseWithResult) event).getGuildId())));
|
|
activity.finish();
|
|
}
|
|
} else if (event instanceof WidgetGuildCreateViewModel.Event.LaunchInviteShareScreen) {
|
|
if (GuildInviteShareSheetFeatureFlag.Companion.getINSTANCE().isEnabled()) {
|
|
WidgetGuildInviteShareSheet.Companion.enqueueNoticeForHomeTab$default(WidgetGuildInviteShareSheet.Companion, null, ((WidgetGuildCreateViewModel.Event.LaunchInviteShareScreen) event).getGuildId(), "Guild Create", 1, null);
|
|
j.c(requireContext(), false, null, 6);
|
|
} else {
|
|
WidgetGuildInviteShare.Companion companion = WidgetGuildInviteShare.Companion;
|
|
Context requireContext = requireContext();
|
|
FragmentManager parentFragmentManager = getParentFragmentManager();
|
|
m.checkNotNullExpressionValue(parentFragmentManager, "parentFragmentManager");
|
|
WidgetGuildInviteShare.Companion.launch$default(companion, requireContext, parentFragmentManager, ((WidgetGuildCreateViewModel.Event.LaunchInviteShareScreen) event).getGuildId(), null, true, null, null, "Guild Create", 96, null);
|
|
}
|
|
requireActivity().finish();
|
|
}
|
|
}
|
|
|
|
public void configureUI(WidgetGuildCreateViewModel.ViewState viewState) {
|
|
ScreenTitleView screenTitleView;
|
|
m.checkNotNullParameter(viewState, "viewState");
|
|
if (!m.areEqual(viewState, WidgetGuildCreateViewModel.ViewState.Uninitialized.INSTANCE) && (viewState instanceof WidgetGuildCreateViewModel.ViewState.Initialized)) {
|
|
WidgetGuildCreateViewModel.ViewState.Initialized initialized = (WidgetGuildCreateViewModel.ViewState.Initialized) viewState;
|
|
String guildName = initialized.getGuildName(requireContext());
|
|
boolean z2 = true;
|
|
if (!m.areEqual(guildName, ViewExtensions.getTextOrEmpty(getViews().getGuildCreateName()))) {
|
|
ViewExtensions.setText(getViews().getGuildCreateName(), guildName);
|
|
}
|
|
if (!m.areEqual(this.currentImageUri, initialized.getGuildIconUri())) {
|
|
Group iconUploaderPlaceholderGroup = getViews().getIconUploaderPlaceholderGroup();
|
|
int i = 0;
|
|
if (initialized.getGuildIconUri() != null) {
|
|
z2 = false;
|
|
}
|
|
if (!z2) {
|
|
i = 8;
|
|
}
|
|
iconUploaderPlaceholderGroup.setVisibility(i);
|
|
IconUtils.setIcon$default(getViews().getIconUploaderImage(), initialized.getGuildIconUri(), (int) R.dimen.avatar_size_xxlarge, (Function1) null, (MGImages.ChangeDetector) null, 24, (Object) null);
|
|
this.currentImageUri = initialized.getGuildIconUri();
|
|
}
|
|
if (!(initialized.getCustomTitle() == null || (screenTitleView = getViews().getScreenTitleView()) == null)) {
|
|
screenTitleView.setTitle(initialized.getCustomTitle());
|
|
}
|
|
getViews().getGuildCreateButton().setIsLoading(initialized.isBusy());
|
|
}
|
|
}
|
|
|
|
public WidgetGuildCreateViewModel createViewModelFactory() {
|
|
return new WidgetGuildCreateViewModel(R.string.create_server_default_server_name_format, getArgs().getTemplate(), null, getArgs().getShowChannelPrompt(), getArgs().getAnalyticsLocation(), getArgs().getCustomTitle(), getArgs().getCloseWithResult(), null, null, null, 896, null);
|
|
}
|
|
|
|
public final Options getArgs() {
|
|
return (Options) this.args$delegate.getValue();
|
|
}
|
|
|
|
@Override // com.discord.app.AppFragment, com.discord.app.AppLogger.a
|
|
public LoggingConfig getLoggingConfig() {
|
|
return this.loggingConfig;
|
|
}
|
|
|
|
public GuildCreateCloneViews getViews() {
|
|
GuildCreateCloneViews.Companion companion = GuildCreateCloneViews.Companion;
|
|
WidgetGuildCreateBinding binding = getBinding();
|
|
m.checkNotNullExpressionValue(binding, "binding");
|
|
return companion.from(binding);
|
|
}
|
|
|
|
@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, new WidgetGuildCreate$onImageChosen$1(this), 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(requireContext(), uri, str, new WidgetGuildCreate$onImageCropped$1(this));
|
|
}
|
|
|
|
@Override // com.discord.app.AppFragment, androidx.fragment.app.Fragment
|
|
public void onResume() {
|
|
super.onResume();
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.bindToComponentLifecycle$default(getViewModel().observeViewState(), this, null, 2, null), getClass(), (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetGuildCreate$onResume$1(this), 62, (Object) null);
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.bindToComponentLifecycle$default(getViewModel().observeEvents(), this, null, 2, null), getClass(), (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetGuildCreate$onResume$2(this), 62, (Object) null);
|
|
getViews().getGuildCreateIconUploader().setOnClickListener(new WidgetGuildCreate$onResume$3(this));
|
|
b.a.k.b.n(getViews().getGuidelinesTextView(), R.string.create_server_guidelines, new Object[]{GUIDELINES_URL}, null, 4);
|
|
EditText editText = getViews().getGuildCreateName().getEditText();
|
|
if (editText != null) {
|
|
TextWatcherKt.addLifecycleAwareTextWatcher(editText, this, new WidgetGuildCreate$onResume$4(this));
|
|
}
|
|
getViews().getGuildCreateButton().setOnClickListener(new WidgetGuildCreate$onResume$5(this));
|
|
}
|
|
}
|