2021-08-03 07:33:18 +00:00
|
|
|
package com.discord.widgets.guilds.invite;
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
import android.content.res.Resources;
|
|
|
|
import android.view.View;
|
|
|
|
import android.widget.TextView;
|
|
|
|
import androidx.fragment.app.Fragment;
|
|
|
|
import androidx.fragment.app.FragmentViewModelLazyKt;
|
2021-08-13 06:23:11 +00:00
|
|
|
import c.a.d.f0;
|
2021-08-11 06:37:47 +00:00
|
|
|
import c.a.d.h0;
|
|
|
|
import c.a.k.b;
|
2021-08-03 07:33:18 +00:00
|
|
|
import c.d.b.a.a;
|
2021-08-09 22:51:56 +00:00
|
|
|
import com.discord.BuildConfig;
|
|
|
|
import com.discord.R;
|
2021-08-03 07:33:18 +00:00
|
|
|
import com.discord.app.AppFragment;
|
|
|
|
import com.discord.databinding.WidgetGuildInviteShareEmptySuggestionsBinding;
|
|
|
|
import com.discord.models.domain.ModelInvite;
|
|
|
|
import com.discord.utilities.drawable.DrawableCompat;
|
|
|
|
import com.discord.utilities.resources.StringResourceUtilsKt;
|
|
|
|
import com.discord.utilities.rx.ObservableExtensionsKt;
|
|
|
|
import com.discord.utilities.viewbinding.FragmentViewBindingDelegate;
|
|
|
|
import com.discord.utilities.viewbinding.FragmentViewBindingDelegateKt;
|
|
|
|
import com.discord.widgets.guilds.invite.WidgetGuildInviteShareViewModel;
|
|
|
|
import com.google.android.material.bottomsheet.BottomSheetBehavior;
|
|
|
|
import d0.g;
|
|
|
|
import d0.z.d.a0;
|
|
|
|
import d0.z.d.m;
|
|
|
|
import kotlin.Lazy;
|
|
|
|
import kotlin.jvm.functions.Function0;
|
|
|
|
import kotlin.jvm.functions.Function1;
|
|
|
|
import kotlin.reflect.KProperty;
|
|
|
|
import rx.Observable;
|
|
|
|
/* compiled from: WidgetGuildInviteShareEmptySuggestions.kt */
|
|
|
|
public final class WidgetGuildInviteShareEmptySuggestions extends AppFragment {
|
2021-08-25 07:02:36 +00:00
|
|
|
public static final /* synthetic */ KProperty[] $$delegatedProperties = {a.Y(WidgetGuildInviteShareEmptySuggestions.class, "binding", "getBinding()Lcom/discord/databinding/WidgetGuildInviteShareEmptySuggestionsBinding;", 0)};
|
2021-08-03 07:33:18 +00:00
|
|
|
private final FragmentViewBindingDelegate binding$delegate = FragmentViewBindingDelegateKt.viewBinding$default(this, WidgetGuildInviteShareEmptySuggestions$binding$2.INSTANCE, null, 2, null);
|
|
|
|
private BottomSheetBehavior<ViewInviteSettingsSheet> bottomSheetBehavior;
|
|
|
|
private final Lazy guildId$delegate;
|
|
|
|
private final Lazy viewModel$delegate;
|
|
|
|
|
|
|
|
public WidgetGuildInviteShareEmptySuggestions() {
|
2021-08-09 22:51:56 +00:00
|
|
|
super(R.layout.widget_guild_invite_share_empty_suggestions);
|
2021-08-03 07:33:18 +00:00
|
|
|
WidgetGuildInviteShareEmptySuggestions$viewModel$2 widgetGuildInviteShareEmptySuggestions$viewModel$2 = new WidgetGuildInviteShareEmptySuggestions$viewModel$2(this);
|
2021-08-13 06:23:11 +00:00
|
|
|
f0 f0Var = new f0(this);
|
|
|
|
this.viewModel$delegate = FragmentViewModelLazyKt.createViewModelLazy(this, a0.getOrCreateKotlinClass(WidgetGuildInviteShareViewModel.class), new WidgetGuildInviteShareEmptySuggestions$appViewModels$$inlined$viewModels$1(f0Var), new h0(widgetGuildInviteShareEmptySuggestions$viewModel$2));
|
2021-08-03 07:33:18 +00:00
|
|
|
this.guildId$delegate = g.lazy(new WidgetGuildInviteShareEmptySuggestions$guildId$2(this));
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final /* synthetic */ WidgetGuildInviteShareEmptySuggestionsBinding access$getBinding$p(WidgetGuildInviteShareEmptySuggestions widgetGuildInviteShareEmptySuggestions) {
|
|
|
|
return widgetGuildInviteShareEmptySuggestions.getBinding();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final /* synthetic */ BottomSheetBehavior access$getBottomSheetBehavior$p(WidgetGuildInviteShareEmptySuggestions widgetGuildInviteShareEmptySuggestions) {
|
|
|
|
BottomSheetBehavior<ViewInviteSettingsSheet> bottomSheetBehavior = widgetGuildInviteShareEmptySuggestions.bottomSheetBehavior;
|
|
|
|
if (bottomSheetBehavior == null) {
|
|
|
|
m.throwUninitializedPropertyAccessException("bottomSheetBehavior");
|
|
|
|
}
|
|
|
|
return bottomSheetBehavior;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final /* synthetic */ WidgetGuildInviteShareViewModel access$getViewModel$p(WidgetGuildInviteShareEmptySuggestions widgetGuildInviteShareEmptySuggestions) {
|
|
|
|
return widgetGuildInviteShareEmptySuggestions.getViewModel();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final /* synthetic */ void access$setBottomSheetBehavior$p(WidgetGuildInviteShareEmptySuggestions widgetGuildInviteShareEmptySuggestions, BottomSheetBehavior bottomSheetBehavior) {
|
|
|
|
widgetGuildInviteShareEmptySuggestions.bottomSheetBehavior = bottomSheetBehavior;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final /* synthetic */ void access$updateUi(WidgetGuildInviteShareEmptySuggestions widgetGuildInviteShareEmptySuggestions, WidgetGuildInviteShareViewModel.ViewState.Loaded loaded) {
|
|
|
|
widgetGuildInviteShareEmptySuggestions.updateUi(loaded);
|
|
|
|
}
|
|
|
|
|
|
|
|
private final WidgetGuildInviteShareEmptySuggestionsBinding getBinding() {
|
|
|
|
return (WidgetGuildInviteShareEmptySuggestionsBinding) this.binding$delegate.getValue((Fragment) this, $$delegatedProperties[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
private final CharSequence getHoursExpirationString(int i, CharSequence charSequence) {
|
|
|
|
Resources resources = getResources();
|
|
|
|
m.checkNotNullExpressionValue(resources, "resources");
|
2021-08-09 22:51:56 +00:00
|
|
|
CharSequence quantityString = StringResourceUtilsKt.getQuantityString(resources, requireContext(), (int) R.plurals.duration_hours_hours, i, Integer.valueOf(i));
|
2021-08-03 07:33:18 +00:00
|
|
|
Resources resources2 = getResources();
|
|
|
|
m.checkNotNullExpressionValue(resources2, "resources");
|
2021-08-09 22:51:56 +00:00
|
|
|
return b.i(resources2, R.string.invite_settings_expired_description, new Object[]{quantityString, charSequence}, null, 4);
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private final String getInviteLink(ModelInvite modelInvite) {
|
2021-08-09 22:51:56 +00:00
|
|
|
return modelInvite == null ? BuildConfig.HOST_INVITE : modelInvite.toLink(getResources(), BuildConfig.HOST_INVITE);
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private final WidgetGuildInviteShareViewModel getViewModel() {
|
|
|
|
return (WidgetGuildInviteShareViewModel) this.viewModel$delegate.getValue();
|
|
|
|
}
|
|
|
|
|
|
|
|
private final void initBottomSheet() {
|
|
|
|
getBinding().g.setOnGenerateLinkListener(new WidgetGuildInviteShareEmptySuggestions$initBottomSheet$1(this));
|
|
|
|
getBinding().g.setViewModel(getViewModel());
|
|
|
|
}
|
|
|
|
|
|
|
|
private final void initBottomSheetBehavior(BottomSheetBehavior<ViewInviteSettingsSheet> bottomSheetBehavior) {
|
|
|
|
bottomSheetBehavior.setState(5);
|
|
|
|
bottomSheetBehavior.addBottomSheetCallback(new WidgetGuildInviteShareEmptySuggestions$initBottomSheetBehavior$1(this));
|
|
|
|
}
|
|
|
|
|
|
|
|
private final void updateUi(WidgetGuildInviteShareViewModel.ViewState.Loaded loaded) {
|
|
|
|
CharSequence charSequence;
|
|
|
|
WidgetInviteModel widgetInviteModel = loaded.getWidgetInviteModel();
|
|
|
|
getBinding().g.configureUi(widgetInviteModel);
|
|
|
|
ModelInvite invite = widgetInviteModel.getInvite();
|
2021-08-25 07:02:36 +00:00
|
|
|
TextView textView = getBinding().f1838c;
|
2021-08-03 07:33:18 +00:00
|
|
|
m.checkNotNullExpressionValue(textView, "binding.guildInviteEmptySuggestionsInviteLink");
|
|
|
|
textView.setText(getInviteLink(invite));
|
2021-08-25 07:02:36 +00:00
|
|
|
getBinding().f1838c.setOnClickListener(new WidgetGuildInviteShareEmptySuggestions$updateUi$1(this, invite));
|
2021-08-03 07:33:18 +00:00
|
|
|
getBinding().d.setOnClickListener(new WidgetGuildInviteShareEmptySuggestions$updateUi$2(this, invite));
|
|
|
|
getBinding().e.setOnClickListener(new WidgetGuildInviteShareEmptySuggestions$updateUi$3(this));
|
|
|
|
ModelInvite.Settings settings = widgetInviteModel.getSettings();
|
|
|
|
if (settings != null) {
|
|
|
|
if (settings.getMaxUses() == 0) {
|
2021-08-09 22:51:56 +00:00
|
|
|
charSequence = getResources().getString(R.string.max_uses_description_unlimited_uses);
|
2021-08-03 07:33:18 +00:00
|
|
|
m.checkNotNullExpressionValue(charSequence, "resources.getString(R.st…scription_unlimited_uses)");
|
|
|
|
} else {
|
|
|
|
Resources resources = getResources();
|
|
|
|
m.checkNotNullExpressionValue(resources, "resources");
|
2021-08-09 22:51:56 +00:00
|
|
|
charSequence = StringResourceUtilsKt.getQuantityString(resources, requireContext(), (int) R.plurals.max_uses_description_mobile_maxUses, settings.getMaxUses(), Integer.valueOf(settings.getMaxUses()));
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
|
|
|
int maxAge = widgetInviteModel.getSettings().getMaxAge();
|
|
|
|
if (maxAge == 0) {
|
2021-08-09 22:51:56 +00:00
|
|
|
String str = getResources().getString(R.string.max_age_never_description_mobile) + ", " + charSequence;
|
2021-08-03 07:33:18 +00:00
|
|
|
m.checkNotNullExpressionValue(str, "StringBuilder()\n … .toString()");
|
|
|
|
TextView textView2 = getBinding().f;
|
|
|
|
m.checkNotNullExpressionValue(textView2, "binding.guildInviteEmpty…SettingsInviteLinkSubtext");
|
|
|
|
textView2.setText(str);
|
|
|
|
} else if (maxAge == 1800) {
|
|
|
|
Resources resources2 = getResources();
|
|
|
|
m.checkNotNullExpressionValue(resources2, "resources");
|
2021-08-09 22:51:56 +00:00
|
|
|
CharSequence quantityString = StringResourceUtilsKt.getQuantityString(resources2, requireContext(), (int) R.plurals.duration_minutes_minutes, 30, 30);
|
2021-08-03 07:33:18 +00:00
|
|
|
TextView textView3 = getBinding().f;
|
|
|
|
m.checkNotNullExpressionValue(textView3, "binding.guildInviteEmpty…SettingsInviteLinkSubtext");
|
|
|
|
Resources resources3 = getResources();
|
|
|
|
m.checkNotNullExpressionValue(resources3, "resources");
|
2021-08-09 22:51:56 +00:00
|
|
|
textView3.setText(b.i(resources3, R.string.invite_settings_expired_description, new Object[]{quantityString, charSequence}, null, 4));
|
2021-08-03 07:33:18 +00:00
|
|
|
} else if (maxAge == 3600) {
|
|
|
|
TextView textView4 = getBinding().f;
|
|
|
|
m.checkNotNullExpressionValue(textView4, "binding.guildInviteEmpty…SettingsInviteLinkSubtext");
|
|
|
|
textView4.setText(getHoursExpirationString(1, charSequence));
|
|
|
|
} else if (maxAge == 21600) {
|
|
|
|
TextView textView5 = getBinding().f;
|
|
|
|
m.checkNotNullExpressionValue(textView5, "binding.guildInviteEmpty…SettingsInviteLinkSubtext");
|
|
|
|
textView5.setText(getHoursExpirationString(6, charSequence));
|
|
|
|
} else if (maxAge == 43200) {
|
|
|
|
TextView textView6 = getBinding().f;
|
|
|
|
m.checkNotNullExpressionValue(textView6, "binding.guildInviteEmpty…SettingsInviteLinkSubtext");
|
|
|
|
textView6.setText(getHoursExpirationString(12, charSequence));
|
|
|
|
} else if (maxAge == 86400) {
|
|
|
|
Resources resources4 = getResources();
|
|
|
|
m.checkNotNullExpressionValue(resources4, "resources");
|
2021-08-09 22:51:56 +00:00
|
|
|
CharSequence quantityString2 = StringResourceUtilsKt.getQuantityString(resources4, requireContext(), (int) R.plurals.duration_days_days, 1, 1);
|
2021-08-03 07:33:18 +00:00
|
|
|
TextView textView7 = getBinding().f;
|
|
|
|
m.checkNotNullExpressionValue(textView7, "binding.guildInviteEmpty…SettingsInviteLinkSubtext");
|
|
|
|
Resources resources5 = getResources();
|
|
|
|
m.checkNotNullExpressionValue(resources5, "resources");
|
2021-08-09 22:51:56 +00:00
|
|
|
textView7.setText(b.i(resources5, R.string.invite_settings_expired_description, new Object[]{quantityString2, charSequence}, null, 4));
|
2021-08-03 07:33:18 +00:00
|
|
|
} else if (maxAge == 604800) {
|
|
|
|
Resources resources6 = getResources();
|
|
|
|
m.checkNotNullExpressionValue(resources6, "resources");
|
2021-08-09 22:51:56 +00:00
|
|
|
CharSequence quantityString3 = StringResourceUtilsKt.getQuantityString(resources6, requireContext(), (int) R.plurals.duration_days_days, 7, 7);
|
2021-08-03 07:33:18 +00:00
|
|
|
TextView textView8 = getBinding().f;
|
|
|
|
m.checkNotNullExpressionValue(textView8, "binding.guildInviteEmpty…SettingsInviteLinkSubtext");
|
|
|
|
Resources resources7 = getResources();
|
|
|
|
m.checkNotNullExpressionValue(resources7, "resources");
|
2021-08-09 22:51:56 +00:00
|
|
|
textView8.setText(b.i(resources7, R.string.invite_settings_expired_description, new Object[]{quantityString3, charSequence}, null, 4));
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public final long getGuildId() {
|
|
|
|
return ((Number) this.guildId$delegate.getValue()).longValue();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // com.discord.app.AppFragment
|
|
|
|
public void onViewBound(View view) {
|
|
|
|
m.checkNotNullParameter(view, "view");
|
|
|
|
super.onViewBound(view);
|
|
|
|
if (getMostRecentIntent().getLongExtra("com.discord.intent.extra.EXTRA_GUILD_ID", 0) <= 0) {
|
|
|
|
requireActivity().finish();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
long longExtra = getMostRecentIntent().getLongExtra("com.discord.intent.extra.EXTRA_CHANNEL_ID", 0);
|
|
|
|
if (longExtra != 0) {
|
|
|
|
getViewModel().selectChannel(longExtra);
|
|
|
|
}
|
2021-08-09 22:51:56 +00:00
|
|
|
boolean booleanExtra = getMostRecentIntent().getBooleanExtra(WidgetGuildInviteShare.INTENT_IS_NUX_FLOW, false);
|
|
|
|
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);
|
2021-08-03 07:33:18 +00:00
|
|
|
AppFragment.setOnBackPressed$default(this, new WidgetGuildInviteShareEmptySuggestions$onViewBound$1(this, booleanExtra), 0, 2, null);
|
|
|
|
BottomSheetBehavior<ViewInviteSettingsSheet> from = BottomSheetBehavior.from(getBinding().g);
|
|
|
|
m.checkNotNullExpressionValue(from, "BottomSheetBehavior.from…nviteSettingsBottomSheet)");
|
|
|
|
this.bottomSheetBehavior = from;
|
|
|
|
if (from == null) {
|
|
|
|
m.throwUninitializedPropertyAccessException("bottomSheetBehavior");
|
|
|
|
}
|
|
|
|
initBottomSheetBehavior(from);
|
|
|
|
initBottomSheet();
|
|
|
|
getBinding().b.setOnClickListener(new WidgetGuildInviteShareEmptySuggestions$onViewBound$2(this));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // com.discord.app.AppFragment
|
|
|
|
public void onViewBoundOrOnResume() {
|
|
|
|
super.onViewBoundOrOnResume();
|
|
|
|
Observable F = ObservableExtensionsKt.computationBuffered(getViewModel().observeViewState()).x(WidgetGuildInviteShareEmptySuggestions$onViewBoundOrOnResume$$inlined$filterIs$1.INSTANCE).F(WidgetGuildInviteShareEmptySuggestions$onViewBoundOrOnResume$$inlined$filterIs$2.INSTANCE);
|
|
|
|
m.checkNotNullExpressionValue(F, "filter { it is T }.map { it as T }");
|
|
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(F, this, null, 2, null), WidgetGuildInviteShareEmptySuggestions.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetGuildInviteShareEmptySuggestions$onViewBoundOrOnResume$1(this), 62, (Object) null);
|
|
|
|
}
|
|
|
|
}
|