forked from Juby210/discord-jadx
319 lines
18 KiB
Java
319 lines
18 KiB
Java
package com.discord.widgets.guilds.invite;
|
|
|
|
import android.content.Context;
|
|
import android.content.Intent;
|
|
import android.view.View;
|
|
import android.view.Window;
|
|
import android.widget.ImageView;
|
|
import android.widget.TextView;
|
|
import androidx.fragment.app.Fragment;
|
|
import androidx.fragment.app.FragmentManager;
|
|
import androidx.fragment.app.FragmentViewModelLazyKt;
|
|
import androidx.recyclerview.widget.RecyclerView;
|
|
import c.a.d.f0;
|
|
import c.a.d.h0;
|
|
import c.d.b.a.a;
|
|
import com.discord.BuildConfig;
|
|
import com.discord.R;
|
|
import com.discord.api.guild.Guild;
|
|
import com.discord.app.AppActivity;
|
|
import com.discord.app.AppFragment;
|
|
import com.discord.app.AppViewFlipper;
|
|
import com.discord.app.LoggingConfig;
|
|
import com.discord.databinding.WidgetGuildInviteShareBinding;
|
|
import com.discord.models.domain.ModelInvite;
|
|
import com.discord.models.experiments.domain.Experiment;
|
|
import com.discord.stores.StoreStream;
|
|
import com.discord.utilities.analytics.AnalyticsTracker;
|
|
import com.discord.utilities.drawable.DrawableCompat;
|
|
import com.discord.utilities.mg_recycler.MGRecyclerAdapter;
|
|
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.views.CheckedSetting;
|
|
import com.discord.widgets.guilds.invite.InviteSuggestionItem;
|
|
import com.discord.widgets.guilds.invite.WidgetGuildInviteShareViewModel;
|
|
import com.google.android.material.bottomsheet.BottomSheetBehavior;
|
|
import com.google.android.material.textfield.TextInputLayout;
|
|
import d0.t.n;
|
|
import d0.t.o;
|
|
import d0.t.u;
|
|
import d0.z.d.a0;
|
|
import d0.z.d.m;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import kotlin.Lazy;
|
|
import kotlin.jvm.functions.Function0;
|
|
import kotlin.jvm.functions.Function1;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
import kotlin.reflect.KProperty;
|
|
import rx.Observable;
|
|
/* compiled from: WidgetGuildInviteShare.kt */
|
|
public final class WidgetGuildInviteShare extends AppFragment {
|
|
public static final /* synthetic */ KProperty[] $$delegatedProperties = {a.W(WidgetGuildInviteShare.class, "binding", "getBinding()Lcom/discord/databinding/WidgetGuildInviteShareBinding;", 0)};
|
|
public static final Companion Companion = new Companion(null);
|
|
public static final String INTENT_IS_NUX_FLOW = "INTENT_IS_NUX_FLOW";
|
|
private PrivateChannelAdapter adapter;
|
|
private final FragmentViewBindingDelegate binding$delegate = FragmentViewBindingDelegateKt.viewBinding$default(this, WidgetGuildInviteShare$binding$2.INSTANCE, null, 2, null);
|
|
private BottomSheetBehavior<ViewInviteSettingsSheet> bottomSheetBehavior;
|
|
private boolean hasTrackedSuggestionsViewed;
|
|
private final LoggingConfig loggingConfig;
|
|
private final Lazy viewModel$delegate;
|
|
|
|
/* compiled from: WidgetGuildInviteShare.kt */
|
|
public static final class Companion {
|
|
private Companion() {
|
|
}
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
|
|
public static /* synthetic */ void launch$default(Companion companion, Context context, FragmentManager fragmentManager, long j, Long l, boolean z2, Long l2, String str, int i, Object obj) {
|
|
companion.launch(context, fragmentManager, j, (i & 8) != 0 ? null : l, (i & 16) != 0 ? false : z2, (i & 32) != 0 ? null : l2, str);
|
|
}
|
|
|
|
public final void launch(Context context, FragmentManager fragmentManager, long j, Long l, boolean z2, Long l2, String str) {
|
|
m.checkNotNullParameter(context, "context");
|
|
m.checkNotNullParameter(fragmentManager, "fragmentManager");
|
|
m.checkNotNullParameter(str, "source");
|
|
if (GuildInviteShareSheetFeatureFlag.Companion.getINSTANCE().isEnabled()) {
|
|
WidgetGuildInviteShareSheet.Companion.show(fragmentManager, l, j, str);
|
|
return;
|
|
}
|
|
Intent intent = new Intent();
|
|
intent.putExtra(WidgetGuildInviteShare.INTENT_IS_NUX_FLOW, z2);
|
|
intent.putExtra("com.discord.intent.extra.EXTRA_GUILD_ID", j);
|
|
intent.putExtra("com.discord.intent.extra.EXTRA_CHANNEL_ID", l != null ? l.longValue() : 0);
|
|
intent.putExtra("com.discord.intent.ORIGIN_SOURCE", str);
|
|
intent.putExtra("com.discord.intent.extra.EXTRA_GUILD_SCHEDULED_EVENT_ID", l2);
|
|
Observable j2 = Observable.j(StoreStream.Companion.getExperiments().observeUserExperiment("2020-01_mobile_invite_suggestion_compact", true), new InviteSuggestionsManager(null, null, null, null, null, 31, null).observeInviteSuggestions(), WidgetGuildInviteShare$Companion$launch$1.INSTANCE);
|
|
m.checkNotNullExpressionValue(j2, "Observable.combineLatest…-> exp to inviteService }");
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.takeSingleUntilTimeout(ObservableExtensionsKt.computationLatest(j2), 50, false), WidgetGuildInviteShare.class, (Context) null, (Function1) null, new WidgetGuildInviteShare$Companion$launch$2(str, context, intent), (Function0) null, (Function0) null, new WidgetGuildInviteShare$Companion$launch$3(str, context, intent), 54, (Object) null);
|
|
}
|
|
}
|
|
|
|
public WidgetGuildInviteShare() {
|
|
super(R.layout.widget_guild_invite_share);
|
|
WidgetGuildInviteShare$viewModel$2 widgetGuildInviteShare$viewModel$2 = new WidgetGuildInviteShare$viewModel$2(this);
|
|
f0 f0Var = new f0(this);
|
|
this.viewModel$delegate = FragmentViewModelLazyKt.createViewModelLazy(this, a0.getOrCreateKotlinClass(WidgetGuildInviteShareViewModel.class), new WidgetGuildInviteShare$appViewModels$$inlined$viewModels$1(f0Var), new h0(widgetGuildInviteShare$viewModel$2));
|
|
this.loggingConfig = new LoggingConfig(false, null, WidgetGuildInviteShare$loggingConfig$1.INSTANCE, 3);
|
|
}
|
|
|
|
public static final /* synthetic */ void access$configureUI(WidgetGuildInviteShare widgetGuildInviteShare, WidgetGuildInviteShareViewModel.ViewState.Loaded loaded) {
|
|
widgetGuildInviteShare.configureUI(loaded);
|
|
}
|
|
|
|
public static final /* synthetic */ PrivateChannelAdapter access$getAdapter$p(WidgetGuildInviteShare widgetGuildInviteShare) {
|
|
PrivateChannelAdapter privateChannelAdapter = widgetGuildInviteShare.adapter;
|
|
if (privateChannelAdapter == null) {
|
|
m.throwUninitializedPropertyAccessException("adapter");
|
|
}
|
|
return privateChannelAdapter;
|
|
}
|
|
|
|
public static final /* synthetic */ WidgetGuildInviteShareBinding access$getBinding$p(WidgetGuildInviteShare widgetGuildInviteShare) {
|
|
return widgetGuildInviteShare.getBinding();
|
|
}
|
|
|
|
public static final /* synthetic */ BottomSheetBehavior access$getBottomSheetBehavior$p(WidgetGuildInviteShare widgetGuildInviteShare) {
|
|
BottomSheetBehavior<ViewInviteSettingsSheet> bottomSheetBehavior = widgetGuildInviteShare.bottomSheetBehavior;
|
|
if (bottomSheetBehavior == null) {
|
|
m.throwUninitializedPropertyAccessException("bottomSheetBehavior");
|
|
}
|
|
return bottomSheetBehavior;
|
|
}
|
|
|
|
public static final /* synthetic */ WidgetGuildInviteShareViewModel access$getViewModel$p(WidgetGuildInviteShare widgetGuildInviteShare) {
|
|
return widgetGuildInviteShare.getViewModel();
|
|
}
|
|
|
|
public static final /* synthetic */ void access$sendInvite(WidgetGuildInviteShare widgetGuildInviteShare, InviteSuggestionItem inviteSuggestionItem, WidgetGuildInviteShareViewModel.ViewState.Loaded loaded, ModelInvite modelInvite) {
|
|
widgetGuildInviteShare.sendInvite(inviteSuggestionItem, loaded, modelInvite);
|
|
}
|
|
|
|
public static final /* synthetic */ void access$setAdapter$p(WidgetGuildInviteShare widgetGuildInviteShare, PrivateChannelAdapter privateChannelAdapter) {
|
|
widgetGuildInviteShare.adapter = privateChannelAdapter;
|
|
}
|
|
|
|
public static final /* synthetic */ void access$setBottomSheetBehavior$p(WidgetGuildInviteShare widgetGuildInviteShare, BottomSheetBehavior bottomSheetBehavior) {
|
|
widgetGuildInviteShare.bottomSheetBehavior = bottomSheetBehavior;
|
|
}
|
|
|
|
private final void configureUI(WidgetGuildInviteShareViewModel.ViewState.Loaded loaded) {
|
|
Guild guild;
|
|
WidgetInviteModel widgetInviteModel = loaded.getWidgetInviteModel();
|
|
List<InviteSuggestionItem> inviteSuggestionItems = loaded.getInviteSuggestionItems();
|
|
ModelInvite invite = widgetInviteModel.getInvite();
|
|
AppViewFlipper appViewFlipper = getBinding().j;
|
|
m.checkNotNullExpressionValue(appViewFlipper, "binding.guildInviteSuggestionsFlipper");
|
|
boolean z2 = true;
|
|
appViewFlipper.setDisplayedChild(!inviteSuggestionItems.isEmpty() ? 1 : 0);
|
|
int i = 0;
|
|
if (inviteSuggestionItems.size() == 1 && (u.firstOrNull(inviteSuggestionItems) instanceof InviteSuggestionItem.SearchNoResultsItem)) {
|
|
inviteSuggestionItems = null;
|
|
}
|
|
if (inviteSuggestionItems == null) {
|
|
inviteSuggestionItems = n.emptyList();
|
|
}
|
|
if ((!inviteSuggestionItems.isEmpty()) && !this.hasTrackedSuggestionsViewed) {
|
|
ModelInvite invite2 = widgetInviteModel.getInvite();
|
|
long p = (invite2 == null || (guild = invite2.getGuild()) == null) ? 0 : guild.p();
|
|
AnalyticsTracker analyticsTracker = AnalyticsTracker.INSTANCE;
|
|
ArrayList<InviteSuggestionItem.ChannelItem> arrayList = new ArrayList();
|
|
for (Object obj : inviteSuggestionItems) {
|
|
if (obj instanceof InviteSuggestionItem.ChannelItem) {
|
|
arrayList.add(obj);
|
|
}
|
|
}
|
|
ArrayList arrayList2 = new ArrayList(o.collectionSizeOrDefault(arrayList, 10));
|
|
for (InviteSuggestionItem.ChannelItem channelItem : arrayList) {
|
|
arrayList2.add(channelItem.getChannel());
|
|
}
|
|
ArrayList<InviteSuggestionItem.UserItem> arrayList3 = new ArrayList();
|
|
for (Object obj2 : inviteSuggestionItems) {
|
|
if (obj2 instanceof InviteSuggestionItem.UserItem) {
|
|
arrayList3.add(obj2);
|
|
}
|
|
}
|
|
ArrayList arrayList4 = new ArrayList(o.collectionSizeOrDefault(arrayList3, 10));
|
|
for (InviteSuggestionItem.UserItem userItem : arrayList3) {
|
|
arrayList4.add(userItem.getUser());
|
|
}
|
|
analyticsTracker.inviteSuggestionOpened(p, arrayList2, arrayList4);
|
|
this.hasTrackedSuggestionsViewed = true;
|
|
}
|
|
TextView textView = getBinding().f1824c;
|
|
m.checkNotNullExpressionValue(textView, "binding.guildInviteEmptyResults");
|
|
textView.setVisibility(inviteSuggestionItems.isEmpty() ? 0 : 8);
|
|
RecyclerView recyclerView = getBinding().i;
|
|
m.checkNotNullExpressionValue(recyclerView, "binding.guildInviteSuggestionList");
|
|
recyclerView.setVisibility(inviteSuggestionItems.isEmpty() ^ true ? 0 : 8);
|
|
PrivateChannelAdapter privateChannelAdapter = this.adapter;
|
|
if (privateChannelAdapter == null) {
|
|
m.throwUninitializedPropertyAccessException("adapter");
|
|
}
|
|
privateChannelAdapter.setData(inviteSuggestionItems);
|
|
PrivateChannelAdapter privateChannelAdapter2 = this.adapter;
|
|
if (privateChannelAdapter2 == null) {
|
|
m.throwUninitializedPropertyAccessException("adapter");
|
|
}
|
|
privateChannelAdapter2.setOnClick(new WidgetGuildInviteShare$configureUI$3(this, loaded, invite));
|
|
getBinding().k.configureUi(loaded.getWidgetInviteModel());
|
|
TextView textView2 = getBinding().d;
|
|
m.checkNotNullExpressionValue(textView2, "binding.guildInviteLink");
|
|
textView2.setText(getInviteLink(invite));
|
|
getBinding().d.setOnClickListener(new WidgetGuildInviteShare$configureUI$4(this, invite));
|
|
ModelInvite.Settings settings = widgetInviteModel.getSettings();
|
|
if (settings == null || settings.getMaxAge() != 0) {
|
|
z2 = false;
|
|
}
|
|
CheckedSetting checkedSetting = getBinding().e;
|
|
m.checkNotNullExpressionValue(checkedSetting, "binding.guildInviteNeverExpire");
|
|
checkedSetting.setChecked(z2);
|
|
Experiment defaultInviteExperiment = getViewModel().getDefaultInviteExperiment();
|
|
CheckedSetting.i(getBinding().e, GuildInviteUiHelperKt.getInviteLinkText(requireContext(), defaultInviteExperiment), false, 2);
|
|
getBinding().e.e(new WidgetGuildInviteShare$configureUI$5(this, widgetInviteModel, defaultInviteExperiment));
|
|
getBinding().g.setOnClickListener(new WidgetGuildInviteShare$configureUI$6(this, invite));
|
|
ImageView imageView = getBinding().f;
|
|
m.checkNotNullExpressionValue(imageView, "binding.guildInviteSettingsEdit");
|
|
imageView.setVisibility(loaded.getShowInviteSettings() ? 0 : 8);
|
|
CheckedSetting checkedSetting2 = getBinding().e;
|
|
m.checkNotNullExpressionValue(checkedSetting2, "binding.guildInviteNeverExpire");
|
|
if (!loaded.getShowInviteSettings()) {
|
|
i = 8;
|
|
}
|
|
checkedSetting2.setVisibility(i);
|
|
}
|
|
|
|
private final WidgetGuildInviteShareBinding getBinding() {
|
|
return (WidgetGuildInviteShareBinding) this.binding$delegate.getValue((Fragment) this, $$delegatedProperties[0]);
|
|
}
|
|
|
|
private final String getInviteLink(ModelInvite modelInvite) {
|
|
return modelInvite == null ? BuildConfig.HOST_INVITE : modelInvite.toLink(getResources(), BuildConfig.HOST_INVITE);
|
|
}
|
|
|
|
private final WidgetGuildInviteShareViewModel getViewModel() {
|
|
return (WidgetGuildInviteShareViewModel) this.viewModel$delegate.getValue();
|
|
}
|
|
|
|
private final void initBottomSheet() {
|
|
getBinding().k.setOnGenerateLinkListener(new WidgetGuildInviteShare$initBottomSheet$1(this));
|
|
getBinding().k.setViewModel(getViewModel());
|
|
}
|
|
|
|
private final void initBottomSheetBehavior(BottomSheetBehavior<ViewInviteSettingsSheet> bottomSheetBehavior) {
|
|
bottomSheetBehavior.setState(5);
|
|
bottomSheetBehavior.addBottomSheetCallback(new WidgetGuildInviteShare$initBottomSheetBehavior$1(this));
|
|
bottomSheetBehavior.setUpdateImportantForAccessibilityOnSiblings(true);
|
|
}
|
|
|
|
public static final void launch(Context context, FragmentManager fragmentManager, long j, Long l, boolean z2, Long l2, String str) {
|
|
Companion.launch(context, fragmentManager, j, l, z2, l2, str);
|
|
}
|
|
|
|
private final void sendInvite(InviteSuggestionItem inviteSuggestionItem, WidgetGuildInviteShareViewModel.ViewState.Loaded loaded, ModelInvite modelInvite) {
|
|
if (inviteSuggestionItem instanceof InviteSuggestionItem.ChannelItem) {
|
|
getViewModel().sendInviteToChannel(((InviteSuggestionItem.ChannelItem) inviteSuggestionItem).getChannel().h(), loaded, modelInvite);
|
|
} else if (inviteSuggestionItem instanceof InviteSuggestionItem.UserItem) {
|
|
getViewModel().sendInviteToUser(((InviteSuggestionItem.UserItem) inviteSuggestionItem).getUser().getId(), loaded, modelInvite);
|
|
}
|
|
}
|
|
|
|
@Override // com.discord.app.AppFragment, com.discord.app.AppLogger.a
|
|
public LoggingConfig getLoggingConfig() {
|
|
return this.loggingConfig;
|
|
}
|
|
|
|
@Override // com.discord.app.AppFragment
|
|
public void onViewBound(View view) {
|
|
Window window;
|
|
m.checkNotNullParameter(view, "view");
|
|
super.onViewBound(view);
|
|
MGRecyclerAdapter.Companion companion = MGRecyclerAdapter.Companion;
|
|
RecyclerView recyclerView = getBinding().i;
|
|
m.checkNotNullExpressionValue(recyclerView, "binding.guildInviteSuggestionList");
|
|
this.adapter = (PrivateChannelAdapter) companion.configure(new PrivateChannelAdapter(recyclerView));
|
|
boolean booleanExtra = getMostRecentIntent().getBooleanExtra(INTENT_IS_NUX_FLOW, false);
|
|
long longExtra = getMostRecentIntent().getLongExtra("com.discord.intent.extra.EXTRA_CHANNEL_ID", 0);
|
|
if (longExtra != 0) {
|
|
getViewModel().selectChannel(longExtra);
|
|
}
|
|
AppFragment.setActionBarDisplayHomeAsUpEnabled$default(this, true, booleanExtra ? Integer.valueOf(DrawableCompat.getThemedDrawableRes$default(requireContext(), (int) R.attr.ic_close_24dp, 0, 2, (Object) null)) : null, booleanExtra ? Integer.valueOf((int) R.string.close) : null, null, 8, null);
|
|
setActionBarTitle(R.string.invite_people);
|
|
AppActivity appActivity = getAppActivity();
|
|
if (!(appActivity == null || (window = appActivity.getWindow()) == null)) {
|
|
window.setSoftInputMode(32);
|
|
}
|
|
AppFragment.setOnBackPressed$default(this, new WidgetGuildInviteShare$onViewBound$1(this, booleanExtra), 0, 2, null);
|
|
TextInputLayout textInputLayout = getBinding().h;
|
|
m.checkNotNullExpressionValue(textInputLayout, "binding.guildInviteShareSearch");
|
|
ViewExtensions.addBindedTextWatcher(textInputLayout, this, new WidgetGuildInviteShare$onViewBound$2(this));
|
|
BottomSheetBehavior<ViewInviteSettingsSheet> from = BottomSheetBehavior.from(getBinding().k);
|
|
m.checkNotNullExpressionValue(from, "BottomSheetBehavior.from…nviteSettingsBottomSheet)");
|
|
this.bottomSheetBehavior = from;
|
|
if (from == null) {
|
|
m.throwUninitializedPropertyAccessException("bottomSheetBehavior");
|
|
}
|
|
initBottomSheetBehavior(from);
|
|
initBottomSheet();
|
|
getBinding().f.setOnClickListener(new WidgetGuildInviteShare$onViewBound$3(this));
|
|
getBinding().b.setOnClickListener(new WidgetGuildInviteShare$onViewBound$4(this));
|
|
}
|
|
|
|
@Override // com.discord.app.AppFragment
|
|
public void onViewBoundOrOnResume() {
|
|
super.onViewBoundOrOnResume();
|
|
Observable F = ObservableExtensionsKt.computationBuffered(getViewModel().observeViewState()).x(WidgetGuildInviteShare$onViewBoundOrOnResume$$inlined$filterIs$1.INSTANCE).F(WidgetGuildInviteShare$onViewBoundOrOnResume$$inlined$filterIs$2.INSTANCE);
|
|
m.checkNotNullExpressionValue(F, "filter { it is T }.map { it as T }");
|
|
PrivateChannelAdapter privateChannelAdapter = this.adapter;
|
|
if (privateChannelAdapter == null) {
|
|
m.throwUninitializedPropertyAccessException("adapter");
|
|
}
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui(F, this, privateChannelAdapter), WidgetGuildInviteShare.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetGuildInviteShare$onViewBoundOrOnResume$1(this), 62, (Object) null);
|
|
}
|
|
}
|