216 lines
10 KiB
Java
216 lines
10 KiB
Java
|
package com.discord.widgets.chat.list.utils;
|
||
|
|
||
|
import android.content.Context;
|
||
|
import c.d.b.a.a;
|
||
|
import com.discord.api.role.GuildRole;
|
||
|
import com.discord.models.domain.ModelMessage;
|
||
|
import com.discord.stores.StoreMessageState;
|
||
|
import com.discord.stores.StoreStream;
|
||
|
import com.discord.stores.StoreUserSettings;
|
||
|
import com.discord.utilities.color.ColorCompat;
|
||
|
import com.discord.utilities.textprocessing.DiscordParser;
|
||
|
import com.discord.utilities.textprocessing.MessagePreprocessor;
|
||
|
import com.discord.utilities.textprocessing.MessageRenderContext;
|
||
|
import com.discord.widgets.chat.list.adapter.WidgetChatListAdapter;
|
||
|
import com.facebook.drawee.span.DraweeSpanStringBuilder;
|
||
|
import d0.z.d.m;
|
||
|
import java.util.Map;
|
||
|
import java.util.Objects;
|
||
|
import kotlin.text.Regex;
|
||
|
/* compiled from: EmbeddedMessageParser.kt */
|
||
|
public final class EmbeddedMessageParser {
|
||
|
public static final EmbeddedMessageParser INSTANCE = new EmbeddedMessageParser();
|
||
|
|
||
|
/* compiled from: EmbeddedMessageParser.kt */
|
||
|
public static final class ParserData {
|
||
|
private final WidgetChatListAdapter adapter;
|
||
|
private final boolean animateEmojis;
|
||
|
private final Context context;
|
||
|
private final Integer maxNodes;
|
||
|
private final ModelMessage message;
|
||
|
private final StoreMessageState.State messageState;
|
||
|
private final Map<Long, String> nickOrUsernames;
|
||
|
private final Map<Long, GuildRole> roleMentions;
|
||
|
|
||
|
public ParserData(Context context, Map<Long, GuildRole> map, Map<Long, String> map2, boolean z2, StoreMessageState.State state, Integer num, ModelMessage modelMessage, WidgetChatListAdapter widgetChatListAdapter) {
|
||
|
m.checkNotNullParameter(context, "context");
|
||
|
m.checkNotNullParameter(map2, "nickOrUsernames");
|
||
|
m.checkNotNullParameter(modelMessage, "message");
|
||
|
m.checkNotNullParameter(widgetChatListAdapter, "adapter");
|
||
|
this.context = context;
|
||
|
this.roleMentions = map;
|
||
|
this.nickOrUsernames = map2;
|
||
|
this.animateEmojis = z2;
|
||
|
this.messageState = state;
|
||
|
this.maxNodes = num;
|
||
|
this.message = modelMessage;
|
||
|
this.adapter = widgetChatListAdapter;
|
||
|
}
|
||
|
|
||
|
public static /* synthetic */ ParserData copy$default(ParserData parserData, Context context, Map map, Map map2, boolean z2, StoreMessageState.State state, Integer num, ModelMessage modelMessage, WidgetChatListAdapter widgetChatListAdapter, int i, Object obj) {
|
||
|
return parserData.copy((i & 1) != 0 ? parserData.context : context, (i & 2) != 0 ? parserData.roleMentions : map, (i & 4) != 0 ? parserData.nickOrUsernames : map2, (i & 8) != 0 ? parserData.animateEmojis : z2, (i & 16) != 0 ? parserData.messageState : state, (i & 32) != 0 ? parserData.maxNodes : num, (i & 64) != 0 ? parserData.message : modelMessage, (i & 128) != 0 ? parserData.adapter : widgetChatListAdapter);
|
||
|
}
|
||
|
|
||
|
public final Context component1() {
|
||
|
return this.context;
|
||
|
}
|
||
|
|
||
|
public final Map<Long, GuildRole> component2() {
|
||
|
return this.roleMentions;
|
||
|
}
|
||
|
|
||
|
public final Map<Long, String> component3() {
|
||
|
return this.nickOrUsernames;
|
||
|
}
|
||
|
|
||
|
public final boolean component4() {
|
||
|
return this.animateEmojis;
|
||
|
}
|
||
|
|
||
|
public final StoreMessageState.State component5() {
|
||
|
return this.messageState;
|
||
|
}
|
||
|
|
||
|
public final Integer component6() {
|
||
|
return this.maxNodes;
|
||
|
}
|
||
|
|
||
|
public final ModelMessage component7() {
|
||
|
return this.message;
|
||
|
}
|
||
|
|
||
|
public final WidgetChatListAdapter component8() {
|
||
|
return this.adapter;
|
||
|
}
|
||
|
|
||
|
public final ParserData copy(Context context, Map<Long, GuildRole> map, Map<Long, String> map2, boolean z2, StoreMessageState.State state, Integer num, ModelMessage modelMessage, WidgetChatListAdapter widgetChatListAdapter) {
|
||
|
m.checkNotNullParameter(context, "context");
|
||
|
m.checkNotNullParameter(map2, "nickOrUsernames");
|
||
|
m.checkNotNullParameter(modelMessage, "message");
|
||
|
m.checkNotNullParameter(widgetChatListAdapter, "adapter");
|
||
|
return new ParserData(context, map, map2, z2, state, num, modelMessage, widgetChatListAdapter);
|
||
|
}
|
||
|
|
||
|
public boolean equals(Object obj) {
|
||
|
if (this == obj) {
|
||
|
return true;
|
||
|
}
|
||
|
if (!(obj instanceof ParserData)) {
|
||
|
return false;
|
||
|
}
|
||
|
ParserData parserData = (ParserData) obj;
|
||
|
return m.areEqual(this.context, parserData.context) && m.areEqual(this.roleMentions, parserData.roleMentions) && m.areEqual(this.nickOrUsernames, parserData.nickOrUsernames) && this.animateEmojis == parserData.animateEmojis && m.areEqual(this.messageState, parserData.messageState) && m.areEqual(this.maxNodes, parserData.maxNodes) && m.areEqual(this.message, parserData.message) && m.areEqual(this.adapter, parserData.adapter);
|
||
|
}
|
||
|
|
||
|
public final WidgetChatListAdapter getAdapter() {
|
||
|
return this.adapter;
|
||
|
}
|
||
|
|
||
|
public final boolean getAnimateEmojis() {
|
||
|
return this.animateEmojis;
|
||
|
}
|
||
|
|
||
|
public final Context getContext() {
|
||
|
return this.context;
|
||
|
}
|
||
|
|
||
|
public final Integer getMaxNodes() {
|
||
|
return this.maxNodes;
|
||
|
}
|
||
|
|
||
|
public final ModelMessage getMessage() {
|
||
|
return this.message;
|
||
|
}
|
||
|
|
||
|
public final StoreMessageState.State getMessageState() {
|
||
|
return this.messageState;
|
||
|
}
|
||
|
|
||
|
public final Map<Long, String> getNickOrUsernames() {
|
||
|
return this.nickOrUsernames;
|
||
|
}
|
||
|
|
||
|
public final Map<Long, GuildRole> getRoleMentions() {
|
||
|
return this.roleMentions;
|
||
|
}
|
||
|
|
||
|
public int hashCode() {
|
||
|
Context context = this.context;
|
||
|
int i = 0;
|
||
|
int hashCode = (context != null ? context.hashCode() : 0) * 31;
|
||
|
Map<Long, GuildRole> map = this.roleMentions;
|
||
|
int hashCode2 = (hashCode + (map != null ? map.hashCode() : 0)) * 31;
|
||
|
Map<Long, String> map2 = this.nickOrUsernames;
|
||
|
int hashCode3 = (hashCode2 + (map2 != null ? map2.hashCode() : 0)) * 31;
|
||
|
boolean z2 = this.animateEmojis;
|
||
|
if (z2) {
|
||
|
z2 = true;
|
||
|
}
|
||
|
int i2 = z2 ? 1 : 0;
|
||
|
int i3 = z2 ? 1 : 0;
|
||
|
int i4 = z2 ? 1 : 0;
|
||
|
int i5 = (hashCode3 + i2) * 31;
|
||
|
StoreMessageState.State state = this.messageState;
|
||
|
int hashCode4 = (i5 + (state != null ? state.hashCode() : 0)) * 31;
|
||
|
Integer num = this.maxNodes;
|
||
|
int hashCode5 = (hashCode4 + (num != null ? num.hashCode() : 0)) * 31;
|
||
|
ModelMessage modelMessage = this.message;
|
||
|
int hashCode6 = (hashCode5 + (modelMessage != null ? modelMessage.hashCode() : 0)) * 31;
|
||
|
WidgetChatListAdapter widgetChatListAdapter = this.adapter;
|
||
|
if (widgetChatListAdapter != null) {
|
||
|
i = widgetChatListAdapter.hashCode();
|
||
|
}
|
||
|
return hashCode6 + i;
|
||
|
}
|
||
|
|
||
|
public String toString() {
|
||
|
StringBuilder L = a.L("ParserData(context=");
|
||
|
L.append(this.context);
|
||
|
L.append(", roleMentions=");
|
||
|
L.append(this.roleMentions);
|
||
|
L.append(", nickOrUsernames=");
|
||
|
L.append(this.nickOrUsernames);
|
||
|
L.append(", animateEmojis=");
|
||
|
L.append(this.animateEmojis);
|
||
|
L.append(", messageState=");
|
||
|
L.append(this.messageState);
|
||
|
L.append(", maxNodes=");
|
||
|
L.append(this.maxNodes);
|
||
|
L.append(", message=");
|
||
|
L.append(this.message);
|
||
|
L.append(", adapter=");
|
||
|
L.append(this.adapter);
|
||
|
L.append(")");
|
||
|
return L.toString();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private EmbeddedMessageParser() {
|
||
|
}
|
||
|
|
||
|
private final MessagePreprocessor getMessagePreprocessor(long j, ModelMessage modelMessage, StoreMessageState.State state, Integer num) {
|
||
|
StoreUserSettings userSettings = StoreStream.Companion.getUserSettings();
|
||
|
return new MessagePreprocessor(j, state, (!userSettings.getIsEmbedMediaInlined() || !userSettings.getIsRenderEmbedsEnabled()) ? null : modelMessage.getEmbeds(), false, num);
|
||
|
}
|
||
|
|
||
|
private final MessageRenderContext getMessageRenderContext(ParserData parserData) {
|
||
|
return new MessageRenderContext(parserData.getContext(), parserData.getAdapter().getData().getUserId(), parserData.getAnimateEmojis(), parserData.getNickOrUsernames(), parserData.getAdapter().getData().getChannelNames(), parserData.getRoleMentions(), 2130968986, EmbeddedMessageParser$getMessageRenderContext$1.INSTANCE, new EmbeddedMessageParser$getMessageRenderContext$2(parserData), ColorCompat.getThemedColor(parserData.getContext(), 2130970178), ColorCompat.getThemedColor(parserData.getContext(), 2130970179), null, new EmbeddedMessageParser$getMessageRenderContext$3(parserData), new EmbeddedMessageParser$getMessageRenderContext$4(parserData));
|
||
|
}
|
||
|
|
||
|
public final DraweeSpanStringBuilder parse(ParserData parserData) {
|
||
|
m.checkNotNullParameter(parserData, "parserData");
|
||
|
MessageRenderContext messageRenderContext = getMessageRenderContext(parserData);
|
||
|
MessagePreprocessor messagePreprocessor = getMessagePreprocessor(parserData.getMessage().getAuthor().i(), parserData.getMessage(), parserData.getMessageState(), parserData.getMaxNodes());
|
||
|
String content = parserData.getMessage().getContent();
|
||
|
if (content == null) {
|
||
|
content = "";
|
||
|
}
|
||
|
m.checkNotNullExpressionValue(content, "parserData.message.content ?: \"\"");
|
||
|
Context context = parserData.getContext();
|
||
|
String property = System.getProperty("line.separator");
|
||
|
Objects.requireNonNull(property);
|
||
|
m.checkNotNullExpressionValue(property, "Objects.requireNonNull(S…operty(\"line.separator\"))");
|
||
|
return DiscordParser.parseChannelMessage(context, new Regex(property).replace(content, " "), messageRenderContext, messagePreprocessor, DiscordParser.ParserOptions.REPLY, false);
|
||
|
}
|
||
|
}
|