discord-jadx/app/src/main/java/com/discord/widgets/user/usersheet/WidgetUserSheet.java

798 lines
45 KiB
Java

package com.discord.widgets.user.usersheet;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.cardview.widget.CardView;
import androidx.core.view.ViewCompat;
import androidx.core.widget.ContentLoadingProgressBar;
import androidx.core.widget.NestedScrollView;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentViewModelLazyKt;
import c.a.d.h0;
import c.a.d.j0;
import c.a.d.o;
import c.d.b.a.a;
import com.airbnb.lottie.parser.AnimatableValueParser;
import com.discord.api.activity.Activity;
import com.discord.api.activity.ActivityPlatform;
import com.discord.api.channel.Channel;
import com.discord.api.role.GuildRole;
import com.discord.app.AppBottomSheet;
import com.discord.app.RebrandFeatureFlag;
import com.discord.databinding.WidgetUserSheetBinding;
import com.discord.models.domain.ModelUserRelationship;
import com.discord.models.presence.Presence;
import com.discord.models.user.User;
import com.discord.simpleast.core.node.Node;
import com.discord.stores.StoreNotices;
import com.discord.stores.StoreStream;
import com.discord.stores.StoreUserNotes;
import com.discord.utilities.accessibility.AccessibilityUtils;
import com.discord.utilities.analytics.AnalyticsTracker;
import com.discord.utilities.color.ColorCompat;
import com.discord.utilities.presence.ActivityUtilsKt;
import com.discord.utilities.presence.PresenceUtils;
import com.discord.utilities.rest.RestAPIAbortMessages;
import com.discord.utilities.rx.ObservableExtensionsKt;
import com.discord.utilities.streams.StreamContext;
import com.discord.utilities.textprocessing.AstRenderer;
import com.discord.utilities.textprocessing.MessageRenderContext;
import com.discord.utilities.view.extensions.ViewExtensions;
import com.discord.utilities.view.text.LinkifiedTextView;
import com.discord.utilities.view.text.TextWatcherKt;
import com.discord.utilities.viewbinding.FragmentViewBindingDelegate;
import com.discord.utilities.viewbinding.FragmentViewBindingDelegateKt;
import com.discord.widgets.channels.WidgetChannelSelector;
import com.discord.widgets.roles.RolesListView;
import com.discord.widgets.servers.WidgetServerSettingsEditMember;
import com.discord.widgets.stage.usersheet.UserProfileStageActionsView;
import com.discord.widgets.user.Badge;
import com.discord.widgets.user.WidgetBanUser;
import com.discord.widgets.user.WidgetKickUser;
import com.discord.widgets.user.calls.PrivateCallLauncher;
import com.discord.widgets.user.presence.ViewHolderStreamRichPresence;
import com.discord.widgets.user.presence.ViewHolderUserRichPresence;
import com.discord.widgets.user.profile.UserProfileAdminView;
import com.discord.widgets.user.profile.UserProfileConnectionsView;
import com.discord.widgets.user.profile.UserProfileHeaderView;
import com.discord.widgets.user.profile.UserProfileHeaderViewModel;
import com.discord.widgets.user.usersheet.UserProfileVoiceSettingsView;
import com.discord.widgets.user.usersheet.WidgetUserSheetViewModel;
import com.discord.widgets.voice.fullscreen.WidgetCallFullscreen;
import com.google.android.material.textfield.TextInputEditText;
import com.google.android.material.textfield.TextInputLayout;
import d0.t.n;
import d0.z.d.a0;
import d0.z.d.m;
import java.util.List;
import kotlin.Lazy;
import kotlin.NoWhenBranchMatchedException;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.reflect.KProperty;
import rx.subscriptions.CompositeSubscription;
/* compiled from: WidgetUserSheet.kt */
public final class WidgetUserSheet extends AppBottomSheet {
public static final /* synthetic */ KProperty[] $$delegatedProperties = {a.W(WidgetUserSheet.class, "binding", "getBinding()Lcom/discord/databinding/WidgetUserSheetBinding;", 0)};
private static final String ARG_CHANNEL_ID = "ARG_CHANNEL_ID";
private static final String ARG_FRIEND_TOKEN = "ARG_FRIEND_TOKEN";
private static final String ARG_GUILD_ID = "ARG_GUILD_ID";
private static final String ARG_IS_VOICE_CONTEXT = "ARG_IS_VOICE_CONTEXT";
private static final String ARG_STREAM_PREVIEW_CLICK_BEHAVIOR = "ARG_STREAM_PREVIEW_CLICK_BEHAVIOR";
private static final String ARG_USER_ID = "ARG_USER_ID";
public static final Companion Companion = new Companion(null);
private static final String REQUEST_KEY_MOVE_USER = "REQUEST_KEY_MOVE_USER";
private ViewHolderUserRichPresence activityViewHolder;
private final FragmentViewBindingDelegate binding$delegate = FragmentViewBindingDelegateKt.viewBinding$default(this, WidgetUserSheet$binding$2.INSTANCE, null, 2, null);
private PrivateCallLauncher privateCallLauncher;
private final Lazy viewModel$delegate;
private final Lazy viewModelUserProfileHeader$delegate;
/* compiled from: WidgetUserSheet.kt */
public static final class Companion {
private Companion() {
}
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
public static /* synthetic */ void enqueueNotice$default(Companion companion, long j, String str, int i, Object obj) {
if ((i & 2) != 0) {
str = null;
}
companion.enqueueNotice(j, str);
}
private final String getNoticeName(long j) {
String str = "User Sheet Notice for user ID: " + j;
m.checkNotNullExpressionValue(str, "StringBuilder(\"User Shee…)\n .toString()");
return str;
}
public static /* synthetic */ void show$default(Companion companion, long j, Long l, FragmentManager fragmentManager, Long l2, Boolean bool, StreamPreviewClickBehavior streamPreviewClickBehavior, String str, int i, Object obj) {
companion.show(j, (i & 2) != 0 ? null : l, fragmentManager, (i & 8) != 0 ? null : l2, (i & 16) != 0 ? null : bool, (i & 32) != 0 ? StreamPreviewClickBehavior.TARGET_AND_LAUNCH_SPECTATE : streamPreviewClickBehavior, (i & 64) != 0 ? null : str);
}
public final void enqueueNotice(long j, String str) {
StoreNotices notices = StoreStream.Companion.getNotices();
String noticeName = getNoticeName(j);
notices.requestToShow(new StoreNotices.Notice(noticeName, null, 0, 0, false, null, 0, 0, new WidgetUserSheet$Companion$enqueueNotice$showUserSheetNotice$1(j, str, notices, noticeName), 54, null));
}
public final void show(long j, FragmentManager fragmentManager) {
show$default(this, j, null, fragmentManager, null, null, null, null, 122, null);
}
public final void show(long j, Long l, FragmentManager fragmentManager) {
show$default(this, j, l, fragmentManager, null, null, null, null, 120, null);
}
public final void show(long j, Long l, FragmentManager fragmentManager, Long l2) {
show$default(this, j, l, fragmentManager, l2, null, null, null, 112, null);
}
public final void show(long j, Long l, FragmentManager fragmentManager, Long l2, Boolean bool) {
show$default(this, j, l, fragmentManager, l2, bool, null, null, 96, null);
}
public final void show(long j, Long l, FragmentManager fragmentManager, Long l2, Boolean bool, StreamPreviewClickBehavior streamPreviewClickBehavior) {
show$default(this, j, l, fragmentManager, l2, bool, streamPreviewClickBehavior, null, 64, null);
}
public final void show(long j, Long l, FragmentManager fragmentManager, Long l2, Boolean bool, StreamPreviewClickBehavior streamPreviewClickBehavior, String str) {
m.checkNotNullParameter(fragmentManager, "fragmentManager");
m.checkNotNullParameter(streamPreviewClickBehavior, "streamPreviewClickBehavior");
WidgetUserSheet widgetUserSheet = new WidgetUserSheet();
Bundle bundle = new Bundle();
bundle.putLong("ARG_USER_ID", j);
if (l != null) {
bundle.putLong("ARG_CHANNEL_ID", l.longValue());
}
if (str != null) {
bundle.putString("ARG_FRIEND_TOKEN", str);
}
if (l2 != null) {
bundle.putLong("ARG_GUILD_ID", l2.longValue());
}
bundle.putBoolean("ARG_IS_VOICE_CONTEXT", bool != null ? bool.booleanValue() : false);
bundle.putSerializable("ARG_STREAM_PREVIEW_CLICK_BEHAVIOR", streamPreviewClickBehavior);
widgetUserSheet.setArguments(bundle);
widgetUserSheet.show(fragmentManager, WidgetUserSheet.class.getName());
}
}
/* compiled from: WidgetUserSheet.kt */
public enum StreamPreviewClickBehavior {
TARGET_AND_LAUNCH_SPECTATE,
TARGET_AND_DISMISS
}
public WidgetUserSheet() {
super(false, 1, null);
WidgetUserSheet$viewModelUserProfileHeader$2 widgetUserSheet$viewModelUserProfileHeader$2 = new WidgetUserSheet$viewModelUserProfileHeader$2(this);
h0 h0Var = new h0(this);
this.viewModelUserProfileHeader$delegate = FragmentViewModelLazyKt.createViewModelLazy(this, a0.getOrCreateKotlinClass(UserProfileHeaderViewModel.class), new WidgetUserSheet$appViewModels$$inlined$viewModels$1(h0Var), new j0(widgetUserSheet$viewModelUserProfileHeader$2));
WidgetUserSheet$viewModel$2 widgetUserSheet$viewModel$2 = new WidgetUserSheet$viewModel$2(this);
h0 h0Var2 = new h0(this);
this.viewModel$delegate = FragmentViewModelLazyKt.createViewModelLazy(this, a0.getOrCreateKotlinClass(WidgetUserSheetViewModel.class), new WidgetUserSheet$appViewModels$$inlined$viewModels$2(h0Var2), new j0(widgetUserSheet$viewModel$2));
}
private final void acceptFriendRequest(String str) {
getViewModel().addRelationship(null, str, 2131886115);
}
public static final /* synthetic */ void access$acceptFriendRequest(WidgetUserSheet widgetUserSheet, String str) {
widgetUserSheet.acceptFriendRequest(str);
}
public static final /* synthetic */ void access$addFriend(WidgetUserSheet widgetUserSheet, String str) {
widgetUserSheet.addFriend(str);
}
public static final /* synthetic */ void access$configureUI(WidgetUserSheet widgetUserSheet, WidgetUserSheetViewModel.ViewState viewState) {
widgetUserSheet.configureUI(viewState);
}
public static final /* synthetic */ Bundle access$getArgumentsOrDefault$p(WidgetUserSheet widgetUserSheet) {
return widgetUserSheet.getArgumentsOrDefault();
}
public static final /* synthetic */ WidgetUserSheetBinding access$getBinding$p(WidgetUserSheet widgetUserSheet) {
return widgetUserSheet.getBinding();
}
public static final /* synthetic */ WidgetUserSheetViewModel access$getViewModel$p(WidgetUserSheet widgetUserSheet) {
return widgetUserSheet.getViewModel();
}
public static final /* synthetic */ void access$handleEvent(WidgetUserSheet widgetUserSheet, WidgetUserSheetViewModel.Event event) {
widgetUserSheet.handleEvent(event);
}
public static final /* synthetic */ void access$ignoreFriendRequest(WidgetUserSheet widgetUserSheet) {
widgetUserSheet.ignoreFriendRequest();
}
public static final /* synthetic */ void access$onStreamPreviewClicked(WidgetUserSheet widgetUserSheet, StreamContext streamContext) {
widgetUserSheet.onStreamPreviewClicked(streamContext);
}
private final void addFriend(String str) {
getViewModel().addRelationship(null, str, 2131888809);
}
private final void configureAboutMe(WidgetUserSheetViewModel.ViewState.Loaded loaded) {
List<Node<MessageRenderContext>> bioAst = loaded.getBioAst();
TextView textView = getBinding().f1993c;
m.checkNotNullExpressionValue(textView, "binding.aboutMeHeader");
boolean z2 = true;
int i = 0;
textView.setVisibility(bioAst != null ? 0 : 8);
CardView cardView = getBinding().b;
m.checkNotNullExpressionValue(cardView, "binding.aboutMeCard");
if (bioAst == null) {
z2 = false;
}
if (!z2) {
i = 8;
}
cardView.setVisibility(i);
if (bioAst != null) {
LinkifiedTextView linkifiedTextView = getBinding().d;
m.checkNotNullExpressionValue(linkifiedTextView, "binding.aboutMeText");
Context context = linkifiedTextView.getContext();
m.checkNotNullExpressionValue(context, "binding.aboutMeText.context");
MessageRenderContext messageRenderContext = new MessageRenderContext(context, 0, false, null, null, null, 0, null, null, 0, 0, new WidgetUserSheet$configureAboutMe$renderContext$1(getViewModel()), null, null, 14328, null);
LinkifiedTextView linkifiedTextView2 = getBinding().d;
m.checkNotNullExpressionValue(linkifiedTextView2, "binding.aboutMeText");
linkifiedTextView2.setText(AstRenderer.render(loaded.getBioAst(), messageRenderContext));
}
}
private final void configureConnectionsSection(WidgetUserSheetViewModel.ViewState.Loaded loaded) {
UserProfileConnectionsView.ViewState connectionsViewState = loaded.getConnectionsViewState();
TextView textView = getBinding().k;
m.checkNotNullExpressionValue(textView, "binding.userSheetConnectionsHeader");
int i = 0;
textView.setVisibility(connectionsViewState.getShowConnectionsSection() ? 0 : 8);
UserProfileConnectionsView userProfileConnectionsView = getBinding().l;
m.checkNotNullExpressionValue(userProfileConnectionsView, "binding.userSheetConnectionsView");
if (!connectionsViewState.getShowConnectionsSection()) {
i = 8;
}
userProfileConnectionsView.setVisibility(i);
WidgetUserSheet$configureConnectionsSection$onConnectedAccountClick$1 widgetUserSheet$configureConnectionsSection$onConnectedAccountClick$1 = new WidgetUserSheet$configureConnectionsSection$onConnectedAccountClick$1(this);
User user = loaded.getUser();
getBinding().l.updateViewState(connectionsViewState, widgetUserSheet$configureConnectionsSection$onConnectedAccountClick$1, new WidgetUserSheet$configureConnectionsSection$onMutualGuildsItemClick$1(this, user), new WidgetUserSheet$configureConnectionsSection$onMutualFriendsItemClick$1(this, user));
}
private final void configureDeveloperSection(WidgetUserSheetViewModel.ViewState.Loaded loaded) {
TextView textView = getBinding().m;
int i = 8;
textView.setVisibility(StoreStream.Companion.getUserSettings().getIsDeveloperMode() ? 0 : 8);
textView.setOnClickListener(new WidgetUserSheet$configureDeveloperSection$$inlined$apply$lambda$1(textView, this, loaded));
TextView textView2 = getBinding().m;
m.checkNotNullExpressionValue(textView2, "binding.userSheetCopyId");
boolean z2 = textView2.getVisibility() == 0;
TextView textView3 = getBinding().n;
m.checkNotNullExpressionValue(textView3, "binding.userSheetDeveloperHeader");
if (z2) {
i = 0;
}
textView3.setVisibility(i);
}
private final void configureGuildSection(WidgetUserSheetViewModel.ViewState.Loaded loaded) {
List<GuildRole> roleItems = loaded.getRoleItems();
UserProfileAdminView.ViewState adminViewState = loaded.getAdminViewState();
boolean z2 = true;
boolean z3 = !roleItems.isEmpty();
int i = 0;
boolean z4 = adminViewState != null && adminViewState.isAdminSectionEnabled();
LinearLayout linearLayout = getBinding().r;
m.checkNotNullExpressionValue(linearLayout, "binding.userSheetGuildContainer");
if (!z3 && !z4) {
z2 = false;
}
linearLayout.setVisibility(z2 ? 0 : 8);
RolesListView rolesListView = getBinding().I;
m.checkNotNullExpressionValue(rolesListView, "binding.userSheetRolesList");
rolesListView.setVisibility(z3 ? 0 : 8);
RolesListView rolesListView2 = getBinding().I;
RolesListView rolesListView3 = getBinding().I;
m.checkNotNullExpressionValue(rolesListView3, "binding.userSheetRolesList");
rolesListView2.updateView(roleItems, ColorCompat.getThemedColor(rolesListView3.getContext(), 2130969877));
String guildSectionHeaderText = loaded.getGuildSectionHeaderText();
if (guildSectionHeaderText != null) {
TextView textView = getBinding().f1994s;
m.checkNotNullExpressionValue(textView, "binding.userSheetGuildHeader");
textView.setText(guildSectionHeaderText);
}
CardView cardView = getBinding().h;
m.checkNotNullExpressionValue(cardView, "binding.userSheetAdminCard");
cardView.setVisibility(z4 ? 0 : 8);
UserProfileAdminView userProfileAdminView = getBinding().i;
m.checkNotNullExpressionValue(userProfileAdminView, "binding.userSheetAdminView");
if (!z4) {
i = 8;
}
userProfileAdminView.setVisibility(i);
if (adminViewState != null) {
getBinding().i.updateView(adminViewState);
}
}
private final void configureIncomingFriendRequest(WidgetUserSheetViewModel.ViewState.Loaded loaded) {
int i = 0;
boolean z2 = ModelUserRelationship.getType(Integer.valueOf(loaded.getUserRelationshipType())) == 3;
TextView textView = getBinding().t;
m.checkNotNullExpressionValue(textView, "binding.userSheetIncomingFriendRequestHeader");
textView.setVisibility(z2 ? 0 : 8);
LinearLayout linearLayout = getBinding().q;
m.checkNotNullExpressionValue(linearLayout, "binding.userSheetFriendRequestIncomingContainer");
if (!z2) {
i = 8;
}
linearLayout.setVisibility(i);
getBinding().o.setOnClickListener(new WidgetUserSheet$configureIncomingFriendRequest$1(this, loaded));
getBinding().p.setOnClickListener(new WidgetUserSheet$configureIncomingFriendRequest$2(this));
}
private final void configureNote(WidgetUserSheetViewModel.ViewState.Loaded loaded) {
getBinding().f1996y.setRawInputType(1);
StoreUserNotes.UserNoteState userNoteFetchState = loaded.getUserNoteFetchState();
if (userNoteFetchState instanceof StoreUserNotes.UserNoteState.Empty) {
TextInputLayout textInputLayout = getBinding().f1997z;
m.checkNotNullExpressionValue(textInputLayout, "binding.userSheetNoteTextFieldWrap");
textInputLayout.setHint(getString(2131891446));
TextInputLayout textInputLayout2 = getBinding().f1997z;
m.checkNotNullExpressionValue(textInputLayout2, "binding.userSheetNoteTextFieldWrap");
textInputLayout2.setEnabled(true);
TextInputLayout textInputLayout3 = getBinding().f1997z;
m.checkNotNullExpressionValue(textInputLayout3, "binding.userSheetNoteTextFieldWrap");
ViewExtensions.setTextIfDifferent(textInputLayout3, loaded.getUserNote());
} else if (userNoteFetchState instanceof StoreUserNotes.UserNoteState.Loading) {
TextInputLayout textInputLayout4 = getBinding().f1997z;
m.checkNotNullExpressionValue(textInputLayout4, "binding.userSheetNoteTextFieldWrap");
textInputLayout4.setHint(getString(2131890843));
TextInputLayout textInputLayout5 = getBinding().f1997z;
m.checkNotNullExpressionValue(textInputLayout5, "binding.userSheetNoteTextFieldWrap");
textInputLayout5.setEnabled(false);
TextInputLayout textInputLayout6 = getBinding().f1997z;
m.checkNotNullExpressionValue(textInputLayout6, "binding.userSheetNoteTextFieldWrap");
ViewExtensions.setTextIfDifferent(textInputLayout6, loaded.getUserNote());
} else if (userNoteFetchState instanceof StoreUserNotes.UserNoteState.Loaded) {
TextInputLayout textInputLayout7 = getBinding().f1997z;
m.checkNotNullExpressionValue(textInputLayout7, "binding.userSheetNoteTextFieldWrap");
textInputLayout7.setHint(getString(2131891446));
TextInputLayout textInputLayout8 = getBinding().f1997z;
m.checkNotNullExpressionValue(textInputLayout8, "binding.userSheetNoteTextFieldWrap");
textInputLayout8.setEnabled(true);
TextInputLayout textInputLayout9 = getBinding().f1997z;
m.checkNotNullExpressionValue(textInputLayout9, "binding.userSheetNoteTextFieldWrap");
ViewExtensions.setTextIfDifferent(textInputLayout9, loaded.getUserNote());
}
}
private final void configureProfileActionButtons(WidgetUserSheetViewModel.ViewState.Loaded loaded) {
boolean isMe = loaded.isMe();
boolean isBot = loaded.getUser().isBot();
boolean isSystemUser = loaded.getUser().isSystemUser();
int userRelationshipType = loaded.getUserRelationshipType();
boolean z2 = true;
int i = 0;
boolean z3 = !isMe && !isSystemUser;
View view = getBinding().C;
m.checkNotNullExpressionValue(view, "binding.userSheetProfileActionsDivider");
view.setVisibility(z3 ? 0 : 8);
LinearLayout linearLayout = getBinding().B;
m.checkNotNullExpressionValue(linearLayout, "binding.userSheetProfileActionsContainer");
linearLayout.setVisibility(z3 ? 0 : 8);
if (z3) {
Button button = getBinding().v;
m.checkNotNullExpressionValue(button, "binding.userSheetMessageActionButton");
Channel channel = loaded.getChannel();
button.setVisibility(channel == null || channel.z() != 1 ? 0 : 8);
getBinding().v.setOnClickListener(new WidgetUserSheet$configureProfileActionButtons$1(this, loaded));
getBinding().j.setOnClickListener(new WidgetUserSheet$configureProfileActionButtons$2(this));
getBinding().J.setOnClickListener(new WidgetUserSheet$configureProfileActionButtons$3(this));
if (userRelationshipType == 0) {
Button button2 = getBinding().g;
m.checkNotNullExpressionValue(button2, "binding.userSheetAddFriendActionButton");
button2.setVisibility(0);
Button button3 = getBinding().A;
m.checkNotNullExpressionValue(button3, "binding.userSheetPendingFriendRequestActionButton");
button3.setVisibility(8);
} else if (userRelationshipType == 3 || userRelationshipType == 4) {
Button button4 = getBinding().g;
m.checkNotNullExpressionValue(button4, "binding.userSheetAddFriendActionButton");
button4.setVisibility(8);
Button button5 = getBinding().A;
m.checkNotNullExpressionValue(button5, "binding.userSheetPendingFriendRequestActionButton");
button5.setVisibility(0);
} else {
Button button6 = getBinding().g;
m.checkNotNullExpressionValue(button6, "binding.userSheetAddFriendActionButton");
button6.setVisibility(8);
Button button7 = getBinding().A;
m.checkNotNullExpressionValue(button7, "binding.userSheetPendingFriendRequestActionButton");
button7.setVisibility(8);
}
if (isMe || isBot || userRelationshipType != 0) {
z2 = false;
}
Button button8 = getBinding().g;
m.checkNotNullExpressionValue(button8, "binding.userSheetAddFriendActionButton");
if (!z2) {
i = 8;
}
button8.setVisibility(i);
getBinding().g.setOnClickListener(new WidgetUserSheet$configureProfileActionButtons$4(this, loaded));
getBinding().A.setOnClickListener(new WidgetUserSheet$configureProfileActionButtons$5(this, userRelationshipType, loaded));
}
}
private final void configureStageActionsSection(WidgetUserSheetViewModel.ViewState.Loaded loaded) {
getBinding().F.updateView(loaded.getStageViewState());
CardView cardView = getBinding().E;
m.checkNotNullExpressionValue(cardView, "binding.userSheetProfileStageActionsCard");
UserProfileStageActionsView userProfileStageActionsView = getBinding().F;
m.checkNotNullExpressionValue(userProfileStageActionsView, "binding.userSheetProfileStageActionsView");
int i = 0;
if (!(userProfileStageActionsView.getVisibility() == 0)) {
i = 8;
}
cardView.setVisibility(i);
}
private final void configureUI(WidgetUserSheetViewModel.ViewState viewState) {
int i = 0;
if (viewState instanceof WidgetUserSheetViewModel.ViewState.Uninitialized) {
FrameLayout frameLayout = getBinding().u;
m.checkNotNullExpressionValue(frameLayout, "binding.userSheetLoadingContainer");
frameLayout.setVisibility(0);
} else if (viewState instanceof WidgetUserSheetViewModel.ViewState.Loaded) {
FrameLayout frameLayout2 = getBinding().u;
m.checkNotNullExpressionValue(frameLayout2, "binding.userSheetLoadingContainer");
frameLayout2.setVisibility(8);
WidgetUserSheetViewModel.ViewState.Loaded loaded = (WidgetUserSheetViewModel.ViewState.Loaded) viewState;
Presence presence = loaded.getPresence();
ActivityPlatform activityPlatform = null;
Activity primaryActivity = presence != null ? PresenceUtils.INSTANCE.getPrimaryActivity(presence) : null;
boolean isMe = loaded.isMe();
boolean isSystemUser = loaded.getUser().isSystemUser();
ImageView imageView = getBinding().w;
m.checkNotNullExpressionValue(imageView, "binding.userSheetMoreButton");
if (!(!isMe && !isSystemUser)) {
i = 8;
}
imageView.setVisibility(i);
if (loaded.getConnectionsViewState().getShowConnectionsSection()) {
setPeekHeightBottomView(getBinding().k);
}
ViewHolderUserRichPresence.Companion companion = ViewHolderUserRichPresence.Companion;
FrameLayout frameLayout3 = getBinding().f;
m.checkNotNullExpressionValue(frameLayout3, "binding.richPresenceContainer");
ViewHolderUserRichPresence richPresence = companion.setRichPresence(frameLayout3, primaryActivity, loaded.getStreamContext(), this.activityViewHolder);
FragmentManager parentFragmentManager = getParentFragmentManager();
m.checkNotNullExpressionValue(parentFragmentManager, "parentFragmentManager");
StreamContext streamContext = loaded.getStreamContext();
boolean isMe2 = loaded.isMe();
User user = loaded.getUser();
Context applicationContext = requireAppActivity().getApplicationContext();
m.checkNotNullExpressionValue(applicationContext, "requireAppActivity().applicationContext");
richPresence.configureUi(parentFragmentManager, streamContext, isMe2, user, applicationContext, loaded.getRichPresence(), loaded.getUserInSameVoiceChannel());
richPresence.configureUiTimestamp(primaryActivity, this);
this.activityViewHolder = richPresence;
if (!(richPresence instanceof ViewHolderStreamRichPresence)) {
richPresence = null;
}
ViewHolderStreamRichPresence viewHolderStreamRichPresence = (ViewHolderStreamRichPresence) richPresence;
if (!(loaded.getStreamContext() == null || viewHolderStreamRichPresence == null)) {
viewHolderStreamRichPresence.setOnStreamPreviewClicked(new WidgetUserSheet$configureUI$2(this, viewState));
}
ViewHolderUserRichPresence viewHolderUserRichPresence = this.activityViewHolder;
if (viewHolderUserRichPresence != null) {
viewHolderUserRichPresence.setOnActivityCustomButtonClicked(new WidgetUserSheet$configureUI$3(getViewModel()));
}
configureProfileActionButtons(loaded);
configureStageActionsSection(loaded);
configureAboutMe(loaded);
configureIncomingFriendRequest(loaded);
configureVoiceSection(loaded);
configureGuildSection(loaded);
configureConnectionsSection(loaded);
configureNote(loaded);
configureDeveloperSection(loaded);
AnalyticsTracker analyticsTracker = AnalyticsTracker.INSTANCE;
String h = primaryActivity != null ? primaryActivity.h() : null;
if (primaryActivity != null) {
activityPlatform = ActivityUtilsKt.getGamePlatform(primaryActivity);
}
analyticsTracker.openUserSheet(h, activityPlatform);
} else {
throw new NoWhenBranchMatchedException();
}
}
private final void configureVoiceSection(WidgetUserSheetViewModel.ViewState.Loaded loaded) {
UserProfileVoiceSettingsView.ViewState voiceSettingsViewState = loaded.getVoiceSettingsViewState();
boolean showVoiceSettings = loaded.getShowVoiceSettings();
TextView textView = getBinding().G;
m.checkNotNullExpressionValue(textView, "binding.userSheetProfileVoiceSettingsHeader");
int i = 0;
textView.setVisibility(showVoiceSettings ? 0 : 8);
CardView cardView = getBinding().K;
m.checkNotNullExpressionValue(cardView, "binding.voiceSettingsViewCard");
if (!showVoiceSettings) {
i = 8;
}
cardView.setVisibility(i);
getBinding().H.updateView(voiceSettingsViewState);
}
private final WidgetUserSheetBinding getBinding() {
return (WidgetUserSheetBinding) this.binding$delegate.getValue((Fragment) this, $$delegatedProperties[0]);
}
private final WidgetUserSheetViewModel getViewModel() {
return (WidgetUserSheetViewModel) this.viewModel$delegate.getValue();
}
private final UserProfileHeaderViewModel getViewModelUserProfileHeader() {
return (UserProfileHeaderViewModel) this.viewModelUserProfileHeader$delegate.getValue();
}
private final void handleBanUser(WidgetUserSheetViewModel.Event.LaunchBanUser launchBanUser) {
WidgetBanUser.Companion.launch(launchBanUser.getUsername(), launchBanUser.getGuildId(), launchBanUser.getUserId(), getParentFragmentManager());
}
private final void handleDismissSheet() {
dismiss();
}
private final void handleEvent(WidgetUserSheetViewModel.Event event) {
if (event instanceof WidgetUserSheetViewModel.Event.ShowToast) {
handleShowToast((WidgetUserSheetViewModel.Event.ShowToast) event);
} else if (event instanceof WidgetUserSheetViewModel.Event.ShowFriendRequestErrorToast) {
handleShowFriendRequestErrorToast((WidgetUserSheetViewModel.Event.ShowFriendRequestErrorToast) event);
} else if (event instanceof WidgetUserSheetViewModel.Event.LaunchVoiceCall) {
handleLaunchVoiceCall((WidgetUserSheetViewModel.Event.LaunchVoiceCall) event);
} else if (event instanceof WidgetUserSheetViewModel.Event.LaunchVideoCall) {
handleLaunchVideoCall((WidgetUserSheetViewModel.Event.LaunchVideoCall) event);
} else if (event instanceof WidgetUserSheetViewModel.Event.LaunchSpectate) {
handleLaunchSpectate((WidgetUserSheetViewModel.Event.LaunchSpectate) event);
} else if (event instanceof WidgetUserSheetViewModel.Event.LaunchEditMember) {
handleLaunchEditMember((WidgetUserSheetViewModel.Event.LaunchEditMember) event);
} else if (event instanceof WidgetUserSheetViewModel.Event.LaunchKickUser) {
handleKickUser((WidgetUserSheetViewModel.Event.LaunchKickUser) event);
} else if (event instanceof WidgetUserSheetViewModel.Event.LaunchBanUser) {
handleBanUser((WidgetUserSheetViewModel.Event.LaunchBanUser) event);
} else if (event instanceof WidgetUserSheetViewModel.Event.LaunchMoveUser) {
handleMoveUser((WidgetUserSheetViewModel.Event.LaunchMoveUser) event);
} else if (event instanceof WidgetUserSheetViewModel.Event.RequestPermissionsForSpectateStream) {
handleRequestPermissionsForSpectateStream((WidgetUserSheetViewModel.Event.RequestPermissionsForSpectateStream) event);
} else if (event instanceof WidgetUserSheetViewModel.Event.UserNotFound) {
o.i(this, 2131894242, 0, 4);
handleDismissSheet();
} else if (event instanceof WidgetUserSheetViewModel.Event.DismissSheet) {
handleDismissSheet();
} else {
throw new NoWhenBranchMatchedException();
}
}
private final void handleKickUser(WidgetUserSheetViewModel.Event.LaunchKickUser launchKickUser) {
WidgetKickUser.Companion companion = WidgetKickUser.Companion;
String username = launchKickUser.getUsername();
long guildId = launchKickUser.getGuildId();
long userId = launchKickUser.getUserId();
FragmentManager parentFragmentManager = getParentFragmentManager();
m.checkNotNullExpressionValue(parentFragmentManager, "parentFragmentManager");
companion.launch(username, guildId, userId, parentFragmentManager);
}
private final void handleLaunchEditMember(WidgetUserSheetViewModel.Event.LaunchEditMember launchEditMember) {
WidgetServerSettingsEditMember.Companion companion = WidgetServerSettingsEditMember.Companion;
long guildId = launchEditMember.getGuildId();
long userId = launchEditMember.getUserId();
WidgetUserSheetBinding binding = getBinding();
m.checkNotNullExpressionValue(binding, "binding");
NestedScrollView nestedScrollView = binding.a;
m.checkNotNullExpressionValue(nestedScrollView, "binding.root");
Context context = nestedScrollView.getContext();
m.checkNotNullExpressionValue(context, "binding.root.context");
companion.launch(guildId, userId, context);
}
private final void handleLaunchSpectate(WidgetUserSheetViewModel.Event.LaunchSpectate launchSpectate) {
WidgetCallFullscreen.Companion companion = WidgetCallFullscreen.Companion;
Context requireContext = requireContext();
m.checkNotNullExpressionValue(requireContext, "requireContext()");
WidgetCallFullscreen.Companion.launch$default(companion, requireContext, launchSpectate.getStream().getChannelId(), false, launchSpectate.getStream().getEncodedStreamKey(), null, 20, null);
dismiss();
}
private final void handleLaunchVideoCall(WidgetUserSheetViewModel.Event.LaunchVideoCall launchVideoCall) {
PrivateCallLauncher privateCallLauncher = this.privateCallLauncher;
if (privateCallLauncher == null) {
m.throwUninitializedPropertyAccessException("privateCallLauncher");
}
privateCallLauncher.launchVideoCall(launchVideoCall.getChannelId());
}
private final void handleLaunchVoiceCall(WidgetUserSheetViewModel.Event.LaunchVoiceCall launchVoiceCall) {
PrivateCallLauncher privateCallLauncher = this.privateCallLauncher;
if (privateCallLauncher == null) {
m.throwUninitializedPropertyAccessException("privateCallLauncher");
}
privateCallLauncher.launchVoiceCall(launchVoiceCall.getChannelId());
}
private final void handleMoveUser(WidgetUserSheetViewModel.Event.LaunchMoveUser launchMoveUser) {
WidgetChannelSelector.Companion.launchForVocal$default(WidgetChannelSelector.Companion, this, launchMoveUser.getGuildId(), "REQUEST_KEY_MOVE_USER", false, 0, 24, null);
}
private final void handleRequestPermissionsForSpectateStream(WidgetUserSheetViewModel.Event.RequestPermissionsForSpectateStream requestPermissionsForSpectateStream) {
AnimatableValueParser.o2(this, null, new WidgetUserSheet$handleRequestPermissionsForSpectateStream$1(this, requestPermissionsForSpectateStream), 1, null);
}
private final void handleShowFriendRequestErrorToast(WidgetUserSheetViewModel.Event.ShowFriendRequestErrorToast showFriendRequestErrorToast) {
o.j(this, RestAPIAbortMessages.ResponseResolver.INSTANCE.getRelationshipResponse(getContext(), showFriendRequestErrorToast.getAbortCode(), showFriendRequestErrorToast.getUsername()), 0, 4);
}
private final void handleShowToast(WidgetUserSheetViewModel.Event.ShowToast showToast) {
o.i(this, showToast.getStringRes(), 0, 4);
}
private final void ignoreFriendRequest() {
getViewModel().removeRelationship(2131888801);
}
private final void onStreamPreviewClicked(StreamContext streamContext) {
getViewModel().onStreamPreviewClicked(streamContext);
}
public static final void show(long j, FragmentManager fragmentManager) {
Companion.show$default(Companion, j, null, fragmentManager, null, null, null, null, 122, null);
}
public static final void show(long j, Long l, FragmentManager fragmentManager) {
Companion.show$default(Companion, j, l, fragmentManager, null, null, null, null, 120, null);
}
public static final void show(long j, Long l, FragmentManager fragmentManager, Long l2) {
Companion.show$default(Companion, j, l, fragmentManager, l2, null, null, null, 112, null);
}
public static final void show(long j, Long l, FragmentManager fragmentManager, Long l2, Boolean bool) {
Companion.show$default(Companion, j, l, fragmentManager, l2, bool, null, null, 96, null);
}
public static final void show(long j, Long l, FragmentManager fragmentManager, Long l2, Boolean bool, StreamPreviewClickBehavior streamPreviewClickBehavior) {
Companion.show$default(Companion, j, l, fragmentManager, l2, bool, streamPreviewClickBehavior, null, 64, null);
}
public static final void show(long j, Long l, FragmentManager fragmentManager, Long l2, Boolean bool, StreamPreviewClickBehavior streamPreviewClickBehavior, String str) {
Companion.show(j, l, fragmentManager, l2, bool, streamPreviewClickBehavior, str);
}
@Override // com.discord.app.AppBottomSheet
public void bindSubscriptions(CompositeSubscription compositeSubscription) {
m.checkNotNullParameter(compositeSubscription, "compositeSubscription");
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(getViewModel().observeViewState(), this, null, 2, null), WidgetUserSheet.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetUserSheet$bindSubscriptions$1(this), 62, (Object) null);
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(getViewModel().observeEvents(), this, null, 2, null), WidgetUserSheet.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetUserSheet$bindSubscriptions$2(this), 62, (Object) null);
UserProfileHeaderView.Companion companion = UserProfileHeaderView.Companion;
UserProfileHeaderView userProfileHeaderView = getBinding().D;
m.checkNotNullExpressionValue(userProfileHeaderView, "binding.userSheetProfileHeaderView");
companion.bind(userProfileHeaderView, this, getViewModelUserProfileHeader());
}
@Override // com.discord.app.AppBottomSheet
public int getContentViewResId() {
return 2131559275;
}
@Override // com.discord.app.AppBottomSheet, androidx.fragment.app.Fragment
public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
m.checkNotNullParameter(layoutInflater, "inflater");
Context requireContext = requireContext();
m.checkNotNullExpressionValue(requireContext, "requireContext()");
FragmentManager parentFragmentManager = getParentFragmentManager();
m.checkNotNullExpressionValue(parentFragmentManager, "parentFragmentManager");
this.privateCallLauncher = new PrivateCallLauncher(this, this, requireContext, parentFragmentManager);
return super.onCreateView(layoutInflater, viewGroup, bundle);
}
@Override // com.discord.app.AppBottomSheet, androidx.fragment.app.Fragment
public void onPause() {
ViewHolderUserRichPresence viewHolderUserRichPresence = this.activityViewHolder;
if (viewHolderUserRichPresence != null) {
viewHolderUserRichPresence.disposeSubscriptions();
}
long j = getArgumentsOrDefault().getLong("ARG_USER_ID");
long j2 = getArgumentsOrDefault().getLong("ARG_GUILD_ID");
if (j > 0 && j2 > 0) {
StoreStream.Companion.getGuildSubscriptions().unsubscribeUser(j2, j);
}
hideKeyboard(getBinding().f1997z);
WidgetUserSheetViewModel viewModel = getViewModel();
Context context = getContext();
TextInputLayout textInputLayout = getBinding().f1997z;
m.checkNotNullExpressionValue(textInputLayout, "binding.userSheetNoteTextFieldWrap");
viewModel.saveUserNote(context, ViewExtensions.getTextOrEmpty(textInputLayout));
super.onPause();
}
@Override // com.discord.app.AppBottomSheet, androidx.fragment.app.Fragment
public void onResume() {
super.onResume();
AppBottomSheet.hideKeyboard$default(this, null, 1, null);
long j = getArgumentsOrDefault().getLong("ARG_USER_ID");
long j2 = getArgumentsOrDefault().getLong("ARG_GUILD_ID");
if (j > 0 && j2 > 0) {
StoreStream.Companion.getGuildSubscriptions().subscribeUser(j2, j);
}
}
@Override // com.discord.app.AppBottomSheet, androidx.fragment.app.Fragment
public void onViewCreated(View view, Bundle bundle) {
m.checkNotNullParameter(view, "view");
super.onViewCreated(view, bundle);
long j = getArgumentsOrDefault().getLong("ARG_USER_ID");
boolean z2 = j == StoreStream.Companion.getUsers().getMe().getId();
getBinding().w.setOnClickListener(new WidgetUserSheet$onViewCreated$1(this, j));
UserProfileHeaderView userProfileHeaderView = getBinding().D;
Badge.Companion companion = Badge.Companion;
FragmentManager parentFragmentManager = getParentFragmentManager();
m.checkNotNullExpressionValue(parentFragmentManager, "parentFragmentManager");
Context requireContext = requireContext();
m.checkNotNullExpressionValue(requireContext, "requireContext()");
userProfileHeaderView.setOnBadgeClick(companion.onBadgeClick(parentFragmentManager, requireContext));
getBinding().F.setOnInviteToSpeak(new WidgetUserSheet$onViewCreated$2(this, z2));
getBinding().F.setOnMoveToAudience(new WidgetUserSheet$onViewCreated$3(this));
getBinding().H.setOnMuteChecked(new WidgetUserSheet$onViewCreated$4(this));
getBinding().H.setOnDeafenChecked(new WidgetUserSheet$onViewCreated$5(this));
getBinding().H.setOnVolumeChange(new WidgetUserSheet$onViewCreated$6(this));
getBinding().i.setOnEditMember(new WidgetUserSheet$onViewCreated$7(this));
getBinding().i.setOnKick(new WidgetUserSheet$onViewCreated$8(this));
getBinding().i.setOnBan(new WidgetUserSheet$onViewCreated$9(this));
getBinding().i.setOnServerMute(new WidgetUserSheet$onViewCreated$10(this));
getBinding().i.setOnServerDeafen(new WidgetUserSheet$onViewCreated$11(this));
getBinding().i.setOnServerMove(new WidgetUserSheet$onViewCreated$12(this));
getBinding().i.setOnDisconnect(new WidgetUserSheet$onViewCreated$13(this));
TextInputEditText textInputEditText = getBinding().f1996y;
m.checkNotNullExpressionValue(textInputEditText, "binding.userSheetNoteTextField");
TextWatcherKt.addLifecycleAwareTextWatcher(textInputEditText, this, new WidgetUserSheet$onViewCreated$14(this));
TextInputLayout textInputLayout = getBinding().f1997z;
m.checkNotNullExpressionValue(textInputLayout, "binding.userSheetNoteTextFieldWrap");
ViewExtensions.setOnEditTextFocusChangeListener(textInputLayout, new WidgetUserSheet$onViewCreated$15(this));
TextInputLayout textInputLayout2 = getBinding().f1997z;
m.checkNotNullExpressionValue(textInputLayout2, "binding.userSheetNoteTextFieldWrap");
ViewExtensions.setOnImeActionDone$default(textInputLayout2, false, new WidgetUserSheet$onViewCreated$16(this, view), 1, null);
ViewCompat.setAccessibilityDelegate(getBinding().w, new WidgetUserSheet$onViewCreated$17(this));
for (TextView textView : n.listOf((Object[]) new TextView[]{getBinding().k, getBinding().f1994s, getBinding().f1995x, getBinding().n, getBinding().t, getBinding().G})) {
AccessibilityUtils accessibilityUtils = AccessibilityUtils.INSTANCE;
m.checkNotNullExpressionValue(textView, "header");
accessibilityUtils.setViewIsHeading(textView);
}
WidgetChannelSelector.Companion.registerForResult$default(WidgetChannelSelector.Companion, this, "REQUEST_KEY_MOVE_USER", false, new WidgetUserSheet$onViewCreated$18(this), 4, null);
RebrandFeatureFlag rebrandFeatureFlag = RebrandFeatureFlag.f1595c;
int color = RebrandFeatureFlag.b ? ColorCompat.getColor(view, 2131099764) : ColorCompat.getColor(view, 2131099736);
ContentLoadingProgressBar contentLoadingProgressBar = getBinding().e;
m.checkNotNullExpressionValue(contentLoadingProgressBar, "binding.loadingProgressBar");
contentLoadingProgressBar.getIndeterminateDrawable().setTint(color);
}
}