discord-jadx/app/src/main/java/com/discord/widgets/user/Badge.java

233 lines
11 KiB
Java

package com.discord.widgets.user;
import android.content.Context;
import androidx.annotation.DrawableRes;
import androidx.fragment.app.FragmentManager;
import b.a.k.b;
import b.d.b.a.a;
import com.discord.R;
import com.discord.api.user.UserProfile;
import com.discord.models.user.User;
import com.discord.utilities.user.UserProfileUtilsKt;
import com.discord.utilities.user.UserUtils;
import d0.z.d.m;
import java.util.ArrayList;
import java.util.List;
import kotlin.Unit;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.DefaultConstructorMarker;
/* compiled from: Badge.kt */
public final class Badge {
public static final Companion Companion = new Companion(null);
private static final int GUILD_BOOST_LEVEL_1_MONTHS = 1;
private static final int GUILD_BOOST_LEVEL_2_MONTHS = 2;
private static final int GUILD_BOOST_LEVEL_3_MONTHS = 3;
private static final int GUILD_BOOST_LEVEL_4_MONTHS = 6;
private static final int GUILD_BOOST_LEVEL_5_MONTHS = 9;
private static final int GUILD_BOOST_LEVEL_6_MONTHS = 12;
private static final int GUILD_BOOST_LEVEL_7_MONTHS = 15;
private static final int GUILD_BOOST_LEVEL_8_MONTHS = 18;
private static final int GUILD_BOOST_LEVEL_9_MONTHS = 24;
private final int icon;
private final String objectType;
private final boolean showPremiumUpSell;
private final CharSequence text;
private final CharSequence tooltip;
/* compiled from: Badge.kt */
public static final class Companion {
private Companion() {
}
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
public final List<Badge> getBadgesForUser(User user, UserProfile userProfile, boolean z2, boolean z3, Context context) {
m.checkNotNullParameter(user, "user");
m.checkNotNullParameter(userProfile, "profile");
m.checkNotNullParameter(context, "context");
ArrayList arrayList = new ArrayList(8);
UserUtils userUtils = UserUtils.INSTANCE;
if (userUtils.isStaff(user)) {
arrayList.add(new Badge(R.drawable.ic_profile_badge_staff_32dp, context.getString(R.string.staff_badge_tooltip), null, false, null, 28, null));
}
if (userUtils.isPartner(user)) {
arrayList.add(new Badge(R.drawable.ic_profile_badge_partner_32dp, context.getString(R.string.partner_badge_tooltip), null, false, null, 28, null));
}
if (userUtils.isCertifiedModerator(user)) {
arrayList.add(new Badge(R.drawable.ic_profile_badge_certified_moderator_32dp, context.getString(R.string.certified_moderator_badge_tooltip), null, false, null, 28, null));
}
if (userUtils.isHypeSquad(user)) {
arrayList.add(new Badge(R.drawable.ic_profile_badge_hypesquad_32dp, context.getString(R.string.hypesquad_badge_tooltip), null, false, null, 28, null));
}
if (userUtils.isHypesquadHouse1(user)) {
arrayList.add(new Badge(R.drawable.ic_hypesquad_house1_32dp, context.getString(R.string.hypesquad_house_1), b.h(context, R.string.hypesquad_online_badge_tooltip, new Object[]{b.h(context, R.string.hypesquad_house_1, new Object[0], null, 4)}, null, 4), false, null, 24, null));
}
if (userUtils.isHypesquadHouse2(user)) {
arrayList.add(new Badge(R.drawable.ic_hypesquad_house2_32dp, b.h(context, R.string.hypesquad_house_2, new Object[0], null, 4), b.h(context, R.string.hypesquad_online_badge_tooltip, new Object[]{context.getString(R.string.hypesquad_house_2)}, null, 4), false, null, 24, null));
}
if (userUtils.isHypesquadHouse3(user)) {
arrayList.add(new Badge(R.drawable.ic_hypesquad_house3_32dp, context.getString(R.string.hypesquad_house_3), b.h(context, R.string.hypesquad_online_badge_tooltip, new Object[]{b.h(context, R.string.hypesquad_house_3, new Object[0], null, 4)}, null, 4), false, null, 24, null));
}
if (userUtils.isBugHunterLevel1(user)) {
arrayList.add(new Badge(R.drawable.ic_profile_badge_bughunter_level_1_32dp, context.getString(R.string.bug_hunter_badge_tooltip), null, false, null, 28, null));
}
if (userUtils.isBugHunterLevel2(user)) {
arrayList.add(new Badge(R.drawable.ic_profile_badge_bughunter_level_2_32dp, context.getString(R.string.bug_hunter_badge_tooltip), null, false, null, 28, null));
}
if (userUtils.isVerifiedDeveloper(user)) {
arrayList.add(new Badge(R.drawable.ic_profile_badge_verified_developer_32dp, context.getString(R.string.verified_developer_badge_tooltip), null, false, null, 28, null));
}
if (userUtils.isPremiumEarlySupporter(user)) {
arrayList.add(new Badge(R.drawable.ic_profile_badge_premium_early_supporter_32dp, context.getString(R.string.early_supporter_tooltip), null, !z2 && z3, "PREMIUM_EARLY_SUPPORTER", 4, null));
}
if (UserProfileUtilsKt.isPremium(userProfile)) {
arrayList.add(new Badge(R.drawable.ic_profile_badge_nitro_32dp, context.getString(R.string.premium_title), b.h(context, R.string.premium_badge_tooltip, new Object[]{UserProfileUtilsKt.getPremiumSince(userProfile, context)}, null, 4), !z2 && z3, "PREMIUM"));
}
if (UserProfileUtilsKt.isGuildBooster(userProfile)) {
Integer guildBoostMonthsSubscribed = UserProfileUtilsKt.getGuildBoostMonthsSubscribed(userProfile);
int intValue = guildBoostMonthsSubscribed != null ? guildBoostMonthsSubscribed.intValue() : 0;
arrayList.add(new Badge(intValue >= 24 ? R.drawable.ic_profile_badge_premium_guild_subscription_lvl9_32dp : intValue >= 18 ? R.drawable.ic_profile_badge_premium_guild_subscription_lvl8_32dp : intValue >= 15 ? R.drawable.ic_profile_badge_premium_guild_subscription_lvl7_32dp : intValue >= 12 ? R.drawable.ic_profile_badge_premium_guild_subscription_lvl6_32dp : intValue >= 9 ? R.drawable.ic_profile_badge_premium_guild_subscription_lvl5_32dp : intValue >= 6 ? R.drawable.ic_profile_badge_premium_guild_subscription_lvl4_32dp : intValue >= 3 ? R.drawable.ic_profile_badge_premium_guild_subscription_lvl3_32dp : intValue >= 2 ? R.drawable.ic_profile_badge_premium_guild_subscription_lvl2_32dp : R.drawable.ic_profile_badge_premium_guild_subscription_lvl1_32dp, context.getString(R.string.premium_title), b.h(context, R.string.premium_guild_subscription_tooltip, new Object[]{UserProfileUtilsKt.getBoostingSince(userProfile, context)}, null, 4), !z2 && z3, "PREMIUM_GUILD"));
}
return arrayList;
}
public final Function1<Badge, Unit> onBadgeClick(FragmentManager fragmentManager, Context context) {
m.checkNotNullParameter(fragmentManager, "fragmentManager");
m.checkNotNullParameter(context, "context");
return new Badge$Companion$onBadgeClick$1(fragmentManager, context);
}
}
public Badge() {
this(0, null, null, false, null, 31, null);
}
public Badge(@DrawableRes int i, CharSequence charSequence, CharSequence charSequence2, boolean z2, String str) {
this.icon = i;
this.text = charSequence;
this.tooltip = charSequence2;
this.showPremiumUpSell = z2;
this.objectType = str;
}
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
public /* synthetic */ Badge(int i, CharSequence charSequence, CharSequence charSequence2, boolean z2, String str, int i2, DefaultConstructorMarker defaultConstructorMarker) {
this((i2 & 1) != 0 ? 0 : i, (i2 & 2) != 0 ? null : charSequence, (i2 & 4) != 0 ? null : charSequence2, (i2 & 8) == 0 ? z2 : false, (i2 & 16) != 0 ? null : str);
}
public static /* synthetic */ Badge copy$default(Badge badge, int i, CharSequence charSequence, CharSequence charSequence2, boolean z2, String str, int i2, Object obj) {
if ((i2 & 1) != 0) {
i = badge.icon;
}
if ((i2 & 2) != 0) {
charSequence = badge.text;
}
if ((i2 & 4) != 0) {
charSequence2 = badge.tooltip;
}
if ((i2 & 8) != 0) {
z2 = badge.showPremiumUpSell;
}
if ((i2 & 16) != 0) {
str = badge.objectType;
}
return badge.copy(i, charSequence, charSequence2, z2, str);
}
public static final Function1<Badge, Unit> onBadgeClick(FragmentManager fragmentManager, Context context) {
return Companion.onBadgeClick(fragmentManager, context);
}
public final int component1() {
return this.icon;
}
public final CharSequence component2() {
return this.text;
}
public final CharSequence component3() {
return this.tooltip;
}
public final boolean component4() {
return this.showPremiumUpSell;
}
public final String component5() {
return this.objectType;
}
public final Badge copy(@DrawableRes int i, CharSequence charSequence, CharSequence charSequence2, boolean z2, String str) {
return new Badge(i, charSequence, charSequence2, z2, str);
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof Badge)) {
return false;
}
Badge badge = (Badge) obj;
return this.icon == badge.icon && m.areEqual(this.text, badge.text) && m.areEqual(this.tooltip, badge.tooltip) && this.showPremiumUpSell == badge.showPremiumUpSell && m.areEqual(this.objectType, badge.objectType);
}
public final int getIcon() {
return this.icon;
}
public final String getObjectType() {
return this.objectType;
}
public final boolean getShowPremiumUpSell() {
return this.showPremiumUpSell;
}
public final CharSequence getText() {
return this.text;
}
public final CharSequence getTooltip() {
return this.tooltip;
}
public int hashCode() {
int i = this.icon * 31;
CharSequence charSequence = this.text;
int i2 = 0;
int hashCode = (i + (charSequence != null ? charSequence.hashCode() : 0)) * 31;
CharSequence charSequence2 = this.tooltip;
int hashCode2 = (hashCode + (charSequence2 != null ? charSequence2.hashCode() : 0)) * 31;
boolean z2 = this.showPremiumUpSell;
if (z2) {
z2 = true;
}
int i3 = z2 ? 1 : 0;
int i4 = z2 ? 1 : 0;
int i5 = z2 ? 1 : 0;
int i6 = (hashCode2 + i3) * 31;
String str = this.objectType;
if (str != null) {
i2 = str.hashCode();
}
return i6 + i2;
}
public String toString() {
StringBuilder R = a.R("Badge(icon=");
R.append(this.icon);
R.append(", text=");
R.append(this.text);
R.append(", tooltip=");
R.append(this.tooltip);
R.append(", showPremiumUpSell=");
R.append(this.showPremiumUpSell);
R.append(", objectType=");
return a.H(R, this.objectType, ")");
}
}