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;
|
2021-08-13 06:23:11 +00:00
|
|
|
import c.a.d.m;
|
2021-08-11 06:37:47 +00:00
|
|
|
import c.a.k.b;
|
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.api.channel.Channel;
|
|
|
|
import com.discord.models.domain.ModelInvite;
|
|
|
|
import com.discord.models.experiments.domain.Experiment;
|
|
|
|
import com.discord.utilities.analytics.AnalyticsTracker;
|
|
|
|
import com.discord.utilities.duration.DurationUtilsKt;
|
|
|
|
import com.discord.utilities.intent.IntentUtils;
|
|
|
|
import com.discord.utilities.resources.StringResourceUtilsKt;
|
|
|
|
/* compiled from: GuildInviteUiHelper.kt */
|
|
|
|
public final class GuildInviteUiHelperKt {
|
|
|
|
private static final void copyLink(Context context, String str) {
|
2021-08-13 06:23:11 +00:00
|
|
|
m.a(context, str, R.string.invite_link_copied);
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static final void copyLinkClick(Context context, ModelInvite modelInvite, Intent intent) {
|
2021-08-13 06:23:11 +00:00
|
|
|
d0.z.d.m.checkNotNullParameter(context, "context");
|
|
|
|
d0.z.d.m.checkNotNullParameter(intent, "mostRecentIntent");
|
2021-08-03 07:33:18 +00:00
|
|
|
String stringExtra = intent.getStringExtra("com.discord.intent.ORIGIN_SOURCE");
|
|
|
|
if (stringExtra == null) {
|
|
|
|
stringExtra = "";
|
|
|
|
}
|
|
|
|
copyLinkClick(context, modelInvite, stringExtra);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final void copyLinkClick(Context context, ModelInvite modelInvite, String str) {
|
2021-08-13 06:23:11 +00:00
|
|
|
d0.z.d.m.checkNotNullParameter(context, "context");
|
|
|
|
d0.z.d.m.checkNotNullParameter(str, "analyticsSource");
|
2021-08-03 07:33:18 +00:00
|
|
|
AnalyticsTracker.inviteCopied(modelInvite, str);
|
|
|
|
Resources resources = context.getResources();
|
2021-08-13 06:23:11 +00:00
|
|
|
d0.z.d.m.checkNotNullExpressionValue(resources, "context.resources");
|
2021-08-03 07:33:18 +00:00
|
|
|
copyLink(context, getInviteLink(modelInvite, resources));
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final void copyLinkClick(Context context, GuildInvite guildInvite, Channel channel, String str) {
|
2021-08-13 06:23:11 +00:00
|
|
|
d0.z.d.m.checkNotNullParameter(context, "context");
|
|
|
|
d0.z.d.m.checkNotNullParameter(guildInvite, "guildInvite");
|
|
|
|
d0.z.d.m.checkNotNullParameter(str, "analyticsSource");
|
2021-08-03 07:33:18 +00:00
|
|
|
AnalyticsTracker.INSTANCE.inviteCopied(guildInvite, channel, str);
|
|
|
|
copyLink(context, guildInvite.toLink());
|
|
|
|
}
|
|
|
|
|
|
|
|
private static final String getInviteLink(ModelInvite modelInvite, Resources resources) {
|
|
|
|
if (modelInvite == null) {
|
2021-08-09 22:51:56 +00:00
|
|
|
return BuildConfig.HOST_INVITE;
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
2021-08-09 22:51:56 +00:00
|
|
|
String link = modelInvite.toLink(resources, BuildConfig.HOST_INVITE);
|
2021-08-13 06:23:11 +00:00
|
|
|
d0.z.d.m.checkNotNullExpressionValue(link, "inviteModel.toLink(resou… BuildConfig.HOST_INVITE)");
|
2021-08-03 07:33:18 +00:00
|
|
|
return link;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final CharSequence getInviteLinkText(Context context, Experiment experiment) {
|
2021-08-13 06:23:11 +00:00
|
|
|
d0.z.d.m.checkNotNullParameter(context, "context");
|
2021-08-09 22:51:56 +00:00
|
|
|
return b.h(context, R.string.invite_links_expire_after_default, new Object[]{(experiment == null || experiment.getBucket() != 1) ? StringResourceUtilsKt.getI18nPluralString(context, R.plurals.duration_days_days, 1, 1) : StringResourceUtilsKt.getI18nPluralString(context, R.plurals.duration_days_days, 7, 7)}, null, 4);
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static final CharSequence getInviteSettingsText(Context context, long j) {
|
2021-08-13 06:23:11 +00:00
|
|
|
d0.z.d.m.checkNotNullParameter(context, "context");
|
2021-08-09 22:51:56 +00:00
|
|
|
return j <= 0 ? b.h(context, R.string.max_age_never_description_mobile, new Object[0], null, 4) : b.h(context, R.string.invite_expired_subtext_mobile, new Object[]{DurationUtilsKt.humanizeDurationRounded(context, j)}, null, 4);
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static final CharSequence getInviteSettingsText(Context context, long j, int i) {
|
|
|
|
Object obj;
|
2021-08-13 06:23:11 +00:00
|
|
|
d0.z.d.m.checkNotNullParameter(context, "context");
|
2021-08-03 07:33:18 +00:00
|
|
|
if (i == 0) {
|
2021-08-09 22:51:56 +00:00
|
|
|
obj = context.getString(R.string.max_uses_description_unlimited_uses);
|
2021-08-13 06:23:11 +00:00
|
|
|
d0.z.d.m.checkNotNullExpressionValue(obj, "context.getString(R.stri…scription_unlimited_uses)");
|
2021-08-03 07:33:18 +00:00
|
|
|
} else {
|
|
|
|
Resources resources = context.getResources();
|
2021-08-13 06:23:11 +00:00
|
|
|
d0.z.d.m.checkNotNullExpressionValue(resources, "context.resources");
|
2021-08-09 22:51:56 +00:00
|
|
|
obj = StringResourceUtilsKt.getQuantityString(resources, context, (int) R.plurals.max_uses_description_mobile_maxUses, i, Integer.valueOf(i));
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
2021-08-09 22:51:56 +00:00
|
|
|
return j <= 0 ? b.h(context, R.string.invite_settings_description_no_expiration, new Object[]{context.getString(R.string.max_age_never_description_mobile), obj}, null, 4) : b.h(context, R.string.invite_settings_expired_description, new Object[]{DurationUtilsKt.humanizeDurationRounded(context, j), obj}, null, 4);
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private static final void shareLink(Context context, String str) {
|
2021-08-09 22:51:56 +00:00
|
|
|
String string = context.getResources().getString(R.string.tip_instant_invite_title3);
|
2021-08-13 06:23:11 +00:00
|
|
|
d0.z.d.m.checkNotNullExpressionValue(string, "context.resources.getStr…ip_instant_invite_title3)");
|
2021-08-03 07:33:18 +00:00
|
|
|
IntentUtils.performChooserSendIntent(context, str, string);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final void shareLinkClick(Context context, ModelInvite modelInvite) {
|
2021-08-13 06:23:11 +00:00
|
|
|
d0.z.d.m.checkNotNullParameter(modelInvite, "invite");
|
2021-08-03 07:33:18 +00:00
|
|
|
AnalyticsTracker.inviteShareClicked(modelInvite);
|
|
|
|
if (context != null) {
|
|
|
|
Resources resources = context.getResources();
|
2021-08-13 06:23:11 +00:00
|
|
|
d0.z.d.m.checkNotNullExpressionValue(resources, "context.resources");
|
2021-08-03 07:33:18 +00:00
|
|
|
shareLink(context, getInviteLink(modelInvite, resources));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final void shareLinkClick(Context context, GuildInvite guildInvite, Channel channel) {
|
2021-08-13 06:23:11 +00:00
|
|
|
d0.z.d.m.checkNotNullParameter(guildInvite, "guildInvite");
|
2021-08-03 07:33:18 +00:00
|
|
|
AnalyticsTracker.INSTANCE.inviteShareClicked(guildInvite, channel);
|
|
|
|
if (context != null) {
|
|
|
|
shareLink(context, guildInvite.toLink());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|