2021-08-03 07:33:18 +00:00
|
|
|
package com.discord.widgets.guilds.invite;
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
import android.content.Intent;
|
|
|
|
import android.content.res.Resources;
|
|
|
|
import android.util.DisplayMetrics;
|
|
|
|
import android.view.View;
|
|
|
|
import androidx.fragment.app.Fragment;
|
|
|
|
import androidx.fragment.app.FragmentManager;
|
2021-08-13 06:23:11 +00:00
|
|
|
import c.a.d.j;
|
|
|
|
import c.a.d.o;
|
2021-08-03 07:33:18 +00:00
|
|
|
import c.d.b.a.a;
|
|
|
|
import com.airbnb.lottie.parser.AnimatableValueParser;
|
2021-08-09 22:51:56 +00:00
|
|
|
import com.discord.R;
|
2021-08-03 07:33:18 +00:00
|
|
|
import com.discord.api.channel.Channel;
|
|
|
|
import com.discord.api.guild.Guild;
|
|
|
|
import com.discord.api.guild.GuildFeature;
|
|
|
|
import com.discord.app.AppFragment;
|
|
|
|
import com.discord.databinding.WidgetGuildInviteBinding;
|
2021-08-09 22:51:56 +00:00
|
|
|
import com.discord.models.domain.ModelAuditLogEntry;
|
2021-08-03 07:33:18 +00:00
|
|
|
import com.discord.models.domain.ModelInvite;
|
|
|
|
import com.discord.stores.StoreInstantInvites;
|
|
|
|
import com.discord.stores.StoreStream;
|
|
|
|
import com.discord.utilities.analytics.AnalyticsTracker;
|
|
|
|
import com.discord.utilities.channel.ChannelSelector;
|
|
|
|
import com.discord.utilities.error.Error;
|
|
|
|
import com.discord.utilities.guilds.MemberVerificationUtils;
|
|
|
|
import com.discord.utilities.icon.IconUtils;
|
|
|
|
import com.discord.utilities.rx.ObservableExtensionsKt;
|
|
|
|
import com.discord.utilities.viewbinding.FragmentViewBindingDelegate;
|
|
|
|
import com.discord.utilities.viewbinding.FragmentViewBindingDelegateKt;
|
|
|
|
import com.facebook.drawee.view.SimpleDraweeView;
|
|
|
|
import com.google.android.material.button.MaterialButton;
|
|
|
|
import d0.g0.t;
|
|
|
|
import d0.t.n0;
|
|
|
|
import d0.z.d.m;
|
|
|
|
import java.util.Collection;
|
|
|
|
import java.util.List;
|
|
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
|
|
import kotlin.reflect.KProperty;
|
|
|
|
import rx.Observable;
|
|
|
|
/* compiled from: WidgetGuildInvite.kt */
|
|
|
|
public final class WidgetGuildInvite extends AppFragment {
|
2021-08-11 06:37:47 +00:00
|
|
|
public static final /* synthetic */ KProperty[] $$delegatedProperties = {a.W(WidgetGuildInvite.class, "binding", "getBinding()Lcom/discord/databinding/WidgetGuildInviteBinding;", 0)};
|
2021-08-03 07:33:18 +00:00
|
|
|
public static final Companion Companion = new Companion(null);
|
|
|
|
private static final String EXTRA_CODE = "EXTRA_CODE";
|
|
|
|
private static final String EXTRA_LOCATION = "EXTRA_LOCATION";
|
|
|
|
private final FragmentViewBindingDelegate binding$delegate = FragmentViewBindingDelegateKt.viewBinding$default(this, WidgetGuildInvite$binding$2.INSTANCE, null, 2, null);
|
|
|
|
private String inviteCode;
|
|
|
|
private String inviteLocation;
|
|
|
|
private boolean inviteResolved;
|
|
|
|
private StoreInstantInvites.InviteState.Resolved inviteState;
|
|
|
|
|
|
|
|
/* compiled from: WidgetGuildInvite.kt */
|
|
|
|
public static final class Companion {
|
|
|
|
private Companion() {
|
|
|
|
}
|
|
|
|
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
|
|
this();
|
|
|
|
}
|
|
|
|
|
|
|
|
public final void launch(Context context, String str, String str2) {
|
|
|
|
m.checkNotNullParameter(context, "context");
|
2021-08-09 22:51:56 +00:00
|
|
|
m.checkNotNullParameter(str, ModelAuditLogEntry.CHANGE_KEY_CODE);
|
2021-08-03 07:33:18 +00:00
|
|
|
m.checkNotNullParameter(str2, "location");
|
|
|
|
Intent intent = new Intent();
|
2021-08-09 22:51:56 +00:00
|
|
|
intent.putExtra(WidgetGuildInvite.EXTRA_CODE, str);
|
|
|
|
intent.putExtra(WidgetGuildInvite.EXTRA_LOCATION, str2);
|
2021-08-13 06:23:11 +00:00
|
|
|
j.d(context, WidgetGuildInvite.class, intent);
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public WidgetGuildInvite() {
|
2021-08-09 22:51:56 +00:00
|
|
|
super(R.layout.widget_guild_invite);
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static final /* synthetic */ void access$configureUI(WidgetGuildInvite widgetGuildInvite, StoreInstantInvites.InviteState.Resolved resolved) {
|
|
|
|
widgetGuildInvite.configureUI(resolved);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final /* synthetic */ void access$configureUIFailure(WidgetGuildInvite widgetGuildInvite, Error error) {
|
|
|
|
widgetGuildInvite.configureUIFailure(error);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final /* synthetic */ void access$displayInviteTarget(WidgetGuildInvite widgetGuildInvite, ModelInvite modelInvite) {
|
|
|
|
widgetGuildInvite.displayInviteTarget(modelInvite);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final /* synthetic */ String access$getInviteCode$p(WidgetGuildInvite widgetGuildInvite) {
|
|
|
|
return widgetGuildInvite.inviteCode;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final /* synthetic */ String access$getInviteLocation$p(WidgetGuildInvite widgetGuildInvite) {
|
|
|
|
return widgetGuildInvite.inviteLocation;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final /* synthetic */ void access$onAcceptedGuildInvite(WidgetGuildInvite widgetGuildInvite, ModelInvite modelInvite) {
|
|
|
|
widgetGuildInvite.onAcceptedGuildInvite(modelInvite);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final /* synthetic */ void access$setInviteCode$p(WidgetGuildInvite widgetGuildInvite, String str) {
|
|
|
|
widgetGuildInvite.inviteCode = str;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final /* synthetic */ void access$setInviteLocation$p(WidgetGuildInvite widgetGuildInvite, String str) {
|
|
|
|
widgetGuildInvite.inviteLocation = str;
|
|
|
|
}
|
|
|
|
|
|
|
|
private final void configureUI(StoreInstantInvites.InviteState.Resolved resolved) {
|
|
|
|
String str;
|
|
|
|
List<GuildFeature> l;
|
|
|
|
this.inviteState = resolved;
|
|
|
|
ModelInvite invite = resolved.getInvite();
|
|
|
|
Guild guild = resolved.getInvite().getGuild();
|
|
|
|
boolean z2 = (guild == null || (l = guild.l()) == null || !l.contains(GuildFeature.HUB)) ? false : true;
|
|
|
|
Context context = getContext();
|
|
|
|
if (context != null) {
|
|
|
|
m.checkNotNullExpressionValue(context, "context ?: return");
|
|
|
|
trackAndConsumeDynamicLinkCache(invite);
|
|
|
|
getBinding().d.configureUI(invite);
|
2021-08-19 06:48:32 +00:00
|
|
|
MaterialButton materialButton = getBinding().f1821c;
|
2021-08-03 07:33:18 +00:00
|
|
|
m.checkNotNullExpressionValue(materialButton, "binding.guildInviteCancel");
|
|
|
|
materialButton.setVisibility(8);
|
|
|
|
MaterialButton materialButton2 = getBinding().b;
|
|
|
|
m.checkNotNullExpressionValue(materialButton2, "binding.guildInviteAccept");
|
|
|
|
materialButton2.setVisibility(0);
|
|
|
|
getBinding().b.setOnClickListener(new WidgetGuildInvite$configureUI$1(this, z2, context, resolved, invite));
|
|
|
|
SimpleDraweeView simpleDraweeView = getBinding().e;
|
|
|
|
IconUtils iconUtils = IconUtils.INSTANCE;
|
|
|
|
Guild guild2 = resolved.getInvite().getGuild();
|
2021-08-13 06:23:11 +00:00
|
|
|
long p = guild2 != null ? guild2.p() : 0;
|
2021-08-03 07:33:18 +00:00
|
|
|
Guild guild3 = resolved.getInvite().getGuild();
|
2021-08-13 06:23:11 +00:00
|
|
|
if (guild3 == null || (str = guild3.G()) == null) {
|
2021-08-03 07:33:18 +00:00
|
|
|
str = "";
|
|
|
|
}
|
|
|
|
Resources resources = getResources();
|
|
|
|
m.checkNotNullExpressionValue(resources, "resources");
|
|
|
|
DisplayMetrics displayMetrics = resources.getDisplayMetrics();
|
2021-08-13 06:23:11 +00:00
|
|
|
simpleDraweeView.setImageURI(iconUtils.getGuildSplashUrl(p, str, displayMetrics != null ? Integer.valueOf(displayMetrics.widthPixels) : null));
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private final void configureUIFailure(Error error) {
|
2021-08-19 06:48:32 +00:00
|
|
|
MaterialButton materialButton = getBinding().f1821c;
|
2021-08-03 07:33:18 +00:00
|
|
|
m.checkNotNullExpressionValue(materialButton, "binding.guildInviteCancel");
|
|
|
|
materialButton.setVisibility(0);
|
|
|
|
MaterialButton materialButton2 = getBinding().b;
|
|
|
|
m.checkNotNullExpressionValue(materialButton2, "binding.guildInviteAccept");
|
|
|
|
materialButton2.setVisibility(8);
|
|
|
|
getBinding().d.configureUIFailure(error);
|
|
|
|
trackAndConsumeDynamicLinkCache(null);
|
|
|
|
}
|
|
|
|
|
|
|
|
private final void displayInviteTarget(ModelInvite modelInvite) {
|
|
|
|
Collection collection;
|
|
|
|
WidgetGuildInvite$displayInviteTarget$1 widgetGuildInvite$displayInviteTarget$1 = new WidgetGuildInvite$displayInviteTarget$1(this, modelInvite);
|
|
|
|
Guild guild = modelInvite.getGuild();
|
|
|
|
if (guild == null || (collection = guild.l()) == null) {
|
|
|
|
collection = n0.emptySet();
|
|
|
|
}
|
|
|
|
if (collection.contains(GuildFeature.MEMBER_VERIFICATION_GATE_ENABLED) && !collection.contains(GuildFeature.PREVIEW_ENABLED)) {
|
|
|
|
MemberVerificationUtils memberVerificationUtils = MemberVerificationUtils.INSTANCE;
|
|
|
|
Context requireContext = requireContext();
|
|
|
|
Guild guild2 = modelInvite.getGuild();
|
2021-08-13 06:23:11 +00:00
|
|
|
long p = guild2 != null ? guild2.p() : -1;
|
2021-08-03 07:33:18 +00:00
|
|
|
FragmentManager childFragmentManager = getChildFragmentManager();
|
|
|
|
m.checkNotNullExpressionValue(childFragmentManager, "childFragmentManager");
|
2021-08-13 06:23:11 +00:00
|
|
|
memberVerificationUtils.maybeShowVerificationGate(requireContext, childFragmentManager, p, "Accept Invite Page", modelInvite, new WidgetGuildInvite$displayInviteTarget$2(widgetGuildInvite$displayInviteTarget$1));
|
2021-08-03 07:33:18 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
widgetGuildInvite$displayInviteTarget$1.mo1invoke();
|
|
|
|
}
|
|
|
|
|
|
|
|
private final WidgetGuildInviteBinding getBinding() {
|
|
|
|
return (WidgetGuildInviteBinding) this.binding$delegate.getValue((Fragment) this, $$delegatedProperties[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
private final Observable<? extends StoreInstantInvites.InviteState> getResolvedInviteOrDefault(String str) {
|
|
|
|
StoreInstantInvites.InviteState.Resolved resolved = this.inviteState;
|
|
|
|
if (resolved != null) {
|
2021-08-13 06:23:11 +00:00
|
|
|
return new j0.l.e.j(resolved);
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
|
|
|
if (str == null || !(!t.isBlank(str))) {
|
2021-08-13 06:23:11 +00:00
|
|
|
return new j0.l.e.j(null);
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
|
|
|
StoreStream.Companion companion = StoreStream.Companion;
|
2021-08-11 06:37:47 +00:00
|
|
|
StoreInstantInvites.fetchInviteIfNotLoaded$default(companion.getInstantInvites(), str, null, this.inviteLocation, 2, null);
|
2021-08-03 07:33:18 +00:00
|
|
|
return companion.getInstantInvites().observeInvite(str).x(WidgetGuildInvite$getResolvedInviteOrDefault$1.INSTANCE);
|
|
|
|
}
|
|
|
|
|
|
|
|
private final void onAcceptedGuildInvite(ModelInvite modelInvite) {
|
|
|
|
Channel channel = modelInvite.getChannel();
|
|
|
|
m.checkNotNullExpressionValue(channel, "invite.channel");
|
|
|
|
if (AnimatableValueParser.m1(channel)) {
|
|
|
|
requestMicrophone(new WidgetGuildInvite$onAcceptedGuildInvite$1(this, modelInvite), new WidgetGuildInvite$onAcceptedGuildInvite$2(this, modelInvite));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
ChannelSelector.Companion.getInstance().findAndSet(getContext(), modelInvite.getChannel().h());
|
|
|
|
displayInviteTarget(modelInvite);
|
|
|
|
}
|
|
|
|
|
|
|
|
private final void trackAndConsumeDynamicLinkCache(ModelInvite modelInvite) {
|
|
|
|
StoreStream.Companion.getInviteSettings().clearInviteCode();
|
|
|
|
if (!this.inviteResolved) {
|
|
|
|
this.inviteResolved = true;
|
|
|
|
String str = "";
|
|
|
|
if (modelInvite != null) {
|
|
|
|
AnalyticsTracker analyticsTracker = AnalyticsTracker.INSTANCE;
|
|
|
|
String str2 = this.inviteLocation;
|
|
|
|
if (str2 != null) {
|
|
|
|
str = str2;
|
|
|
|
}
|
|
|
|
analyticsTracker.inviteResolved(modelInvite, str);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
String str3 = this.inviteCode;
|
|
|
|
String str4 = str3 != null ? str3 : str;
|
|
|
|
String str5 = this.inviteLocation;
|
|
|
|
AnalyticsTracker.inviteResolveFailed$default(str4, str5 != null ? str5 : str, null, null, 12, null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // com.discord.app.AppFragment
|
|
|
|
public void onViewBound(View view) {
|
|
|
|
m.checkNotNullParameter(view, "view");
|
|
|
|
super.onViewBound(view);
|
|
|
|
setRetainInstance(true);
|
|
|
|
AppFragment.setActionBarDisplayHomeAsUpEnabled$default(this, false, 1, null);
|
2021-08-09 22:51:56 +00:00
|
|
|
String stringExtra = getMostRecentIntent().getStringExtra(EXTRA_CODE);
|
2021-08-03 07:33:18 +00:00
|
|
|
this.inviteCode = stringExtra;
|
|
|
|
AnalyticsTracker.INSTANCE.impressionInviteAccept(stringExtra);
|
2021-08-19 06:48:32 +00:00
|
|
|
getBinding().f1821c.setOnClickListener(new WidgetGuildInvite$onViewBound$1(this));
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override // com.discord.app.AppFragment
|
|
|
|
public void onViewBoundOrOnResume() {
|
|
|
|
super.onViewBoundOrOnResume();
|
2021-08-09 22:51:56 +00:00
|
|
|
this.inviteCode = getMostRecentIntent().getStringExtra(EXTRA_CODE);
|
|
|
|
this.inviteLocation = getMostRecentIntent().getStringExtra(EXTRA_LOCATION);
|
2021-08-03 07:33:18 +00:00
|
|
|
Observable<? extends StoreInstantInvites.InviteState> resolvedInviteOrDefault = getResolvedInviteOrDefault(this.inviteCode);
|
|
|
|
m.checkNotNullExpressionValue(resolvedInviteOrDefault, "getResolvedInviteOrDefault(inviteCode)");
|
2021-08-13 06:23:11 +00:00
|
|
|
ObservableExtensionsKt.ui$default(ObservableExtensionsKt.restSubscribeOn$default(resolvedInviteOrDefault, false, 1, null), this, null, 2, null).k(o.a.g(getContext(), new WidgetGuildInvite$onViewBoundOrOnResume$1(this), new WidgetGuildInvite$onViewBoundOrOnResume$2(this)));
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
|
|
|
}
|