discord-jadx/app/src/main/java/com/discord/utilities/message/MessageUtils.java
Juby210 02b39b5eaf
Enable replacing const values in jadx
Tracking changes should be much easier now.
2021-08-10 00:50:52 +02:00

136 lines
6.9 KiB
Java

package com.discord.utilities.message;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.Build;
import android.os.LocaleList;
import com.discord.R;
import com.discord.api.channel.Channel;
import com.discord.api.channel.ChannelRecipientNick;
import com.discord.api.interaction.Interaction;
import com.discord.api.sticker.StickerFormatType;
import com.discord.api.sticker.StickerPartial;
import com.discord.api.user.User;
import com.discord.models.member.GuildMember;
import com.discord.models.message.Message;
import com.discord.models.user.CoreUser;
import com.discord.utilities.time.TimeUtils;
import d0.z.d.m;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
/* compiled from: MessageUtils.kt */
public final class MessageUtils {
public static final MessageUtils INSTANCE = new MessageUtils();
private static final Comparator<Long> SORT_BY_IDS_COMPARATOR = MessageUtils$SORT_BY_IDS_COMPARATOR$1.INSTANCE;
private static final int[] WELCOME_MESSAGES = {R.string.system_message_guild_member_join_001, R.string.system_message_guild_member_join_002, R.string.system_message_guild_member_join_003, R.string.system_message_guild_member_join_004, R.string.system_message_guild_member_join_005, R.string.system_message_guild_member_join_006, R.string.system_message_guild_member_join_007, R.string.system_message_guild_member_join_008, R.string.system_message_guild_member_join_009, R.string.system_message_guild_member_join_010, R.string.system_message_guild_member_join_011, R.string.system_message_guild_member_join_012, R.string.system_message_guild_member_join_013};
private static final StickerPartial[] WELCOME_STICKERS;
static {
StickerFormatType stickerFormatType = StickerFormatType.LOTTIE;
WELCOME_STICKERS = new StickerPartial[]{new StickerPartial(749054660769218631L, stickerFormatType, "Wumpus waves hello"), new StickerPartial(751606379340365864L, stickerFormatType, "Nelly peeks around a wall and waves hello"), new StickerPartial(754108890559283200L, stickerFormatType, "Clyde cheerfully waving"), new StickerPartial(781291131828699156L, StickerFormatType.APNG, "Choco waves in greeting"), new StickerPartial(816087792291282944L, stickerFormatType, "Doggo spins and greets you"), new StickerPartial(819128604311027752L, stickerFormatType, "Peach raising her arms in distress")};
}
private MessageUtils() {
}
public static final int compareMessages(Long l, Long l2) {
long j = 0;
long longValue = l != null ? l.longValue() : 0;
if (l2 != null) {
j = l2.longValue();
}
int i = (longValue > j ? 1 : (longValue == j ? 0 : -1));
if (i == 0) {
return 0;
}
return i < 0 ? -1 : 1;
}
public static final Map<Long, String> getNickOrUsernames(Message message, Channel channel, Map<Long, GuildMember> map, List<ChannelRecipientNick> list) {
m.checkNotNullParameter(message, "message");
m.checkNotNullParameter(map, "guildMembers");
List<User> mentions = message.getMentions();
HashMap hashMap = new HashMap((mentions != null ? mentions.size() : 0) + 1);
List<User> mentions2 = message.getMentions();
if (mentions2 != null) {
for (User user : mentions2) {
hashMap.put(Long.valueOf(user.i()), GuildMember.Companion.getNickOrUsername(new CoreUser(user), map.get(Long.valueOf(user.i())), channel, list));
}
}
User author = message.getAuthor();
if (author != null) {
hashMap.put(Long.valueOf(author.i()), GuildMember.Companion.getNickOrUsername(new CoreUser(author), map.get(Long.valueOf(author.i())), channel, list));
}
Interaction interaction = message.getInteraction();
User c2 = interaction != null ? interaction.c() : null;
if (c2 != null) {
hashMap.put(Long.valueOf(c2.i()), GuildMember.Companion.getNickOrUsername(new CoreUser(c2), map.get(Long.valueOf(c2.i())), channel, list));
}
return hashMap;
}
public static /* synthetic */ Map getNickOrUsernames$default(Message message, Channel channel, Map map, List list, int i, Object obj) {
if ((i & 8) != 0) {
list = null;
}
return getNickOrUsernames(message, channel, map, list);
}
public static final Comparator<Long> getSORT_BY_IDS_COMPARATOR() {
return SORT_BY_IDS_COMPARATOR;
}
public static /* synthetic */ void getSORT_BY_IDS_COMPARATOR$annotations() {
}
public static final boolean isNewer(Long l, Long l2) {
return compareMessages(l, l2) < 0;
}
/* JADX WARNING: Removed duplicated region for block: B:17:0x003d */
/* JADX WARNING: Removed duplicated region for block: B:20:0x004d */
/* JADX WARNING: Removed duplicated region for block: B:21:0x0050 */
public final int getSystemMessageUserJoin(Context context, long j) {
Locale locale;
Configuration configuration;
Configuration configuration2;
LocaleList locales;
m.checkNotNullParameter(context, "context");
String str = null;
if (Build.VERSION.SDK_INT >= 24) {
Resources resources = context.getResources();
if (!(resources == null || (configuration2 = resources.getConfiguration()) == null || (locales = configuration2.getLocales()) == null)) {
locale = locales.get(0);
Locale locale2 = new Locale("en");
if (locale != null) {
str = locale.getLanguage();
}
return WELCOME_MESSAGES[(int) (m.areEqual(str, locale2.getLanguage()) ^ true ? 0 : TimeUtils.parseSnowflake(Long.valueOf(j)) % ((long) WELCOME_MESSAGES.length))];
}
} else {
Resources resources2 = context.getResources();
if (!(resources2 == null || (configuration = resources2.getConfiguration()) == null)) {
locale = configuration.locale;
Locale locale2 = new Locale("en");
if (locale != null) {
}
return WELCOME_MESSAGES[(int) (m.areEqual(str, locale2.getLanguage()) ^ true ? 0 : TimeUtils.parseSnowflake(Long.valueOf(j)) % ((long) WELCOME_MESSAGES.length))];
}
}
locale = null;
Locale locale2 = new Locale("en");
if (locale != null) {
}
return WELCOME_MESSAGES[(int) (m.areEqual(str, locale2.getLanguage()) ^ true ? 0 : TimeUtils.parseSnowflake(Long.valueOf(j)) % ((long) WELCOME_MESSAGES.length))];
}
public final StickerPartial getWelcomeSticker(long j, long j2) {
long parseSnowflake = TimeUtils.parseSnowflake(Long.valueOf(j2)) + TimeUtils.parseSnowflake(Long.valueOf(j));
StickerPartial[] stickerPartialArr = WELCOME_STICKERS;
return stickerPartialArr[(int) (parseSnowflake % ((long) stickerPartialArr.length))];
}
}