forked from Juby210/discord-jadx
326 lines
18 KiB
Java
326 lines
18 KiB
Java
package com.discord.widgets.guilds.profile;
|
|
|
|
import android.content.Context;
|
|
import android.content.Intent;
|
|
import android.content.SharedPreferences;
|
|
import android.content.res.Resources;
|
|
import android.net.Uri;
|
|
import android.text.Editable;
|
|
import android.text.Selection;
|
|
import android.view.LayoutInflater;
|
|
import android.view.View;
|
|
import android.widget.EditText;
|
|
import android.widget.LinearLayout;
|
|
import androidx.annotation.StringRes;
|
|
import androidx.appcompat.app.AlertDialog;
|
|
import androidx.core.app.NotificationCompat;
|
|
import androidx.fragment.app.Fragment;
|
|
import androidx.fragment.app.FragmentManager;
|
|
import androidx.fragment.app.FragmentViewModelLazyKt;
|
|
import b.a.a.b.d;
|
|
import b.a.d.f0;
|
|
import b.a.d.h0;
|
|
import b.a.d.j;
|
|
import b.a.k.b;
|
|
import b.a.y.d0;
|
|
import b.d.b.a.a;
|
|
import com.discord.R;
|
|
import com.discord.app.AppFragment;
|
|
import com.discord.databinding.ViewDialogConfirmationBinding;
|
|
import com.discord.databinding.WidgetChangeGuildIdentityBinding;
|
|
import com.discord.utilities.analytics.AnalyticsTracker;
|
|
import com.discord.utilities.analytics.Traits;
|
|
import com.discord.utilities.cache.SharedPreferencesProvider;
|
|
import com.discord.utilities.color.ColorCompat;
|
|
import com.discord.utilities.dimmer.DimmerView;
|
|
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.viewbinding.FragmentViewBindingDelegate;
|
|
import com.discord.utilities.viewbinding.FragmentViewBindingDelegateKt;
|
|
import com.discord.widgets.guilds.profile.WidgetChangeGuildIdentityViewModel;
|
|
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.z.d.a0;
|
|
import d0.z.d.m;
|
|
import java.util.List;
|
|
import java.util.concurrent.atomic.AtomicBoolean;
|
|
import kotlin.Lazy;
|
|
import kotlin.Unit;
|
|
import kotlin.jvm.functions.Function0;
|
|
import kotlin.jvm.functions.Function1;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
import kotlin.reflect.KProperty;
|
|
import rx.functions.Action1;
|
|
/* compiled from: WidgetChangeGuildIdentity.kt */
|
|
public final class WidgetChangeGuildIdentity extends AppFragment {
|
|
public static final /* synthetic */ KProperty[] $$delegatedProperties = {a.b0(WidgetChangeGuildIdentity.class, "binding", "getBinding()Lcom/discord/databinding/WidgetChangeGuildIdentityBinding;", 0)};
|
|
public static final Companion Companion = new Companion(null);
|
|
public static final String USER_GUILD_PROFILE_VIEWED_CACHE_KEY = "USER_GUILD_PROFILE_VIEWED_CACHE_KEY";
|
|
private Function1<? super String, Unit> avatarSelectedResult = WidgetChangeGuildIdentity$avatarSelectedResult$1.INSTANCE;
|
|
private final FragmentViewBindingDelegate binding$delegate = FragmentViewBindingDelegateKt.viewBinding$default(this, WidgetChangeGuildIdentity$binding$2.INSTANCE, null, 2, null);
|
|
private final AtomicBoolean discardConfirmed = new AtomicBoolean(false);
|
|
private Function1<? super String, Unit> imageSelectedResult = WidgetChangeGuildIdentity$imageSelectedResult$1.INSTANCE;
|
|
private final MGImages.DistinctChangeDetector imagesChangeDetector = new MGImages.DistinctChangeDetector();
|
|
private final Lazy viewModel$delegate;
|
|
|
|
/* compiled from: WidgetChangeGuildIdentity.kt */
|
|
public static final class Companion {
|
|
private Companion() {
|
|
}
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
|
|
public final void launch(long j, String str, Context context) {
|
|
m.checkNotNullParameter(str, "source");
|
|
m.checkNotNullParameter(context, "context");
|
|
Intent putExtra = new Intent().putExtra("com.discord.intent.extra.EXTRA_GUILD_ID", j).putExtra("com.discord.intent.extra.EXTRA_SOURCE", str);
|
|
m.checkNotNullExpressionValue(putExtra, "Intent()\n .putE…nts.EXTRA_SOURCE, source)");
|
|
j.d(context, WidgetChangeGuildIdentity.class, putExtra);
|
|
}
|
|
}
|
|
|
|
public WidgetChangeGuildIdentity() {
|
|
super(R.layout.widget_change_guild_identity);
|
|
WidgetChangeGuildIdentity$viewModel$2 widgetChangeGuildIdentity$viewModel$2 = new WidgetChangeGuildIdentity$viewModel$2(this);
|
|
f0 f0Var = new f0(this);
|
|
this.viewModel$delegate = FragmentViewModelLazyKt.createViewModelLazy(this, a0.getOrCreateKotlinClass(WidgetChangeGuildIdentityViewModel.class), new WidgetChangeGuildIdentity$appViewModels$$inlined$viewModels$1(f0Var), new h0(widgetChangeGuildIdentity$viewModel$2));
|
|
}
|
|
|
|
public static final /* synthetic */ void access$configureUI(WidgetChangeGuildIdentity widgetChangeGuildIdentity, WidgetChangeGuildIdentityViewModel.ViewState viewState) {
|
|
widgetChangeGuildIdentity.configureUI(viewState);
|
|
}
|
|
|
|
public static final /* synthetic */ Function1 access$getAvatarSelectedResult$p(WidgetChangeGuildIdentity widgetChangeGuildIdentity) {
|
|
return widgetChangeGuildIdentity.avatarSelectedResult;
|
|
}
|
|
|
|
public static final /* synthetic */ WidgetChangeGuildIdentityBinding access$getBinding$p(WidgetChangeGuildIdentity widgetChangeGuildIdentity) {
|
|
return widgetChangeGuildIdentity.getBinding();
|
|
}
|
|
|
|
public static final /* synthetic */ AtomicBoolean access$getDiscardConfirmed$p(WidgetChangeGuildIdentity widgetChangeGuildIdentity) {
|
|
return widgetChangeGuildIdentity.discardConfirmed;
|
|
}
|
|
|
|
public static final /* synthetic */ Function1 access$getImageSelectedResult$p(WidgetChangeGuildIdentity widgetChangeGuildIdentity) {
|
|
return widgetChangeGuildIdentity.imageSelectedResult;
|
|
}
|
|
|
|
public static final /* synthetic */ WidgetChangeGuildIdentityViewModel access$getViewModel$p(WidgetChangeGuildIdentity widgetChangeGuildIdentity) {
|
|
return widgetChangeGuildIdentity.getViewModel();
|
|
}
|
|
|
|
public static final /* synthetic */ boolean access$handleBackPressed(WidgetChangeGuildIdentity widgetChangeGuildIdentity, WidgetChangeGuildIdentityViewModel.ViewState.Loaded loaded) {
|
|
return widgetChangeGuildIdentity.handleBackPressed(loaded);
|
|
}
|
|
|
|
public static final /* synthetic */ void access$navigateToUpsellModal(WidgetChangeGuildIdentity widgetChangeGuildIdentity) {
|
|
widgetChangeGuildIdentity.navigateToUpsellModal();
|
|
}
|
|
|
|
public static final /* synthetic */ void access$setAvatarSelectedResult$p(WidgetChangeGuildIdentity widgetChangeGuildIdentity, Function1 function1) {
|
|
widgetChangeGuildIdentity.avatarSelectedResult = function1;
|
|
}
|
|
|
|
public static final /* synthetic */ void access$setImageSelectedResult$p(WidgetChangeGuildIdentity widgetChangeGuildIdentity, Function1 function1) {
|
|
widgetChangeGuildIdentity.imageSelectedResult = function1;
|
|
}
|
|
|
|
public static final /* synthetic */ void access$showToast(WidgetChangeGuildIdentity widgetChangeGuildIdentity, int i) {
|
|
widgetChangeGuildIdentity.showToast(i);
|
|
}
|
|
|
|
public static final /* synthetic */ void access$showToast(WidgetChangeGuildIdentity widgetChangeGuildIdentity, String str) {
|
|
widgetChangeGuildIdentity.showToast(str);
|
|
}
|
|
|
|
private final void configureAvatar(WidgetChangeGuildIdentityViewModel.ViewState.Loaded loaded) {
|
|
SimpleDraweeView simpleDraweeView = getBinding().d;
|
|
m.checkNotNullExpressionValue(simpleDraweeView, "binding.guildAvatar");
|
|
IconUtils.setIcon$default(simpleDraweeView, loaded.getDisplayedAvatarURL(), 0, (Function1) null, this.imagesChangeDetector, 12, (Object) null);
|
|
this.avatarSelectedResult = new WidgetChangeGuildIdentity$configureAvatar$1(this);
|
|
List mutableListOf = n.mutableListOf(new d0(getString(R.string.change_guild_member_avatar), null, null, null, null, null, null, 116));
|
|
if (loaded.getDisplayingGuildAvatar()) {
|
|
mutableListOf.add(new d0(getString(R.string.change_identity_modal_reset_primary_avatar), null, null, null, null, Integer.valueOf(ColorCompat.getColor(requireContext(), (int) R.color.status_red_500)), null, 84));
|
|
}
|
|
getBinding().e.setOnClickListener(new WidgetChangeGuildIdentity$configureAvatar$2(this, loaded, mutableListOf));
|
|
}
|
|
|
|
private final void configureNickname(WidgetChangeGuildIdentityViewModel.ViewState.Loaded loaded) {
|
|
TextInputLayout textInputLayout = getBinding().g;
|
|
m.checkNotNullExpressionValue(textInputLayout, "textInputLayout");
|
|
String currentNickname = loaded.getCurrentNickname();
|
|
boolean z2 = false;
|
|
textInputLayout.setEndIconVisible(!(currentNickname == null || currentNickname.length() == 0));
|
|
Editable editable = null;
|
|
ViewExtensions.setEnabledAndAlpha$default(textInputLayout, loaded.getCanChangeNickname(), 0.0f, 2, null);
|
|
textInputLayout.setHint(loaded.getCanChangeNickname() ? getString(R.string.nickname) : getString(R.string.change_identity_modal_change_nickname_disabled));
|
|
textInputLayout.setPlaceholderText(loaded.getMeUser().getUsername());
|
|
ViewExtensions.addBindedTextWatcher(textInputLayout, this, new WidgetChangeGuildIdentity$configureNickname$$inlined$also$lambda$1(this, loaded));
|
|
textInputLayout.setEndIconOnClickListener(new WidgetChangeGuildIdentity$configureNickname$$inlined$also$lambda$2(this, loaded));
|
|
TextInputLayout textInputLayout2 = getBinding().g;
|
|
m.checkNotNullExpressionValue(textInputLayout2, "binding.setNicknameText");
|
|
String textOrEmpty = ViewExtensions.getTextOrEmpty(textInputLayout2);
|
|
if (!m.areEqual(loaded.getCurrentNickname(), textOrEmpty)) {
|
|
ViewExtensions.setText(textInputLayout, loaded.getCurrentNickname());
|
|
if (textOrEmpty.length() == 0) {
|
|
z2 = true;
|
|
}
|
|
if (z2) {
|
|
EditText editText = textInputLayout.getEditText();
|
|
if (editText != null) {
|
|
editable = editText.getText();
|
|
}
|
|
Selection.setSelection(editable, ViewExtensions.getTextOrEmpty(textInputLayout).length());
|
|
}
|
|
}
|
|
}
|
|
|
|
private final void configureUI(WidgetChangeGuildIdentityViewModel.ViewState viewState) {
|
|
if (viewState instanceof WidgetChangeGuildIdentityViewModel.ViewState.Loaded) {
|
|
if (!getViewModel().getTrackedModalOpen()) {
|
|
AnalyticsTracker.INSTANCE.openModal("Change Server Identity", new Traits.Source(Traits.Location.Page.GUILD_CHANNEL, getViewModel().getSourceSection(), null, null, null, 28, null));
|
|
getViewModel().setTrackedModalOpen(true);
|
|
}
|
|
WidgetChangeGuildIdentityViewModel.ViewState.Loaded loaded = (WidgetChangeGuildIdentityViewModel.ViewState.Loaded) viewState;
|
|
configureNickname(loaded);
|
|
configureAvatar(loaded);
|
|
configureUpsell(loaded);
|
|
WidgetChangeGuildIdentity$configureUI$1 widgetChangeGuildIdentity$configureUI$1 = new WidgetChangeGuildIdentity$configureUI$1(this, viewState);
|
|
int i = 0;
|
|
AppFragment.setOnBackPressed$default(this, widgetChangeGuildIdentity$configureUI$1, 0, 2, null);
|
|
DimmerView.setDimmed$default(getBinding().f2223b, loaded.getDimmed(), false, 2, null);
|
|
FloatingActionButton floatingActionButton = getBinding().f;
|
|
m.checkNotNullExpressionValue(floatingActionButton, "binding.saveFab");
|
|
if (!loaded.getShowSaveFab()) {
|
|
i = 8;
|
|
}
|
|
floatingActionButton.setVisibility(i);
|
|
}
|
|
}
|
|
|
|
private final void configureUpsell(WidgetChangeGuildIdentityViewModel.ViewState.Loaded loaded) {
|
|
LinearLayout linearLayout = getBinding().h;
|
|
m.checkNotNullExpressionValue(linearLayout, "binding.upsellSection");
|
|
linearLayout.setVisibility(loaded.getShouldUpsell() ? 0 : 8);
|
|
getBinding().c.setOnClickListener(new WidgetChangeGuildIdentity$configureUpsell$1(this));
|
|
if (!getViewModel().getTrackedUpsell() && loaded.getShouldUpsell()) {
|
|
AnalyticsTracker.premiumUpsellViewed$default(AnalyticsTracker.INSTANCE, AnalyticsTracker.PremiumUpsellType.PerGuildIdentityInline, new Traits.Location(Traits.Location.Page.GUILD_CHANNEL, "Change Per Server Identity Modal", "Nitro upsell button", null, null, 24, null), null, null, 12, null);
|
|
getViewModel().setTrackedUpsell(true);
|
|
}
|
|
}
|
|
|
|
private final WidgetChangeGuildIdentityBinding getBinding() {
|
|
return (WidgetChangeGuildIdentityBinding) this.binding$delegate.getValue((Fragment) this, $$delegatedProperties[0]);
|
|
}
|
|
|
|
private final WidgetChangeGuildIdentityViewModel getViewModel() {
|
|
return (WidgetChangeGuildIdentityViewModel) this.viewModel$delegate.getValue();
|
|
}
|
|
|
|
private final boolean handleBackPressed(WidgetChangeGuildIdentityViewModel.ViewState.Loaded loaded) {
|
|
hideKeyboard(getBinding().g);
|
|
if (!loaded.isDirty() || this.discardConfirmed.get()) {
|
|
return false;
|
|
}
|
|
ViewDialogConfirmationBinding b2 = ViewDialogConfirmationBinding.b(LayoutInflater.from(getActivity()));
|
|
m.checkNotNullExpressionValue(b2, "ViewDialogConfirmationBi…tInflater.from(activity))");
|
|
AlertDialog create = new AlertDialog.Builder(requireContext()).setView(b2.a).create();
|
|
m.checkNotNullExpressionValue(create, "AlertDialog.Builder(requ…logBinding.root).create()");
|
|
b2.d.setText(R.string.discard_changes);
|
|
b2.e.setText(R.string.discard_changes_description);
|
|
b2.f2155b.setOnClickListener(new WidgetChangeGuildIdentity$handleBackPressed$1(create));
|
|
b2.c.setText(R.string.okay);
|
|
b2.c.setOnClickListener(new WidgetChangeGuildIdentity$handleBackPressed$2(this, create));
|
|
create.show();
|
|
return true;
|
|
}
|
|
|
|
private final void navigateToUpsellModal() {
|
|
d.b bVar = d.k;
|
|
FragmentManager parentFragmentManager = getParentFragmentManager();
|
|
m.checkNotNullExpressionValue(parentFragmentManager, "parentFragmentManager");
|
|
AnalyticsTracker.PremiumUpsellType premiumUpsellType = AnalyticsTracker.PremiumUpsellType.PerGuildIdentityUpsellModal;
|
|
Resources resources = getResources();
|
|
m.checkNotNullExpressionValue(resources, "resources");
|
|
String obj = b.i(resources, R.string.guild_member_avatar_upsell_title, new Object[0], null, 4).toString();
|
|
Resources resources2 = getResources();
|
|
m.checkNotNullExpressionValue(resources2, "resources");
|
|
bVar.a(parentFragmentManager, premiumUpsellType, R.drawable.per_guild_identity_modal_image, obj, b.i(resources2, R.string.guild_member_avatar_upsell_body, new Object[0], null, 4).toString(), Traits.Location.Page.GUILD_CHANNEL, "Change Per Server Identity Modal", "Nitro upsell button");
|
|
}
|
|
|
|
private final void showToast(@StringRes int i) {
|
|
b.a.d.m.i(this, i, 0, 4);
|
|
}
|
|
|
|
private final void showToast(String str) {
|
|
b.a.d.m.j(this, str, 0, 4);
|
|
}
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
/* JADX WARNING: Unknown variable types count: 1 */
|
|
@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);
|
|
if (!t.startsWith$default(str, "image", false, 2, null)) {
|
|
b.a.d.m.g(getContext(), R.string.user_settings_image_upload_filetype_error, 0, null, 12);
|
|
} else if (m.areEqual(str, "image/gif")) {
|
|
Context context = getContext();
|
|
Function1<? super String, Unit> function1 = this.imageSelectedResult;
|
|
if (function1 != null) {
|
|
function1 = new WidgetChangeGuildIdentity$sam$rx_functions_Action1$0(function1);
|
|
}
|
|
MGImages.requestDataUrl(context, uri, str, (Action1) function1);
|
|
} else {
|
|
MGImages.requestImageCrop(requireContext(), this, uri, 1.0f, 1.0f, 1024);
|
|
}
|
|
}
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
/* JADX WARNING: Unknown variable types count: 1 */
|
|
@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);
|
|
Context context = getContext();
|
|
Function1<? super String, Unit> function1 = this.imageSelectedResult;
|
|
if (function1 != null) {
|
|
function1 = new WidgetChangeGuildIdentity$sam$rx_functions_Action1$0(function1);
|
|
}
|
|
MGImages.requestDataUrl(context, uri, str, (Action1) function1);
|
|
}
|
|
|
|
@Override // com.discord.app.AppFragment
|
|
public void onViewBound(View view) {
|
|
m.checkNotNullParameter(view, "view");
|
|
super.onViewBound(view);
|
|
SharedPreferences.Editor edit = SharedPreferencesProvider.INSTANCE.get().edit();
|
|
m.checkNotNullExpressionValue(edit, "editor");
|
|
edit.putBoolean(USER_GUILD_PROFILE_VIEWED_CACHE_KEY, true);
|
|
edit.apply();
|
|
setActionBarTitle(R.string.change_identity);
|
|
AppFragment.setActionBarDisplayHomeAsUpEnabled$default(this, false, 1, null);
|
|
getBinding().f.setOnClickListener(new WidgetChangeGuildIdentity$onViewBound$2(this, view));
|
|
TextInputLayout textInputLayout = getBinding().g;
|
|
m.checkNotNullExpressionValue(textInputLayout, "binding.setNicknameText");
|
|
showKeyboard(textInputLayout);
|
|
}
|
|
|
|
@Override // com.discord.app.AppFragment
|
|
public void onViewBoundOrOnResume() {
|
|
super.onViewBoundOrOnResume();
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.bindToComponentLifecycle$default(getViewModel().observeViewState(), this, null, 2, null), WidgetChangeGuildIdentity.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetChangeGuildIdentity$onViewBoundOrOnResume$1(this), 62, (Object) null);
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.bindToComponentLifecycle$default(getViewModel().observeEvents(), this, null, 2, null), WidgetChangeGuildIdentity.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetChangeGuildIdentity$onViewBoundOrOnResume$2(this), 62, (Object) null);
|
|
}
|
|
}
|