discord-jadx/app/src/main/java/com/discord/widgets/home/WidgetHome.java

706 lines
38 KiB
Java

package com.discord.widgets.home;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.appcompat.widget.Toolbar;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.core.view.ViewCompat;
import androidx.core.view.ViewGroupKt;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentContainerView;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import androidx.fragment.app.FragmentViewModelLazyKt;
import androidx.recyclerview.widget.RecyclerView;
import b.a.d.f0;
import b.a.d.h0;
import b.a.i.d5;
import b.a.i.e5;
import b.a.i.f5;
import b.a.i.g5;
import b.a.i.i5;
import b.a.o.b;
import b.d.b.a.a;
import com.discord.R;
import com.discord.api.channel.Channel;
import com.discord.api.channel.ChannelUtils;
import com.discord.app.AppActivity;
import com.discord.app.AppFragment;
import com.discord.databinding.WidgetHomeBinding;
import com.discord.panels.OverlappingPanelsLayout;
import com.discord.stores.StoreChannelsSelected;
import com.discord.stores.StoreConnectionOpen;
import com.discord.stores.StoreNavigation;
import com.discord.stores.StoreNotices;
import com.discord.stores.StoreNux;
import com.discord.stores.StoreStream;
import com.discord.stores.StoreTabsNavigation;
import com.discord.stores.StoreUser;
import com.discord.utilities.accessibility.AccessibilityUtils;
import com.discord.utilities.channel.ChannelSelector;
import com.discord.utilities.dimen.DimenUtils;
import com.discord.utilities.locale.LocaleManager;
import com.discord.utilities.rx.ObservableExtensionsKt;
import com.discord.utilities.rx.ObservableExtensionsKt$filterNull$1;
import com.discord.utilities.rx.ObservableExtensionsKt$filterNull$2;
import com.discord.utilities.surveys.SurveyUtils;
import com.discord.utilities.time.ClockFactory;
import com.discord.utilities.view.extensions.ViewExtensions;
import com.discord.utilities.view.rounded.RoundedRelativeLayout;
import com.discord.utilities.viewbinding.FragmentViewBindingDelegate;
import com.discord.utilities.viewbinding.FragmentViewBindingDelegateKt;
import com.discord.widgets.accessibility.AccessibilityDetectionNavigator;
import com.discord.widgets.channels.WidgetChannelOnboarding;
import com.discord.widgets.chat.input.SmoothKeyboardReactionHelper;
import com.discord.widgets.chat.list.WidgetChatList;
import com.discord.widgets.directories.WidgetDirectoryChannel;
import com.discord.widgets.guilds.join.WidgetGuildWelcomeSheet;
import com.discord.widgets.guildscheduledevent.WidgetGuildScheduledEventDetailsBottomSheet;
import com.discord.widgets.guildscheduledevent.WidgetGuildScheduledEventUpsellBottomSheet;
import com.discord.widgets.home.WidgetHomeModel;
import com.discord.widgets.home.WidgetHomeViewModel;
import com.discord.widgets.hubs.WidgetHubEmailFlow;
import com.discord.widgets.notice.WidgetNoticeNuxSamsungLink;
import com.discord.widgets.status.WidgetGlobalStatusIndicatorState;
import com.discord.widgets.tabs.NavigationTab;
import com.discord.widgets.tabs.OnTabSelectedListener;
import com.discord.widgets.tabs.WidgetTabsHost;
import com.discord.widgets.voice.fullscreen.WidgetCallFullscreen;
import com.discord.widgets.voice.fullscreen.WidgetCallPreviewFullscreen;
import com.google.android.material.appbar.AppBarLayout;
import d0.t.m0;
import d0.t.u;
import d0.z.d.a0;
import d0.z.d.m;
import java.io.Serializable;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import kotlin.Lazy;
import kotlin.Unit;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.reflect.KProperty;
import rx.Observable;
/* compiled from: WidgetHome.kt */
public final class WidgetHome extends AppFragment implements OnTabSelectedListener, b.a {
public static final /* synthetic */ KProperty[] $$delegatedProperties = {a.b0(WidgetHome.class, "binding", "getBinding()Lcom/discord/databinding/WidgetHomeBinding;", 0)};
public static final Companion Companion = new Companion(null);
private static final long DELAY_DRAWER_OPEN_FINISH = 2000;
private static final long DELAY_DRAWER_OPEN_START = 1000;
private final FragmentViewBindingDelegate binding$delegate = FragmentViewBindingDelegateKt.viewBinding$default(this, WidgetHome$binding$2.INSTANCE, null, 2, null);
private final Set<Integer> fixedPositionViewIds;
private final WidgetGlobalStatusIndicatorState globalStatusIndicatorStateObserver;
private final LeftPanelManager leftPanelManager;
private final LocaleManager localeManager;
private Function1<? super View, Unit> onGuildListAddHintCreate;
private WidgetHomePanelLoading panelLoading;
private WidgetHomePanelNsfw panelNsfw;
private final StoreTabsNavigation storeTabsNavigation;
private final Lazy viewModel$delegate;
/* compiled from: WidgetHome.kt */
public static final class Companion {
private Companion() {
}
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
}
public final /* synthetic */ class WhenMappings {
public static final /* synthetic */ int[] $EnumSwitchMapping$0;
static {
OverlappingPanelsLayout.Panel.values();
int[] iArr = new int[3];
$EnumSwitchMapping$0 = iArr;
iArr[OverlappingPanelsLayout.Panel.END.ordinal()] = 1;
iArr[OverlappingPanelsLayout.Panel.CENTER.ordinal()] = 2;
iArr[OverlappingPanelsLayout.Panel.START.ordinal()] = 3;
}
}
public WidgetHome() {
super(R.layout.widget_home);
WidgetHome$viewModel$2 widgetHome$viewModel$2 = WidgetHome$viewModel$2.INSTANCE;
f0 f0Var = new f0(this);
this.viewModel$delegate = FragmentViewModelLazyKt.createViewModelLazy(this, a0.getOrCreateKotlinClass(WidgetHomeViewModel.class), new WidgetHome$appViewModels$$inlined$viewModels$1(f0Var), new h0(widgetHome$viewModel$2));
this.fixedPositionViewIds = m0.setOf(Integer.valueOf((int) R.id.unread));
this.leftPanelManager = new LeftPanelManager(null, null, 3, null);
this.localeManager = new LocaleManager();
this.onGuildListAddHintCreate = WidgetHome$onGuildListAddHintCreate$1.INSTANCE;
this.storeTabsNavigation = StoreStream.Companion.getTabsNavigation();
this.globalStatusIndicatorStateObserver = WidgetGlobalStatusIndicatorState.Provider.get();
}
public static final /* synthetic */ void access$configureFirstOpen(WidgetHome widgetHome) {
widgetHome.configureFirstOpen();
}
public static final /* synthetic */ void access$configureUI(WidgetHome widgetHome, WidgetHomeModel widgetHomeModel) {
widgetHome.configureUI(widgetHomeModel);
}
public static final /* synthetic */ WidgetHomeBinding access$getBinding$p(WidgetHome widgetHome) {
return widgetHome.getBinding();
}
public static final /* synthetic */ LocaleManager access$getLocaleManager$p(WidgetHome widgetHome) {
return widgetHome.localeManager;
}
public static final /* synthetic */ WidgetHomePanelNsfw access$getPanelNsfw$p(WidgetHome widgetHome) {
return widgetHome.panelNsfw;
}
public static final /* synthetic */ WidgetHomeViewModel access$getViewModel$p(WidgetHome widgetHome) {
return widgetHome.getViewModel();
}
public static final /* synthetic */ boolean access$handleBackPressed(WidgetHome widgetHome) {
return widgetHome.handleBackPressed();
}
public static final /* synthetic */ void access$handleEvent(WidgetHome widgetHome, WidgetHomeViewModel.Event event) {
widgetHome.handleEvent(event);
}
public static final /* synthetic */ void access$handleGlobalStatusIndicatorState(WidgetHome widgetHome, WidgetGlobalStatusIndicatorState.State state) {
widgetHome.handleGlobalStatusIndicatorState(state);
}
public static final /* synthetic */ void access$handleViewState(WidgetHome widgetHome, WidgetHomeViewModel.ViewState viewState) {
widgetHome.handleViewState(viewState);
}
public static final /* synthetic */ void access$maybeShowHubEmailUpsell(WidgetHome widgetHome) {
widgetHome.maybeShowHubEmailUpsell();
}
public static final /* synthetic */ void access$maybeToggleChannel(WidgetHome widgetHome, WidgetHomeModel widgetHomeModel) {
widgetHome.maybeToggleChannel(widgetHomeModel);
}
public static final /* synthetic */ void access$onNsfwToggle(WidgetHome widgetHome, boolean z2) {
widgetHome.onNsfwToggle(z2);
}
public static final /* synthetic */ void access$setPanelNsfw$p(WidgetHome widgetHome, WidgetHomePanelNsfw widgetHomePanelNsfw) {
widgetHome.panelNsfw = widgetHomePanelNsfw;
}
public static final /* synthetic */ void access$showSurvey(WidgetHome widgetHome, SurveyUtils.Survey survey) {
widgetHome.showSurvey(survey);
}
public static final /* synthetic */ void access$showUrgentMessageDialog(WidgetHome widgetHome) {
widgetHome.showUrgentMessageDialog();
}
private final void animatePeek(WidgetHomeViewModel.Event event) {
View view;
long j;
float f;
float f2;
View view2;
if (!AccessibilityUtils.INSTANCE.isReducedMotionEnabled()) {
Fragment findFragmentById = getChildFragmentManager().findFragmentById(R.id.widget_chat_list);
if (!(findFragmentById instanceof WidgetChatList)) {
findFragmentById = null;
}
WidgetChatList widgetChatList = (WidgetChatList) findFragmentById;
if (widgetChatList != null) {
d5 d5Var = getBinding().d;
m.checkNotNullExpressionValue(d5Var, "binding.panelCenter");
RoundedRelativeLayout roundedRelativeLayout = d5Var.a;
m.checkNotNullExpressionValue(roundedRelativeLayout, "binding.panelCenter.root");
Bitmap createBitmap = Bitmap.createBitmap(roundedRelativeLayout.getMeasuredWidth(), roundedRelativeLayout.getMeasuredHeight(), Bitmap.Config.ARGB_8888);
roundedRelativeLayout.draw(new Canvas(createBitmap));
getBinding().g.setImageBitmap(createBitmap);
if (event instanceof WidgetHomeViewModel.Event.AnimatePeekIn) {
View view3 = getBinding().g;
m.checkNotNullExpressionValue(view3, "binding.peekTransitionBitmap");
f = (float) roundedRelativeLayout.getRight();
view2 = view3;
view = roundedRelativeLayout;
j = 250;
f2 = 0.0f;
} else {
view = getBinding().g;
m.checkNotNullExpressionValue(view, "binding.peekTransitionBitmap");
view2 = roundedRelativeLayout;
j = 200;
f2 = (float) roundedRelativeLayout.getRight();
f = 0.0f;
}
view.setTranslationX(f);
view.animate().setDuration(j).translationX(f2).withEndAction(new WidgetHome$animatePeek$1(this, widgetChatList)).start();
view2.setTranslationX(f - ((float) roundedRelativeLayout.getMeasuredWidth()));
view2.animate().setDuration(j).translationX(f2 - ((float) roundedRelativeLayout.getMeasuredWidth())).start();
widgetChatList.disableItemAnimations();
ImageView imageView = getBinding().g;
m.checkNotNullExpressionValue(imageView, "binding.peekTransitionBitmap");
imageView.setVisibility(0);
}
}
}
private final void configureFirstOpen() {
StoreStream.Companion companion = StoreStream.Companion;
Observable y2 = Observable.j(StoreConnectionOpen.observeConnectionOpen$default(companion.getConnectionOpen(), false, 1, null), companion.getChannels().observeGuildAndPrivateChannels(), WidgetHome$configureFirstOpen$1.INSTANCE).y();
m.checkNotNullExpressionValue(y2, "Observable\n .comb… }\n .first()");
ObservableExtensionsKt.appSubscribe$default(y2, WidgetHome.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetHome$configureFirstOpen$2(this), 62, (Object) null);
}
private final void configureLeftPanel() {
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(ObservableExtensionsKt.computationLatest(this.leftPanelManager.observeLockState()), this, null, 2, null), WidgetHome.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetHome$configureLeftPanel$1(this), 62, (Object) null);
}
private final void configureNavigationDrawerAction(StoreNavigation storeNavigation) {
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(storeNavigation.getNavigationPanelAction(), this, null, 2, null), StoreNavigation.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetHome$configureNavigationDrawerAction$1(this, storeNavigation), 62, (Object) null);
}
private final void configureOverlappingPanels() {
getBinding().c.registerStartPanelStateListeners(new WidgetHome$configureOverlappingPanels$1(this));
getBinding().c.registerEndPanelStateListeners(new WidgetHome$configureOverlappingPanels$2(this));
}
private final void configureUI(WidgetHomeModel widgetHomeModel) {
getViewModel().setWidgetHomeModel$app_productionCanaryRelease(widgetHomeModel);
if (isOnHomeTab()) {
WidgetHomeHeaderManager widgetHomeHeaderManager = WidgetHomeHeaderManager.INSTANCE;
WidgetHomeBinding binding = getBinding();
m.checkNotNullExpressionValue(binding, "binding");
widgetHomeHeaderManager.configure(this, widgetHomeModel, binding);
}
}
private final void enqueueEventDetails(long j) {
WidgetGuildScheduledEventDetailsBottomSheet.Companion.enqueue(j);
}
private final WidgetHomeBinding getBinding() {
return (WidgetHomeBinding) this.binding$delegate.getValue((Fragment) this, $$delegatedProperties[0]);
}
private final WidgetHomeViewModel getViewModel() {
return (WidgetHomeViewModel) this.viewModel$delegate.getValue();
}
private final boolean handleBackPressed() {
int ordinal = getBinding().c.getSelectedPanel().ordinal();
if (ordinal == 0) {
requireActivity().moveTaskToBack(true);
} else if (ordinal == 1) {
handleCenterPanelBack$app_productionCanaryRelease();
} else if (ordinal == 2) {
getBinding().c.closePanels();
}
return true;
}
private final void handleEvent(WidgetHomeViewModel.Event event) {
if (m.areEqual(event, WidgetHomeViewModel.Event.OpenLeftPanel.INSTANCE)) {
getBinding().c.openStartPanel();
} else if (m.areEqual(event, WidgetHomeViewModel.Event.ClosePanels.INSTANCE)) {
getBinding().c.closePanels();
} else if (m.areEqual(event, WidgetHomeViewModel.Event.UnlockLeftPanel.INSTANCE)) {
getBinding().c.setStartPanelLockState(OverlappingPanelsLayout.LockState.UNLOCKED);
} else if (m.areEqual(event, WidgetHomeViewModel.Event.ShowChannelOnboardingSheet.INSTANCE)) {
showChannelOnboardingSheet();
} else if (m.areEqual(event, WidgetHomeViewModel.Event.AnimatePeekIn.INSTANCE) || m.areEqual(event, WidgetHomeViewModel.Event.AnimatePeekOut.INSTANCE)) {
animatePeek(event);
} else if (event instanceof WidgetHomeViewModel.Event.ShowGuildWelcomeSheet) {
showWelcomeSheet$default(this, ((WidgetHomeViewModel.Event.ShowGuildWelcomeSheet) event).getGuildId(), null, 2, null);
} else if (event instanceof WidgetHomeViewModel.Event.ShowGuildEventUpsell) {
showGuildEventUpsell(((WidgetHomeViewModel.Event.ShowGuildEventUpsell) event).getGuildId());
}
}
private final void handleGlobalStatusIndicatorState(WidgetGlobalStatusIndicatorState.State state) {
if (state.isCustomBackground()) {
unroundPanelCorners();
} else {
roundPanelCorners();
}
}
private final void handleHomeConfig(HomeConfig homeConfig) {
Long l = null;
if ((homeConfig != null ? homeConfig.getGuildWelcomeSheetId() : null) == null || homeConfig.getGuildScheduledEventId() == null) {
if ((homeConfig != null ? homeConfig.getGuildWelcomeSheetId() : null) != null) {
showWelcomeSheet$default(this, homeConfig.getGuildWelcomeSheetId().longValue(), null, 2, null);
return;
}
if (homeConfig != null) {
l = homeConfig.getGuildScheduledEventId();
}
if (l != null) {
enqueueEventDetails(homeConfig.getGuildScheduledEventId().longValue());
return;
}
return;
}
showWelcomeSheet(homeConfig.getGuildWelcomeSheetId().longValue(), homeConfig.getGuildScheduledEventId());
}
private final void handleViewState(WidgetHomeViewModel.ViewState viewState) {
getBinding().c.handleStartPanelState(viewState.getLeftPanelState());
getBinding().c.handleEndPanelState(viewState.getRightPanelState());
WidgetHomePanelNsfw widgetHomePanelNsfw = this.panelNsfw;
if (widgetHomePanelNsfw != null) {
WidgetHomePanelNsfw.configureUI$default(widgetHomePanelNsfw, viewState.getGuildId(), viewState.isChannelNsfw(), viewState.isNsfwUnconsented(), viewState.getNsfwAllowed(), getBinding().d.f99b.f105b, new WidgetHome$handleViewState$1(this), null, 64, null);
}
}
private final boolean isOnHomeTab() {
return this.storeTabsNavigation.getSelectedTab() == NavigationTab.HOME;
}
private final void maybeShowHubEmailUpsell() {
StoreNotices notices = StoreStream.Companion.getNotices();
String name = WidgetHubEmailFlow.Companion.getNAME();
m.checkNotNullExpressionValue(name, "WidgetHubEmailFlow.NAME");
notices.requestToShow(new StoreNotices.Notice(name, null, 0, 0, true, d0.t.m.listOf(a0.getOrCreateKotlinClass(WidgetHome.class)), 0, true, RecyclerView.FOREVER_NS, WidgetHome$maybeShowHubEmailUpsell$1.INSTANCE, 6, null));
}
private final void maybeToggleChannel(WidgetHomeModel widgetHomeModel) {
Channel channel = widgetHomeModel.getChannel();
int i = 0;
boolean z2 = channel != null && ChannelUtils.o(channel);
FragmentContainerView fragmentContainerView = getBinding().d.c;
m.checkNotNullExpressionValue(fragmentContainerView, "binding.panelCenter.widgetHomePanelDirectory");
fragmentContainerView.setVisibility(z2 ? 0 : 8);
Fragment findFragmentById = getChildFragmentManager().findFragmentById(R.id.widget_home_panel_directory);
if (!(findFragmentById instanceof WidgetDirectoryChannel)) {
findFragmentById = null;
}
WidgetDirectoryChannel widgetDirectoryChannel = (WidgetDirectoryChannel) findFragmentById;
if (widgetDirectoryChannel != null) {
WidgetDirectoryChannel.bindGestureObservers$default(widgetDirectoryChannel, z2, null, 2, null);
}
e5 e5Var = getBinding().d.f99b;
m.checkNotNullExpressionValue(e5Var, "binding.panelCenter.widgetHomePanelCenterChat");
ConstraintLayout constraintLayout = e5Var.a;
m.checkNotNullExpressionValue(constraintLayout, "binding.panelCenter.widgetHomePanelCenterChat.root");
if (!(!z2)) {
i = 8;
}
constraintLayout.setVisibility(i);
}
private final void onNsfwToggle(boolean z2) {
FragmentManager childFragmentManager = getChildFragmentManager();
m.checkNotNullExpressionValue(childFragmentManager, "childFragmentManager");
Fragment findFragmentById = childFragmentManager.findFragmentById(R.id.widget_chat_list);
if (findFragmentById != null) {
m.checkNotNullExpressionValue(findFragmentById, "fragmentManager.findFrag…dget_chat_list) ?: return");
FragmentTransaction beginTransaction = childFragmentManager.beginTransaction();
m.checkNotNullExpressionValue(beginTransaction, "fragmentManager.beginTransaction()");
if (z2) {
beginTransaction.hide(findFragmentById);
} else {
beginTransaction.show(findFragmentById);
}
beginTransaction.commit();
}
}
private final void roundPanelCorners() {
setPanelCorners((float) DimenUtils.dpToPixels(8));
}
private final void setPanelCorners(float f) {
d5 d5Var = getBinding().d;
m.checkNotNullExpressionValue(d5Var, "binding.panelCenter");
d5Var.a.updateTopLeftRadius(f);
d5 d5Var2 = getBinding().d;
m.checkNotNullExpressionValue(d5Var2, "binding.panelCenter");
d5Var2.a.updateTopRightRadius(f);
getBinding().f.f131b.updateTopLeftRadius(f);
getBinding().f.f131b.updateTopRightRadius(f);
}
private final void setPanelWindowInsetsListeners() {
FrameLayout frameLayout = getBinding().h;
m.checkNotNullExpressionValue(frameLayout, "binding.widgetHomeContainer");
ViewExtensions.setForwardingWindowInsetsListener(frameLayout);
HomePanelsLayout homePanelsLayout = getBinding().c;
m.checkNotNullExpressionValue(homePanelsLayout, "binding.overlappingPanels");
ViewExtensions.setForwardingWindowInsetsListener(homePanelsLayout);
g5 g5Var = getBinding().e;
m.checkNotNullExpressionValue(g5Var, "binding.panelLeft");
ViewCompat.setOnApplyWindowInsetsListener(g5Var.a, new WidgetHome$setPanelWindowInsetsListeners$1(this));
d5 d5Var = getBinding().d;
m.checkNotNullExpressionValue(d5Var, "binding.panelCenter");
ViewCompat.setOnApplyWindowInsetsListener(d5Var.a, new WidgetHome$setPanelWindowInsetsListeners$2(this));
i5 i5Var = getBinding().f;
m.checkNotNullExpressionValue(i5Var, "binding.panelRight");
ViewCompat.setOnApplyWindowInsetsListener(i5Var.a, new WidgetHome$setPanelWindowInsetsListeners$3(this));
}
private final void setupSmoothKeyboardReaction() {
d5 d5Var = getBinding().d;
m.checkNotNullExpressionValue(d5Var, "binding.panelCenter");
RoundedRelativeLayout roundedRelativeLayout = d5Var.a;
m.checkNotNullExpressionValue(roundedRelativeLayout, "binding.panelCenter.root");
Iterator<View> it = ViewGroupKt.iterator(roundedRelativeLayout);
while (it.hasNext()) {
View next = it.next();
if (!(next instanceof AppBarLayout) && !this.fixedPositionViewIds.contains(Integer.valueOf(next.getId()))) {
SmoothKeyboardReactionHelper.INSTANCE.install(next);
}
}
}
private final void showChannelOnboardingSheet() {
WidgetChannelOnboarding.Companion companion = WidgetChannelOnboarding.Companion;
FragmentManager parentFragmentManager = getParentFragmentManager();
m.checkNotNullExpressionValue(parentFragmentManager, "parentFragmentManager");
companion.show(parentFragmentManager);
}
private final void showGuildEventUpsell(long j) {
WidgetGuildScheduledEventUpsellBottomSheet.Companion companion = WidgetGuildScheduledEventUpsellBottomSheet.Companion;
FragmentManager parentFragmentManager = getParentFragmentManager();
m.checkNotNullExpressionValue(parentFragmentManager, "parentFragmentManager");
companion.launch(parentFragmentManager, j);
}
private final void showSurvey(SurveyUtils.Survey survey) {
StoreStream.Companion.getNotices().requestToShow(new StoreNotices.Notice(survey.getNoticeKey(), null, 0, 5, true, null, 0, false, 0, new WidgetHome$showSurvey$1(survey), 486, null));
}
private final void showUrgentMessageDialog() {
StoreStream.Companion.getNotices().requestToShow(new StoreNotices.Notice("URGENT_MESSAGE_DIALOG", null, 0, 0, false, null, 0, false, 0, WidgetHome$showUrgentMessageDialog$1.INSTANCE, 166, null));
}
private final void showWelcomeSheet(long j, Long l) {
if (!StoreStream.Companion.getGuildWelcomeScreens().hasWelcomeScreenBeenSeen(j)) {
WidgetGuildWelcomeSheet.Companion companion = WidgetGuildWelcomeSheet.Companion;
FragmentManager parentFragmentManager = getParentFragmentManager();
m.checkNotNullExpressionValue(parentFragmentManager, "parentFragmentManager");
companion.show(parentFragmentManager, j, l);
}
}
public static /* synthetic */ void showWelcomeSheet$default(WidgetHome widgetHome, long j, Long l, int i, Object obj) {
if ((i & 2) != 0) {
l = null;
}
widgetHome.showWelcomeSheet(j, l);
}
private final void unroundPanelCorners() {
setPanelCorners(0.0f);
}
public final PanelLayout getPanelLayout() {
HomePanelsLayout homePanelsLayout = getBinding().c;
m.checkNotNullExpressionValue(homePanelsLayout, "binding.overlappingPanels");
return homePanelsLayout;
}
public final Toolbar getToolbar() {
AppActivity appActivity = getAppActivity();
if (appActivity != null) {
return appActivity.u;
}
return null;
}
public final TextView getUnreadCountView() {
f5 f5Var = getBinding().d.f99b.c;
m.checkNotNullExpressionValue(f5Var, "binding.panelCenter.widg…omePanelCenterChat.unread");
TextView textView = f5Var.a;
m.checkNotNullExpressionValue(textView, "binding.panelCenter.widg…nelCenterChat.unread.root");
return textView;
}
public final void handleCenterPanelBack$app_productionCanaryRelease() {
WidgetHomeModel widgetHomeModel$app_productionCanaryRelease = getViewModel().getWidgetHomeModel$app_productionCanaryRelease();
Channel channel = null;
StoreChannelsSelected.ResolvedSelectedChannel selectedChannel = widgetHomeModel$app_productionCanaryRelease != null ? widgetHomeModel$app_productionCanaryRelease.getSelectedChannel() : null;
WidgetHomeModel widgetHomeModel$app_productionCanaryRelease2 = getViewModel().getWidgetHomeModel$app_productionCanaryRelease();
if (widgetHomeModel$app_productionCanaryRelease2 != null) {
channel = widgetHomeModel$app_productionCanaryRelease2.getSelectedVoiceChannel();
}
if (selectedChannel instanceof StoreChannelsSelected.ResolvedSelectedChannel.ThreadDraft) {
ChannelSelector.Companion.getInstance().dismissCreateThread();
return;
}
boolean z2 = selectedChannel instanceof StoreChannelsSelected.ResolvedSelectedChannel.Channel;
if (z2) {
StoreChannelsSelected.ResolvedSelectedChannel.Channel channel2 = (StoreChannelsSelected.ResolvedSelectedChannel.Channel) selectedChannel;
if (channel2.getPeekParent() != null) {
ChannelSelector.selectChannel$default(ChannelSelector.Companion.getInstance(), channel2.getChannel().f(), channel2.getPeekParent().longValue(), null, null, 12, null);
return;
}
}
if (z2) {
StoreChannelsSelected.ResolvedSelectedChannel.Channel channel3 = (StoreChannelsSelected.ResolvedSelectedChannel.Channel) selectedChannel;
if (ChannelUtils.E(channel3.getChannel())) {
if (channel == null || channel.h() == 0 || ChannelUtils.x(channel)) {
WidgetCallPreviewFullscreen.Companion.launch$default(WidgetCallPreviewFullscreen.Companion, requireContext(), channel3.getChannel().h(), null, 4, null);
requireAppActivity().overridePendingTransition(R.anim.activity_slide_horizontal_close_in, R.anim.activity_slide_horizontal_close_out);
return;
}
WidgetCallFullscreen.Companion.launch$default(WidgetCallFullscreen.Companion, requireContext(), channel3.getChannel().h(), false, null, null, 28, null);
requireAppActivity().overridePendingTransition(R.anim.activity_slide_horizontal_close_in, R.anim.activity_slide_horizontal_close_out);
return;
}
}
getBinding().c.openStartPanel();
}
public final void lockCloseRightPanel(boolean z2) {
getBinding().c.setEndPanelLockState(z2 ? OverlappingPanelsLayout.LockState.CLOSE : OverlappingPanelsLayout.LockState.UNLOCKED);
}
@Override // androidx.fragment.app.Fragment
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
b.a.o.a aVar = b.a.o.a.f246b;
WidgetHome$onCreate$1 widgetHome$onCreate$1 = new WidgetHome$onCreate$1(this);
m.checkParameterIsNotNull(widgetHome$onCreate$1, "provider");
b.a.o.a.a = widgetHome$onCreate$1;
}
@Override // b.a.o.b.a
public void onGestureRegionsUpdate(List<Rect> list) {
m.checkNotNullParameter(list, "gestureRegions");
getBinding().c.setChildGestureRegions(list);
}
@Override // com.discord.app.AppFragment, androidx.fragment.app.Fragment
public void onPause() {
super.onPause();
b a = b.C0031b.a();
m.checkParameterIsNotNull(this, "gestureRegionsListener");
a.l.remove(this);
}
@Override // com.discord.app.AppFragment, androidx.fragment.app.Fragment
public void onResume() {
super.onResume();
b a = b.C0031b.a();
m.checkParameterIsNotNull(this, "gestureRegionsListener");
onGestureRegionsUpdate(u.toList(a.j.values()));
a.l.add(this);
}
@Override // com.discord.widgets.tabs.OnTabSelectedListener
public void onTabSelected() {
WidgetHomeModel widgetHomeModel$app_productionCanaryRelease = getViewModel().getWidgetHomeModel$app_productionCanaryRelease();
if (widgetHomeModel$app_productionCanaryRelease != null) {
WidgetHomeHeaderManager widgetHomeHeaderManager = WidgetHomeHeaderManager.INSTANCE;
WidgetHomeBinding binding = getBinding();
m.checkNotNullExpressionValue(binding, "binding");
widgetHomeHeaderManager.configure(this, widgetHomeModel$app_productionCanaryRelease, binding);
}
if (getBinding().c.getSelectedPanel() == OverlappingPanelsLayout.Panel.CENTER) {
setActionBarTitleAccessibilityViewFocused();
}
}
@Override // com.discord.app.AppFragment
public void onViewBound(View view) {
m.checkNotNullParameter(view, "view");
super.onViewBound(view);
boolean z2 = TextUtils.getLayoutDirectionFromLocale(new LocaleManager().getPrimaryLocale(requireContext())) == 0;
RoundedRelativeLayout roundedRelativeLayout = getBinding().f.f131b;
m.checkNotNullExpressionValue(roundedRelativeLayout, "binding.panelRight.mainPanelRightRoundedContainer");
ViewGroup.LayoutParams layoutParams = roundedRelativeLayout.getLayoutParams();
Objects.requireNonNull(layoutParams, "null cannot be cast to non-null type android.view.ViewGroup.MarginLayoutParams");
ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) layoutParams;
int dpToPixels = DimenUtils.dpToPixels(8);
int i = z2 ? marginLayoutParams.leftMargin : dpToPixels;
if (!z2) {
dpToPixels = marginLayoutParams.rightMargin;
}
marginLayoutParams.setMargins(i, marginLayoutParams.topMargin, dpToPixels, marginLayoutParams.bottomMargin);
RoundedRelativeLayout roundedRelativeLayout2 = getBinding().f.f131b;
m.checkNotNullExpressionValue(roundedRelativeLayout2, "binding.panelRight.mainPanelRightRoundedContainer");
roundedRelativeLayout2.setLayoutParams(marginLayoutParams);
Fragment parentFragment = getParentFragment();
if (!(parentFragment instanceof WidgetTabsHost)) {
parentFragment = null;
}
WidgetTabsHost widgetTabsHost = (WidgetTabsHost) parentFragment;
if (widgetTabsHost != null) {
widgetTabsHost.registerTabSelectionListener(NavigationTab.HOME, this);
}
this.panelNsfw = new WidgetHomePanelNsfw(this);
WidgetHomeBinding binding = getBinding();
m.checkNotNullExpressionValue(binding, "binding");
this.panelLoading = new WidgetHomePanelLoading(binding);
Function1<? super View, Unit> function1 = this.onGuildListAddHintCreate;
TextView textView = getBinding().e.f117b;
m.checkNotNullExpressionValue(textView, "binding.panelLeft.guildListAddHint");
function1.invoke(textView);
AppFragment.setOnBackPressed$default(this, new WidgetHome$onViewBound$1(this), 0, 2, null);
WidgetNoticeNuxSamsungLink.Companion.enqueue(requireContext(), ClockFactory.get());
setPanelWindowInsetsListeners();
setupSmoothKeyboardReaction();
Observable<StoreNux.NuxState> y2 = StoreStream.Companion.getNux().getNuxState().x(new WidgetHome$onViewBound$2(this)).y();
m.checkNotNullExpressionValue(y2, "StoreStream\n .get… }\n .first()");
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(ObservableExtensionsKt.takeSingleUntilTimeout$default(y2, 0, false, 1, null), this, null, 2, null), WidgetHome.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetHome$onViewBound$3(this), 62, (Object) null);
}
@Override // com.discord.app.AppFragment
public void onViewBoundOrOnResume() {
super.onViewBoundOrOnResume();
Serializable serializableExtra = getMostRecentIntent().getSerializableExtra("com.discord.intent.extra.EXTRA_HOME_CONFIG");
if (!(serializableExtra instanceof HomeConfig)) {
serializableExtra = null;
}
handleHomeConfig((HomeConfig) serializableExtra);
WidgetHomePanelLoading widgetHomePanelLoading = this.panelLoading;
if (widgetHomePanelLoading != null) {
widgetHomePanelLoading.configure(this);
}
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.bindToComponentLifecycle$default(getViewModel().observeViewState(), this, null, 2, null), WidgetHome.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetHome$onViewBoundOrOnResume$1(this), 62, (Object) null);
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.bindToComponentLifecycle$default(getViewModel().observeEvents(), this, null, 2, null), WidgetHome.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetHome$onViewBoundOrOnResume$2(this), 62, (Object) null);
WidgetHomeModel.Companion companion = WidgetHomeModel.Companion;
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(companion.get(), this, null, 2, null), WidgetHome.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetHome$onViewBoundOrOnResume$3(this), 62, (Object) null);
Observable r = ObservableExtensionsKt.ui$default(companion.get(), this, null, 2, null).r(WidgetHome$onViewBoundOrOnResume$4.INSTANCE);
m.checkNotNullExpressionValue(r, "WidgetHomeModel\n …lId == model2.channelId }");
ObservableExtensionsKt.appSubscribe$default(r, WidgetHome.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetHome$onViewBoundOrOnResume$5(this), 62, (Object) null);
AccessibilityDetectionNavigator.INSTANCE.enqueueNoticeWhenEnabled(this);
StoreStream.Companion companion2 = StoreStream.Companion;
configureNavigationDrawerAction(companion2.getNavigation());
configureOverlappingPanels();
Observable F = ObservableExtensionsKt.ui$default(ObservableExtensionsKt.takeSingleUntilTimeout$default(SurveyUtils.INSTANCE.getSurveyToShow(), 0, false, 3, null), this, null, 2, null).x(ObservableExtensionsKt$filterNull$1.INSTANCE).F(ObservableExtensionsKt$filterNull$2.INSTANCE);
m.checkNotNullExpressionValue(F, "filter { it != null }.map { it!! }");
Observable x2 = F.x(WidgetHome$onViewBoundOrOnResume$6.INSTANCE);
m.checkNotNullExpressionValue(x2, "SurveyUtils\n .get…SurveyUtils.Survey.None }");
ObservableExtensionsKt.appSubscribe$default(x2, WidgetHome.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetHome$onViewBoundOrOnResume$7(this), 62, (Object) null);
Observable<StoreNux.NuxState> x3 = companion2.getNux().getNuxState().x(WidgetHome$onViewBoundOrOnResume$8.INSTANCE);
m.checkNotNullExpressionValue(x3, "StoreStream\n .get… .filter { it.firstOpen }");
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(ObservableExtensionsKt.takeSingleUntilTimeout$default(x3, 0, false, 1, null), this, null, 2, null), WidgetHome.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetHome$onViewBoundOrOnResume$9(this), 62, (Object) null);
Observable x4 = StoreUser.observeMe$default(companion2.getUsers(), false, 1, null).x(WidgetHome$onViewBoundOrOnResume$10.INSTANCE);
m.checkNotNullExpressionValue(x4, "StoreStream\n .get…hasUnreadUrgentMessages }");
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(x4, this, null, 2, null), WidgetHome.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetHome$onViewBoundOrOnResume$11(this), 62, (Object) null);
configureLeftPanel();
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.bindToComponentLifecycle$default(this.globalStatusIndicatorStateObserver.observeState(), this, null, 2, null), WidgetHome.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetHome$onViewBoundOrOnResume$12(this), 62, (Object) null);
}
public final void setOnGuildListAddHintCreate(Function1<? super View, Unit> function1) {
m.checkNotNullParameter(function1, "onGuildListAddHintCreate");
this.onGuildListAddHintCreate = function1;
}
}