package com.discord.widgets.chat.input; import android.annotation.SuppressLint; import android.content.ContentResolver; import android.content.Context; import android.net.Uri; import android.view.View; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.RelativeLayout; import android.widget.TextView; import androidx.core.view.ViewCompat; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentContainerView; import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentViewModelLazyKt; import c.a.a.a; import c.a.a.e.b; import c.a.d.e0; import c.a.d.f; import c.a.i.n4; import c.a.i.o4; import c.a.i.p4; import c.a.k.b; import c.a.o.b; import c.d.b.a.a; import com.discord.R; import com.discord.api.channel.Channel; import com.discord.api.channel.ChannelUtils; import com.discord.api.guild.GuildVerificationLevel; import com.discord.api.guildjoinrequest.ApplicationStatus; import com.discord.app.AppFragment; import com.discord.databinding.WidgetChatInputBinding; import com.discord.models.member.GuildMember; import com.discord.utilities.KotlinExtensionsKt; import com.discord.utilities.ShareUtils; import com.discord.utilities.color.ColorCompat; import com.discord.utilities.color.ColorCompatKt; import com.discord.utilities.intent.IntentUtils; import com.discord.utilities.locale.LocaleManager; import com.discord.utilities.rx.ObservableExtensionsKt; import com.discord.utilities.time.Clock; import com.discord.utilities.time.ClockFactory; import com.discord.utilities.view.extensions.ViewExtensions; import com.discord.utilities.viewbinding.FragmentViewBindingDelegate; import com.discord.utilities.viewbinding.FragmentViewBindingDelegateKt; import com.discord.utilities.views.ViewVisibilityObserver; import com.discord.utilities.views.ViewVisibilityObserverProvider; import com.discord.widgets.announcements.WidgetChannelFollowSheet; import com.discord.widgets.chat.MessageManager; import com.discord.widgets.chat.input.ChatInputViewModel; import com.discord.widgets.chat.input.MessageDraftsRepo; import com.discord.widgets.chat.input.autocomplete.InputAutocomplete; import com.discord.widgets.notice.WidgetNoticeDialog; import com.google.android.material.button.MaterialButton; import com.lytefast.flexinput.fragment.FlexInputFragment; import com.lytefast.flexinput.model.Attachment; import d0.g; import d0.g0.t; import d0.z.d.a0; import d0.z.d.m; import java.text.NumberFormat; import java.util.List; import java.util.concurrent.TimeUnit; import kotlin.Lazy; import kotlin.NoWhenBranchMatchedException; import kotlin.Unit; import kotlin.jvm.functions.Function0; import kotlin.jvm.functions.Function1; import kotlin.reflect.KProperty; import rx.Observable; import rx.Subscription; /* compiled from: WidgetChatInput.kt */ public final class WidgetChatInput extends AppFragment { public static final /* synthetic */ KProperty[] $$delegatedProperties = {a.b0(WidgetChatInput.class, "binding", "getBinding()Lcom/discord/databinding/WidgetChatInputBinding;", 0)}; private InputAutocomplete autocomplete; private final FragmentViewBindingDelegate binding$delegate = FragmentViewBindingDelegateKt.viewBinding(this, WidgetChatInput$binding$2.INSTANCE, new WidgetChatInput$binding$3(this)); private WidgetChatInputAttachments chatAttachments; private WidgetChatInputEditText chatInputEditTextHolder; private WidgetChatInputTruncatedHint chatInputTruncatedHint; private final Clock clock = ClockFactory.get(); private Subscription communicationDisabledCountdownSubscription; private final Lazy flexInputFragment$delegate = g.lazy(new WidgetChatInput$flexInputFragment$2(this)); private final Lazy flexInputViewModel$delegate = FragmentViewModelLazyKt.createViewModelLazy(this, a0.getOrCreateKotlinClass(AppFlexInputViewModel.class), new WidgetChatInput$appActivityViewModels$$inlined$activityViewModels$3(this), new e0(new WidgetChatInput$flexInputViewModel$2(this))); private final ViewVisibilityObserver inlineVoiceVisibilityObserver = ViewVisibilityObserverProvider.INSTANCE.get(ViewVisibilityObserverProvider.INLINE_VOICE_FEATURE); private final MessageDraftsRepo messageDraftsRepo = MessageDraftsRepo.Provider.INSTANCE.get(); private final Lazy viewModel$delegate = FragmentViewModelLazyKt.createViewModelLazy(this, a0.getOrCreateKotlinClass(ChatInputViewModel.class), new WidgetChatInput$appActivityViewModels$$inlined$activityViewModels$1(this), new e0(WidgetChatInput$viewModel$2.INSTANCE)); public final /* synthetic */ class WhenMappings { public static final /* synthetic */ int[] $EnumSwitchMapping$0; public static final /* synthetic */ int[] $EnumSwitchMapping$1; public static final /* synthetic */ int[] $EnumSwitchMapping$2; static { ApplicationStatus.values(); int[] iArr = new int[5]; $EnumSwitchMapping$0 = iArr; iArr[ApplicationStatus.REJECTED.ordinal()] = 1; iArr[ApplicationStatus.PENDING.ordinal()] = 2; GuildVerificationLevel.values(); int[] iArr2 = new int[5]; $EnumSwitchMapping$1 = iArr2; GuildVerificationLevel guildVerificationLevel = GuildVerificationLevel.LOW; iArr2[guildVerificationLevel.ordinal()] = 1; iArr2[GuildVerificationLevel.MEDIUM.ordinal()] = 2; iArr2[GuildVerificationLevel.HIGH.ordinal()] = 3; GuildVerificationLevel guildVerificationLevel2 = GuildVerificationLevel.HIGHEST; iArr2[guildVerificationLevel2.ordinal()] = 4; GuildVerificationLevel.values(); int[] iArr3 = new int[5]; $EnumSwitchMapping$2 = iArr3; iArr3[guildVerificationLevel.ordinal()] = 1; iArr3[guildVerificationLevel2.ordinal()] = 2; } } public WidgetChatInput() { super(R.layout.widget_chat_input); } public static final /* synthetic */ void access$configureSendListeners(WidgetChatInput widgetChatInput, ChatInputViewModel.ViewState.Loaded loaded) { widgetChatInput.configureSendListeners(loaded); } public static final /* synthetic */ void access$configureUI(WidgetChatInput widgetChatInput, ChatInputViewModel.ViewState viewState) { widgetChatInput.configureUI(viewState); } public static final /* synthetic */ InputAutocomplete access$getAutocomplete$p(WidgetChatInput widgetChatInput) { return widgetChatInput.autocomplete; } public static final /* synthetic */ WidgetChatInputBinding access$getBinding$p(WidgetChatInput widgetChatInput) { return widgetChatInput.getBinding(); } public static final /* synthetic */ WidgetChatInputEditText access$getChatInputEditTextHolder$p(WidgetChatInput widgetChatInput) { return widgetChatInput.chatInputEditTextHolder; } public static final /* synthetic */ WidgetChatInputTruncatedHint access$getChatInputTruncatedHint$p(WidgetChatInput widgetChatInput) { return widgetChatInput.chatInputTruncatedHint; } public static final /* synthetic */ Clock access$getClock$p(WidgetChatInput widgetChatInput) { return widgetChatInput.clock; } public static final /* synthetic */ Subscription access$getCommunicationDisabledCountdownSubscription$p(WidgetChatInput widgetChatInput) { return widgetChatInput.communicationDisabledCountdownSubscription; } public static final /* synthetic */ FlexInputFragment access$getFlexInputFragment$p(WidgetChatInput widgetChatInput) { return widgetChatInput.getFlexInputFragment(); } public static final /* synthetic */ CharSequence access$getHint(WidgetChatInput widgetChatInput, Context context, Channel channel, boolean z2, boolean z3) { return widgetChatInput.getHint(context, channel, z2, z3); } public static final /* synthetic */ ChatInputViewModel access$getViewModel$p(WidgetChatInput widgetChatInput) { return widgetChatInput.getViewModel(); } public static final /* synthetic */ void access$handleEvent(WidgetChatInput widgetChatInput, ChatInputViewModel.Event event) { widgetChatInput.handleEvent(event); } public static final /* synthetic */ void access$onViewBindingDestroy(WidgetChatInput widgetChatInput, WidgetChatInputBinding widgetChatInputBinding) { widgetChatInput.onViewBindingDestroy(widgetChatInputBinding); } public static final /* synthetic */ void access$setAutocomplete$p(WidgetChatInput widgetChatInput, InputAutocomplete inputAutocomplete) { widgetChatInput.autocomplete = inputAutocomplete; } public static final /* synthetic */ void access$setChatInputEditTextHolder$p(WidgetChatInput widgetChatInput, WidgetChatInputEditText widgetChatInputEditText) { widgetChatInput.chatInputEditTextHolder = widgetChatInputEditText; } public static final /* synthetic */ void access$setChatInputTruncatedHint$p(WidgetChatInput widgetChatInput, WidgetChatInputTruncatedHint widgetChatInputTruncatedHint) { widgetChatInput.chatInputTruncatedHint = widgetChatInputTruncatedHint; } public static final /* synthetic */ void access$setCommunicationDisabledCountdownSubscription$p(WidgetChatInput widgetChatInput, Subscription subscription) { widgetChatInput.communicationDisabledCountdownSubscription = subscription; } public static final /* synthetic */ void access$setWindowInsetsListeners(WidgetChatInput widgetChatInput, boolean z2) { widgetChatInput.setWindowInsetsListeners(z2); } public static final /* synthetic */ void access$showFollowSheet(WidgetChatInput widgetChatInput, long j, long j2) { widgetChatInput.showFollowSheet(j, j2); } private final void clearInput(Boolean bool, boolean z2) { WidgetChatInputEditText widgetChatInputEditText = this.chatInputEditTextHolder; if (widgetChatInputEditText != null) { if (z2) { getFlexInputViewModel().onInputTextChanged("", bool); } getFlexInputViewModel().clean(z2); widgetChatInputEditText.clearLastTypingEmission(); getViewModel().deleteEditingMessage(); } } public static /* synthetic */ void clearInput$default(WidgetChatInput widgetChatInput, Boolean bool, boolean z2, int i, Object obj) { if ((i & 1) != 0) { bool = null; } if ((i & 2) != 0) { z2 = true; } widgetChatInput.clearInput(bool, z2); } private final void configureChatGuard(ChatInputViewModel.ViewState.Loaded loaded) { Subscription subscription; o4 o4Var = getBinding().r; m.checkNotNullExpressionValue(o4Var, "binding.guard"); LinearLayout linearLayout = o4Var.a; m.checkNotNullExpressionValue(linearLayout, "binding.guard.root"); linearLayout.setVisibility(loaded.isLurking() || loaded.isVerificationLevelTriggered() || loaded.isSystemDM() || loaded.getShouldShowFollow() ? 0 : 8); p4 p4Var = getBinding().t; m.checkNotNullExpressionValue(p4Var, "binding.guardMemberVerification"); RelativeLayout relativeLayout = p4Var.a; m.checkNotNullExpressionValue(relativeLayout, "binding.guardMemberVerification.root"); o4 o4Var2 = getBinding().r; m.checkNotNullExpressionValue(o4Var2, "binding.guard"); LinearLayout linearLayout2 = o4Var2.a; m.checkNotNullExpressionValue(linearLayout2, "binding.guard.root"); relativeLayout.setVisibility(!(linearLayout2.getVisibility() == 0) && loaded.getShouldShowVerificationGate() ? 0 : 8); n4 n4Var = getBinding().f1805s; m.checkNotNullExpressionValue(n4Var, "binding.guardCommunicationDisabled"); RelativeLayout relativeLayout2 = n4Var.a; m.checkNotNullExpressionValue(relativeLayout2, "binding.guardCommunicationDisabled.root"); o4 o4Var3 = getBinding().r; m.checkNotNullExpressionValue(o4Var3, "binding.guard"); LinearLayout linearLayout3 = o4Var3.a; m.checkNotNullExpressionValue(linearLayout3, "binding.guard.root"); relativeLayout2.setVisibility(!(linearLayout3.getVisibility() == 0) && !loaded.getShouldShowVerificationGate() && loaded.isCommunicationDisabled() ? 0 : 8); if (loaded.isSystemDM()) { getBinding().r.e.setText(R.string.system_dm_channel_description); TextView textView = getBinding().r.d; m.checkNotNullExpressionValue(textView, "binding.guard.chatInputGuardSubtext"); ViewExtensions.setTextAndVisibilityBy(textView, getString(R.string.system_dm_channel_description_subtext)); MaterialButton materialButton = getBinding().r.b; m.checkNotNullExpressionValue(materialButton, "binding.guard.chatInputGuardAction"); materialButton.setVisibility(8); MaterialButton materialButton2 = getBinding().r.f140c; m.checkNotNullExpressionValue(materialButton2, "binding.guard.chatInputGuardActionSecondary"); materialButton2.setVisibility(8); } else if (loaded.getShouldShowFollow()) { getBinding().r.e.setText(R.string.follow_news_chat_input_message); MaterialButton materialButton3 = getBinding().r.b; m.checkNotNullExpressionValue(materialButton3, "binding.guard.chatInputGuardAction"); ViewExtensions.setTextAndVisibilityBy(materialButton3, getString(R.string.game_popout_follow)); getBinding().r.b.setOnClickListener(new WidgetChatInput$configureChatGuard$1(this, loaded)); MaterialButton materialButton4 = getBinding().r.f140c; m.checkNotNullExpressionValue(materialButton4, "binding.guard.chatInputGuardActionSecondary"); materialButton4.setVisibility(8); } else if (loaded.isLurking()) { if (loaded.getShouldShowFollow()) { getBinding().r.e.setText(R.string.follow_news_chat_input_message); MaterialButton materialButton5 = getBinding().r.b; m.checkNotNullExpressionValue(materialButton5, "binding.guard.chatInputGuardAction"); ViewExtensions.setTextAndVisibilityBy(materialButton5, getString(R.string.game_popout_follow)); getBinding().r.b.setOnClickListener(new WidgetChatInput$configureChatGuard$2(this, loaded)); MaterialButton materialButton6 = getBinding().r.f140c; m.checkNotNullExpressionValue(materialButton6, "binding.guard.chatInputGuardActionSecondary"); ViewExtensions.setTextAndVisibilityBy(materialButton6, getString(R.string.lurker_mode_chat_input_button)); getBinding().r.f140c.setOnClickListener(new WidgetChatInput$configureChatGuard$3(this)); return; } getBinding().r.e.setText(R.string.lurker_mode_chat_input_message); MaterialButton materialButton7 = getBinding().r.b; m.checkNotNullExpressionValue(materialButton7, "binding.guard.chatInputGuardAction"); ViewExtensions.setTextAndVisibilityBy(materialButton7, getString(R.string.lurker_mode_chat_input_button)); getBinding().r.b.setOnClickListener(new WidgetChatInput$configureChatGuard$4(this)); MaterialButton materialButton8 = getBinding().r.f140c; m.checkNotNullExpressionValue(materialButton8, "binding.guard.chatInputGuardActionSecondary"); materialButton8.setVisibility(8); } else if (loaded.isCommunicationDisabled()) { configureCommunicationDisabledTimer(loaded); String a = f.a.a(360045138571L, null); TextView textView2 = getBinding().f1805s.b; m.checkNotNullExpressionValue(textView2, "binding.guardCommunicati…nicationDisabledGuardText"); b.n(textView2, R.string.guild_communication_disabled_chat_notice_description, new Object[]{a}, null, 4); getBinding().f1805s.b.setOnClickListener(new WidgetChatInput$configureChatGuard$5(this, a)); } else if (!loaded.isCommunicationDisabled() && (subscription = this.communicationDisabledCountdownSubscription) != null) { if (subscription != null) { subscription.unsubscribe(); } this.communicationDisabledCountdownSubscription = null; } else if (loaded.getShouldShowVerificationGate()) { getBinding().t.b.setOnClickListener(new WidgetChatInput$configureChatGuard$6(this, loaded)); ApplicationStatus joinRequestStatus = loaded.getJoinRequestStatus(); if (joinRequestStatus != null) { int ordinal = joinRequestStatus.ordinal(); if (ordinal == 1) { getBinding().t.d.setText(R.string.member_verification_application_confirmation_title); getBinding().t.f146c.setImageResource(R.drawable.img_member_verification_pending); getBinding().t.b.setImageResource(R.drawable.ic_close_circle_nova_grey_24dp); return; } else if (ordinal == 2) { getBinding().t.d.setText(R.string.member_verification_application_rejected_title); getBinding().t.f146c.setImageResource(R.drawable.img_member_verification_denied); getBinding().t.b.setImageResource(R.drawable.ic_member_verification_chat_guard_cta); return; } } getBinding().t.d.setText(R.string.member_verification_chat_blocker_text); getBinding().t.f146c.setImageResource(R.drawable.img_member_verification_started); getBinding().t.b.setImageResource(R.drawable.ic_member_verification_chat_guard_cta); } else { TextView textView3 = getBinding().r.e; m.checkNotNullExpressionValue(textView3, "binding.guard.chatInputGuardText"); TextView textView4 = getBinding().r.e; m.checkNotNullExpressionValue(textView4, "binding.guard.chatInputGuardText"); Context context = textView4.getContext(); m.checkNotNullExpressionValue(context, "binding.guard.chatInputGuardText.context"); textView3.setText(getVerificationText(context, loaded.getVerificationLevelTriggered())); MaterialButton materialButton9 = getBinding().r.b; m.checkNotNullExpressionValue(materialButton9, "binding.guard.chatInputGuardAction"); MaterialButton materialButton10 = getBinding().r.b; m.checkNotNullExpressionValue(materialButton10, "binding.guard.chatInputGuardAction"); Context context2 = materialButton10.getContext(); m.checkNotNullExpressionValue(context2, "binding.guard.chatInputGuardAction.context"); ViewExtensions.setTextAndVisibilityBy(materialButton9, getVerificationActionText(context2, loaded.getVerificationLevelTriggered())); getBinding().r.b.setOnClickListener(new WidgetChatInput$configureChatGuard$7(this)); MaterialButton materialButton11 = getBinding().r.f140c; m.checkNotNullExpressionValue(materialButton11, "binding.guard.chatInputGuardActionSecondary"); materialButton11.setVisibility(8); } } private final void configureCommunicationDisabledTimer(ChatInputViewModel.ViewState.Loaded loaded) { if (this.communicationDisabledCountdownSubscription == null) { Observable D = Observable.D(0, 1, TimeUnit.SECONDS); m.checkNotNullExpressionValue(D, "Observable\n .inte…0L, 1L, TimeUnit.SECONDS)"); ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(D, this, null, 2, null), WidgetChatInput.class, (Context) null, new WidgetChatInput$configureCommunicationDisabledTimer$2(this), (Function1) null, (Function0) null, (Function0) null, new WidgetChatInput$configureCommunicationDisabledTimer$1(this, loaded), 58, (Object) null); } } private final void configureContextBar(ChatInputViewModel.ViewState.Loaded loaded) { if (loaded.isEditing()) { configureContextBarEditing(); } else if (loaded.getPendingReplyState() instanceof ChatInputViewModel.ViewState.Loaded.PendingReplyState.Replying) { configureContextBarReplying((ChatInputViewModel.ViewState.Loaded.PendingReplyState.Replying) loaded.getPendingReplyState()); } else { RelativeLayout relativeLayout = getBinding().e; m.checkNotNullExpressionValue(relativeLayout, "binding.chatInputContextBar"); relativeLayout.setVisibility(8); } } private final void configureContextBarEditing() { RelativeLayout relativeLayout = getBinding().e; m.checkNotNullExpressionValue(relativeLayout, "binding.chatInputContextBar"); relativeLayout.setVisibility(0); RelativeLayout relativeLayout2 = getBinding().e; m.checkNotNullExpressionValue(relativeLayout2, "binding.chatInputContextBar"); relativeLayout2.setClickable(false); getBinding().g.setText(R.string.editing_message); getBinding().f.setOnClickListener(new WidgetChatInput$configureContextBarEditing$1(this)); LinearLayout linearLayout = getBinding().h; m.checkNotNullExpressionValue(linearLayout, "binding.chatInputContextReplyMentionButton"); linearLayout.setVisibility(8); } private final void configureContextBarReplying(ChatInputViewModel.ViewState.Loaded.PendingReplyState.Replying replying) { String str; Context requireContext = requireContext(); RelativeLayout relativeLayout = getBinding().e; m.checkNotNullExpressionValue(relativeLayout, "binding.chatInputContextBar"); int i = 0; relativeLayout.setVisibility(0); GuildMember repliedAuthorGuildMember = replying.getRepliedAuthorGuildMember(); if (repliedAuthorGuildMember == null || (str = repliedAuthorGuildMember.getNick()) == null) { str = replying.getRepliedAuthor().getUsername(); } TextView textView = getBinding().g; m.checkNotNullExpressionValue(textView, "binding.chatInputContextDescription"); b.m(textView, R.string.mobile_replying_to, new Object[]{str}, new WidgetChatInput$configureContextBarReplying$1(requireContext, replying)); getBinding().e.setOnClickListener(new WidgetChatInput$configureContextBarReplying$2(this, replying)); getBinding().f.setOnClickListener(new WidgetChatInput$configureContextBarReplying$3(this)); LinearLayout linearLayout = getBinding().h; m.checkNotNullExpressionValue(linearLayout, "binding.chatInputContextReplyMentionButton"); if (!replying.getShowMentionToggle()) { i = 8; } linearLayout.setVisibility(i); getBinding().h.setOnClickListener(new WidgetChatInput$configureContextBarReplying$4(this)); int themedColor = replying.getShouldMention() ? ColorCompat.getThemedColor(requireContext, (int) R.attr.colorControlBrandForeground) : ColorCompat.getThemedColor(requireContext, (int) R.attr.colorTextMuted); ImageView imageView = getBinding().i; m.checkNotNullExpressionValue(imageView, "binding.chatInputContextReplyMentionButtonImage"); ColorCompatKt.tintWithColor(imageView, themedColor); getBinding().j.setTextColor(themedColor); getBinding().j.setText(replying.getShouldMention() ? R.string.reply_mention_on : R.string.reply_mention_off); } private final void configureInitialText(ChatInputViewModel.ViewState.Loaded loaded) { String str; getFlexInputViewModel().hideExpressionTray(); if (!loaded.isEditing() || loaded.getEditingMessage() == null) { CharSequence textChannelInput = this.messageDraftsRepo.getTextChannelInput(loaded.getChannelId()); AppFlexInputViewModel flexInputViewModel = getFlexInputViewModel(); if (textChannelInput == null || (str = textChannelInput.toString()) == null) { str = ""; } flexInputViewModel.onInputTextChanged(str, (loaded.isEditing() || loaded.isReplying()) ? Boolean.TRUE : null); return; } getFlexInputViewModel().onInputTextChanged(loaded.getEditingMessage().getContent().toString(), Boolean.TRUE); } private final void configureSendListeners(ChatInputViewModel.ViewState.Loaded loaded) { WidgetChatInputEditText widgetChatInputEditText = this.chatInputEditTextHolder; if (widgetChatInputEditText != null) { Context requireContext = requireContext(); MessageManager messageManager = new MessageManager(requireContext, null, null, null, null, null, null, null, null, 510, null); WidgetChatInput$configureSendListeners$1 widgetChatInput$configureSendListeners$1 = new WidgetChatInput$configureSendListeners$1(this, requireContext, messageManager); WidgetChatInput$configureSendListeners$3 widgetChatInput$configureSendListeners$3 = new WidgetChatInput$configureSendListeners$3(this, widgetChatInput$configureSendListeners$1, new WidgetChatInput$configureSendListeners$2(this, widgetChatInputEditText, requireContext, messageManager)); WidgetChatInput$configureSendListeners$4 widgetChatInput$configureSendListeners$4 = new WidgetChatInput$configureSendListeners$4(requireContext); boolean z2 = widgetChatInputEditText.getChannelId() != loaded.getChannelId(); widgetChatInputEditText.setChannelId(loaded.getChannelId(), z2); InputAutocomplete inputAutocomplete = this.autocomplete; if (inputAutocomplete != null) { inputAutocomplete.setOnPerformCommandAutocomplete(new WidgetChatInput$configureSendListeners$5(this, widgetChatInput$configureSendListeners$1)); } widgetChatInputEditText.setOnSendListener(new WidgetChatInput$configureSendListeners$6(this, widgetChatInput$configureSendListeners$3)); if (z2) { configureInitialText(loaded); } configureText(loaded); WidgetChatInputAttachments widgetChatInputAttachments = this.chatAttachments; if (widgetChatInputAttachments == null) { m.throwUninitializedPropertyAccessException("chatAttachments"); } widgetChatInputAttachments.setInputListener(new WidgetChatInput$configureSendListeners$7(this, loaded, widgetChatInput$configureSendListeners$4, widgetChatInput$configureSendListeners$3)); } } private final void configureText(ChatInputViewModel.ViewState.Loaded loaded) { if (!loaded.getAbleToSendMessage()) { c.i.a.f.e.o.f.F0(getFlexInputViewModel(), "", null, 2, null); } } private final void configureUI(ChatInputViewModel.ViewState viewState) { int i = 8; if (viewState instanceof ChatInputViewModel.ViewState.Loading) { LinearLayout linearLayout = getBinding().q; m.checkNotNullExpressionValue(linearLayout, "binding.chatInputWrap"); linearLayout.setVisibility(8); p4 p4Var = getBinding().t; m.checkNotNullExpressionValue(p4Var, "binding.guardMemberVerification"); RelativeLayout relativeLayout = p4Var.a; m.checkNotNullExpressionValue(relativeLayout, "binding.guardMemberVerification.root"); relativeLayout.setVisibility(8); n4 n4Var = getBinding().f1805s; m.checkNotNullExpressionValue(n4Var, "binding.guardCommunicationDisabled"); RelativeLayout relativeLayout2 = n4Var.a; m.checkNotNullExpressionValue(relativeLayout2, "binding.guardCommunicationDisabled.root"); relativeLayout2.setVisibility(8); o4 o4Var = getBinding().r; m.checkNotNullExpressionValue(o4Var, "binding.guard"); LinearLayout linearLayout2 = o4Var.a; m.checkNotNullExpressionValue(linearLayout2, "binding.guard.root"); linearLayout2.setVisibility(8); } else if (viewState instanceof ChatInputViewModel.ViewState.Loaded) { WidgetChatInputAttachments widgetChatInputAttachments = this.chatAttachments; if (widgetChatInputAttachments == null) { m.throwUninitializedPropertyAccessException("chatAttachments"); } ChatInputViewModel.ViewState.Loaded loaded = (ChatInputViewModel.ViewState.Loaded) viewState; widgetChatInputAttachments.configureFlexInputContentPages(loaded.getShowCreateThreadOption()); LinearLayout linearLayout3 = getBinding().q; m.checkNotNullExpressionValue(linearLayout3, "binding.chatInputWrap"); if (loaded.isInputShowing()) { i = 0; } linearLayout3.setVisibility(i); configureChatGuard(loaded); getFlexInputFragment().i(new WidgetChatInput$configureUI$1(this, viewState)); configureContextBar(loaded); getFlexInputViewModel().setShowExpressionTrayButtonBadge(loaded.getShouldBadgeChatInput()); } } private final WidgetChatInputBinding getBinding() { return (WidgetChatInputBinding) this.binding$delegate.getValue((Fragment) this, $$delegatedProperties[0]); } private final FlexInputFragment getFlexInputFragment() { return (FlexInputFragment) this.flexInputFragment$delegate.getValue(); } private final AppFlexInputViewModel getFlexInputViewModel() { return (AppFlexInputViewModel) this.flexInputViewModel$delegate.getValue(); } private final CharSequence getHint(Context context, Channel channel, boolean z2, boolean z3) { if (z2) { String string = context.getString(R.string.dm_verification_text_blocked); m.checkNotNullExpressionValue(string, "context.getString(R.stri…erification_text_blocked)"); return string; } else if (z3) { return b.h(context, R.string.textarea_placeholder, new Object[]{ChannelUtils.e(channel, context, false, 2)}, null, 4); } else { String string2 = context.getString(R.string.no_send_messages_permission_placeholder); m.checkNotNullExpressionValue(string2, "context.getString(R.stri…s_permission_placeholder)"); return string2; } } private final String getVerificationActionText(Context context, GuildVerificationLevel guildVerificationLevel) { int ordinal = guildVerificationLevel.ordinal(); if (ordinal == 1) { return context.getString(R.string.verify_account); } if (ordinal != 4) { return null; } return context.getString(R.string.verify_phone); } private final CharSequence getVerificationText(Context context, GuildVerificationLevel guildVerificationLevel) { int ordinal = guildVerificationLevel.ordinal(); if (ordinal == 1) { return context.getString(R.string.guild_verification_text_not_claimed); } if (ordinal == 2) { return b.h(context, R.string.guild_verification_text_account_age, new Object[]{"5"}, null, 4); } if (ordinal == 3) { return b.h(context, R.string.guild_verification_text_member_age, new Object[]{"10"}, null, 4); } if (ordinal != 4) { return null; } return context.getString(R.string.guild_verification_text_not_phone_verified); } private final ChatInputViewModel getViewModel() { return (ChatInputViewModel) this.viewModel$delegate.getValue(); } @SuppressLint({"StringFormatMatches"}) private final void handleEvent(ChatInputViewModel.Event event) { Unit unit = null; if (event instanceof ChatInputViewModel.Event.FilesTooLarge) { getFlexInputViewModel().hideKeyboard(); a.b bVar = c.a.a.a.j; FragmentManager parentFragmentManager = getParentFragmentManager(); m.checkNotNullExpressionValue(parentFragmentManager, "parentFragmentManager"); ChatInputViewModel.Event.FilesTooLarge filesTooLarge = (ChatInputViewModel.Event.FilesTooLarge) event; float currentFileSizeMB = filesTooLarge.getCurrentFileSizeMB(); float maxAttachmentSizeMB = filesTooLarge.getMaxAttachmentSizeMB(); bVar.a(parentFragmentManager, filesTooLarge.isUserPremium(), filesTooLarge.getMaxFileSizeMB(), maxAttachmentSizeMB, currentFileSizeMB, new WidgetChatInput$handleEvent$1(this, event), filesTooLarge.getAttachments().size(), filesTooLarge.getHasImage(), filesTooLarge.getHasVideo(), filesTooLarge.getHasGif()); clearInput$default(this, null, false, 1, null); unit = Unit.a; } else if (event instanceof ChatInputViewModel.Event.MessageTooLong) { getFlexInputViewModel().hideKeyboard(); NumberFormat numberInstance = NumberFormat.getNumberInstance(new LocaleManager().getPrimaryLocale(requireContext())); WidgetNoticeDialog.Companion companion = WidgetNoticeDialog.Companion; FragmentManager parentFragmentManager2 = getParentFragmentManager(); m.checkNotNullExpressionValue(parentFragmentManager2, "parentFragmentManager"); ChatInputViewModel.Event.MessageTooLong messageTooLong = (ChatInputViewModel.Event.MessageTooLong) event; WidgetNoticeDialog.Companion.show$default(companion, parentFragmentManager2, getString(R.string.message_too_long_header), b.k(this, R.string.message_too_long_body_text, new Object[]{numberInstance.format(Integer.valueOf(messageTooLong.getCurrentCharacterCount())), numberInstance.format(Integer.valueOf(messageTooLong.getMaxCharacterCount()))}, null, 4), getString(R.string.okay), null, null, null, null, null, null, null, null, 0, null, 16368, null); unit = Unit.a; } else if (event instanceof ChatInputViewModel.Event.EmptyThreadName) { getFlexInputViewModel().hideKeyboard(); WidgetNoticeDialog.Companion companion2 = WidgetNoticeDialog.Companion; FragmentManager parentFragmentManager3 = getParentFragmentManager(); m.checkNotNullExpressionValue(parentFragmentManager3, "parentFragmentManager"); WidgetNoticeDialog.Companion.show$default(companion2, parentFragmentManager3, null, b.k(this, R.string.form_thread_name_required_error, new Object[0], null, 4), getString(R.string.okay), null, null, null, null, null, null, null, null, 0, null, 16370, null); unit = Unit.a; } else if (event instanceof ChatInputViewModel.Event.FailedDeliveryToRecipient) { getFlexInputViewModel().hideKeyboard(); WidgetNoticeDialog.Companion companion3 = WidgetNoticeDialog.Companion; FragmentManager parentFragmentManager4 = getParentFragmentManager(); m.checkNotNullExpressionValue(parentFragmentManager4, "parentFragmentManager"); WidgetNoticeDialog.Companion.show$default(companion3, parentFragmentManager4, getString(R.string.error), b.k(this, R.string.bot_dm_send_failed_with_help_link_mobile, new Object[]{f.a.a(360060145013L, null)}, null, 4), getString(R.string.okay), null, null, null, null, null, null, null, null, 0, null, 16368, null); unit = Unit.a; } else if (event instanceof ChatInputViewModel.Event.AppendChatText) { getFlexInputViewModel().onInputTextAppended(((ChatInputViewModel.Event.AppendChatText) event).getText()); unit = Unit.a; } else if (event instanceof ChatInputViewModel.Event.SetChatText) { getFlexInputViewModel().hideExpressionTray(); getFlexInputViewModel().onInputTextChanged(((ChatInputViewModel.Event.SetChatText) event).getText(), Boolean.TRUE); unit = Unit.a; } else if (event instanceof ChatInputViewModel.Event.CommandInputsInvalid) { InputAutocomplete inputAutocomplete = this.autocomplete; if (inputAutocomplete != null) { inputAutocomplete.onCommandInputsSendError(); unit = Unit.a; } } else if (event instanceof ChatInputViewModel.Event.ShowPremiumUpsell) { b.C0012b bVar2 = c.a.a.e.b.j; FragmentManager parentFragmentManager5 = getParentFragmentManager(); m.checkNotNullExpressionValue(parentFragmentManager5, "parentFragmentManager"); ChatInputViewModel.Event.ShowPremiumUpsell showPremiumUpsell = (ChatInputViewModel.Event.ShowPremiumUpsell) event; b.C0012b.a(bVar2, parentFragmentManager5, showPremiumUpsell.getPage(), getString(showPremiumUpsell.getHeaderResId()), getString(showPremiumUpsell.getBodyResId()), null, null, null, null, showPremiumUpsell.getShowOtherPages(), showPremiumUpsell.getShowLearnMore(), 240); unit = Unit.a; } else if (event instanceof ChatInputViewModel.Event.ThreadDraftClosed) { getFlexInputViewModel().hideKeyboard(); clearInput$default(this, null, false, 3, null); unit = Unit.a; } else { throw new NoWhenBranchMatchedException(); } KotlinExtensionsKt.getExhaustive(unit); } private final void onViewBindingDestroy(WidgetChatInputBinding widgetChatInputBinding) { c.a.o.b a = b.C0033b.a(); LinearLayout linearLayout = widgetChatInputBinding.q; m.checkNotNullExpressionValue(linearLayout, "binding.chatInputWrap"); a.c(linearLayout); } private final void populateDirectShareData() { ContentResolver contentResolver; List uris; Long directShareId = IntentUtils.INSTANCE.getDirectShareId(getMostRecentIntent()); if (directShareId != null) { long longValue = directShareId.longValue(); boolean z2 = true; ShareUtils.SharedContent sharedContent = ShareUtils.INSTANCE.getSharedContent(getMostRecentIntent(), true); CharSequence text = sharedContent.getText(); if (text != null && !t.isBlank(text)) { z2 = false; } if (!z2) { this.messageDraftsRepo.setTextChannelInput(longValue, sharedContent.getText().toString()); } Context context = getContext(); if (!(context == null || (contentResolver = context.getContentResolver()) == null || (uris = sharedContent.getUris()) == null)) { for (Uri uri : uris) { WidgetChatInputAttachments widgetChatInputAttachments = this.chatAttachments; if (widgetChatInputAttachments == null) { m.throwUninitializedPropertyAccessException("chatAttachments"); } widgetChatInputAttachments.addExternalAttachment(Attachment.Companion.b(uri, contentResolver)); } } } } private final void setWindowInsetsListeners(boolean z2) { LinearLayout linearLayout = getBinding().q; m.checkNotNullExpressionValue(linearLayout, "binding.chatInputWrap"); ViewExtensions.setForwardingWindowInsetsListener(linearLayout); FragmentContainerView fragmentContainerView = getBinding().p; m.checkNotNullExpressionValue(fragmentContainerView, "binding.chatInputWidget"); ViewExtensions.setForwardingWindowInsetsListener(fragmentContainerView); o4 o4Var = getBinding().r; m.checkNotNullExpressionValue(o4Var, "binding.guard"); ViewCompat.setOnApplyWindowInsetsListener(o4Var.a, WidgetChatInput$setWindowInsetsListeners$1.INSTANCE); p4 p4Var = getBinding().t; m.checkNotNullExpressionValue(p4Var, "binding.guardMemberVerification"); ViewCompat.setOnApplyWindowInsetsListener(p4Var.a, WidgetChatInput$setWindowInsetsListeners$2.INSTANCE); n4 n4Var = getBinding().f1805s; m.checkNotNullExpressionValue(n4Var, "binding.guardCommunicationDisabled"); ViewCompat.setOnApplyWindowInsetsListener(n4Var.a, WidgetChatInput$setWindowInsetsListeners$3.INSTANCE); ViewCompat.setOnApplyWindowInsetsListener(getBinding().d, new WidgetChatInput$setWindowInsetsListeners$4(this, z2)); getBinding().d.requestApplyInsets(); } public static /* synthetic */ void setWindowInsetsListeners$default(WidgetChatInput widgetChatInput, boolean z2, int i, Object obj) { if ((i & 1) != 0) { z2 = true; } widgetChatInput.setWindowInsetsListeners(z2); } private final void showFollowSheet(long j, long j2) { WidgetChannelFollowSheet.Companion companion = WidgetChannelFollowSheet.Companion; FragmentManager parentFragmentManager = getParentFragmentManager(); m.checkNotNullExpressionValue(parentFragmentManager, "parentFragmentManager"); companion.show(parentFragmentManager, j, j2); } @Override // androidx.fragment.app.Fragment public void onDestroy() { super.onDestroy(); Subscription subscription = this.communicationDisabledCountdownSubscription; if (subscription != null) { subscription.unsubscribe(); } } @Override // com.discord.app.AppFragment public void onViewBound(View view) { m.checkNotNullParameter(view, "view"); super.onViewBound(view); WidgetChatInputAttachments widgetChatInputAttachments = new WidgetChatInputAttachments(getFlexInputFragment()); this.chatAttachments = widgetChatInputAttachments; if (widgetChatInputAttachments == null) { m.throwUninitializedPropertyAccessException("chatAttachments"); } widgetChatInputAttachments.configureFlexInputFragment(this); getFlexInputFragment().i(new WidgetChatInput$onViewBound$1(this)); c.a.o.b a = b.C0033b.a(); LinearLayout linearLayout = getBinding().q; m.checkNotNullExpressionValue(linearLayout, "binding.chatInputWrap"); a.b(linearLayout); setWindowInsetsListeners$default(this, false, 1, null); } @Override // com.discord.app.AppFragment public void onViewBoundOrOnResume() { super.onViewBoundOrOnResume(); populateDirectShareData(); WidgetChatInputTruncatedHint widgetChatInputTruncatedHint = this.chatInputTruncatedHint; if (widgetChatInputTruncatedHint != null) { widgetChatInputTruncatedHint.addBindedTextWatcher(this); } Observable q = getViewModel().observeViewState().q(); m.checkNotNullExpressionValue(q, "viewModel\n .obser… .distinctUntilChanged()"); ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.bindToComponentLifecycle$default(q, this, null, 2, null), WidgetChatInput.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetChatInput$onViewBoundOrOnResume$1(this), 62, (Object) null); ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.bindToComponentLifecycle$default(getViewModel().observeEvents(), this, null, 2, null), WidgetChatInput.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetChatInput$onViewBoundOrOnResume$2(this), 62, (Object) null); WidgetChatInputAttachments widgetChatInputAttachments = this.chatAttachments; if (widgetChatInputAttachments == null) { m.throwUninitializedPropertyAccessException("chatAttachments"); } widgetChatInputAttachments.setViewModel(getFlexInputViewModel()); InputAutocomplete inputAutocomplete = this.autocomplete; if (inputAutocomplete != null) { inputAutocomplete.onViewBoundOrOnResume(); } ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.bindToComponentLifecycle$default(this.inlineVoiceVisibilityObserver.observeIsVisible(), this, null, 2, null), WidgetChatInput.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetChatInput$onViewBoundOrOnResume$3(this), 62, (Object) null); } }