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.a; import c.a.d.f; import c.a.d.g0; import c.a.i.g4; import c.a.i.h4; import c.a.j.a; import c.a.l.b; import c.a.p.b; import c.d.b.a.a; import c.i.a.f.e.o.c; import com.airbnb.lottie.parser.AnimatableValueParser; import com.discord.api.channel.Channel; import com.discord.api.guild.GuildVerificationLevel; import com.discord.api.guildjoinrequest.ApplicationStatus; import com.discord.app.AppFragment; import com.discord.app.AppLog; import com.discord.databinding.WidgetChatInputBinding; import com.discord.models.member.GuildMember; import com.discord.stores.StoreExperiments; import com.discord.stores.StoreStream; import com.discord.tooltips.TooltipManager; 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.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.expression.ExpressionPickerSparkleTooltip; import com.discord.widgets.chat.input.sticker.StickerPickerFeatureFlag; 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.lang.ref.WeakReference; import java.text.NumberFormat; import java.util.List; import java.util.Set; 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; /* compiled from: WidgetChatInput.kt */ public final class WidgetChatInput extends AppFragment { public static final /* synthetic */ KProperty[] $$delegatedProperties = {a.W(WidgetChatInput.class, "binding", "getBinding()Lcom/discord/databinding/WidgetChatInputBinding;", 0)}; 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 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 g0(new WidgetChatInput$flexInputViewModel$2(this))); private final ViewVisibilityObserver inlineVoiceVisibilityObserver = ViewVisibilityObserverProvider.INSTANCE.get("INLINE_VOICE_FEATURE"); private final MessageDraftsRepo messageDraftsRepo = MessageDraftsRepo.Provider.INSTANCE.get(); private final TooltipManager tooltipManager; private final Lazy viewModel$delegate = FragmentViewModelLazyKt.createViewModelLazy(this, a0.getOrCreateKotlinClass(ChatInputViewModel.class), new WidgetChatInput$appActivityViewModels$$inlined$activityViewModels$1(this), new g0(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(2131558913); AppLog appLog = AppLog.g; m.checkNotNullParameter(appLog, "logger"); WeakReference weakReference = a.b.a; TooltipManager tooltipManager = null; c.a.j.a aVar = weakReference != null ? weakReference.get() : null; if (aVar == null) { aVar = new c.a.j.a(appLog); a.b.a = new WeakReference<>(aVar); } TooltipManager.a aVar2 = TooltipManager.a.d; m.checkNotNullParameter(aVar, "floatingViewManager"); WeakReference weakReference2 = TooltipManager.a.a; tooltipManager = weakReference2 != null ? weakReference2.get() : tooltipManager; if (tooltipManager == null) { tooltipManager = new TooltipManager((c.a.w.a) TooltipManager.a.b.getValue(), (Set) TooltipManager.a.f2108c.getValue(), 0, aVar, 4); TooltipManager.a.a = new WeakReference<>(tooltipManager); } this.tooltipManager = tooltipManager; } 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 */ 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 */ 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 */ TooltipManager access$getTooltipManager$p(WidgetChatInput widgetChatInput) { return widgetChatInput.tooltipManager; } 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$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$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) { g4 g4Var = getBinding().r; m.checkNotNullExpressionValue(g4Var, "binding.guard"); LinearLayout linearLayout = g4Var.a; m.checkNotNullExpressionValue(linearLayout, "binding.guard.root"); int i = 0; linearLayout.setVisibility(loaded.isLurking() || loaded.isVerificationLevelTriggered() || loaded.isSystemDM() || loaded.getShouldShowFollow() ? 0 : 8); h4 h4Var = getBinding().f1720s; m.checkNotNullExpressionValue(h4Var, "binding.guardMemberVerification"); RelativeLayout relativeLayout = h4Var.a; m.checkNotNullExpressionValue(relativeLayout, "binding.guardMemberVerification.root"); g4 g4Var2 = getBinding().r; m.checkNotNullExpressionValue(g4Var2, "binding.guard"); LinearLayout linearLayout2 = g4Var2.a; m.checkNotNullExpressionValue(linearLayout2, "binding.guard.root"); if (!(!(linearLayout2.getVisibility() == 0) && loaded.getShouldShowVerificationGate())) { i = 8; } relativeLayout.setVisibility(i); h4 h4Var2 = getBinding().f1720s; m.checkNotNullExpressionValue(h4Var2, "binding.guardMemberVerification"); h4Var2.a.setOnClickListener(new WidgetChatInput$configureChatGuard$1(this, loaded)); if (loaded.isSystemDM()) { getBinding().r.e.setText(2131893819); TextView textView = getBinding().r.d; m.checkNotNullExpressionValue(textView, "binding.guard.chatInputGuardSubtext"); ViewExtensions.setTextAndVisibilityBy(textView, getString(2131893820)); MaterialButton materialButton = getBinding().r.b; m.checkNotNullExpressionValue(materialButton, "binding.guard.chatInputGuardAction"); materialButton.setVisibility(8); MaterialButton materialButton2 = getBinding().r.f97c; m.checkNotNullExpressionValue(materialButton2, "binding.guard.chatInputGuardActionSecondary"); materialButton2.setVisibility(8); } else if (loaded.isLurking()) { if (loaded.getShouldShowFollow()) { getBinding().r.e.setText(2131888536); MaterialButton materialButton3 = getBinding().r.b; m.checkNotNullExpressionValue(materialButton3, "binding.guard.chatInputGuardAction"); ViewExtensions.setTextAndVisibilityBy(materialButton3, getString(2131888954)); getBinding().r.b.setOnClickListener(new WidgetChatInput$configureChatGuard$2(this, loaded)); MaterialButton materialButton4 = getBinding().r.f97c; m.checkNotNullExpressionValue(materialButton4, "binding.guard.chatInputGuardActionSecondary"); ViewExtensions.setTextAndVisibilityBy(materialButton4, getString(2131890961)); getBinding().r.f97c.setOnClickListener(new WidgetChatInput$configureChatGuard$3(this)); } else { getBinding().r.e.setText(2131890962); MaterialButton materialButton5 = getBinding().r.b; m.checkNotNullExpressionValue(materialButton5, "binding.guard.chatInputGuardAction"); ViewExtensions.setTextAndVisibilityBy(materialButton5, getString(2131890961)); getBinding().r.b.setOnClickListener(new WidgetChatInput$configureChatGuard$4(this)); MaterialButton materialButton6 = getBinding().r.f97c; m.checkNotNullExpressionValue(materialButton6, "binding.guard.chatInputGuardActionSecondary"); materialButton6.setVisibility(8); } } else if (loaded.getShouldShowFollow()) { getBinding().r.e.setText(2131888536); MaterialButton materialButton7 = getBinding().r.b; m.checkNotNullExpressionValue(materialButton7, "binding.guard.chatInputGuardAction"); ViewExtensions.setTextAndVisibilityBy(materialButton7, getString(2131888954)); getBinding().r.b.setOnClickListener(new WidgetChatInput$configureChatGuard$5(this, loaded)); MaterialButton materialButton8 = getBinding().r.f97c; m.checkNotNullExpressionValue(materialButton8, "binding.guard.chatInputGuardActionSecondary"); materialButton8.setVisibility(8); } else { TextView textView2 = getBinding().r.e; m.checkNotNullExpressionValue(textView2, "binding.guard.chatInputGuardText"); TextView textView3 = getBinding().r.e; m.checkNotNullExpressionValue(textView3, "binding.guard.chatInputGuardText"); Context context = textView3.getContext(); m.checkNotNullExpressionValue(context, "binding.guard.chatInputGuardText.context"); textView2.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$6(this)); MaterialButton materialButton11 = getBinding().r.f97c; m.checkNotNullExpressionValue(materialButton11, "binding.guard.chatInputGuardActionSecondary"); materialButton11.setVisibility(8); } if (loaded.getShouldShowVerificationGate()) { ApplicationStatus joinRequestStatus = loaded.getJoinRequestStatus(); if (joinRequestStatus != null) { int ordinal = joinRequestStatus.ordinal(); if (ordinal == 1) { getBinding().f1720s.f101c.setText(2131891087); getBinding().f1720s.b.setImageResource(2131232191); return; } else if (ordinal == 2) { getBinding().f1720s.f101c.setText(2131891092); getBinding().f1720s.b.setImageResource(2131232190); return; } } getBinding().f1720s.f101c.setText(2131891101); getBinding().f1720s.b.setImageResource(2131232192); } } 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(2131888214); 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.l(textView, 2131891294, 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, 2130968915) : ColorCompat.getThemedColor(requireContext, 2130968988); ImageView imageView = getBinding().i; m.checkNotNullExpressionValue(imageView, "binding.chatInputContextReplyMentionButtonImage"); ColorCompatKt.tintWithColor(imageView, themedColor); getBinding().j.setTextColor(themedColor); getBinding().j.setText(replying.getShouldMention() ? 2131892665 : 2131892663); } 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(); WidgetChatInput$configureSendListeners$3 widgetChatInput$configureSendListeners$3 = new WidgetChatInput$configureSendListeners$3(this, widgetChatInputEditText, new WidgetChatInput$configureSendListeners$1(this), new WidgetChatInput$configureSendListeners$2(this, widgetChatInputEditText, requireContext, new MessageManager(requireContext, null, null, null, null, null, null, null, null, 510, null))); WidgetChatInput$configureSendListeners$4 widgetChatInput$configureSendListeners$4 = new WidgetChatInput$configureSendListeners$4(requireContext); boolean z2 = widgetChatInputEditText.getChannelId() != loaded.getChannelId(); widgetChatInputEditText.setChannelId(loaded.getChannelId(), z2); widgetChatInputEditText.setOnSendListener(new WidgetChatInput$configureSendListeners$5(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$6(this, loaded, widgetChatInput$configureSendListeners$4, widgetChatInput$configureSendListeners$3)); } } private final void configureText(ChatInputViewModel.ViewState.Loaded loaded) { if (!loaded.getAbleToSendMessage()) { c.c0(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); h4 h4Var = getBinding().f1720s; m.checkNotNullExpressionValue(h4Var, "binding.guardMemberVerification"); RelativeLayout relativeLayout = h4Var.a; m.checkNotNullExpressionValue(relativeLayout, "binding.guardMemberVerification.root"); relativeLayout.setVisibility(8); g4 g4Var = getBinding().r; m.checkNotNullExpressionValue(g4Var, "binding.guard"); LinearLayout linearLayout2 = g4Var.a; m.checkNotNullExpressionValue(linearLayout2, "binding.guard.root"); linearLayout2.setVisibility(8); } else if (viewState instanceof ChatInputViewModel.ViewState.Loaded) { LinearLayout linearLayout3 = getBinding().q; m.checkNotNullExpressionValue(linearLayout3, "binding.chatInputWrap"); ChatInputViewModel.ViewState.Loaded loaded = (ChatInputViewModel.ViewState.Loaded) viewState; if (loaded.isInputShowing()) { i = 0; } linearLayout3.setVisibility(i); configureChatGuard(loaded); getFlexInputFragment().i(new WidgetChatInput$configureUI$1(this, viewState)); configureContextBar(loaded); if (!loaded.getAbleToSendMessage() || !loaded.getCanShowStickerPickerNfx()) { this.tooltipManager.c(ExpressionPickerSparkleTooltip.INSTANCE); } else { showExpressionButtonSparkle(ExpressionPickerSparkleTooltip.INSTANCE); } 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(2131888174); m.checkNotNullExpressionValue(string, "context.getString(R.stri…erification_text_blocked)"); return string; } else if (z3) { return b.g(context, 2131893931, new Object[]{AnimatableValueParser.A0(channel, context, false, 2)}, null, 4); } else { String string2 = context.getString(2131891488); 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(2131894573); } if (ordinal != 4) { return null; } return context.getString(2131894585); } private final CharSequence getVerificationText(Context context, GuildVerificationLevel guildVerificationLevel) { int ordinal = guildVerificationLevel.ordinal(); if (ordinal == 1) { return context.getString(2131890140); } if (ordinal == 2) { return b.g(context, 2131890138, new Object[]{"5"}, null, 4); } if (ordinal == 3) { return b.g(context, 2131890139, new Object[]{"10"}, null, 4); } if (ordinal != 4) { return null; } return context.getString(2131890141); } 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(2131891249), b.j(this, 2131891248, new Object[]{numberInstance.format(Integer.valueOf(messageTooLong.getCurrentCharacterCount())), numberInstance.format(Integer.valueOf(messageTooLong.getMaxCharacterCount()))}, null, 4), getString(2131891735), null, null, null, null, null, null, null, null, 0, null, 16368, null); unit = Unit.a; } else if (event instanceof ChatInputViewModel.Event.FailedDeliveryToRecipient) { getFlexInputViewModel().hideKeyboard(); WidgetNoticeDialog.Companion companion2 = WidgetNoticeDialog.Companion; FragmentManager parentFragmentManager3 = getParentFragmentManager(); m.checkNotNullExpressionValue(parentFragmentManager3, "parentFragmentManager"); WidgetNoticeDialog.Companion.show$default(companion2, parentFragmentManager3, getString(2131888376), b.j(this, 2131887043, new Object[]{f.a.a(360060145013L, null)}, null, 4), getString(2131891735), 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) { WidgetChatInputEditText widgetChatInputEditText = this.chatInputEditTextHolder; if (widgetChatInputEditText != null) { widgetChatInputEditText.onCommandInputsSendError(); unit = Unit.a; } } else if (event instanceof ChatInputViewModel.Event.ShowPremiumUpsell) { a.b bVar2 = c.a.a.e.a.j; FragmentManager parentFragmentManager4 = getParentFragmentManager(); m.checkNotNullExpressionValue(parentFragmentManager4, "parentFragmentManager"); ChatInputViewModel.Event.ShowPremiumUpsell showPremiumUpsell = (ChatInputViewModel.Event.ShowPremiumUpsell) event; a.b.a(bVar2, parentFragmentManager4, showPremiumUpsell.getPage(), getString(showPremiumUpsell.getHeaderResId()), getString(showPremiumUpsell.getBodyResId()), null, null, null, null, showPremiumUpsell.getShowOtherPages(), showPremiumUpsell.getShowLearnMore(), 240); unit = Unit.a; } else { throw new NoWhenBranchMatchedException(); } KotlinExtensionsKt.getExhaustive(unit); } private final void onViewBindingDestroy(WidgetChatInputBinding widgetChatInputBinding) { c.a.p.b a = b.C0032b.a(); LinearLayout linearLayout = widgetChatInputBinding.q; m.checkNotNullExpressionValue(linearLayout, "binding.chatInputWrap"); a.i.remove(Integer.valueOf(linearLayout.getId())); a.a(); } 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.a(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); g4 g4Var = getBinding().r; m.checkNotNullExpressionValue(g4Var, "binding.guard"); ViewCompat.setOnApplyWindowInsetsListener(g4Var.a, WidgetChatInput$setWindowInsetsListeners$1.INSTANCE); h4 h4Var = getBinding().f1720s; m.checkNotNullExpressionValue(h4Var, "binding.guardMemberVerification"); ViewCompat.setOnApplyWindowInsetsListener(h4Var.a, WidgetChatInput$setWindowInsetsListeners$2.INSTANCE); ViewCompat.setOnApplyWindowInsetsListener(getBinding().d, new WidgetChatInput$setWindowInsetsListeners$3(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 showExpressionButtonSparkle(TooltipManager.Tooltip tooltip) { getFlexInputFragment().i(new WidgetChatInput$showExpressionButtonSparkle$1(this, tooltip)); } 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 // com.discord.app.AppFragment public void onViewBound(View view) { m.checkNotNullParameter(view, "view"); super.onViewBound(view); StoreExperiments experiments = StoreStream.Companion.getExperiments(); WidgetChatInputAttachments widgetChatInputAttachments = new WidgetChatInputAttachments(getFlexInputFragment()); this.chatAttachments = widgetChatInputAttachments; if (widgetChatInputAttachments == null) { m.throwUninitializedPropertyAccessException("chatAttachments"); } widgetChatInputAttachments.configureFlexInputFragment(this); StickerPickerFeatureFlag.Companion.getINSTANCE().fetchExperiment(experiments); getFlexInputFragment().i(new WidgetChatInput$onViewBound$1(this)); getBinding().q.addOnLayoutChangeListener(b.C0032b.a()); 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); } WidgetChatInputEditText widgetChatInputEditText = this.chatInputEditTextHolder; if (widgetChatInputEditText != null) { widgetChatInputEditText.configureMentionsDataSubscriptions(this); } Observable r = getViewModel().observeViewState().r(); m.checkNotNullExpressionValue(r, "viewModel\n .obser… .distinctUntilChanged()"); ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.bindToComponentLifecycle(r, this), 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(getViewModel().observeEvents(), this), 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()); ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.bindToComponentLifecycle(this.inlineVoiceVisibilityObserver.observeIsVisible(), this), WidgetChatInput.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetChatInput$onViewBoundOrOnResume$3(this), 62, (Object) null); } }