forked from Juby210/discord-jadx
322 lines
16 KiB
Java
322 lines
16 KiB
Java
package com.discord.widgets.guilds.invite;
|
|
|
|
import android.content.Context;
|
|
import android.content.res.TypedArray;
|
|
import android.util.AttributeSet;
|
|
import android.view.LayoutInflater;
|
|
import android.widget.LinearLayout;
|
|
import android.widget.TextView;
|
|
import androidx.constraintlayout.widget.ConstraintLayout;
|
|
import c.a.k.b;
|
|
import c.d.b.a.a;
|
|
import com.discord.R;
|
|
import com.discord.api.channel.Channel;
|
|
import com.discord.api.channel.ChannelUtils;
|
|
import com.discord.api.guild.Guild;
|
|
import com.discord.api.guild.GuildFeature;
|
|
import com.discord.api.user.User;
|
|
import com.discord.databinding.WidgetGuildInviteInfoViewBinding;
|
|
import com.discord.models.domain.ModelInvite;
|
|
import com.discord.models.user.CoreUser;
|
|
import com.discord.models.user.MeUser;
|
|
import com.discord.stores.StoreStream;
|
|
import com.discord.utilities.dimen.DimenUtils;
|
|
import com.discord.utilities.drawable.DrawableCompat;
|
|
import com.discord.utilities.error.Error;
|
|
import com.discord.utilities.guilds.GuildUtilsKt;
|
|
import com.discord.utilities.icon.IconUtils;
|
|
import com.discord.utilities.images.MGImages;
|
|
import com.discord.utilities.view.extensions.ViewExtensions;
|
|
import com.discord.views.GuildView;
|
|
import com.discord.views.guilds.ServerMemberCount;
|
|
import com.facebook.drawee.view.SimpleDraweeView;
|
|
import d0.z.d.m;
|
|
import java.util.List;
|
|
import java.util.Objects;
|
|
import kotlin.jvm.functions.Function1;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
/* compiled from: WidgetInviteInfo.kt */
|
|
public final class WidgetInviteInfo extends ConstraintLayout {
|
|
private final WidgetGuildInviteInfoViewBinding binding;
|
|
|
|
public WidgetInviteInfo(Context context) {
|
|
this(context, null, 0, 6, null);
|
|
}
|
|
|
|
public WidgetInviteInfo(Context context, AttributeSet attributeSet) {
|
|
this(context, attributeSet, 0, 4, null);
|
|
}
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public WidgetInviteInfo(Context context, AttributeSet attributeSet, int i) {
|
|
super(context, attributeSet, i);
|
|
m.checkNotNullParameter(context, "ctx");
|
|
LayoutInflater.from(getContext()).inflate(R.layout.widget_guild_invite_info_view, this);
|
|
int i2 = R.id.invite_avatar;
|
|
GuildView guildView = (GuildView) findViewById(R.id.invite_avatar);
|
|
if (guildView != null) {
|
|
i2 = R.id.invite_avatar_small;
|
|
SimpleDraweeView simpleDraweeView = (SimpleDraweeView) findViewById(R.id.invite_avatar_small);
|
|
if (simpleDraweeView != null) {
|
|
i2 = R.id.invite_member_container_layout;
|
|
ServerMemberCount serverMemberCount = (ServerMemberCount) findViewById(R.id.invite_member_container_layout);
|
|
if (serverMemberCount != null) {
|
|
i2 = R.id.invite_message;
|
|
TextView textView = (TextView) findViewById(R.id.invite_message);
|
|
if (textView != null) {
|
|
i2 = R.id.invite_title;
|
|
TextView textView2 = (TextView) findViewById(R.id.invite_title);
|
|
if (textView2 != null) {
|
|
i2 = R.id.title_layout;
|
|
LinearLayout linearLayout = (LinearLayout) findViewById(R.id.title_layout);
|
|
if (linearLayout != null) {
|
|
WidgetGuildInviteInfoViewBinding widgetGuildInviteInfoViewBinding = new WidgetGuildInviteInfoViewBinding(this, guildView, simpleDraweeView, serverMemberCount, textView, textView2, linearLayout);
|
|
m.checkNotNullExpressionValue(widgetGuildInviteInfoViewBinding, "WidgetGuildInviteInfoVie…ater.from(context), this)");
|
|
this.binding = widgetGuildInviteInfoViewBinding;
|
|
Context context2 = getContext();
|
|
m.checkNotNullExpressionValue(context2, "context");
|
|
parseAttributeSet(context2, attributeSet, i);
|
|
setBackgroundResource(R.drawable.bg_guild_scheduled_event_list_item_primary);
|
|
int dpToPixels = DimenUtils.dpToPixels(24);
|
|
setPadding(dpToPixels, dpToPixels, dpToPixels, dpToPixels);
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
throw new NullPointerException("Missing required view with ID: ".concat(getResources().getResourceName(i2)));
|
|
}
|
|
|
|
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
|
|
public /* synthetic */ WidgetInviteInfo(Context context, AttributeSet attributeSet, int i, int i2, DefaultConstructorMarker defaultConstructorMarker) {
|
|
this(context, (i2 & 2) != 0 ? null : attributeSet, (i2 & 4) != 0 ? 0 : i);
|
|
}
|
|
|
|
public static final /* synthetic */ WidgetGuildInviteInfoViewBinding access$getBinding$p(WidgetInviteInfo widgetInviteInfo) {
|
|
return widgetInviteInfo.binding;
|
|
}
|
|
|
|
private final void configureForDirectFriend(ModelInvite modelInvite) {
|
|
GuildView guildView = this.binding.b;
|
|
User inviter = modelInvite.getInviter();
|
|
String str = null;
|
|
String forUser$default = IconUtils.getForUser$default(inviter != null ? new CoreUser(inviter) : null, true, null, 4, null);
|
|
int i = GuildView.i;
|
|
guildView.a(forUser$default, null);
|
|
User inviter2 = modelInvite.getInviter();
|
|
String r = inviter2 != null ? inviter2.r() : null;
|
|
String str2 = "";
|
|
if (r == null) {
|
|
r = str2;
|
|
}
|
|
StringBuilder sb = new StringBuilder();
|
|
User inviter3 = modelInvite.getInviter();
|
|
String r2 = inviter3 != null ? inviter3.r() : null;
|
|
if (r2 == null) {
|
|
r2 = str2;
|
|
}
|
|
sb.append(r2);
|
|
sb.append("#");
|
|
User inviter4 = modelInvite.getInviter();
|
|
if (inviter4 != null) {
|
|
str = inviter4.f();
|
|
}
|
|
if (str != null) {
|
|
str2 = str;
|
|
}
|
|
sb.append(str2);
|
|
String sb2 = sb.toString();
|
|
SimpleDraweeView simpleDraweeView = this.binding.f1850c;
|
|
m.checkNotNullExpressionValue(simpleDraweeView, "binding.inviteAvatarSmall");
|
|
simpleDraweeView.setVisibility(8);
|
|
ServerMemberCount serverMemberCount = this.binding.d;
|
|
m.checkNotNullExpressionValue(serverMemberCount, "binding.inviteMemberContainerLayout");
|
|
serverMemberCount.setVisibility(8);
|
|
TextView textView = this.binding.f;
|
|
m.checkNotNullExpressionValue(textView, "binding.inviteTitle");
|
|
textView.setText(getInviteTitleForDirectFriend(r));
|
|
this.binding.f.setTextSize(2, 26.0f);
|
|
TextView textView2 = this.binding.e;
|
|
m.checkNotNullExpressionValue(textView2, "binding.inviteMessage");
|
|
textView2.setText(getInviteSubtitleForDirectFriend(sb2));
|
|
this.binding.e.setTextSize(2, 18.0f);
|
|
}
|
|
|
|
/* JADX WARNING: Code restructure failed: missing block: B:27:0x006c, code lost:
|
|
if ((r6.length() > 0) == true) goto L_0x0070;
|
|
*/
|
|
private final void configureForGDM(ModelInvite modelInvite) {
|
|
Channel channel = modelInvite.getChannel();
|
|
if (channel != null) {
|
|
m.checkNotNullExpressionValue(channel, "model.channel ?: return");
|
|
SimpleDraweeView simpleDraweeView = this.binding.f1850c;
|
|
m.checkNotNullExpressionValue(simpleDraweeView, "binding.inviteAvatarSmall");
|
|
User inviter = modelInvite.getInviter();
|
|
IconUtils.setIcon$default(simpleDraweeView, inviter != null ? new CoreUser(inviter) : null, R.dimen.avatar_size_hero, null, null, null, 56, null);
|
|
User inviter2 = modelInvite.getInviter();
|
|
String r = inviter2 != null ? inviter2.r() : null;
|
|
if (r == null) {
|
|
r = "";
|
|
}
|
|
boolean z2 = true;
|
|
int i = 0;
|
|
String c2 = ChannelUtils.c(channel).length() > 0 ? ChannelUtils.c(channel) : r;
|
|
if (ChannelUtils.v(channel) && (r6 = channel.g()) != null) {
|
|
}
|
|
z2 = false;
|
|
this.binding.b.a(z2 ? IconUtils.getForChannel$default(channel, null, 2, null) : IconUtils.INSTANCE.getDefaultForGroupDM(channel.h()), null);
|
|
SimpleDraweeView simpleDraweeView2 = this.binding.f1850c;
|
|
m.checkNotNullExpressionValue(simpleDraweeView2, "binding.inviteAvatarSmall");
|
|
if (!z2) {
|
|
i = 8;
|
|
}
|
|
simpleDraweeView2.setVisibility(i);
|
|
TextView textView = this.binding.e;
|
|
m.checkNotNullExpressionValue(textView, "binding.inviteMessage");
|
|
textView.setText(getFormattedGuildName(c2));
|
|
TextView textView2 = this.binding.f;
|
|
m.checkNotNullExpressionValue(textView2, "binding.inviteTitle");
|
|
textView2.setText(getIntroTextForGroup(r, ChannelUtils.c(channel)));
|
|
this.binding.d.setOnline(null);
|
|
this.binding.d.setMembers(Integer.valueOf(modelInvite.getApproximateMemberCount()));
|
|
}
|
|
}
|
|
|
|
private final void configureForGuild(ModelInvite modelInvite) {
|
|
List<GuildFeature> l;
|
|
List<GuildFeature> l2;
|
|
int i = 0;
|
|
boolean z2 = modelInvite.getInviter() != null && modelInvite.getApproximateMemberCount() < 200;
|
|
Guild guild = modelInvite.getGuild();
|
|
if (guild != null) {
|
|
GuildView guildView = this.binding.b;
|
|
m.checkNotNullExpressionValue(guild, "it");
|
|
guildView.a(IconUtils.getForGuild$default(new com.discord.models.guild.Guild(guild), null, true, null, 10, null), GuildUtilsKt.computeShortName(guild.v()));
|
|
}
|
|
String str = null;
|
|
if (z2) {
|
|
SimpleDraweeView simpleDraweeView = this.binding.f1850c;
|
|
m.checkNotNullExpressionValue(simpleDraweeView, "binding.inviteAvatarSmall");
|
|
User inviter = modelInvite.getInviter();
|
|
IconUtils.setIcon$default(simpleDraweeView, IconUtils.getForUser$default(inviter != null ? new CoreUser(inviter) : null, true, null, 4, null), (int) R.dimen.avatar_size_medium, (Function1) null, (MGImages.ChangeDetector) null, 24, (Object) null);
|
|
}
|
|
this.binding.d.setMembers(!z2 ? Integer.valueOf(modelInvite.getApproximateMemberCount()) : null);
|
|
this.binding.d.setOnline(!z2 ? Integer.valueOf(modelInvite.getApproximatePresenceCount()) : null);
|
|
SimpleDraweeView simpleDraweeView2 = this.binding.f1850c;
|
|
m.checkNotNullExpressionValue(simpleDraweeView2, "binding.inviteAvatarSmall");
|
|
if (!z2) {
|
|
i = 8;
|
|
}
|
|
simpleDraweeView2.setVisibility(i);
|
|
TextView textView = this.binding.e;
|
|
m.checkNotNullExpressionValue(textView, "binding.inviteMessage");
|
|
Guild guild2 = modelInvite.getGuild();
|
|
String v = guild2 != null ? guild2.v() : null;
|
|
if (v == null) {
|
|
v = "";
|
|
}
|
|
textView.setText(getFormattedGuildName(v));
|
|
Guild guild3 = modelInvite.getGuild();
|
|
if (guild3 == null || (l2 = guild3.l()) == null || !l2.contains(GuildFeature.VERIFIED)) {
|
|
Guild guild4 = modelInvite.getGuild();
|
|
if (!(guild4 == null || (l = guild4.l()) == null || !l.contains(GuildFeature.PARTNERED))) {
|
|
TextView textView2 = this.binding.e;
|
|
m.checkNotNullExpressionValue(textView2, "binding.inviteMessage");
|
|
ViewExtensions.setCompoundDrawableWithIntrinsicBounds$default(textView2, R.drawable.ic_partnered_badge, 0, 0, 0, 14, null);
|
|
}
|
|
} else {
|
|
TextView textView3 = this.binding.e;
|
|
m.checkNotNullExpressionValue(textView3, "binding.inviteMessage");
|
|
ViewExtensions.setCompoundDrawableWithIntrinsicBounds$default(textView3, R.drawable.ic_verified_badge, 0, 0, 0, 14, null);
|
|
}
|
|
TextView textView4 = this.binding.f;
|
|
m.checkNotNullExpressionValue(textView4, "binding.inviteTitle");
|
|
User inviter2 = modelInvite.getInviter();
|
|
if (inviter2 != null) {
|
|
str = inviter2.r();
|
|
}
|
|
textView4.setText(getIntroText(str));
|
|
}
|
|
|
|
private final CharSequence getFormattedGuildName(String str) {
|
|
return b.l(a.v("**", str, "**"), new Object[0], null, 2);
|
|
}
|
|
|
|
private final CharSequence getIntroText(String str) {
|
|
return str == null ? b.j(this, R.string.instant_invite_you_have_been_invited_to_join, new Object[0], null, 4) : b.j(this, R.string.auth_message_invited_by, new Object[]{str}, null, 4);
|
|
}
|
|
|
|
private final CharSequence getIntroTextForGroup(String str, String str2) {
|
|
return str2.length() > 0 ? b.j(this, R.string.auth_message_invited_by, new Object[]{str}, null, 4) : b.j(this, R.string.instant_invite_you_have_been_invited_to_join_group_dm, new Object[0], null, 4);
|
|
}
|
|
|
|
private final CharSequence getInviteSubtitleForDirectFriend(String str) {
|
|
return b.j(this, R.string.instant_invite_direct_friend_description, new Object[]{str}, null, 4);
|
|
}
|
|
|
|
private final CharSequence getInviteTitleForDirectFriend(String str) {
|
|
return b.j(this, R.string.instant_invite_you_have_been_invited_to_chat, new Object[]{str}, null, 4);
|
|
}
|
|
|
|
private final void parseAttributeSet(Context context, AttributeSet attributeSet, int i) {
|
|
if (attributeSet != null) {
|
|
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, R.a.WidgetInviteInfo, i, 0);
|
|
m.checkNotNullExpressionValue(obtainStyledAttributes, "context.obtainStyledAttr…iteInfo, defStyleAttr, 0)");
|
|
obtainStyledAttributes.recycle();
|
|
post(new WidgetInviteInfo$parseAttributeSet$1(this, (int) obtainStyledAttributes.getDimension(0, 0.0f), (int) obtainStyledAttributes.getDimension(1, 0.0f)));
|
|
}
|
|
}
|
|
|
|
public final void configureUI(ModelInvite modelInvite) {
|
|
m.checkNotNullParameter(modelInvite, "model");
|
|
this.binding.b.b();
|
|
if (modelInvite.getGuild() == null && modelInvite.getChannel() == null && modelInvite.getInviter() != null) {
|
|
configureForDirectFriend(modelInvite);
|
|
} else if (modelInvite.getGuild() == null) {
|
|
configureForGDM(modelInvite);
|
|
} else {
|
|
configureForGuild(modelInvite);
|
|
}
|
|
}
|
|
|
|
public final void configureUIFailure(Error error) {
|
|
this.binding.f.setText(R.string.instant_invite_expired);
|
|
this.binding.e.setText(R.string.invite_button_expired);
|
|
if (error != null) {
|
|
Error.Response response = error.getResponse();
|
|
m.checkNotNullExpressionValue(response, "e.response");
|
|
if (response.getCode() == 30001) {
|
|
MeUser me2 = StoreStream.Companion.getUsers().getMe();
|
|
TextView textView = this.binding.f;
|
|
m.checkNotNullExpressionValue(textView, "binding.inviteTitle");
|
|
b.m(textView, R.string.too_many_user_guilds_alert_description, new Object[0], new WidgetInviteInfo$configureUIFailure$1(me2));
|
|
this.binding.e.setText(R.string.too_many_user_guilds_description);
|
|
this.binding.e.setTextSize(0, getResources().getDimension(R.dimen.uikit_textsize_medium));
|
|
}
|
|
}
|
|
TextView textView2 = this.binding.e;
|
|
m.checkNotNullExpressionValue(textView2, "binding.inviteMessage");
|
|
ViewExtensions.setCompoundDrawableWithIntrinsicBounds$default(textView2, 0, 0, 0, 0, 15, null);
|
|
ServerMemberCount serverMemberCount = this.binding.d;
|
|
m.checkNotNullExpressionValue(serverMemberCount, "binding.inviteMemberContainerLayout");
|
|
serverMemberCount.setVisibility(8);
|
|
GuildView guildView = this.binding.b;
|
|
Context context = getContext();
|
|
m.checkNotNullExpressionValue(context, "context");
|
|
int themedDrawableRes = DrawableCompat.getThemedDrawableRes(context, (int) R.attr.img_poop, (int) R.drawable.img_poop_dark);
|
|
Objects.requireNonNull(guildView);
|
|
MGImages mGImages = MGImages.INSTANCE;
|
|
SimpleDraweeView simpleDraweeView = guildView.j.b;
|
|
m.checkNotNullExpressionValue(simpleDraweeView, "binding.guildAvatar");
|
|
MGImages.setImage$default(mGImages, simpleDraweeView, themedDrawableRes, (MGImages.ChangeDetector) null, 4, (Object) null);
|
|
TextView textView3 = guildView.j.f93c;
|
|
m.checkNotNullExpressionValue(textView3, "binding.guildText");
|
|
textView3.setVisibility(8);
|
|
SimpleDraweeView simpleDraweeView2 = this.binding.f1850c;
|
|
m.checkNotNullExpressionValue(simpleDraweeView2, "binding.inviteAvatarSmall");
|
|
simpleDraweeView2.setVisibility(8);
|
|
}
|
|
}
|