Ruiyuanjb v2.7.0版本的 MD5 值为:45f663f003665a0ca2d09dcbec30071a
以下内容为反编译后的 MessageObject.java 源代码,内容仅作参考
package im.mvtqiwsorf.messenger;
import android.graphics.Color;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build;
import android.text.Layout;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.SpannableStringBuilder;
import android.text.StaticLayout;
import android.text.TextPaint;
import android.text.TextUtils;
import android.text.style.ClickableSpan;
import android.text.style.ForegroundColorSpan;
import android.text.style.ImageSpan;
import android.text.style.URLSpan;
import android.text.util.Linkify;
import android.util.Base64;
import android.util.SparseArray;
import android.view.View;
import androidx.recyclerview.widget.ItemTouchHelper;
import com.blankj.utilcode.util.GsonUtils;
import com.google.android.exoplayer2.util.MimeTypes;
import com.king.zxing.util.CodeUtils;
import com.king.zxing.util.LogUtils;
import im.mvtqiwsorf.javaBean.PayBillOverBean;
import im.mvtqiwsorf.messenger.Emoji;
import im.mvtqiwsorf.messenger.browser.Browser;
import im.mvtqiwsorf.phoneformat.PhoneFormat;
import im.mvtqiwsorf.tgnet.ConnectionsManager;
import im.mvtqiwsorf.tgnet.SerializedData;
import im.mvtqiwsorf.tgnet.TLJsonResolve;
import im.mvtqiwsorf.tgnet.TLObject;
import im.mvtqiwsorf.tgnet.TLRPC;
import im.mvtqiwsorf.tgnet.TLRPCContacts;
import im.mvtqiwsorf.tgnet.TLRPCRedpacket;
import im.mvtqiwsorf.ui.actionbar.BaseFragment;
import im.mvtqiwsorf.ui.actionbar.Theme;
import im.mvtqiwsorf.ui.components.TextStyleSpan;
import im.mvtqiwsorf.ui.components.TypefaceSpan;
import im.mvtqiwsorf.ui.components.URLSpanBotCommand;
import im.mvtqiwsorf.ui.components.URLSpanBrowser;
import im.mvtqiwsorf.ui.components.URLSpanMono;
import im.mvtqiwsorf.ui.components.URLSpanNoUnderline;
import im.mvtqiwsorf.ui.components.URLSpanNoUnderlineBold;
import im.mvtqiwsorf.ui.components.URLSpanReplacement;
import im.mvtqiwsorf.ui.components.URLSpanUserMention;
import im.mvtqiwsorf.ui.hui.packet.bean.RedpacketResponse;
import im.mvtqiwsorf.ui.hui.sysnotify.SysNotifyAtTextClickableSpan;
import im.mvtqiwsorf.ui.hui.transfer.bean.TransferResponse;
import im.mvtqiwsorf.ui.utils.number.MoneyUtil;
import im.mvtqiwsorf.ui.utils.number.NumberUtil;
import java.io.BufferedReader;
import java.io.File;
import java.io.StringReader;
import java.math.BigDecimal;
import java.net.URLEncoder;
import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.Iterator;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.slf4j.Marker;
public class MessageObject {
private static final int LINES_PER_BLOCK = 10;
public static final int MESSAGE_SEND_STATE_EDITING = 3;
public static final int MESSAGE_SEND_STATE_SENDING = 1;
public static final int MESSAGE_SEND_STATE_SEND_ERROR = 2;
public static final int MESSAGE_SEND_STATE_SENT = 0;
public static final int POSITION_FLAG_BOTTOM = 8;
public static final int POSITION_FLAG_LEFT = 1;
public static final int POSITION_FLAG_RIGHT = 2;
public static final int POSITION_FLAG_TOP = 4;
public static final int TYPE_ANIMATED_STICKER = 15;
public static final int TYPE_CARD = 103;
public static final int TYPE_LIVE = 207;
public static final int TYPE_PAYBILL = 104;
public static final int TYPE_POLL = 17;
public static final int TYPE_REDPKG = 101;
public static final int TYPE_ROUND_VIDEO = 5;
public static final int TYPE_STICKER = 13;
public static final int TYPE_SYSTEM_NOTIFY = 105;
public static final int TYPE_TRANSF = 102;
static final String[] excludeWords = {" vs. ", " vs ", " versus ", " ft. ", " ft ", " featuring ", " feat. ", " feat ", " presents ", " pres. ", " pres ", " and ", " & ", " . "};
public static Pattern instagramUrlPattern;
public static Pattern urlPattern;
public static Pattern videoTimeUrlPattern;
public boolean attachPathExists;
public int audioPlayerDuration;
public float audioProgress;
public int audioProgressMs;
public int audioProgressSec;
public StringBuilder botButtonsLayout;
public float bufferedProgress;
public boolean cancelEditing;
public CharSequence caption;
public int contentType;
public int currentAccount;
public TLRPC.TL_channelAdminLogEvent currentEvent;
public String customReplyName;
public String dateKey;
public Delegate delegate;
public boolean deleted;
public CharSequence editingMessage;
public ArrayList<TLRPC.MessageEntity> editingMessageEntities;
public TLRPC.Document emojiAnimatedSticker;
public String emojiAnimatedStickerColor;
private int emojiOnlyCount;
ArrayList<TLRPC.MessageEntity> entitiesCopy;
public long eventId;
public float forceSeekTo;
public boolean forceUpdate;
private float generatedWithDensity;
private int generatedWithMinSize;
public float gifState;
public boolean hadAnimationNotReadyLoading;
public boolean hasRtl;
public boolean isDateObject;
public boolean isRestrictedMessage;
private int isRoundVideoCached;
public int lastLineWidth;
private boolean layoutCreated;
public int linesCount;
public CharSequence linkDescription;
public boolean localChannel;
public boolean localEdit;
public long localGroupId;
public String localName;
public long localSentGroupId;
public int localType;
public String localUserName;
public boolean mediaExists;
public TLRPC.Message messageOwner;
public CharSequence messageText;
public String monthKey;
public ArrayList<TLRPC.PhotoSize> photoThumbs;
public ArrayList<TLRPC.PhotoSize> photoThumbs2;
public TLObject photoThumbsObject;
public TLObject photoThumbsObject2;
public long pollLastCheckTime;
public boolean pollVisibleOnScreen;
public String previousAttachPath;
public String previousCaption;
public ArrayList<TLRPC.MessageEntity> previousCaptionEntities;
public TLRPC.MessageMedia previousMedia;
public MessageObject replyMessageObject;
public boolean resendAsIs;
public boolean scheduled;
public int textHeight;
public ArrayList<TextLayoutBlock> textLayoutBlocks;
public int textWidth;
public float textXOffset;
public int transHeight;
public int transWidth;
public int type;
public boolean useCustomPhoto;
public CharSequence vCardData;
public VideoEditedInfo videoEditedInfo;
public boolean viewsReloaded;
public int wantedBotKeyboardWidth;
public interface Delegate {
void onClickRed();
}
public void checkForScam() {
}
public static class VCardData {
private String company;
private ArrayList<String> emails = new ArrayList<>();
private ArrayList<String> phones = new ArrayList<>();
public static CharSequence parse(String str) {
byte[] decodeQuotedPrintable;
try {
BufferedReader bufferedReader = new BufferedReader(new StringReader(str));
boolean z = false;
VCardData vCardData = null;
String str2 = null;
while (true) {
String readLine = bufferedReader.readLine();
if (readLine != null) {
if (!readLine.startsWith("PHOTO")) {
if (readLine.indexOf(58) >= 0) {
if (readLine.startsWith("BEGIN:VCARD")) {
vCardData = new VCardData();
} else if (readLine.startsWith("END:VCARD") && vCardData != null) {
z = true;
}
}
if (str2 != null) {
readLine = str2 + readLine;
str2 = null;
}
if (readLine.contains("=QUOTED-PRINTABLE") && readLine.endsWith("=")) {
str2 = readLine.substring(0, readLine.length() - 1);
} else {
int indexOf = readLine.indexOf(LogUtils.COLON);
int i = 2;
String[] strArr = indexOf >= 0 ? new String[]{readLine.substring(0, indexOf), readLine.substring(indexOf + 1).trim()} : new String[]{readLine.trim()};
if (strArr.length >= 2 && vCardData != null) {
if (strArr[0].startsWith("ORG")) {
String[] split = strArr[0].split(";");
int length = split.length;
int i2 = 0;
String str3 = null;
String str4 = null;
while (i2 < length) {
String[] split2 = split[i2].split("=");
if (split2.length == i) {
if (split2[0].equals("CHARSET")) {
str4 = split2[1];
} else if (split2[0].equals("ENCODING")) {
str3 = split2[1];
}
}
i2++;
i = 2;
}
vCardData.company = strArr[1];
if (str3 != null && str3.equalsIgnoreCase("QUOTED-PRINTABLE") && (decodeQuotedPrintable = AndroidUtilities.decodeQuotedPrintable(AndroidUtilities.getStringBytes(vCardData.company))) != null && decodeQuotedPrintable.length != 0) {
vCardData.company = new String(decodeQuotedPrintable, str4);
}
vCardData.company = vCardData.company.replace(';', ' ');
} else if (strArr[0].startsWith("TEL")) {
if (strArr[1].length() > 0) {
vCardData.phones.add(strArr[1]);
}
} else if (strArr[0].startsWith("EMAIL")) {
String str5 = strArr[1];
if (str5.length() > 0) {
vCardData.emails.add(str5);
}
}
}
}
}
} else {
try {
break;
} catch (Exception e) {
FileLog.e(e);
}
}
}
bufferedReader.close();
if (!z) {
return null;
}
StringBuilder sb = new StringBuilder();
for (int i3 = 0; i3 < vCardData.phones.size(); i3++) {
if (sb.length() > 0) {
sb.append('\n');
}
String str6 = vCardData.phones.get(i3);
if (!str6.contains("#") && !str6.contains("*")) {
sb.append(PhoneFormat.getInstance().format(str6));
}
sb.append(str6);
}
for (int i4 = 0; i4 < vCardData.emails.size(); i4++) {
if (sb.length() > 0) {
sb.append('\n');
}
sb.append(PhoneFormat.getInstance().format(vCardData.emails.get(i4)));
}
if (!TextUtils.isEmpty(vCardData.company)) {
if (sb.length() > 0) {
sb.append('\n');
}
sb.append(vCardData.company);
}
return sb;
} catch (Throwable unused) {
return null;
}
}
}
public static class TextLayoutBlock {
public int charactersEnd;
public int charactersOffset;
public byte directionFlags;
public int height;
public int heightByOffset;
public StaticLayout textLayout;
public float textYOffset;
public boolean isRtl() {
byte b = this.directionFlags;
return (b & 1) != 0 && (b & 2) == 0;
}
}
public static class GroupedMessagePosition {
public float aspectRatio;
public boolean edge;
public int flags;
public boolean last;
public int leftSpanOffset;
public byte maxX;
public byte maxY;
public byte minX;
public byte minY;
public float ph;
public int pw;
public float[] siblingHeights;
public int spanSize;
public void set(int i, int i2, int i3, int i4, int i5, float f, int i6) {
this.minX = (byte) i;
this.maxX = (byte) i2;
this.minY = (byte) i3;
this.maxY = (byte) i4;
this.pw = i5;
this.spanSize = i5;
this.ph = f;
this.flags = (byte) i6;
}
}
public static class GroupedMessages {
public long groupId;
public boolean hasSibling;
public ArrayList<MessageObject> messages = new ArrayList<>();
public ArrayList<GroupedMessagePosition> posArray = new ArrayList<>();
public HashMap<MessageObject, GroupedMessagePosition> positions = new HashMap<>();
private int maxSizeWidth = CodeUtils.DEFAULT_REQ_HEIGHT;
private int firstSpanAdditionalSize = ItemTouchHelper.Callback.DEFAULT_DRAG_ANIMATION_DURATION;
public int getMaxSizeWidth() {
return this.maxSizeWidth;
}
private class MessageGroupedLayoutAttempt {
public float[] heights;
public int[] lineCounts;
public MessageGroupedLayoutAttempt(int i, int i2, float f, float f2) {
this.lineCounts = new int[]{i, i2};
this.heights = new float[]{f, f2};
}
public MessageGroupedLayoutAttempt(int i, int i2, int i3, float f, float f2, float f3) {
this.lineCounts = new int[]{i, i2, i3};
this.heights = new float[]{f, f2, f3};
}
public MessageGroupedLayoutAttempt(int i, int i2, int i3, int i4, float f, float f2, float f3, float f4) {
this.lineCounts = new int[]{i, i2, i3, i4};
this.heights = new float[]{f, f2, f3, f4};
}
}
private float multiHeight(float[] fArr, int i, int i2) {
float f = 0.0f;
while (i < i2) {
f += fArr[i];
i++;
}
return this.maxSizeWidth / f;
}
public void calculate() {
boolean z;
int i;
int i2;
int i3;
int i4;
int i5;
int i6;
float[] fArr;
int i7;
int i8;
float f;
int i9;
this.posArray.clear();
this.positions.clear();
int size = this.messages.size();
if (size <= 1) {
return;
}
StringBuilder sb = new StringBuilder();
this.hasSibling = false;
int i10 = 0;
boolean z2 = false;
float f2 = 1.0f;
boolean z3 = false;
boolean z4 = false;
while (i10 < size) {
MessageObject messageObject = this.messages.get(i10);
if (i10 == 0) {
z4 = messageObject.isOutOwner();
z2 = !z4 && (!(messageObject.messageOwner.fwd_from == null || messageObject.messageOwner.fwd_from.saved_from_peer == null) || (messageObject.messageOwner.from_id > 0 && (messageObject.messageOwner.to_id.channel_id != 0 || messageObject.messageOwner.to_id.chat_id != 0 || (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaGame) || (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaInvoice))));
}
TLRPC.PhotoSize closestPhotoSizeWithSize = FileLoader.getClosestPhotoSizeWithSize(messageObject.photoThumbs, AndroidUtilities.getPhotoSize());
GroupedMessagePosition groupedMessagePosition = new GroupedMessagePosition();
groupedMessagePosition.last = i10 == size + (-1);
groupedMessagePosition.aspectRatio = closestPhotoSizeWithSize == null ? 1.0f : closestPhotoSizeWithSize.w / closestPhotoSizeWithSize.h;
if (groupedMessagePosition.aspectRatio > 1.2f) {
sb.append("w");
} else if (groupedMessagePosition.aspectRatio < 0.8f) {
sb.append("n");
} else {
sb.append("q");
}
f2 += groupedMessagePosition.aspectRatio;
if (groupedMessagePosition.aspectRatio > 2.0f) {
z3 = true;
}
this.positions.put(messageObject, groupedMessagePosition);
this.posArray.add(groupedMessagePosition);
i10++;
}
if (z2) {
this.maxSizeWidth -= 50;
this.firstSpanAdditionalSize += 50;
}
int dp = AndroidUtilities.dp(120.0f);
int dp2 = (int) (AndroidUtilities.dp(120.0f) / (Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y) / this.maxSizeWidth));
float dp3 = AndroidUtilities.dp(40.0f);
float min = Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y);
int i11 = this.maxSizeWidth;
int i12 = (int) (dp3 / (min / i11));
float f3 = i11 / 814.0f;
float f4 = f2 / size;
float dp4 = AndroidUtilities.dp(100.0f) / 814.0f;
int i13 = 3;
if (z3 || !(size == 2 || size == 3 || size == 4)) {
z = z4;
int size2 = this.posArray.size();
float[] fArr2 = new float[size2];
for (int i14 = 0; i14 < size; i14++) {
if (f4 > 1.1f) {
fArr2[i14] = Math.max(1.0f, this.posArray.get(i14).aspectRatio);
} else {
fArr2[i14] = Math.min(1.0f, this.posArray.get(i14).aspectRatio);
}
fArr2[i14] = Math.max(0.66667f, Math.min(1.7f, fArr2[i14]));
}
ArrayList arrayList = new ArrayList();
int i15 = 1;
while (i15 < size2) {
int i16 = size2 - i15;
if (i15 > i13 || i16 > i13) {
i9 = size;
} else {
i9 = size;
arrayList.add(new MessageGroupedLayoutAttempt(i15, i16, multiHeight(fArr2, 0, i15), multiHeight(fArr2, i15, size2)));
}
i15++;
size = i9;
i13 = 3;
}
i = size;
int i17 = 3;
int i18 = 1;
while (i18 < size2 - 1) {
int i19 = 1;
while (true) {
int i20 = size2 - i18;
if (i19 < i20) {
int i21 = i20 - i19;
if (i18 <= i17) {
if (i19 <= (f4 < 0.85f ? 4 : 3) && i21 <= i17) {
int i22 = i18 + i19;
i8 = i19;
f = dp4;
arrayList.add(new MessageGroupedLayoutAttempt(i18, i19, i21, multiHeight(fArr2, 0, i18), multiHeight(fArr2, i18, i22), multiHeight(fArr2, i22, size2)));
i19 = i8 + 1;
dp4 = f;
i17 = 3;
}
}
i8 = i19;
f = dp4;
i19 = i8 + 1;
dp4 = f;
i17 = 3;
}
}
i18++;
i17 = 3;
}
float f5 = dp4;
int i23 = 1;
while (i23 < size2 - 2) {
int i24 = 1;
while (true) {
int i25 = size2 - i23;
if (i24 < i25) {
int i26 = 1;
while (true) {
int i27 = i25 - i24;
if (i26 < i27) {
int i28 = i27 - i26;
if (i23 > 3 || i24 > 3 || i26 > 3 || i28 > 3) {
i4 = i26;
i5 = i25;
i6 = size2;
fArr = fArr2;
i7 = dp2;
} else {
float multiHeight = multiHeight(fArr2, 0, i23);
int i29 = i23 + i24;
float multiHeight2 = multiHeight(fArr2, i23, i29);
int i30 = i29 + i26;
float multiHeight3 = multiHeight(fArr2, i29, i30);
float multiHeight4 = multiHeight(fArr2, i30, size2);
i6 = size2;
i4 = i26;
i5 = i25;
fArr = fArr2;
i7 = dp2;
arrayList.add(new MessageGroupedLayoutAttempt(i23, i24, i26, i28, multiHeight, multiHeight2, multiHeight3, multiHeight4));
}
i26 = i4 + 1;
dp2 = i7;
i25 = i5;
fArr2 = fArr;
size2 = i6;
}
}
i24++;
fArr2 = fArr2;
}
}
i23++;
fArr2 = fArr2;
}
float[] fArr3 = fArr2;
int i31 = dp2;
float f6 = (this.maxSizeWidth / 3) * 4;
MessageGroupedLayoutAttempt messageGroupedLayoutAttempt = null;
float f7 = 0.0f;
for (int i32 = 0; i32 < arrayList.size(); i32++) {
MessageGroupedLayoutAttempt messageGroupedLayoutAttempt2 = (MessageGroupedLayoutAttempt) arrayList.get(i32);
float f8 = Float.MAX_VALUE;
float f9 = 0.0f;
for (int i33 = 0; i33 < messageGroupedLayoutAttempt2.heights.length; i33++) {
f9 += messageGroupedLayoutAttempt2.heights[i33];
if (messageGroupedLayoutAttempt2.heights[i33] < f8) {
f8 = messageGroupedLayoutAttempt2.heights[i33];
}
}
float abs = Math.abs(f9 - f6);
if (messageGroupedLayoutAttempt2.lineCounts.length > 1) {
if (messageGroupedLayoutAttempt2.lineCounts[0] <= messageGroupedLayoutAttempt2.lineCounts[1] && (messageGroupedLayoutAttempt2.lineCounts.length <= 2 || messageGroupedLayoutAttempt2.lineCounts[1] <= messageGroupedLayoutAttempt2.lineCounts[2])) {
if (messageGroupedLayoutAttempt2.lineCounts.length > 3) {
}
}
abs *= 1.2f;
}
if (f8 < i31) {
abs *= 1.5f;
}
if (messageGroupedLayoutAttempt == null || abs < f7) {
messageGroupedLayoutAttempt = messageGroupedLayoutAttempt2;
f7 = abs;
}
}
if (messageGroupedLayoutAttempt == null) {
return;
}
i2 = 0;
int i34 = 0;
int i35 = 0;
while (i35 < messageGroupedLayoutAttempt.lineCounts.length) {
int i36 = messageGroupedLayoutAttempt.lineCounts[i35];
float f10 = messageGroupedLayoutAttempt.heights[i35];
int i37 = this.maxSizeWidth;
int i38 = i36 - 1;
i2 = Math.max(i2, i38);
int i39 = i37;
GroupedMessagePosition groupedMessagePosition2 = null;
for (int i40 = 0; i40 < i36; i40++) {
int i41 = (int) (fArr3[i34] * f10);
i39 -= i41;
GroupedMessagePosition groupedMessagePosition3 = this.posArray.get(i34);
int i42 = i35 == 0 ? 4 : 0;
if (i35 == messageGroupedLayoutAttempt.lineCounts.length - 1) {
i42 |= 8;
}
if (i40 == 0) {
i42 |= 1;
if (z) {
groupedMessagePosition2 = groupedMessagePosition3;
}
}
if (i40 == i38) {
i42 |= 2;
if (!z) {
i3 = i42;
groupedMessagePosition2 = groupedMessagePosition3;
groupedMessagePosition3.set(i40, i40, i35, i35, i41, Math.max(f5, f10 / 814.0f), i3);
i34++;
}
}
i3 = i42;
groupedMessagePosition3.set(i40, i40, i35, i35, i41, Math.max(f5, f10 / 814.0f), i3);
i34++;
}
groupedMessagePosition2.pw += i39;
groupedMessagePosition2.spanSize += i39;
i35++;
}
} else if (size == 2) {
GroupedMessagePosition groupedMessagePosition4 = this.posArray.get(0);
GroupedMessagePosition groupedMessagePosition5 = this.posArray.get(1);
String sb2 = sb.toString();
if (sb2.equals("ww")) {
double d = f4;
z = z4;
double d2 = f3;
Double.isNaN(d2);
if (d > d2 * 1.4d && groupedMessagePosition4.aspectRatio - groupedMessagePosition5.aspectRatio < 0.2d) {
float round = Math.round(Math.min(this.maxSizeWidth / groupedMessagePosition4.aspectRatio, Math.min(this.maxSizeWidth / groupedMessagePosition5.aspectRatio, 407.0f))) / 814.0f;
groupedMessagePosition4.set(0, 0, 0, 0, this.maxSizeWidth, round, 7);
groupedMessagePosition5.set(0, 0, 1, 1, this.maxSizeWidth, round, 11);
i2 = 0;
i = size;
}
} else {
z = z4;
}
if (sb2.equals("ww") || sb2.equals("qq")) {
int i43 = this.maxSizeWidth / 2;
float f11 = i43;
float round2 = Math.round(Math.min(f11 / groupedMessagePosition4.aspectRatio, Math.min(f11 / groupedMessagePosition5.aspectRatio, 814.0f))) / 814.0f;
groupedMessagePosition4.set(0, 0, 0, 0, i43, round2, 13);
groupedMessagePosition5.set(1, 1, 0, 0, i43, round2, 14);
} else {
int max = (int) Math.max(this.maxSizeWidth * 0.4f, Math.round((r0 / groupedMessagePosition4.aspectRatio) / ((1.0f / groupedMessagePosition4.aspectRatio) + (1.0f / groupedMessagePosition5.aspectRatio))));
int i44 = this.maxSizeWidth - max;
if (i44 < dp2) {
max -= dp2 - i44;
i44 = dp2;
}
float min2 = Math.min(814.0f, Math.round(Math.min(i44 / groupedMessagePosition4.aspectRatio, max / groupedMessagePosition5.aspectRatio))) / 814.0f;
groupedMessagePosition4.set(0, 0, 0, 0, i44, min2, 13);
groupedMessagePosition5.set(1, 1, 0, 0, max, min2, 14);
}
i2 = 1;
i = size;
} else {
z = z4;
if (size == 3) {
GroupedMessagePosition groupedMessagePosition6 = this.posArray.get(0);
GroupedMessagePosition groupedMessagePosition7 = this.posArray.get(1);
GroupedMessagePosition groupedMessagePosition8 = this.posArray.get(2);
if (sb.charAt(0) == 'n') {
float min3 = Math.min(407.0f, Math.round((groupedMessagePosition7.aspectRatio * this.maxSizeWidth) / (groupedMessagePosition8.aspectRatio + groupedMessagePosition7.aspectRatio)));
int max2 = (int) Math.max(dp2, Math.min(this.maxSizeWidth * 0.5f, Math.round(Math.min(groupedMessagePosition8.aspectRatio * min3, groupedMessagePosition7.aspectRatio * r4))));
int round3 = Math.round(Math.min((groupedMessagePosition6.aspectRatio * 814.0f) + i12, this.maxSizeWidth - max2));
groupedMessagePosition6.set(0, 0, 0, 1, round3, 1.0f, 13);
float f12 = (814.0f - min3) / 814.0f;
groupedMessagePosition7.set(1, 1, 0, 0, max2, f12, 6);
float f13 = min3 / 814.0f;
groupedMessagePosition8.set(0, 1, 1, 1, max2, f13, 10);
groupedMessagePosition8.spanSize = this.maxSizeWidth;
groupedMessagePosition6.siblingHeights = new float[]{f13, f12};
if (z) {
groupedMessagePosition6.spanSize = this.maxSizeWidth - max2;
} else {
groupedMessagePosition7.spanSize = this.maxSizeWidth - round3;
groupedMessagePosition8.leftSpanOffset = round3;
}
this.hasSibling = true;
} else {
float round4 = Math.round(Math.min(this.maxSizeWidth / groupedMessagePosition6.aspectRatio, 537.24005f)) / 814.0f;
groupedMessagePosition6.set(0, 1, 0, 0, this.maxSizeWidth, round4, 7);
int i45 = this.maxSizeWidth / 2;
float f14 = i45;
float min4 = Math.min(814.0f - round4, Math.round(Math.min(f14 / groupedMessagePosition7.aspectRatio, f14 / groupedMessagePosition8.aspectRatio))) / 814.0f;
if (min4 < dp4) {
min4 = dp4;
}
float f15 = min4;
groupedMessagePosition7.set(0, 0, 1, 1, i45, f15, 9);
groupedMessagePosition8.set(1, 1, 1, 1, i45, f15, 10);
}
i = size;
i2 = 1;
} else if (size == 4) {
GroupedMessagePosition groupedMessagePosition9 = this.posArray.get(0);
GroupedMessagePosition groupedMessagePosition10 = this.posArray.get(1);
GroupedMessagePosition groupedMessagePosition11 = this.posArray.get(2);
GroupedMessagePosition groupedMessagePosition12 = this.posArray.get(3);
if (sb.charAt(0) == 'w') {
float round5 = Math.round(Math.min(this.maxSizeWidth / groupedMessagePosition9.aspectRatio, 537.24005f)) / 814.0f;
groupedMessagePosition9.set(0, 2, 0, 0, this.maxSizeWidth, round5, 7);
float round6 = Math.round(this.maxSizeWidth / ((groupedMessagePosition10.aspectRatio + groupedMessagePosition11.aspectRatio) + groupedMessagePosition12.aspectRatio));
float f16 = dp2;
int max3 = (int) Math.max(f16, Math.min(this.maxSizeWidth * 0.4f, groupedMessagePosition10.aspectRatio * round6));
int max4 = (int) Math.max(Math.max(f16, this.maxSizeWidth * 0.33f), groupedMessagePosition12.aspectRatio * round6);
int i46 = (this.maxSizeWidth - max3) - max4;
if (i46 < AndroidUtilities.dp(58.0f)) {
int dp5 = AndroidUtilities.dp(58.0f) - i46;
i46 = AndroidUtilities.dp(58.0f);
int i47 = dp5 / 2;
max3 -= i47;
max4 -= dp5 - i47;
}
int i48 = max3;
float min5 = Math.min(814.0f - round5, round6) / 814.0f;
if (min5 < dp4) {
min5 = dp4;
}
float f17 = min5;
groupedMessagePosition10.set(0, 0, 1, 1, i48, f17, 9);
groupedMessagePosition11.set(1, 1, 1, 1, i46, f17, 8);
groupedMessagePosition12.set(2, 2, 1, 1, max4, f17, 10);
i2 = 2;
i = size;
} else {
int max5 = Math.max(dp2, Math.round(814.0f / (((1.0f / groupedMessagePosition10.aspectRatio) + (1.0f / groupedMessagePosition11.aspectRatio)) + (1.0f / groupedMessagePosition12.aspectRatio))));
float f18 = dp;
float f19 = max5;
float min6 = Math.min(0.33f, Math.max(f18, f19 / groupedMessagePosition10.aspectRatio) / 814.0f);
float min7 = Math.min(0.33f, Math.max(f18, f19 / groupedMessagePosition11.aspectRatio) / 814.0f);
float f20 = (1.0f - min6) - min7;
int round7 = Math.round(Math.min((814.0f * groupedMessagePosition9.aspectRatio) + i12, this.maxSizeWidth - max5));
groupedMessagePosition9.set(0, 0, 0, 2, round7, min6 + min7 + f20, 13);
groupedMessagePosition10.set(1, 1, 0, 0, max5, min6, 6);
groupedMessagePosition11.set(0, 1, 1, 1, max5, min7, 2);
groupedMessagePosition11.spanSize = this.maxSizeWidth;
groupedMessagePosition12.set(0, 1, 2, 2, max5, f20, 10);
groupedMessagePosition12.spanSize = this.maxSizeWidth;
if (z) {
groupedMessagePosition9.spanSize = this.maxSizeWidth - max5;
} else {
groupedMessagePosition10.spanSize = this.maxSizeWidth - round7;
groupedMessagePosition11.leftSpanOffset = round7;
groupedMessagePosition12.leftSpanOffset = round7;
}
groupedMessagePosition9.siblingHeights = new float[]{min6, min7, f20};
this.hasSibling = true;
i2 = 1;
i = size;
}
} else {
i = size;
i2 = 0;
}
}
int i49 = i;
for (int i50 = 0; i50 < i49; i50++) {
GroupedMessagePosition groupedMessagePosition13 = this.posArray.get(i50);
if (z) {
if (groupedMessagePosition13.minX == 0) {
groupedMessagePosition13.spanSize += this.firstSpanAdditionalSize;
}
if ((groupedMessagePosition13.flags & 2) != 0) {
groupedMessagePosition13.edge = true;
}
} else {
if (groupedMessagePosition13.maxX == i2 || (groupedMessagePosition13.flags & 2) != 0) {
groupedMessagePosition13.spanSize += this.firstSpanAdditionalSize;
}
if ((groupedMessagePosition13.flags & 1) != 0) {
groupedMessagePosition13.edge = true;
}
}
MessageObject messageObject2 = this.messages.get(i50);
if (!z && messageObject2.needDrawAvatarInternal()) {
if (groupedMessagePosition13.edge) {
if (groupedMessagePosition13.spanSize != 1000) {
groupedMessagePosition13.spanSize += 108;
}
groupedMessagePosition13.pw += 108;
} else if ((groupedMessagePosition13.flags & 2) != 0) {
if (groupedMessagePosition13.spanSize != 1000) {
groupedMessagePosition13.spanSize -= 108;
} else if (groupedMessagePosition13.leftSpanOffset != 0) {
groupedMessagePosition13.leftSpanOffset += 108;
}
}
}
if (!z && messageObject2.needDrawAvatar()) {
if (groupedMessagePosition13.edge) {
if (groupedMessagePosition13.spanSize != 1000) {
groupedMessagePosition13.spanSize += 108;
}
groupedMessagePosition13.pw += 108;
} else if ((groupedMessagePosition13.flags & 2) != 0) {
if (groupedMessagePosition13.spanSize != 1000) {
groupedMessagePosition13.spanSize -= 108;
} else if (groupedMessagePosition13.leftSpanOffset != 0) {
groupedMessagePosition13.leftSpanOffset += 108;
}
}
} else if (z && messageObject2.needDrawAvatar()) {
if (groupedMessagePosition13.edge) {
if (groupedMessagePosition13.spanSize != 1000) {
groupedMessagePosition13.spanSize += 108;
}
groupedMessagePosition13.pw += 108;
} else {
if ((groupedMessagePosition13.flags & 1) != 0) {
if (groupedMessagePosition13.spanSize != 1000) {
groupedMessagePosition13.spanSize -= 108;
} else if (groupedMessagePosition13.leftSpanOffset != 0) {
groupedMessagePosition13.leftSpanOffset += 108;
}
}
}
}
}
}
}
public MessageObject(int i, TLRPC.Message message, String str, String str2, String str3, boolean z, boolean z2, boolean z3) {
this.type = 1000;
this.forceSeekTo = -1.0f;
this.entitiesCopy = new ArrayList<>();
this.localType = z ? 2 : 1;
this.currentAccount = i;
this.localName = str2;
this.localUserName = str3;
this.messageText = str;
this.messageOwner = message;
this.localChannel = z2;
this.localEdit = z3;
}
public MessageObject(int i, TLRPC.Message message, AbstractMap<Integer, TLRPC.User> abstractMap, boolean z) {
this(i, message, abstractMap, (AbstractMap<Integer, TLRPC.Chat>) null, z);
}
public MessageObject(int i, TLRPC.Message message, SparseArray<TLRPC.User> sparseArray, boolean z) {
this(i, message, sparseArray, (SparseArray<TLRPC.Chat>) null, z);
}
public MessageObject(int i, TLRPC.Message message, boolean z) {
this(i, message, null, null, null, null, null, z, 0L);
}
public MessageObject(int i, TLRPC.Message message, MessageObject messageObject, boolean z) {
this(i, message, messageObject, null, null, null, null, z, 0L);
}
public MessageObject(int i, TLRPC.Message message, AbstractMap<Integer, TLRPC.User> abstractMap, AbstractMap<Integer, TLRPC.Chat> abstractMap2, boolean z) {
this(i, message, abstractMap, abstractMap2, z, 0L);
}
public MessageObject(int i, TLRPC.Message message, SparseArray<TLRPC.User> sparseArray, SparseArray<TLRPC.Chat> sparseArray2, boolean z) {
this(i, message, null, null, null, sparseArray, sparseArray2, z, 0L);
}
public MessageObject(int i, TLRPC.Message message, AbstractMap<Integer, TLRPC.User> abstractMap, AbstractMap<Integer, TLRPC.Chat> abstractMap2, boolean z, long j) {
this(i, message, null, abstractMap, abstractMap2, null, null, z, j);
}
public MessageObject(int i, TLRPC.Message message, MessageObject messageObject, AbstractMap<Integer, TLRPC.User> abstractMap, AbstractMap<Integer, TLRPC.Chat> abstractMap2, SparseArray<TLRPC.User> sparseArray, SparseArray<TLRPC.Chat> sparseArray2, boolean z, long j) {
AbstractMap<Integer, TLRPC.Chat> abstractMap3;
SparseArray<TLRPC.Chat> sparseArray3;
TLRPC.User user;
TextPaint textPaint;
this.type = 1000;
this.forceSeekTo = -1.0f;
this.entitiesCopy = new ArrayList<>();
Theme.createChatResources(null, true);
this.currentAccount = i;
this.messageOwner = message;
this.replyMessageObject = messageObject;
this.eventId = j;
if (message.replyMessage != null) {
this.replyMessageObject = new MessageObject(this.currentAccount, message.replyMessage, null, abstractMap, abstractMap2, sparseArray, sparseArray2, false, j);
}
if (message.from_id > 0) {
if (abstractMap != null) {
user = abstractMap.get(Integer.valueOf(message.from_id));
} else {
user = sparseArray != null ? sparseArray.get(message.from_id) : null;
}
user = user == null ? MessagesController.getInstance(this.currentAccount).getUser(Integer.valueOf(message.from_id)) : user;
abstractMap3 = abstractMap2;
sparseArray3 = sparseArray2;
} else {
abstractMap3 = abstractMap2;
sparseArray3 = sparseArray2;
user = null;
}
updateMessageText(abstractMap, abstractMap3, sparseArray, sparseArray3);
if (isMediaEmpty()) {
this.messageText = updateMetionText(this.messageText, this.messageOwner.entities);
}
setType();
measureInlineBotButtons();
GregorianCalendar gregorianCalendar = new GregorianCalendar();
gregorianCalendar.setTimeInMillis(this.messageOwner.date * 1000);
int i2 = gregorianCalendar.get(6);
int i3 = gregorianCalendar.get(1);
int i4 = gregorianCalendar.get(2);
this.dateKey = String.format("%d_%02d_%02d", Integer.valueOf(i3), Integer.valueOf(i4), Integer.valueOf(i2));
this.monthKey = String.format("%d_%02d", Integer.valueOf(i3), Integer.valueOf(i4));
createMessageSendInfo();
generateCaption();
if (z) {
if (this.messageOwner.media instanceof TLRPC.TL_messageMediaGame) {
textPaint = Theme.chat_msgGameTextPaint;
} else {
textPaint = Theme.chat_msgTextPaint;
}
int[] iArr = SharedConfig.allowBigEmoji ? new int[1] : null;
this.messageText = Emoji.replaceEmoji(this.messageText, textPaint.getFontMetricsInt(), AndroidUtilities.dp(20.0f), false, iArr);
checkEmojiOnly(iArr);
this.emojiAnimatedSticker = null;
if (this.emojiOnlyCount == 1 && !(message.media instanceof TLRPC.TL_messageMediaWebPage) && message.entities.isEmpty()) {
CharSequence charSequence = this.messageText;
int indexOf = TextUtils.indexOf(charSequence, "🏻");
if (indexOf >= 0) {
this.emojiAnimatedStickerColor = "_c1";
charSequence = charSequence.subSequence(0, indexOf);
} else {
int indexOf2 = TextUtils.indexOf(charSequence, "🏼");
if (indexOf2 >= 0) {
this.emojiAnimatedStickerColor = "_c2";
charSequence = charSequence.subSequence(0, indexOf2);
} else {
int indexOf3 = TextUtils.indexOf(charSequence, "🏽");
if (indexOf3 >= 0) {
this.emojiAnimatedStickerColor = "_c3";
charSequence = charSequence.subSequence(0, indexOf3);
} else {
int indexOf4 = TextUtils.indexOf(charSequence, "🏾");
if (indexOf4 >= 0) {
this.emojiAnimatedStickerColor = "_c4";
charSequence = charSequence.subSequence(0, indexOf4);
} else {
int indexOf5 = TextUtils.indexOf(charSequence, "🏿");
if (indexOf5 >= 0) {
this.emojiAnimatedStickerColor = "_c5";
charSequence = charSequence.subSequence(0, indexOf5);
} else {
this.emojiAnimatedStickerColor = "";
}
}
}
}
}
this.emojiAnimatedSticker = MediaDataController.getInstance(this.currentAccount).getEmojiAnimatedSticker(charSequence);
}
if (this.emojiAnimatedSticker == null) {
generateLayout(user);
} else {
this.type = 1000;
if (isSticker()) {
this.type = 13;
} else if (isAnimatedSticker()) {
this.type = 15;
}
}
}
this.layoutCreated = z;
generateThumbs(false);
checkMediaExistance();
}
public void renderText() {
entityCopy(this.messageOwner.entities);
addEntitiesToText(this.messageText, false);
}
private void entityCopy(ArrayList<TLRPC.MessageEntity> arrayList) {
if (arrayList == null || arrayList.size() == 0) {
return;
}
this.entitiesCopy.clear();
Iterator<TLRPC.MessageEntity> it = arrayList.iterator();
while (it.hasNext()) {
TLRPC.MessageEntity next = it.next();
if (next instanceof TLRPC.TL_messageEntityTextUrl) {
TLRPC.TL_messageEntityTextUrl tL_messageEntityTextUrl = new TLRPC.TL_messageEntityTextUrl();
tL_messageEntityTextUrl.offset = next.offset;
tL_messageEntityTextUrl.length = next.length;
tL_messageEntityTextUrl.url = next.url;
this.entitiesCopy.add(tL_messageEntityTextUrl);
} else if (next instanceof TLRPC.TL_messageEntityBotCommand) {
TLRPC.TL_messageEntityBotCommand tL_messageEntityBotCommand = new TLRPC.TL_messageEntityBotCommand();
tL_messageEntityBotCommand.offset = next.offset;
tL_messageEntityBotCommand.length = next.length;
this.entitiesCopy.add(tL_messageEntityBotCommand);
} else if (next instanceof TLRPC.TL_messageEntityEmail) {
TLRPC.TL_messageEntityEmail tL_messageEntityEmail = new TLRPC.TL_messageEntityEmail();
tL_messageEntityEmail.offset = next.offset;
tL_messageEntityEmail.length = next.length;
this.entitiesCopy.add(tL_messageEntityEmail);
} else if (next instanceof TLRPC.TL_messageEntityPre) {
TLRPC.TL_messageEntityPre tL_messageEntityPre = new TLRPC.TL_messageEntityPre();
tL_messageEntityPre.offset = next.offset;
tL_messageEntityPre.length = next.length;
tL_messageEntityPre.language = next.language;
this.entitiesCopy.add(tL_messageEntityPre);
} else if (next instanceof TLRPC.TL_messageEntityUnknown) {
TLRPC.TL_messageEntityUnknown tL_messageEntityUnknown = new TLRPC.TL_messageEntityUnknown();
tL_messageEntityUnknown.offset = next.offset;
tL_messageEntityUnknown.length = next.length;
this.entitiesCopy.add(tL_messageEntityUnknown);
} else if (next instanceof TLRPC.TL_messageEntityUrl) {
TLRPC.TL_messageEntityUrl tL_messageEntityUrl = new TLRPC.TL_messageEntityUrl();
tL_messageEntityUrl.offset = next.offset;
tL_messageEntityUrl.length = next.length;
this.entitiesCopy.add(tL_messageEntityUrl);
} else if (next instanceof TLRPC.TL_messageEntityItalic) {
TLRPC.TL_messageEntityItalic tL_messageEntityItalic = new TLRPC.TL_messageEntityItalic();
tL_messageEntityItalic.offset = next.offset;
tL_messageEntityItalic.length = next.length;
this.entitiesCopy.add(tL_messageEntityItalic);
} else if (next instanceof TLRPC.TL_messageEntityMention) {
TLRPC.TL_messageEntityMention tL_messageEntityMention = new TLRPC.TL_messageEntityMention();
tL_messageEntityMention.offset = next.offset;
tL_messageEntityMention.length = next.length;
this.entitiesCopy.add(tL_messageEntityMention);
} else if (next instanceof TLRPC.TL_messageEntityMentionName) {
TLRPC.TL_messageEntityMentionName tL_messageEntityMentionName = new TLRPC.TL_messageEntityMentionName();
tL_messageEntityMentionName.offset = next.offset;
tL_messageEntityMentionName.length = next.length;
tL_messageEntityMentionName.user_id = ((TLRPC.TL_messageEntityMentionName) next).user_id;
this.entitiesCopy.add(tL_messageEntityMentionName);
} else if (next instanceof TLRPC.TL_inputMessageEntityMentionName) {
TLRPC.TL_inputMessageEntityMentionName tL_inputMessageEntityMentionName = new TLRPC.TL_inputMessageEntityMentionName();
tL_inputMessageEntityMentionName.offset = next.offset;
tL_inputMessageEntityMentionName.length = next.length;
tL_inputMessageEntityMentionName.user_id = ((TLRPC.TL_inputMessageEntityMentionName) next).user_id;
this.entitiesCopy.add(tL_inputMessageEntityMentionName);
} else if (next instanceof TLRPC.TL_messageEntityCashtag) {
TLRPC.TL_messageEntityCashtag tL_messageEntityCashtag = new TLRPC.TL_messageEntityCashtag();
tL_messageEntityCashtag.offset = next.offset;
tL_messageEntityCashtag.length = next.length;
this.entitiesCopy.add(tL_messageEntityCashtag);
} else if (next instanceof TLRPC.TL_messageEntityBold) {
TLRPC.TL_messageEntityBold tL_messageEntityBold = new TLRPC.TL_messageEntityBold();
tL_messageEntityBold.offset = next.offset;
tL_messageEntityBold.length = next.length;
this.entitiesCopy.add(tL_messageEntityBold);
} else if (next instanceof TLRPC.TL_messageEntityHashtag) {
TLRPC.TL_messageEntityHashtag tL_messageEntityHashtag = new TLRPC.TL_messageEntityHashtag();
tL_messageEntityHashtag.offset = next.offset;
tL_messageEntityHashtag.length = next.length;
this.entitiesCopy.add(tL_messageEntityHashtag);
} else if (next instanceof TLRPC.TL_messageEntityCode) {
TLRPC.TL_messageEntityCode tL_messageEntityCode = new TLRPC.TL_messageEntityCode();
tL_messageEntityCode.offset = next.offset;
tL_messageEntityCode.length = next.length;
this.entitiesCopy.add(tL_messageEntityCode);
} else if (next instanceof TLRPC.TL_messageEntityStrike) {
TLRPC.TL_messageEntityStrike tL_messageEntityStrike = new TLRPC.TL_messageEntityStrike();
tL_messageEntityStrike.offset = next.offset;
tL_messageEntityStrike.length = next.length;
this.entitiesCopy.add(tL_messageEntityStrike);
} else if (next instanceof TLRPC.TL_messageEntityBlockquote) {
TLRPC.TL_messageEntityBlockquote tL_messageEntityBlockquote = new TLRPC.TL_messageEntityBlockquote();
tL_messageEntityBlockquote.offset = next.offset;
tL_messageEntityBlockquote.length = next.length;
this.entitiesCopy.add(tL_messageEntityBlockquote);
} else if (next instanceof TLRPC.TL_messageEntityUnderline) {
TLRPC.TL_messageEntityUnderline tL_messageEntityUnderline = new TLRPC.TL_messageEntityUnderline();
tL_messageEntityUnderline.offset = next.offset;
tL_messageEntityUnderline.length = next.length;
this.entitiesCopy.add(tL_messageEntityUnderline);
} else if (next instanceof TLRPC.TL_messageEntityPhone) {
TLRPC.TL_messageEntityPhone tL_messageEntityPhone = new TLRPC.TL_messageEntityPhone();
tL_messageEntityPhone.offset = next.offset;
tL_messageEntityPhone.length = next.length;
this.entitiesCopy.add(tL_messageEntityPhone);
}
}
}
public CharSequence updateMetionText(CharSequence charSequence, ArrayList<TLRPC.MessageEntity> arrayList) {
if (arrayList == null || arrayList.isEmpty()) {
return charSequence;
}
SpannableString valueOf = SpannableString.valueOf(charSequence);
CharSequence spannableString = new SpannableString("");
URLSpan[] uRLSpanArr = (URLSpan[]) valueOf.getSpans(0, charSequence.length(), URLSpan.class);
ArrayList arrayList2 = new ArrayList();
entityCopy(arrayList);
Collections.sort(this.entitiesCopy, new Comparator() {
@Override
public final int compare(Object obj, Object obj2) {
return MessageObject.lambda$updateMetionText$0((TLRPC.MessageEntity) obj, (TLRPC.MessageEntity) obj2);
}
});
int size = this.entitiesCopy.size();
for (int i = 0; i < size; i++) {
TLRPC.MessageEntity messageEntity = this.entitiesCopy.get(i);
if (messageEntity.length > 0 && messageEntity.offset >= 0 && messageEntity.offset < charSequence.length()) {
if (messageEntity.offset + messageEntity.length > charSequence.length()) {
messageEntity.length = charSequence.length() - messageEntity.offset;
}
boolean z = messageEntity instanceof TLRPC.TL_messageEntityBold;
if ((z || (messageEntity instanceof TLRPC.TL_messageEntityItalic) || (messageEntity instanceof TLRPC.TL_messageEntityStrike) || (messageEntity instanceof TLRPC.TL_messageEntityUnderline) || (messageEntity instanceof TLRPC.TL_messageEntityBlockquote) || (messageEntity instanceof TLRPC.TL_messageEntityCode) || (messageEntity instanceof TLRPC.TL_messageEntityPre) || (messageEntity instanceof TLRPC.TL_messageEntityMentionName) || (messageEntity instanceof TLRPC.TL_inputMessageEntityMentionName) || (messageEntity instanceof TLRPC.TL_messageEntityTextUrl)) && uRLSpanArr != null && uRLSpanArr.length > 0) {
for (int i2 = 0; i2 < uRLSpanArr.length; i2++) {
if (uRLSpanArr[i2] != null) {
int spanStart = valueOf.getSpanStart(uRLSpanArr[i2]);
int spanEnd = valueOf.getSpanEnd(uRLSpanArr[i2]);
if ((messageEntity.offset <= spanStart && messageEntity.offset + messageEntity.length >= spanStart) || (messageEntity.offset <= spanEnd && messageEntity.offset + messageEntity.length >= spanEnd)) {
valueOf.removeSpan(uRLSpanArr[i2]);
uRLSpanArr[i2] = null;
}
}
}
}
TextStyleSpan.TextStyleRun textStyleRun = new TextStyleSpan.TextStyleRun();
textStyleRun.start = messageEntity.offset;
textStyleRun.end = textStyleRun.start + messageEntity.length;
if (messageEntity instanceof TLRPC.TL_messageEntityStrike) {
textStyleRun.flags = 8;
} else if (messageEntity instanceof TLRPC.TL_messageEntityUnderline) {
textStyleRun.flags = 16;
} else if (messageEntity instanceof TLRPC.TL_messageEntityBlockquote) {
textStyleRun.flags = 32;
} else if (z) {
textStyleRun.flags = 1;
} else if (messageEntity instanceof TLRPC.TL_messageEntityItalic) {
textStyleRun.flags = 2;
} else if ((messageEntity instanceof TLRPC.TL_messageEntityCode) || (messageEntity instanceof TLRPC.TL_messageEntityPre)) {
textStyleRun.flags = 4;
} else if (messageEntity instanceof TLRPC.TL_messageEntityMentionName) {
textStyleRun.flags = 64;
textStyleRun.urlEntity = messageEntity;
} else if (messageEntity instanceof TLRPC.TL_inputMessageEntityMentionName) {
textStyleRun.flags = 64;
textStyleRun.urlEntity = messageEntity;
}
int size2 = arrayList2.size();
int i3 = 0;
while (i3 < size2) {
TextStyleSpan.TextStyleRun textStyleRun2 = (TextStyleSpan.TextStyleRun) arrayList2.get(i3);
if (textStyleRun.start > textStyleRun2.start) {
if (textStyleRun.start < textStyleRun2.end) {
if (textStyleRun.end < textStyleRun2.end) {
TextStyleSpan.TextStyleRun textStyleRun3 = new TextStyleSpan.TextStyleRun(textStyleRun);
textStyleRun3.merge(textStyleRun2);
int i4 = i3 + 1;
arrayList2.add(i4, textStyleRun3);
TextStyleSpan.TextStyleRun textStyleRun4 = new TextStyleSpan.TextStyleRun(textStyleRun2);
textStyleRun4.start = textStyleRun.end;
i3 = i4 + 1;
size2 = size2 + 1 + 1;
arrayList2.add(i3, textStyleRun4);
} else if (textStyleRun.end >= textStyleRun2.end) {
TextStyleSpan.TextStyleRun textStyleRun5 = new TextStyleSpan.TextStyleRun(textStyleRun);
textStyleRun5.merge(textStyleRun2);
textStyleRun5.end = textStyleRun2.end;
i3++;
size2++;
arrayList2.add(i3, textStyleRun5);
}
int i5 = textStyleRun.start;
textStyleRun.start = textStyleRun2.end;
textStyleRun2.end = i5;
}
} else if (textStyleRun2.start < textStyleRun.end) {
int i6 = textStyleRun2.start;
if (textStyleRun.end == textStyleRun2.end) {
textStyleRun2.merge(textStyleRun);
} else if (textStyleRun.end < textStyleRun2.end) {
TextStyleSpan.TextStyleRun textStyleRun6 = new TextStyleSpan.TextStyleRun(textStyleRun2);
textStyleRun6.merge(textStyleRun);
textStyleRun6.end = textStyleRun.end;
i3++;
size2++;
arrayList2.add(i3, textStyleRun6);
textStyleRun2.start = textStyleRun.end;
} else {
TextStyleSpan.TextStyleRun textStyleRun7 = new TextStyleSpan.TextStyleRun(textStyleRun);
textStyleRun7.start = textStyleRun2.end;
i3++;
size2++;
arrayList2.add(i3, textStyleRun7);
textStyleRun2.merge(textStyleRun);
}
textStyleRun.end = i6;
}
i3++;
}
if (textStyleRun.start < textStyleRun.end) {
arrayList2.add(textStyleRun);
}
}
}
int size3 = arrayList2.size();
for (int i7 = 0; i7 < size3; i7++) {
TextStyleSpan.TextStyleRun textStyleRun8 = (TextStyleSpan.TextStyleRun) arrayList2.get(i7);
if (textStyleRun8.urlEntity instanceof TLRPC.TL_messageEntityMentionName) {
TLRPC.User user = MessagesController.getInstance(UserConfig.selectedAccount).getUser(Integer.valueOf(((TLRPC.TL_messageEntityMentionName) textStyleRun8.urlEntity).user_id));
if (user != null) {
if (TextUtils.isEmpty(spannableString)) {
spannableString = charSequence;
}
SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(spannableString);
String str = "@" + UserObject.getName(user);
if (textStyleRun8.start < 0) {
textStyleRun8.start = 0;
}
spannableStringBuilder.replace(textStyleRun8.start, textStyleRun8.end, (CharSequence) str);
int i8 = textStyleRun8.end;
textStyleRun8.end = textStyleRun8.start + str.length();
int i9 = i8 - textStyleRun8.end;
for (int i10 = 0; i10 < this.entitiesCopy.size(); i10++) {
TLRPC.MessageEntity messageEntity2 = this.entitiesCopy.get(i10);
if (messageEntity2.offset >= textStyleRun8.start) {
if (messageEntity2.offset == textStyleRun8.start) {
messageEntity2.length = str.length();
} else {
messageEntity2.offset -= i9;
}
}
}
for (int i11 = i7; i11 < size3; i11++) {
TextStyleSpan.TextStyleRun textStyleRun9 = (TextStyleSpan.TextStyleRun) arrayList2.get(i11);
textStyleRun9.start -= i9;
textStyleRun9.end -= i9;
}
valueOf = SpannableString.valueOf(spannableStringBuilder);
}
spannableString = SpannableString.valueOf(valueOf);
}
}
return (!TextUtils.isEmpty(spannableString) || TextUtils.isEmpty(charSequence)) ? spannableString : SpannableString.valueOf(charSequence);
}
public static int lambda$updateMetionText$0(TLRPC.MessageEntity messageEntity, TLRPC.MessageEntity messageEntity2) {
if (messageEntity.offset > messageEntity2.offset) {
return 1;
}
return messageEntity.offset < messageEntity2.offset ? -1 : 0;
}
public SpannableStringBuilder updateMetionText2(CharSequence charSequence, ArrayList<TLRPC.MessageEntity> arrayList, BaseFragment baseFragment) {
TLRPC.User user;
if (arrayList == null || arrayList.isEmpty()) {
return new SpannableStringBuilder(charSequence);
}
SpannableString valueOf = SpannableString.valueOf(charSequence);
SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder("");
URLSpan[] uRLSpanArr = (URLSpan[]) valueOf.getSpans(0, charSequence.length(), URLSpan.class);
ArrayList arrayList2 = new ArrayList();
entityCopy(arrayList);
Collections.sort(this.entitiesCopy, new Comparator() {
@Override
public final int compare(Object obj, Object obj2) {
return MessageObject.lambda$updateMetionText2$1((TLRPC.MessageEntity) obj, (TLRPC.MessageEntity) obj2);
}
});
int size = this.entitiesCopy.size();
for (int i = 0; i < size; i++) {
TLRPC.MessageEntity messageEntity = this.entitiesCopy.get(i);
if (messageEntity.length > 0 && messageEntity.offset >= 0 && messageEntity.offset < charSequence.length()) {
if (messageEntity.offset + messageEntity.length > charSequence.length()) {
messageEntity.length = charSequence.length() - messageEntity.offset;
}
boolean z = messageEntity instanceof TLRPC.TL_messageEntityBold;
if ((z || (messageEntity instanceof TLRPC.TL_messageEntityItalic) || (messageEntity instanceof TLRPC.TL_messageEntityStrike) || (messageEntity instanceof TLRPC.TL_messageEntityUnderline) || (messageEntity instanceof TLRPC.TL_messageEntityBlockquote) || (messageEntity instanceof TLRPC.TL_messageEntityCode) || (messageEntity instanceof TLRPC.TL_messageEntityPre) || (messageEntity instanceof TLRPC.TL_messageEntityMentionName) || (messageEntity instanceof TLRPC.TL_inputMessageEntityMentionName) || (messageEntity instanceof TLRPC.TL_messageEntityTextUrl)) && uRLSpanArr != null && uRLSpanArr.length > 0) {
for (int i2 = 0; i2 < uRLSpanArr.length; i2++) {
if (uRLSpanArr[i2] != null) {
int spanStart = valueOf.getSpanStart(uRLSpanArr[i2]);
int spanEnd = valueOf.getSpanEnd(uRLSpanArr[i2]);
if ((messageEntity.offset <= spanStart && messageEntity.offset + messageEntity.length >= spanStart) || (messageEntity.offset <= spanEnd && messageEntity.offset + messageEntity.length >= spanEnd)) {
valueOf.removeSpan(uRLSpanArr[i2]);
uRLSpanArr[i2] = null;
}
}
}
}
TextStyleSpan.TextStyleRun textStyleRun = new TextStyleSpan.TextStyleRun();
textStyleRun.start = messageEntity.offset;
textStyleRun.end = textStyleRun.start + messageEntity.length;
if (messageEntity instanceof TLRPC.TL_messageEntityStrike) {
textStyleRun.flags = 8;
} else if (messageEntity instanceof TLRPC.TL_messageEntityUnderline) {
textStyleRun.flags = 16;
} else if (messageEntity instanceof TLRPC.TL_messageEntityBlockquote) {
textStyleRun.flags = 32;
} else if (z) {
textStyleRun.flags = 1;
} else if (messageEntity instanceof TLRPC.TL_messageEntityItalic) {
textStyleRun.flags = 2;
} else if ((messageEntity instanceof TLRPC.TL_messageEntityCode) || (messageEntity instanceof TLRPC.TL_messageEntityPre)) {
textStyleRun.flags = 4;
} else if (messageEntity instanceof TLRPC.TL_messageEntityMentionName) {
textStyleRun.flags = 64;
textStyleRun.urlEntity = messageEntity;
} else if (messageEntity instanceof TLRPC.TL_inputMessageEntityMentionName) {
textStyleRun.flags = 64;
textStyleRun.urlEntity = messageEntity;
}
int size2 = arrayList2.size();
int i3 = 0;
while (i3 < size2) {
TextStyleSpan.TextStyleRun textStyleRun2 = (TextStyleSpan.TextStyleRun) arrayList2.get(i3);
if (textStyleRun.start > textStyleRun2.start) {
if (textStyleRun.start < textStyleRun2.end) {
if (textStyleRun.end < textStyleRun2.end) {
TextStyleSpan.TextStyleRun textStyleRun3 = new TextStyleSpan.TextStyleRun(textStyleRun);
textStyleRun3.merge(textStyleRun2);
int i4 = i3 + 1;
arrayList2.add(i4, textStyleRun3);
TextStyleSpan.TextStyleRun textStyleRun4 = new TextStyleSpan.TextStyleRun(textStyleRun2);
textStyleRun4.start = textStyleRun.end;
i3 = i4 + 1;
size2 = size2 + 1 + 1;
arrayList2.add(i3, textStyleRun4);
} else if (textStyleRun.end >= textStyleRun2.end) {
TextStyleSpan.TextStyleRun textStyleRun5 = new TextStyleSpan.TextStyleRun(textStyleRun);
textStyleRun5.merge(textStyleRun2);
textStyleRun5.end = textStyleRun2.end;
i3++;
size2++;
arrayList2.add(i3, textStyleRun5);
}
int i5 = textStyleRun.start;
textStyleRun.start = textStyleRun2.end;
textStyleRun2.end = i5;
}
} else if (textStyleRun2.start < textStyleRun.end) {
int i6 = textStyleRun2.start;
if (textStyleRun.end == textStyleRun2.end) {
textStyleRun2.merge(textStyleRun);
} else if (textStyleRun.end < textStyleRun2.end) {
TextStyleSpan.TextStyleRun textStyleRun6 = new TextStyleSpan.TextStyleRun(textStyleRun2);
textStyleRun6.merge(textStyleRun);
textStyleRun6.end = textStyleRun.end;
i3++;
size2++;
arrayList2.add(i3, textStyleRun6);
textStyleRun2.start = textStyleRun.end;
} else {
TextStyleSpan.TextStyleRun textStyleRun7 = new TextStyleSpan.TextStyleRun(textStyleRun);
textStyleRun7.start = textStyleRun2.end;
i3++;
size2++;
arrayList2.add(i3, textStyleRun7);
textStyleRun2.merge(textStyleRun);
}
textStyleRun.end = i6;
}
i3++;
}
if (textStyleRun.start < textStyleRun.end) {
arrayList2.add(textStyleRun);
}
}
}
int size3 = arrayList2.size();
int i7 = 0;
SpannableStringBuilder spannableStringBuilder2 = spannableStringBuilder;
while (i7 < size3) {
TextStyleSpan.TextStyleRun textStyleRun8 = (TextStyleSpan.TextStyleRun) arrayList2.get(i7);
if ((textStyleRun8.urlEntity instanceof TLRPC.TL_messageEntityMentionName) && (user = MessagesController.getInstance(UserConfig.selectedAccount).getUser(Integer.valueOf(((TLRPC.TL_messageEntityMentionName) textStyleRun8.urlEntity).user_id))) != null) {
boolean isEmpty = TextUtils.isEmpty(spannableStringBuilder2);
CharSequence charSequence2 = spannableStringBuilder2;
if (isEmpty) {
charSequence2 = charSequence;
}
SpannableStringBuilder spannableStringBuilder3 = new SpannableStringBuilder(charSequence2);
String str = "@" + UserObject.getName(user) + " ";
spannableStringBuilder3.replace(textStyleRun8.start, textStyleRun8.end, (CharSequence) str);
int i8 = textStyleRun8.end;
textStyleRun8.end = textStyleRun8.start + str.length();
spannableStringBuilder3.setSpan(new ForegroundColorSpan(-13915656), textStyleRun8.start, textStyleRun8.end, 33);
spannableStringBuilder3.setSpan(new SysNotifyAtTextClickableSpan(user.id, baseFragment), textStyleRun8.start, textStyleRun8.end, 33);
int i9 = i8 - textStyleRun8.end;
for (int i10 = 0; i10 < this.entitiesCopy.size(); i10++) {
TLRPC.MessageEntity messageEntity2 = this.entitiesCopy.get(i10);
if (messageEntity2.offset >= textStyleRun8.start) {
if (messageEntity2.offset == textStyleRun8.start) {
messageEntity2.length = str.length();
} else {
messageEntity2.offset -= i9;
}
}
}
for (int i11 = i7; i11 < size3; i11++) {
TextStyleSpan.TextStyleRun textStyleRun9 = (TextStyleSpan.TextStyleRun) arrayList2.get(i11);
textStyleRun9.start -= i9;
textStyleRun9.end -= i9;
}
spannableStringBuilder2 = spannableStringBuilder3;
}
i7++;
spannableStringBuilder2 = spannableStringBuilder2;
}
return (!TextUtils.isEmpty(spannableStringBuilder2) || TextUtils.isEmpty(charSequence)) ? spannableStringBuilder2 : SpannableStringBuilder.valueOf(charSequence);
}
public static int lambda$updateMetionText2$1(TLRPC.MessageEntity messageEntity, TLRPC.MessageEntity messageEntity2) {
if (messageEntity.offset > messageEntity2.offset) {
return 1;
}
return messageEntity.offset < messageEntity2.offset ? -1 : 0;
}
private void createDateArray(int i, TLRPC.TL_channelAdminLogEvent tL_channelAdminLogEvent, ArrayList<MessageObject> arrayList, HashMap<String, ArrayList<MessageObject>> hashMap) {
if (hashMap.get(this.dateKey) == null) {
hashMap.put(this.dateKey, new ArrayList<>());
TLRPC.TL_message tL_message = new TLRPC.TL_message();
tL_message.message = LocaleController.formatDateChat(tL_channelAdminLogEvent.date);
tL_message.id = 0;
tL_message.date = tL_channelAdminLogEvent.date;
MessageObject messageObject = new MessageObject(i, tL_message, false);
messageObject.type = 10;
messageObject.contentType = 1;
messageObject.isDateObject = true;
arrayList.add(messageObject);
}
}
private void checkEmojiOnly(int[] iArr) {
TextPaint textPaint;
int dp;
if (iArr != null) {
if (iArr[0] < 1 || iArr[0] > 3) {
return;
}
int i = iArr[0];
if (i == 1) {
textPaint = Theme.chat_msgTextPaintOneEmoji;
dp = AndroidUtilities.dp(32.0f);
this.emojiOnlyCount = 1;
} else if (i == 2) {
textPaint = Theme.chat_msgTextPaintTwoEmoji;
int dp2 = AndroidUtilities.dp(28.0f);
this.emojiOnlyCount = 2;
dp = dp2;
} else {
textPaint = Theme.chat_msgTextPaintThreeEmoji;
dp = AndroidUtilities.dp(24.0f);
this.emojiOnlyCount = 3;
}
CharSequence charSequence = this.messageText;
Emoji.EmojiSpan[] emojiSpanArr = (Emoji.EmojiSpan[]) ((Spannable) charSequence).getSpans(0, charSequence.length(), Emoji.EmojiSpan.class);
if (emojiSpanArr == null || emojiSpanArr.length <= 0) {
return;
}
for (Emoji.EmojiSpan emojiSpan : emojiSpanArr) {
emojiSpan.replaceFontMetrics(textPaint.getFontMetricsInt(), dp);
}
}
}
public MessageObject(int i, TLRPC.TL_channelAdminLogEvent tL_channelAdminLogEvent, ArrayList<MessageObject> arrayList, HashMap<String, ArrayList<MessageObject>> hashMap, TLRPC.Chat chat, int[] iArr) {
String formatPluralString;
TLRPC.Message tL_message;
int i2;
String str;
int i3;
String str2;
int i4;
String str3;
String string;
StringBuilder sb;
boolean z;
char c;
String formatPluralString2;
int i5;
boolean z2;
StringBuilder sb2;
int i6;
String str4;
ArrayList<MessageObject> arrayList2;
TextPaint textPaint;
this.type = 1000;
this.forceSeekTo = -1.0f;
this.entitiesCopy = new ArrayList<>();
this.currentEvent = tL_channelAdminLogEvent;
this.currentAccount = i;
TLRPC.User user = tL_channelAdminLogEvent.user_id > 0 ? MessagesController.getInstance(this.currentAccount).getUser(Integer.valueOf(tL_channelAdminLogEvent.user_id)) : null;
GregorianCalendar gregorianCalendar = new GregorianCalendar();
gregorianCalendar.setTimeInMillis(tL_channelAdminLogEvent.date * 1000);
int i7 = gregorianCalendar.get(6);
int i8 = gregorianCalendar.get(1);
int i9 = gregorianCalendar.get(2);
this.dateKey = String.format("%d_%02d_%02d", Integer.valueOf(i8), Integer.valueOf(i9), Integer.valueOf(i7));
this.monthKey = String.format("%d_%02d", Integer.valueOf(i8), Integer.valueOf(i9));
TLRPC.TL_peerChannel tL_peerChannel = new TLRPC.TL_peerChannel();
tL_peerChannel.channel_id = chat.id;
if (tL_channelAdminLogEvent.action instanceof TLRPC.TL_channelAdminLogEventActionChangeTitle) {
String str5 = ((TLRPC.TL_channelAdminLogEventActionChangeTitle) tL_channelAdminLogEvent.action).new_value;
if (chat.megagroup) {
this.messageText = replaceWithLink(LocaleController.formatString("EventLogEditedGroupTitle", R.string.EventLogEditedGroupTitle, str5), "un1", user);
} else {
this.messageText = replaceWithLink(LocaleController.formatString("EventLogEditedChannelTitle", R.string.EventLogEditedChannelTitle, str5), "un1", user);
}
} else if (tL_channelAdminLogEvent.action instanceof TLRPC.TL_channelAdminLogEventActionChangePhoto) {
this.messageOwner = new TLRPC.TL_messageService();
if (tL_channelAdminLogEvent.action.new_photo instanceof TLRPC.TL_photoEmpty) {
this.messageOwner.action = new TLRPC.TL_messageActionChatDeletePhoto();
if (chat.megagroup) {
this.messageText = replaceWithLink(LocaleController.getString("EventLogRemovedWGroupPhoto", R.string.EventLogRemovedWGroupPhoto), "un1", user);
} else {
this.messageText = replaceWithLink(LocaleController.getString("EventLogRemovedChannelPhoto", R.string.EventLogRemovedChannelPhoto), "un1", user);
}
} else {
this.messageOwner.action = new TLRPC.TL_messageActionChatEditPhoto();
this.messageOwner.action.photo = tL_channelAdminLogEvent.action.new_photo;
if (chat.megagroup) {
this.messageText = replaceWithLink(LocaleController.getString("EventLogEditedGroupPhoto", R.string.EventLogEditedGroupPhoto), "un1", user);
} else {
this.messageText = replaceWithLink(LocaleController.getString("EventLogEditedChannelPhoto", R.string.EventLogEditedChannelPhoto), "un1", user);
}
}
} else if (tL_channelAdminLogEvent.action instanceof TLRPC.TL_channelAdminLogEventActionParticipantJoin) {
if (chat.megagroup) {
this.messageText = replaceWithLink(LocaleController.getString("EventLogGroupJoined", R.string.EventLogGroupJoined), "un1", user);
} else {
this.messageText = replaceWithLink(LocaleController.getString("EventLogChannelJoined", R.string.EventLogChannelJoined), "un1", user);
}
} else if (tL_channelAdminLogEvent.action instanceof TLRPC.TL_channelAdminLogEventActionParticipantLeave) {
TLRPC.TL_messageService tL_messageService = new TLRPC.TL_messageService();
this.messageOwner = tL_messageService;
tL_messageService.action = new TLRPC.TL_messageActionChatDeleteUser();
this.messageOwner.action.user_id = tL_channelAdminLogEvent.user_id;
if (chat.megagroup) {
this.messageText = replaceWithLink(LocaleController.getString("EventLogLeftGroup", R.string.EventLogLeftGroup), "un1", user);
} else {
this.messageText = replaceWithLink(LocaleController.getString("EventLogLeftChannel", R.string.EventLogLeftChannel), "un1", user);
}
} else if (tL_channelAdminLogEvent.action instanceof TLRPC.TL_channelAdminLogEventActionParticipantInvite) {
TLRPC.TL_messageService tL_messageService2 = new TLRPC.TL_messageService();
this.messageOwner = tL_messageService2;
tL_messageService2.action = new TLRPC.TL_messageActionChatAddUser();
TLObject user2 = MessagesController.getInstance(this.currentAccount).getUser(Integer.valueOf(tL_channelAdminLogEvent.action.participant.user_id));
if (tL_channelAdminLogEvent.action.participant.user_id == this.messageOwner.from_id) {
if (chat.megagroup) {
this.messageText = replaceWithLink(LocaleController.getString("EventLogGroupJoined", R.string.EventLogGroupJoined), "un1", user);
} else {
this.messageText = replaceWithLink(LocaleController.getString("EventLogChannelJoined", R.string.EventLogChannelJoined), "un1", user);
}
} else {
CharSequence replaceWithLink = replaceWithLink(LocaleController.getString("EventLogAdded", R.string.EventLogAdded), "un2", user2);
this.messageText = replaceWithLink;
this.messageText = replaceWithLink(replaceWithLink, "un1", user);
}
} else if (tL_channelAdminLogEvent.action instanceof TLRPC.TL_channelAdminLogEventActionParticipantToggleAdmin) {
this.messageOwner = new TLRPC.TL_message();
TLRPC.User user3 = MessagesController.getInstance(this.currentAccount).getUser(Integer.valueOf(tL_channelAdminLogEvent.action.prev_participant.user_id));
if (!(tL_channelAdminLogEvent.action.prev_participant instanceof TLRPC.TL_channelParticipantCreator) && (tL_channelAdminLogEvent.action.new_participant instanceof TLRPC.TL_channelParticipantCreator)) {
String string2 = LocaleController.getString("EventLogChangedOwnership", R.string.EventLogChangedOwnership);
sb2 = new StringBuilder(String.format(string2, getUserName(user3, this.messageOwner.entities, string2.indexOf("%1$s"))));
} else {
String string3 = LocaleController.getString("EventLogPromoted", R.string.EventLogPromoted);
StringBuilder sb3 = new StringBuilder(String.format(string3, getUserName(user3, this.messageOwner.entities, string3.indexOf("%1$s"))));
sb3.append("\n");
TLRPC.TL_chatAdminRights tL_chatAdminRights = tL_channelAdminLogEvent.action.prev_participant.admin_rights;
TLRPC.TL_chatAdminRights tL_chatAdminRights2 = tL_channelAdminLogEvent.action.new_participant.admin_rights;
tL_chatAdminRights = tL_chatAdminRights == null ? new TLRPC.TL_chatAdminRights() : tL_chatAdminRights;
tL_chatAdminRights2 = tL_chatAdminRights2 == null ? new TLRPC.TL_chatAdminRights() : tL_chatAdminRights2;
if (!TextUtils.equals(tL_channelAdminLogEvent.action.prev_participant.rank, tL_channelAdminLogEvent.action.new_participant.rank)) {
if (TextUtils.isEmpty(tL_channelAdminLogEvent.action.new_participant.rank)) {
sb3.append('\n');
sb3.append('-');
sb3.append(' ');
sb3.append(LocaleController.getString("EventLogPromotedRemovedTitle", R.string.EventLogPromotedRemovedTitle));
} else {
sb3.append('\n');
sb3.append('+');
sb3.append(' ');
sb3.append(LocaleController.formatString("EventLogPromotedTitle", R.string.EventLogPromotedTitle, tL_channelAdminLogEvent.action.new_participant.rank));
if (tL_chatAdminRights.change_info != tL_chatAdminRights2.change_info) {
sb3.append('\n');
sb3.append(tL_chatAdminRights2.change_info ? '+' : '-');
sb3.append(' ');
if (chat.megagroup) {
i6 = R.string.EventLogPromotedChangeGroupInfo;
str4 = "EventLogPromotedChangeGroupInfo";
} else {
i6 = R.string.EventLogPromotedChangeChannelInfo;
str4 = "EventLogPromotedChangeChannelInfo";
}
sb3.append(LocaleController.getString(str4, i6));
}
if (!chat.megagroup) {
if (tL_chatAdminRights.post_messages != tL_chatAdminRights2.post_messages) {
sb3.append('\n');
sb3.append(tL_chatAdminRights2.post_messages ? '+' : '-');
sb3.append(' ');
sb3.append(LocaleController.getString("EventLogPromotedPostMessages", R.string.EventLogPromotedPostMessages));
}
if (tL_chatAdminRights.edit_messages != tL_chatAdminRights2.edit_messages) {
sb3.append('\n');
sb3.append(tL_chatAdminRights2.edit_messages ? '+' : '-');
sb3.append(' ');
sb3.append(LocaleController.getString("EventLogPromotedEditMessages", R.string.EventLogPromotedEditMessages));
}
}
if (tL_chatAdminRights.delete_messages != tL_chatAdminRights2.delete_messages) {
sb3.append('\n');
sb3.append(tL_chatAdminRights2.delete_messages ? '+' : '-');
sb3.append(' ');
sb3.append(LocaleController.getString("EventLogPromotedDeleteMessages", R.string.EventLogPromotedDeleteMessages));
}
if (tL_chatAdminRights.add_admins != tL_chatAdminRights2.add_admins) {
sb3.append('\n');
sb3.append(tL_chatAdminRights2.add_admins ? '+' : '-');
sb3.append(' ');
sb3.append(LocaleController.getString("EventLogPromotedAddAdmins", R.string.EventLogPromotedAddAdmins));
}
if (chat.megagroup && tL_chatAdminRights.ban_users != tL_chatAdminRights2.ban_users) {
sb3.append('\n');
sb3.append(!tL_chatAdminRights2.ban_users ? '+' : '-');
sb3.append(' ');
sb3.append(LocaleController.getString("EventLogPromotedBanUsers", R.string.EventLogPromotedBanUsers));
}
if (tL_chatAdminRights.invite_users != tL_chatAdminRights2.invite_users) {
sb3.append('\n');
sb3.append(tL_chatAdminRights2.invite_users ? '+' : '-');
sb3.append(' ');
sb3.append(LocaleController.getString("EventLogPromotedAddUsers", R.string.EventLogPromotedAddUsers));
}
if (chat.megagroup && tL_chatAdminRights.pin_messages != tL_chatAdminRights2.pin_messages) {
sb3.append('\n');
sb3.append(!tL_chatAdminRights2.pin_messages ? '+' : '-');
sb3.append(' ');
sb3.append(LocaleController.getString("EventLogPromotedPinMessages", R.string.EventLogPromotedPinMessages));
}
sb2 = sb3;
}
}
if (tL_chatAdminRights.change_info != tL_chatAdminRights2.change_info) {
}
if (!chat.megagroup) {
}
if (tL_chatAdminRights.delete_messages != tL_chatAdminRights2.delete_messages) {
}
if (tL_chatAdminRights.add_admins != tL_chatAdminRights2.add_admins) {
}
if (chat.megagroup) {
sb3.append('\n');
sb3.append(!tL_chatAdminRights2.ban_users ? '+' : '-');
sb3.append(' ');
sb3.append(LocaleController.getString("EventLogPromotedBanUsers", R.string.EventLogPromotedBanUsers));
}
if (tL_chatAdminRights.invite_users != tL_chatAdminRights2.invite_users) {
}
if (chat.megagroup) {
sb3.append('\n');
sb3.append(!tL_chatAdminRights2.pin_messages ? '+' : '-');
sb3.append(' ');
sb3.append(LocaleController.getString("EventLogPromotedPinMessages", R.string.EventLogPromotedPinMessages));
}
sb2 = sb3;
}
this.messageText = sb2.toString();
} else if (tL_channelAdminLogEvent.action instanceof TLRPC.TL_channelAdminLogEventActionDefaultBannedRights) {
TLRPC.TL_channelAdminLogEventActionDefaultBannedRights tL_channelAdminLogEventActionDefaultBannedRights = (TLRPC.TL_channelAdminLogEventActionDefaultBannedRights) tL_channelAdminLogEvent.action;
this.messageOwner = new TLRPC.TL_message();
TLRPC.TL_chatBannedRights tL_chatBannedRights = tL_channelAdminLogEventActionDefaultBannedRights.prev_banned_rights;
TLRPC.TL_chatBannedRights tL_chatBannedRights2 = tL_channelAdminLogEventActionDefaultBannedRights.new_banned_rights;
StringBuilder sb4 = new StringBuilder(LocaleController.getString("EventLogDefaultPermissions", R.string.EventLogDefaultPermissions));
tL_chatBannedRights = tL_chatBannedRights == null ? new TLRPC.TL_chatBannedRights() : tL_chatBannedRights;
tL_chatBannedRights2 = tL_chatBannedRights2 == null ? new TLRPC.TL_chatBannedRights() : tL_chatBannedRights2;
if (tL_chatBannedRights.send_messages != tL_chatBannedRights2.send_messages) {
sb4.append('\n');
sb4.append('\n');
sb4.append(!tL_chatBannedRights2.send_messages ? '+' : '-');
sb4.append(' ');
sb4.append(LocaleController.getString("EventLogRestrictedSendMessages", R.string.EventLogRestrictedSendMessages));
z2 = true;
} else {
z2 = false;
}
if (tL_chatBannedRights.send_stickers != tL_chatBannedRights2.send_stickers || tL_chatBannedRights.send_inline != tL_chatBannedRights2.send_inline || tL_chatBannedRights.send_gifs != tL_chatBannedRights2.send_gifs || tL_chatBannedRights.send_games != tL_chatBannedRights2.send_games) {
if (!z2) {
sb4.append('\n');
z2 = true;
}
sb4.append('\n');
sb4.append(!tL_chatBannedRights2.send_stickers ? '+' : '-');
sb4.append(' ');
sb4.append(LocaleController.getString("EventLogRestrictedSendStickers", R.string.EventLogRestrictedSendStickers));
}
if (tL_chatBannedRights.send_media != tL_chatBannedRights2.send_media) {
if (!z2) {
sb4.append('\n');
z2 = true;
}
sb4.append('\n');
sb4.append(!tL_chatBannedRights2.send_media ? '+' : '-');
sb4.append(' ');
sb4.append(LocaleController.getString("EventLogRestrictedSendMedia", R.string.EventLogRestrictedSendMedia));
}
if (tL_chatBannedRights.send_polls != tL_chatBannedRights2.send_polls) {
if (!z2) {
sb4.append('\n');
z2 = true;
}
sb4.append('\n');
sb4.append(!tL_chatBannedRights2.send_polls ? '+' : '-');
sb4.append(' ');
sb4.append(LocaleController.getString("EventLogRestrictedSendPolls", R.string.EventLogRestrictedSendPolls));
}
if (tL_chatBannedRights.embed_links != tL_chatBannedRights2.embed_links) {
if (!z2) {
sb4.append('\n');
z2 = true;
}
sb4.append('\n');
sb4.append(!tL_chatBannedRights2.embed_links ? '+' : '-');
sb4.append(' ');
sb4.append(LocaleController.getString("EventLogRestrictedSendEmbed", R.string.EventLogRestrictedSendEmbed));
}
if (tL_chatBannedRights.change_info != tL_chatBannedRights2.change_info) {
if (!z2) {
sb4.append('\n');
z2 = true;
}
sb4.append('\n');
sb4.append(!tL_chatBannedRights2.change_info ? '+' : '-');
sb4.append(' ');
sb4.append(LocaleController.getString("EventLogRestrictedChangeInfo", R.string.EventLogRestrictedChangeInfo));
}
if (tL_chatBannedRights.invite_users != tL_chatBannedRights2.invite_users) {
if (!z2) {
sb4.append('\n');
z2 = true;
}
sb4.append('\n');
sb4.append(!tL_chatBannedRights2.invite_users ? '+' : '-');
sb4.append(' ');
sb4.append(LocaleController.getString("EventLogRestrictedInviteUsers", R.string.EventLogRestrictedInviteUsers));
}
if (tL_chatBannedRights.pin_messages != tL_chatBannedRights2.pin_messages) {
if (!z2) {
sb4.append('\n');
}
sb4.append('\n');
sb4.append(!tL_chatBannedRights2.pin_messages ? '+' : '-');
sb4.append(' ');
sb4.append(LocaleController.getString("EventLogRestrictedPinMessages", R.string.EventLogRestrictedPinMessages));
}
this.messageText = sb4.toString();
} else if (tL_channelAdminLogEvent.action instanceof TLRPC.TL_channelAdminLogEventActionParticipantToggleBan) {
this.messageOwner = new TLRPC.TL_message();
TLRPC.User user4 = MessagesController.getInstance(this.currentAccount).getUser(Integer.valueOf(tL_channelAdminLogEvent.action.prev_participant.user_id));
TLRPC.TL_chatBannedRights tL_chatBannedRights3 = tL_channelAdminLogEvent.action.prev_participant.banned_rights;
TLRPC.TL_chatBannedRights tL_chatBannedRights4 = tL_channelAdminLogEvent.action.new_participant.banned_rights;
if (chat.megagroup && (tL_chatBannedRights4 == null || !tL_chatBannedRights4.view_messages || (tL_chatBannedRights4 != null && tL_chatBannedRights3 != null && tL_chatBannedRights4.until_date != tL_chatBannedRights3.until_date))) {
if (tL_chatBannedRights4 != null && !AndroidUtilities.isBannedForever(tL_chatBannedRights4)) {
sb = new StringBuilder();
int i10 = tL_chatBannedRights4.until_date - tL_channelAdminLogEvent.date;
int i11 = ((i10 / 60) / 60) / 24;
int i12 = i10 - (((i11 * 60) * 60) * 24);
int i13 = (i12 / 60) / 60;
int i14 = (i12 - ((i13 * 60) * 60)) / 60;
int i15 = 3;
int i16 = 0;
int i17 = 0;
while (i16 < i15) {
if (i16 == 0) {
if (i11 != 0) {
formatPluralString2 = LocaleController.formatPluralString("Days", i11);
i17++;
}
formatPluralString2 = null;
} else if (i16 == 1) {
if (i13 != 0) {
formatPluralString2 = LocaleController.formatPluralString("Hours", i13);
i17++;
}
formatPluralString2 = null;
} else {
if (i14 != 0) {
formatPluralString2 = LocaleController.formatPluralString("Minutes", i14);
i17++;
}
formatPluralString2 = null;
}
int i18 = i17;
int i19 = i11;
if (formatPluralString2 != null) {
if (sb.length() > 0) {
i5 = i13;
sb.append(", ");
} else {
i5 = i13;
}
sb.append(formatPluralString2);
} else {
i5 = i13;
}
if (i18 == 2) {
break;
}
i16++;
i13 = i5;
i15 = 3;
i17 = i18;
i11 = i19;
}
} else {
sb = new StringBuilder(LocaleController.getString("UserRestrictionsUntilForever", R.string.UserRestrictionsUntilForever));
}
String string4 = LocaleController.getString("EventLogRestrictedUntil", R.string.EventLogRestrictedUntil);
StringBuilder sb5 = new StringBuilder(String.format(string4, getUserName(user4, this.messageOwner.entities, string4.indexOf("%1$s")), sb.toString()));
tL_chatBannedRights3 = tL_chatBannedRights3 == null ? new TLRPC.TL_chatBannedRights() : tL_chatBannedRights3;
tL_chatBannedRights4 = tL_chatBannedRights4 == null ? new TLRPC.TL_chatBannedRights() : tL_chatBannedRights4;
if (tL_chatBannedRights3.view_messages != tL_chatBannedRights4.view_messages) {
sb5.append('\n');
sb5.append('\n');
sb5.append(!tL_chatBannedRights4.view_messages ? '+' : '-');
sb5.append(' ');
sb5.append(LocaleController.getString("EventLogRestrictedReadMessages", R.string.EventLogRestrictedReadMessages));
z = true;
} else {
z = false;
}
if (tL_chatBannedRights3.send_messages != tL_chatBannedRights4.send_messages) {
if (!z) {
sb5.append('\n');
z = true;
}
sb5.append('\n');
sb5.append(!tL_chatBannedRights4.send_messages ? '+' : '-');
sb5.append(' ');
sb5.append(LocaleController.getString("EventLogRestrictedSendMessages", R.string.EventLogRestrictedSendMessages));
}
if (tL_chatBannedRights3.send_stickers != tL_chatBannedRights4.send_stickers || tL_chatBannedRights3.send_inline != tL_chatBannedRights4.send_inline || tL_chatBannedRights3.send_gifs != tL_chatBannedRights4.send_gifs || tL_chatBannedRights3.send_games != tL_chatBannedRights4.send_games) {
if (!z) {
sb5.append('\n');
z = true;
}
sb5.append('\n');
sb5.append(!tL_chatBannedRights4.send_stickers ? '+' : '-');
sb5.append(' ');
sb5.append(LocaleController.getString("EventLogRestrictedSendStickers", R.string.EventLogRestrictedSendStickers));
}
if (tL_chatBannedRights3.send_media != tL_chatBannedRights4.send_media) {
if (!z) {
sb5.append('\n');
z = true;
}
sb5.append('\n');
sb5.append(!tL_chatBannedRights4.send_media ? '+' : '-');
sb5.append(' ');
sb5.append(LocaleController.getString("EventLogRestrictedSendMedia", R.string.EventLogRestrictedSendMedia));
}
if (tL_chatBannedRights3.send_polls != tL_chatBannedRights4.send_polls) {
if (!z) {
sb5.append('\n');
z = true;
}
sb5.append('\n');
sb5.append(!tL_chatBannedRights4.send_polls ? '+' : '-');
sb5.append(' ');
sb5.append(LocaleController.getString("EventLogRestrictedSendPolls", R.string.EventLogRestrictedSendPolls));
}
if (tL_chatBannedRights3.embed_links != tL_chatBannedRights4.embed_links) {
if (!z) {
sb5.append('\n');
z = true;
}
sb5.append('\n');
sb5.append(!tL_chatBannedRights4.embed_links ? '+' : '-');
sb5.append(' ');
sb5.append(LocaleController.getString("EventLogRestrictedSendEmbed", R.string.EventLogRestrictedSendEmbed));
}
if (tL_chatBannedRights3.change_info != tL_chatBannedRights4.change_info) {
if (!z) {
sb5.append('\n');
z = true;
}
sb5.append('\n');
sb5.append(!tL_chatBannedRights4.change_info ? '+' : '-');
sb5.append(' ');
sb5.append(LocaleController.getString("EventLogRestrictedChangeInfo", R.string.EventLogRestrictedChangeInfo));
}
if (tL_chatBannedRights3.invite_users != tL_chatBannedRights4.invite_users) {
if (!z) {
sb5.append('\n');
z = true;
}
sb5.append('\n');
sb5.append(!tL_chatBannedRights4.invite_users ? '+' : '-');
sb5.append(' ');
sb5.append(LocaleController.getString("EventLogRestrictedInviteUsers", R.string.EventLogRestrictedInviteUsers));
}
if (tL_chatBannedRights3.pin_messages != tL_chatBannedRights4.pin_messages) {
if (z) {
c = '\n';
} else {
c = '\n';
sb5.append('\n');
}
sb5.append(c);
sb5.append(!tL_chatBannedRights4.pin_messages ? '+' : '-');
sb5.append(' ');
sb5.append(LocaleController.getString("EventLogRestrictedPinMessages", R.string.EventLogRestrictedPinMessages));
}
this.messageText = sb5.toString();
} else {
if (tL_chatBannedRights4 != null && (tL_chatBannedRights3 == null || tL_chatBannedRights4.view_messages)) {
string = LocaleController.getString("EventLogChannelRestricted", R.string.EventLogChannelRestricted);
} else {
string = LocaleController.getString("EventLogChannelUnrestricted", R.string.EventLogChannelUnrestricted);
}
this.messageText = String.format(string, getUserName(user4, this.messageOwner.entities, string.indexOf("%1$s")));
}
} else if (tL_channelAdminLogEvent.action instanceof TLRPC.TL_channelAdminLogEventActionUpdatePinned) {
if (user != null && user.id == 136817688 && tL_channelAdminLogEvent.action.message.fwd_from != null) {
TLObject chat2 = MessagesController.getInstance(this.currentAccount).getChat(Integer.valueOf(tL_channelAdminLogEvent.action.message.fwd_from.channel_id));
if (tL_channelAdminLogEvent.action.message instanceof TLRPC.TL_messageEmpty) {
this.messageText = replaceWithLink(LocaleController.getString("EventLogUnpinnedMessages", R.string.EventLogUnpinnedMessages), "un1", chat2);
} else {
this.messageText = replaceWithLink(LocaleController.getString("EventLogPinnedMessages", R.string.EventLogPinnedMessages), "un1", chat2);
}
} else if (tL_channelAdminLogEvent.action.message instanceof TLRPC.TL_messageEmpty) {
this.messageText = replaceWithLink(LocaleController.getString("EventLogUnpinnedMessages", R.string.EventLogUnpinnedMessages), "un1", user);
} else {
this.messageText = replaceWithLink(LocaleController.getString("EventLogPinnedMessages", R.string.EventLogPinnedMessages), "un1", user);
}
} else if (tL_channelAdminLogEvent.action instanceof TLRPC.TL_channelAdminLogEventActionStopPoll) {
this.messageText = replaceWithLink(LocaleController.getString("EventLogStopPoll", R.string.EventLogStopPoll), "un1", user);
} else if (tL_channelAdminLogEvent.action instanceof TLRPC.TL_channelAdminLogEventActionToggleSignatures) {
if (((TLRPC.TL_channelAdminLogEventActionToggleSignatures) tL_channelAdminLogEvent.action).new_value) {
this.messageText = replaceWithLink(LocaleController.getString("EventLogToggledSignaturesOn", R.string.EventLogToggledSignaturesOn), "un1", user);
} else {
this.messageText = replaceWithLink(LocaleController.getString("EventLogToggledSignaturesOff", R.string.EventLogToggledSignaturesOff), "un1", user);
}
} else if (tL_channelAdminLogEvent.action instanceof TLRPC.TL_channelAdminLogEventActionToggleInvites) {
if (((TLRPC.TL_channelAdminLogEventActionToggleInvites) tL_channelAdminLogEvent.action).new_value) {
this.messageText = replaceWithLink(LocaleController.getString("EventLogToggledInvitesOn", R.string.EventLogToggledInvitesOn), "un1", user);
} else {
this.messageText = replaceWithLink(LocaleController.getString("EventLogToggledInvitesOff", R.string.EventLogToggledInvitesOff), "un1", user);
}
} else if (tL_channelAdminLogEvent.action instanceof TLRPC.TL_channelAdminLogEventActionDeleteMessage) {
this.messageText = replaceWithLink(LocaleController.getString("EventLogDeletedMessages", R.string.EventLogDeletedMessages), "un1", user);
} else if (tL_channelAdminLogEvent.action instanceof TLRPC.TL_channelAdminLogEventActionChangeLinkedChat) {
int i20 = ((TLRPC.TL_channelAdminLogEventActionChangeLinkedChat) tL_channelAdminLogEvent.action).new_value;
int i21 = ((TLRPC.TL_channelAdminLogEventActionChangeLinkedChat) tL_channelAdminLogEvent.action).prev_value;
if (chat.megagroup) {
if (i20 == 0) {
TLObject chat3 = MessagesController.getInstance(this.currentAccount).getChat(Integer.valueOf(i21));
CharSequence replaceWithLink2 = replaceWithLink(LocaleController.getString("EventLogRemovedLinkedChannel", R.string.EventLogRemovedLinkedChannel), "un1", user);
this.messageText = replaceWithLink2;
this.messageText = replaceWithLink(replaceWithLink2, "un2", chat3);
} else {
TLObject chat4 = MessagesController.getInstance(this.currentAccount).getChat(Integer.valueOf(i20));
CharSequence replaceWithLink3 = replaceWithLink(LocaleController.getString("EventLogChangedLinkedChannel", R.string.EventLogChangedLinkedChannel), "un1", user);
this.messageText = replaceWithLink3;
this.messageText = replaceWithLink(replaceWithLink3, "un2", chat4);
}
} else if (i20 == 0) {
TLObject chat5 = MessagesController.getInstance(this.currentAccount).getChat(Integer.valueOf(i21));
CharSequence replaceWithLink4 = replaceWithLink(LocaleController.getString("EventLogRemovedLinkedGroup", R.string.EventLogRemovedLinkedGroup), "un1", user);
this.messageText = replaceWithLink4;
this.messageText = replaceWithLink(replaceWithLink4, "un2", chat5);
} else {
TLObject chat6 = MessagesController.getInstance(this.currentAccount).getChat(Integer.valueOf(i20));
CharSequence replaceWithLink5 = replaceWithLink(LocaleController.getString("EventLogChangedLinkedGroup", R.string.EventLogChangedLinkedGroup), "un1", user);
this.messageText = replaceWithLink5;
this.messageText = replaceWithLink(replaceWithLink5, "un2", chat6);
}
} else if (tL_channelAdminLogEvent.action instanceof TLRPC.TL_channelAdminLogEventActionTogglePreHistoryHidden) {
if (((TLRPC.TL_channelAdminLogEventActionTogglePreHistoryHidden) tL_channelAdminLogEvent.action).new_value) {
this.messageText = replaceWithLink(LocaleController.getString("EventLogToggledInvitesHistoryOff", R.string.EventLogToggledInvitesHistoryOff), "un1", user);
} else {
this.messageText = replaceWithLink(LocaleController.getString("EventLogToggledInvitesHistoryOn", R.string.EventLogToggledInvitesHistoryOn), "un1", user);
}
} else {
if (tL_channelAdminLogEvent.action instanceof TLRPC.TL_channelAdminLogEventActionChangeAbout) {
if (chat.megagroup) {
i4 = R.string.EventLogEditedGroupDescription;
str3 = "EventLogEditedGroupDescription";
} else {
i4 = R.string.EventLogEditedChannelDescription;
str3 = "EventLogEditedChannelDescription";
}
this.messageText = replaceWithLink(LocaleController.getString(str3, i4), "un1", user);
tL_message = new TLRPC.TL_message();
tL_message.out = false;
tL_message.unread = false;
tL_message.from_id = tL_channelAdminLogEvent.user_id;
tL_message.to_id = tL_peerChannel;
tL_message.date = tL_channelAdminLogEvent.date;
tL_message.message = ((TLRPC.TL_channelAdminLogEventActionChangeAbout) tL_channelAdminLogEvent.action).new_value;
if (!TextUtils.isEmpty(((TLRPC.TL_channelAdminLogEventActionChangeAbout) tL_channelAdminLogEvent.action).prev_value)) {
tL_message.media = new TLRPC.TL_messageMediaWebPage();
tL_message.media.webpage = new TLRPC.TL_webPage();
tL_message.media.webpage.flags = 10;
tL_message.media.webpage.display_url = "";
tL_message.media.webpage.url = "";
tL_message.media.webpage.site_name = LocaleController.getString("EventLogPreviousGroupDescription", R.string.EventLogPreviousGroupDescription);
tL_message.media.webpage.description = ((TLRPC.TL_channelAdminLogEventActionChangeAbout) tL_channelAdminLogEvent.action).prev_value;
} else {
tL_message.media = new TLRPC.TL_messageMediaEmpty();
}
} else if (tL_channelAdminLogEvent.action instanceof TLRPC.TL_channelAdminLogEventActionChangeUsername) {
String str6 = ((TLRPC.TL_channelAdminLogEventActionChangeUsername) tL_channelAdminLogEvent.action).new_value;
if (!TextUtils.isEmpty(str6)) {
if (chat.megagroup) {
i3 = R.string.EventLogChangedGroupLink;
str2 = "EventLogChangedGroupLink";
} else {
i3 = R.string.EventLogChangedChannelLink;
str2 = "EventLogChangedChannelLink";
}
this.messageText = replaceWithLink(LocaleController.getString(str2, i3), "un1", user);
} else {
if (chat.megagroup) {
i2 = R.string.EventLogRemovedGroupLink;
str = "EventLogRemovedGroupLink";
} else {
i2 = R.string.EventLogRemovedChannelLink;
str = "EventLogRemovedChannelLink";
}
this.messageText = replaceWithLink(LocaleController.getString(str, i2), "un1", user);
}
TLRPC.TL_message tL_message2 = new TLRPC.TL_message();
tL_message2.out = false;
tL_message2.unread = false;
tL_message2.from_id = tL_channelAdminLogEvent.user_id;
tL_message2.to_id = tL_peerChannel;
tL_message2.date = tL_channelAdminLogEvent.date;
if (!TextUtils.isEmpty(str6)) {
tL_message2.message = "https://" + MessagesController.getInstance(this.currentAccount).linkPrefix + "/" + str6;
} else {
tL_message2.message = "";
}
TLRPC.TL_messageEntityUrl tL_messageEntityUrl = new TLRPC.TL_messageEntityUrl();
tL_messageEntityUrl.offset = 0;
tL_messageEntityUrl.length = tL_message2.message.length();
tL_message2.entities.add(tL_messageEntityUrl);
if (!TextUtils.isEmpty(((TLRPC.TL_channelAdminLogEventActionChangeUsername) tL_channelAdminLogEvent.action).prev_value)) {
tL_message2.media = new TLRPC.TL_messageMediaWebPage();
tL_message2.media.webpage = new TLRPC.TL_webPage();
tL_message2.media.webpage.flags = 10;
tL_message2.media.webpage.display_url = "";
tL_message2.media.webpage.url = "";
tL_message2.media.webpage.site_name = LocaleController.getString("EventLogPreviousLink", R.string.EventLogPreviousLink);
tL_message2.media.webpage.description = "https://" + MessagesController.getInstance(this.currentAccount).linkPrefix + "/" + ((TLRPC.TL_channelAdminLogEventActionChangeUsername) tL_channelAdminLogEvent.action).prev_value;
} else {
tL_message2.media = new TLRPC.TL_messageMediaEmpty();
}
tL_message = tL_message2;
} else if (tL_channelAdminLogEvent.action instanceof TLRPC.TL_channelAdminLogEventActionEditMessage) {
tL_message = new TLRPC.TL_message();
tL_message.out = false;
tL_message.unread = false;
tL_message.from_id = tL_channelAdminLogEvent.user_id;
tL_message.to_id = tL_peerChannel;
tL_message.date = tL_channelAdminLogEvent.date;
TLRPC.Message message = ((TLRPC.TL_channelAdminLogEventActionEditMessage) tL_channelAdminLogEvent.action).new_message;
TLRPC.Message message2 = ((TLRPC.TL_channelAdminLogEventActionEditMessage) tL_channelAdminLogEvent.action).prev_message;
if (message.media != null && !(message.media instanceof TLRPC.TL_messageMediaEmpty) && !(message.media instanceof TLRPC.TL_messageMediaWebPage)) {
boolean z3 = !TextUtils.equals(message.message, message2.message);
if (((message.media.getClass() == message2.media.getClass() && (message.media.photo == null || message2.media.photo == null || message.media.photo.id == message2.media.photo.id) && (message.media.document == null || message2.media.document == null || message.media.document.id == message2.media.document.id)) ? false : true) && z3) {
this.messageText = replaceWithLink(LocaleController.getString("EventLogEditedMediaCaption", R.string.EventLogEditedMediaCaption), "un1", user);
} else if (z3) {
this.messageText = replaceWithLink(LocaleController.getString("EventLogEditedCaption", R.string.EventLogEditedCaption), "un1", user);
} else {
this.messageText = replaceWithLink(LocaleController.getString("EventLogEditedMedia", R.string.EventLogEditedMedia), "un1", user);
}
tL_message.media = message.media;
if (z3) {
tL_message.media.webpage = new TLRPC.TL_webPage();
tL_message.media.webpage.site_name = LocaleController.getString("EventLogOriginalCaption", R.string.EventLogOriginalCaption);
if (TextUtils.isEmpty(message2.message)) {
tL_message.media.webpage.description = LocaleController.getString("EventLogOriginalCaptionEmpty", R.string.EventLogOriginalCaptionEmpty);
} else {
tL_message.media.webpage.description = message2.message;
}
}
} else {
this.messageText = replaceWithLink(LocaleController.getString("EventLogEditedMessages", R.string.EventLogEditedMessages), "un1", user);
tL_message.message = message.message;
tL_message.media = new TLRPC.TL_messageMediaWebPage();
tL_message.media.webpage = new TLRPC.TL_webPage();
tL_message.media.webpage.site_name = LocaleController.getString("EventLogOriginalMessages", R.string.EventLogOriginalMessages);
if (TextUtils.isEmpty(message2.message)) {
tL_message.media.webpage.description = LocaleController.getString("EventLogOriginalCaptionEmpty", R.string.EventLogOriginalCaptionEmpty);
} else {
tL_message.media.webpage.description = message2.message;
}
}
tL_message.reply_markup = message.reply_markup;
if (tL_message.media.webpage != null) {
tL_message.media.webpage.flags = 10;
tL_message.media.webpage.display_url = "";
tL_message.media.webpage.url = "";
}
} else if (tL_channelAdminLogEvent.action instanceof TLRPC.TL_channelAdminLogEventActionChangeStickerSet) {
TLRPC.InputStickerSet inputStickerSet = ((TLRPC.TL_channelAdminLogEventActionChangeStickerSet) tL_channelAdminLogEvent.action).new_stickerset;
TLRPC.InputStickerSet inputStickerSet2 = ((TLRPC.TL_channelAdminLogEventActionChangeStickerSet) tL_channelAdminLogEvent.action).new_stickerset;
if (inputStickerSet == null || (inputStickerSet instanceof TLRPC.TL_inputStickerSetEmpty)) {
this.messageText = replaceWithLink(LocaleController.getString("EventLogRemovedStickersSet", R.string.EventLogRemovedStickersSet), "un1", user);
} else {
this.messageText = replaceWithLink(LocaleController.getString("EventLogChangedStickersSet", R.string.EventLogChangedStickersSet), "un1", user);
}
} else if (tL_channelAdminLogEvent.action instanceof TLRPC.TL_channelAdminLogEventActionChangeLocation) {
TLRPC.TL_channelAdminLogEventActionChangeLocation tL_channelAdminLogEventActionChangeLocation = (TLRPC.TL_channelAdminLogEventActionChangeLocation) tL_channelAdminLogEvent.action;
if (tL_channelAdminLogEventActionChangeLocation.new_value instanceof TLRPC.TL_channelLocationEmpty) {
this.messageText = replaceWithLink(LocaleController.getString("EventLogRemovedLocation", R.string.EventLogRemovedLocation), "un1", user);
} else {
this.messageText = replaceWithLink(LocaleController.formatString("EventLogChangedLocation", R.string.EventLogChangedLocation, ((TLRPC.TL_channelLocation) tL_channelAdminLogEventActionChangeLocation.new_value).address), "un1", user);
}
} else if (tL_channelAdminLogEvent.action instanceof TLRPC.TL_channelAdminLogEventActionToggleSlowMode) {
TLRPC.TL_channelAdminLogEventActionToggleSlowMode tL_channelAdminLogEventActionToggleSlowMode = (TLRPC.TL_channelAdminLogEventActionToggleSlowMode) tL_channelAdminLogEvent.action;
if (tL_channelAdminLogEventActionToggleSlowMode.new_value == 0) {
this.messageText = replaceWithLink(LocaleController.getString("EventLogToggledSlowmodeOff", R.string.EventLogToggledSlowmodeOff), "un1", user);
} else {
if (tL_channelAdminLogEventActionToggleSlowMode.new_value < 60) {
formatPluralString = LocaleController.formatPluralString("Seconds", tL_channelAdminLogEventActionToggleSlowMode.new_value);
} else if (tL_channelAdminLogEventActionToggleSlowMode.new_value < 3600) {
formatPluralString = LocaleController.formatPluralString("Minutes", tL_channelAdminLogEventActionToggleSlowMode.new_value / 60);
} else {
formatPluralString = LocaleController.formatPluralString("Hours", (tL_channelAdminLogEventActionToggleSlowMode.new_value / 60) / 60);
}
this.messageText = replaceWithLink(LocaleController.formatString("EventLogToggledSlowmodeOn", R.string.EventLogToggledSlowmodeOn, formatPluralString), "un1", user);
}
} else {
this.messageText = "unsupported " + tL_channelAdminLogEvent.action;
}
if (this.messageOwner == null) {
this.messageOwner = new TLRPC.TL_messageService();
}
this.messageOwner.message = this.messageText.toString();
this.messageOwner.from_id = tL_channelAdminLogEvent.user_id;
this.messageOwner.date = tL_channelAdminLogEvent.date;
TLRPC.Message message3 = this.messageOwner;
int i22 = iArr[0];
iArr[0] = i22 + 1;
message3.id = i22;
this.eventId = tL_channelAdminLogEvent.id;
this.messageOwner.out = false;
this.messageOwner.to_id = new TLRPC.TL_peerChannel();
this.messageOwner.to_id.channel_id = chat.id;
this.messageOwner.unread = false;
if (chat.megagroup) {
this.messageOwner.flags |= Integer.MIN_VALUE;
}
MediaController mediaController = MediaController.getInstance();
if (tL_channelAdminLogEvent.action.message != null && !(tL_channelAdminLogEvent.action.message instanceof TLRPC.TL_messageEmpty)) {
tL_message = tL_channelAdminLogEvent.action.message;
}
if (tL_message == null) {
tL_message.out = false;
int i23 = iArr[0];
iArr[0] = i23 + 1;
tL_message.id = i23;
tL_message.reply_to_msg_id = 0;
tL_message.flags &= -32769;
if (chat.megagroup) {
tL_message.flags |= Integer.MIN_VALUE;
}
MessageObject messageObject = new MessageObject(this.currentAccount, tL_message, (AbstractMap<Integer, TLRPC.User>) null, (AbstractMap<Integer, TLRPC.Chat>) null, true, this.eventId);
if (messageObject.contentType >= 0) {
if (mediaController.isPlayingMessage(messageObject)) {
MessageObject playingMessageObject = mediaController.getPlayingMessageObject();
messageObject.audioProgress = playingMessageObject.audioProgress;
messageObject.audioProgressSec = playingMessageObject.audioProgressSec;
}
arrayList2 = arrayList;
createDateArray(this.currentAccount, tL_channelAdminLogEvent, arrayList2, hashMap);
arrayList2.add(arrayList.size() - 1, messageObject);
} else {
arrayList2 = arrayList;
this.contentType = -1;
}
} else {
arrayList2 = arrayList;
}
if (this.contentType < 0) {
createDateArray(this.currentAccount, tL_channelAdminLogEvent, arrayList2, hashMap);
arrayList2.add(arrayList.size() - 1, this);
if (this.messageText == null) {
this.messageText = "";
}
setType();
measureInlineBotButtons();
generateCaption();
if (this.messageOwner.media instanceof TLRPC.TL_messageMediaGame) {
textPaint = Theme.chat_msgGameTextPaint;
} else {
textPaint = Theme.chat_msgTextPaint;
}
int[] iArr2 = SharedConfig.allowBigEmoji ? new int[1] : null;
this.messageText = Emoji.replaceEmoji(this.messageText, textPaint.getFontMetricsInt(), AndroidUtilities.dp(20.0f), false, iArr2);
checkEmojiOnly(iArr2);
if (mediaController.isPlayingMessage(this)) {
MessageObject playingMessageObject2 = mediaController.getPlayingMessageObject();
this.audioProgress = playingMessageObject2.audioProgress;
this.audioProgressSec = playingMessageObject2.audioProgressSec;
}
generateLayout(user);
this.layoutCreated = true;
generateThumbs(false);
checkMediaExistance();
return;
}
return;
}
tL_message = null;
if (this.messageOwner == null) {
}
this.messageOwner.message = this.messageText.toString();
this.messageOwner.from_id = tL_channelAdminLogEvent.user_id;
this.messageOwner.date = tL_channelAdminLogEvent.date;
TLRPC.Message message32 = this.messageOwner;
int i222 = iArr[0];
iArr[0] = i222 + 1;
message32.id = i222;
this.eventId = tL_channelAdminLogEvent.id;
this.messageOwner.out = false;
this.messageOwner.to_id = new TLRPC.TL_peerChannel();
this.messageOwner.to_id.channel_id = chat.id;
this.messageOwner.unread = false;
if (chat.megagroup) {
}
MediaController mediaController2 = MediaController.getInstance();
if (tL_channelAdminLogEvent.action.message != null) {
tL_message = tL_channelAdminLogEvent.action.message;
}
if (tL_message == null) {
}
if (this.contentType < 0) {
}
}
private String getUserName(TLRPC.User user, ArrayList<TLRPC.MessageEntity> arrayList, int i) {
String formatName = user == null ? "" : ContactsController.formatName(user.first_name, user.last_name);
if (i >= 0) {
TLRPC.TL_messageEntityMentionName tL_messageEntityMentionName = new TLRPC.TL_messageEntityMentionName();
tL_messageEntityMentionName.user_id = user.id;
tL_messageEntityMentionName.offset = i;
tL_messageEntityMentionName.length = formatName.length();
arrayList.add(tL_messageEntityMentionName);
}
if (TextUtils.isEmpty(user.username)) {
return formatName;
}
if (i >= 0) {
TLRPC.TL_messageEntityMentionName tL_messageEntityMentionName2 = new TLRPC.TL_messageEntityMentionName();
tL_messageEntityMentionName2.user_id = user.id;
tL_messageEntityMentionName2.offset = i + formatName.length() + 2;
tL_messageEntityMentionName2.length = user.username.length() + 1;
arrayList.add(tL_messageEntityMentionName2);
}
return String.format("%1$s (@%2$s)", formatName, user.username);
}
public void applyNewText() {
TextPaint textPaint;
if (TextUtils.isEmpty(this.messageOwner.message)) {
return;
}
TLRPC.User user = isFromUser() ? MessagesController.getInstance(this.currentAccount).getUser(Integer.valueOf(this.messageOwner.from_id)) : null;
this.messageText = this.messageOwner.message;
if (this.messageOwner.media instanceof TLRPC.TL_messageMediaGame) {
textPaint = Theme.chat_msgGameTextPaint;
} else {
textPaint = Theme.chat_msgTextPaint;
}
int[] iArr = SharedConfig.allowBigEmoji ? new int[1] : null;
this.messageText = Emoji.replaceEmoji(this.messageText, textPaint.getFontMetricsInt(), AndroidUtilities.dp(20.0f), false, iArr);
checkEmojiOnly(iArr);
generateLayout(user);
}
public void generateGameMessageText(TLRPC.User user) {
if (user == null && this.messageOwner.from_id > 0) {
user = MessagesController.getInstance(this.currentAccount).getUser(Integer.valueOf(this.messageOwner.from_id));
}
TLRPC.TL_game tL_game = null;
MessageObject messageObject = this.replyMessageObject;
if (messageObject != null && messageObject.messageOwner.media != null && this.replyMessageObject.messageOwner.media.game != null) {
tL_game = this.replyMessageObject.messageOwner.media.game;
}
if (tL_game == null) {
if (user == null || user.id != UserConfig.getInstance(this.currentAccount).getClientUserId()) {
this.messageText = replaceWithLink(LocaleController.formatString("ActionUserScored", R.string.ActionUserScored, LocaleController.formatPluralString("Points", this.messageOwner.action.score)), "un1", user);
return;
} else {
this.messageText = LocaleController.formatString("ActionYouScored", R.string.ActionYouScored, LocaleController.formatPluralString("Points", this.messageOwner.action.score));
return;
}
}
if (user == null || user.id != UserConfig.getInstance(this.currentAccount).getClientUserId()) {
this.messageText = replaceWithLink(LocaleController.formatString("ActionUserScoredInGame", R.string.ActionUserScoredInGame, LocaleController.formatPluralString("Points", this.messageOwner.action.score)), "un1", user);
} else {
this.messageText = LocaleController.formatString("ActionYouScoredInGame", R.string.ActionYouScoredInGame, LocaleController.formatPluralString("Points", this.messageOwner.action.score));
}
this.messageText = replaceWithLink(this.messageText, "un2", tL_game);
}
public boolean hasValidReplyMessageObject() {
MessageObject messageObject = this.replyMessageObject;
if (messageObject != null) {
TLRPC.Message message = messageObject.messageOwner;
if (!(message instanceof TLRPC.TL_messageEmpty) && !(message.action instanceof TLRPC.TL_messageActionHistoryClear)) {
return true;
}
}
return false;
}
public void generatePaymentSentMessageText(TLRPC.User user) {
if (user == null) {
user = MessagesController.getInstance(this.currentAccount).getUser(Integer.valueOf((int) getDialogId()));
}
String firstName = user != null ? UserObject.getFirstName(user) : "";
MessageObject messageObject = this.replyMessageObject;
if (messageObject == null || !(messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaInvoice)) {
this.messageText = LocaleController.formatString("PaymentSuccessfullyPaidNoItem", R.string.PaymentSuccessfullyPaidNoItem, LocaleController.getInstance().formatCurrencyString(this.messageOwner.action.total_amount, this.messageOwner.action.currency), firstName);
} else {
this.messageText = LocaleController.formatString("PaymentSuccessfullyPaid", R.string.PaymentSuccessfullyPaid, LocaleController.getInstance().formatCurrencyString(this.messageOwner.action.total_amount, this.messageOwner.action.currency), firstName, this.replyMessageObject.messageOwner.media.title);
}
}
public void generatePinMessageText(TLRPC.User user, TLRPC.Chat chat) {
if (user == null && chat == 0) {
if (this.messageOwner.from_id > 0) {
user = MessagesController.getInstance(this.currentAccount).getUser(Integer.valueOf(this.messageOwner.from_id));
}
if (user == null) {
chat = MessagesController.getInstance(this.currentAccount).getChat(Integer.valueOf(this.messageOwner.to_id.channel_id));
}
}
MessageObject messageObject = this.replyMessageObject;
if (messageObject != null) {
TLRPC.Message message = messageObject.messageOwner;
if (!(message instanceof TLRPC.TL_messageEmpty) && !(message.action instanceof TLRPC.TL_messageActionHistoryClear)) {
if (this.replyMessageObject.isMusic()) {
String string = LocaleController.getString("ActionPinnedMusic", R.string.ActionPinnedMusic);
if (user == null) {
user = chat;
}
this.messageText = replaceWithLink(string, "un1", user);
return;
}
if (this.replyMessageObject.isVideo()) {
String string2 = LocaleController.getString("ActionPinnedVideo", R.string.ActionPinnedVideo);
if (user == null) {
user = chat;
}
this.messageText = replaceWithLink(string2, "un1", user);
return;
}
if (this.replyMessageObject.isGif()) {
String string3 = LocaleController.getString("ActionPinnedGif", R.string.ActionPinnedGif);
if (user == null) {
user = chat;
}
this.messageText = replaceWithLink(string3, "un1", user);
return;
}
if (this.replyMessageObject.isVoice()) {
String string4 = LocaleController.getString("ActionPinnedVoice", R.string.ActionPinnedVoice);
if (user == null) {
user = chat;
}
this.messageText = replaceWithLink(string4, "un1", user);
return;
}
if (this.replyMessageObject.isRoundVideo()) {
String string5 = LocaleController.getString("ActionPinnedRound", R.string.ActionPinnedRound);
if (user == null) {
user = chat;
}
this.messageText = replaceWithLink(string5, "un1", user);
return;
}
if (this.replyMessageObject.isSticker() || this.replyMessageObject.isAnimatedSticker()) {
String string6 = LocaleController.getString("ActionPinnedSticker", R.string.ActionPinnedSticker);
if (user == null) {
user = chat;
}
this.messageText = replaceWithLink(string6, "un1", user);
return;
}
if (this.replyMessageObject.messageOwner.media instanceof TLRPC.TL_messageMediaDocument) {
String string7 = LocaleController.getString("ActionPinnedFile", R.string.ActionPinnedFile);
if (user == null) {
user = chat;
}
this.messageText = replaceWithLink(string7, "un1", user);
return;
}
if (this.replyMessageObject.messageOwner.media instanceof TLRPC.TL_messageMediaGeo) {
String string8 = LocaleController.getString("ActionPinnedGeo", R.string.ActionPinnedGeo);
if (user == null) {
user = chat;
}
this.messageText = replaceWithLink(string8, "un1", user);
return;
}
if (this.replyMessageObject.messageOwner.media instanceof TLRPC.TL_messageMediaGeoLive) {
String string9 = LocaleController.getString("ActionPinnedGeoLive", R.string.ActionPinnedGeoLive);
if (user == null) {
user = chat;
}
this.messageText = replaceWithLink(string9, "un1", user);
return;
}
if (this.replyMessageObject.messageOwner.media instanceof TLRPC.TL_messageMediaContact) {
String string10 = LocaleController.getString("ActionPinnedContact", R.string.ActionPinnedContact);
if (user == null) {
user = chat;
}
this.messageText = replaceWithLink(string10, "un1", user);
return;
}
if (this.replyMessageObject.messageOwner.media instanceof TLRPC.TL_messageMediaPoll) {
String string11 = LocaleController.getString("ActionPinnedPoll", R.string.ActionPinnedPoll);
if (user == null) {
user = chat;
}
this.messageText = replaceWithLink(string11, "un1", user);
return;
}
if (this.replyMessageObject.messageOwner.media instanceof TLRPC.TL_messageMediaPhoto) {
String string12 = LocaleController.getString("ActionPinnedPhoto", R.string.ActionPinnedPhoto);
if (user == null) {
user = chat;
}
this.messageText = replaceWithLink(string12, "un1", user);
return;
}
if (this.replyMessageObject.messageOwner.media instanceof TLRPC.TL_messageMediaGame) {
String formatString = LocaleController.formatString("ActionPinnedGame", R.string.ActionPinnedGame, "🎮 " + this.replyMessageObject.messageOwner.media.game.title);
if (user == null) {
user = chat;
}
CharSequence replaceWithLink = replaceWithLink(formatString, "un1", user);
this.messageText = replaceWithLink;
this.messageText = Emoji.replaceEmoji(replaceWithLink, Theme.chat_msgTextPaint.getFontMetricsInt(), AndroidUtilities.dp(20.0f), false);
return;
}
CharSequence charSequence = this.replyMessageObject.messageText;
if (charSequence != null && charSequence.length() > 0) {
CharSequence charSequence2 = this.replyMessageObject.messageText;
if (charSequence2.length() > 20) {
charSequence2 = ((Object) charSequence2.subSequence(0, 20)) + "...";
}
String formatString2 = LocaleController.formatString("ActionPinnedText", R.string.ActionPinnedText, Emoji.replaceEmoji(charSequence2, Theme.chat_msgTextPaint.getFontMetricsInt(), AndroidUtilities.dp(20.0f), false));
if (user == null) {
user = chat;
}
this.messageText = replaceWithLink(formatString2, "un1", user);
return;
}
String string13 = LocaleController.getString("ActionPinnedNoText", R.string.ActionPinnedNoText);
if (user == null) {
user = chat;
}
this.messageText = replaceWithLink(string13, "un1", user);
return;
}
}
String string14 = LocaleController.getString("ActionPinnedNoText", R.string.ActionPinnedNoText);
if (user == null) {
user = chat;
}
this.messageText = replaceWithLink(string14, "un1", user);
}
public static void updateReactions(TLRPC.Message message, TLRPC.TL_messageReactions tL_messageReactions) {
if (message == null || tL_messageReactions == null) {
return;
}
if (tL_messageReactions.min && message.reactions != null) {
int size = message.reactions.results.size();
int i = 0;
int i2 = 0;
while (true) {
if (i2 >= size) {
break;
}
TLRPC.TL_reactionCount tL_reactionCount = message.reactions.results.get(i2);
if (tL_reactionCount.chosen) {
int size2 = tL_messageReactions.results.size();
while (true) {
if (i >= size2) {
break;
}
TLRPC.TL_reactionCount tL_reactionCount2 = tL_messageReactions.results.get(i);
if (tL_reactionCount.reaction.equals(tL_reactionCount2.reaction)) {
tL_reactionCount2.chosen = true;
break;
}
i++;
}
} else {
i2++;
}
}
}
message.reactions = tL_messageReactions;
message.flags |= 1048576;
}
public boolean hasReactions() {
return (this.messageOwner.reactions == null || this.messageOwner.reactions.results.isEmpty()) ? false : true;
}
public static void updatePollResults(TLRPC.TL_messageMediaPoll tL_messageMediaPoll, TLRPC.TL_pollResults tL_pollResults) {
if ((tL_pollResults.flags & 2) != 0) {
byte[] bArr = null;
int i = 0;
if (tL_pollResults.min && tL_messageMediaPoll.results.results != null) {
int size = tL_messageMediaPoll.results.results.size();
int i2 = 0;
while (true) {
if (i2 >= size) {
break;
}
TLRPC.TL_pollAnswerVoters tL_pollAnswerVoters = tL_messageMediaPoll.results.results.get(i2);
if (tL_pollAnswerVoters.chosen) {
bArr = tL_pollAnswerVoters.option;
break;
}
i2++;
}
}
tL_messageMediaPoll.results.results = tL_pollResults.results;
if (bArr != null) {
int size2 = tL_messageMediaPoll.results.results.size();
while (true) {
if (i >= size2) {
break;
}
TLRPC.TL_pollAnswerVoters tL_pollAnswerVoters2 = tL_messageMediaPoll.results.results.get(i);
if (Arrays.equals(tL_pollAnswerVoters2.option, bArr)) {
tL_pollAnswerVoters2.chosen = true;
break;
}
i++;
}
}
tL_messageMediaPoll.results.flags |= 2;
}
if ((tL_pollResults.flags & 4) != 0) {
tL_messageMediaPoll.results.total_voters = tL_pollResults.total_voters;
tL_messageMediaPoll.results.flags |= 4;
}
}
public boolean isPollClosed() {
if (this.type != 17) {
return false;
}
return ((TLRPC.TL_messageMediaPoll) this.messageOwner.media).poll.closed;
}
public boolean isVoted() {
if (this.type != 17) {
return false;
}
TLRPC.TL_messageMediaPoll tL_messageMediaPoll = (TLRPC.TL_messageMediaPoll) this.messageOwner.media;
if (tL_messageMediaPoll.results != null && !tL_messageMediaPoll.results.results.isEmpty()) {
int size = tL_messageMediaPoll.results.results.size();
for (int i = 0; i < size; i++) {
if (tL_messageMediaPoll.results.results.get(i).chosen) {
return true;
}
}
}
return false;
}
public long getPollId() {
if (this.type != 17) {
return 0L;
}
return ((TLRPC.TL_messageMediaPoll) this.messageOwner.media).poll.id;
}
private TLRPC.Photo getPhotoWithId(TLRPC.WebPage webPage, long j) {
if (webPage != null && webPage.cached_page != null) {
if (webPage.photo != null && webPage.photo.id == j) {
return webPage.photo;
}
for (int i = 0; i < webPage.cached_page.photos.size(); i++) {
TLRPC.Photo photo = webPage.cached_page.photos.get(i);
if (photo.id == j) {
return photo;
}
}
}
return null;
}
private TLRPC.Document getDocumentWithId(TLRPC.WebPage webPage, long j) {
if (webPage != null && webPage.cached_page != null) {
if (webPage.document != null && webPage.document.id == j) {
return webPage.document;
}
for (int i = 0; i < webPage.cached_page.documents.size(); i++) {
TLRPC.Document document = webPage.cached_page.documents.get(i);
if (document.id == j) {
return document;
}
}
}
return null;
}
private MessageObject getMessageObjectForBlock(TLRPC.WebPage webPage, TLRPC.PageBlock pageBlock) {
TLRPC.TL_message tL_message;
if (pageBlock instanceof TLRPC.TL_pageBlockPhoto) {
TLRPC.Photo photoWithId = getPhotoWithId(webPage, ((TLRPC.TL_pageBlockPhoto) pageBlock).photo_id);
if (photoWithId == webPage.photo) {
return this;
}
tL_message = new TLRPC.TL_message();
tL_message.media = new TLRPC.TL_messageMediaPhoto();
tL_message.media.photo = photoWithId;
} else if (pageBlock instanceof TLRPC.TL_pageBlockVideo) {
TLRPC.TL_pageBlockVideo tL_pageBlockVideo = (TLRPC.TL_pageBlockVideo) pageBlock;
if (getDocumentWithId(webPage, tL_pageBlockVideo.video_id) == webPage.document) {
return this;
}
TLRPC.TL_message tL_message2 = new TLRPC.TL_message();
tL_message2.media = new TLRPC.TL_messageMediaDocument();
tL_message2.media.document = getDocumentWithId(webPage, tL_pageBlockVideo.video_id);
tL_message = tL_message2;
} else {
tL_message = null;
}
tL_message.message = "";
tL_message.realId = getId();
tL_message.id = Utilities.random.nextInt();
tL_message.date = this.messageOwner.date;
tL_message.to_id = this.messageOwner.to_id;
tL_message.out = this.messageOwner.out;
tL_message.from_id = this.messageOwner.from_id;
return new MessageObject(this.currentAccount, tL_message, false);
}
public ArrayList<MessageObject> getWebPagePhotos(ArrayList<MessageObject> arrayList, ArrayList<TLRPC.PageBlock> arrayList2) {
if (arrayList == null) {
arrayList = new ArrayList<>();
}
if (this.messageOwner.media != null && this.messageOwner.media.webpage != null) {
TLRPC.WebPage webPage = this.messageOwner.media.webpage;
if (webPage.cached_page == null) {
return arrayList;
}
if (arrayList2 == null) {
arrayList2 = webPage.cached_page.blocks;
}
for (int i = 0; i < arrayList2.size(); i++) {
TLRPC.PageBlock pageBlock = arrayList2.get(i);
if (pageBlock instanceof TLRPC.TL_pageBlockSlideshow) {
TLRPC.TL_pageBlockSlideshow tL_pageBlockSlideshow = (TLRPC.TL_pageBlockSlideshow) pageBlock;
for (int i2 = 0; i2 < tL_pageBlockSlideshow.items.size(); i2++) {
arrayList.add(getMessageObjectForBlock(webPage, tL_pageBlockSlideshow.items.get(i2)));
}
} else if (pageBlock instanceof TLRPC.TL_pageBlockCollage) {
TLRPC.TL_pageBlockCollage tL_pageBlockCollage = (TLRPC.TL_pageBlockCollage) pageBlock;
for (int i3 = 0; i3 < tL_pageBlockCollage.items.size(); i3++) {
arrayList.add(getMessageObjectForBlock(webPage, tL_pageBlockCollage.items.get(i3)));
}
}
}
}
return arrayList;
}
public void createMessageSendInfo() {
String str;
if (this.messageOwner.message != null) {
if ((this.messageOwner.id < 0 || isEditing()) && this.messageOwner.params != null) {
String str2 = this.messageOwner.params.get("ve");
if (str2 != null && (isVideo() || isNewGif() || isRoundVideo())) {
VideoEditedInfo videoEditedInfo = new VideoEditedInfo();
this.videoEditedInfo = videoEditedInfo;
if (!videoEditedInfo.parseString(str2)) {
this.videoEditedInfo = null;
} else {
this.videoEditedInfo.roundVideo = isRoundVideo();
}
}
if (this.messageOwner.send_state != 3 || (str = this.messageOwner.params.get("prevMedia")) == null) {
return;
}
SerializedData serializedData = new SerializedData(Base64.decode(str, 0));
this.previousMedia = TLRPC.MessageMedia.TLdeserialize(serializedData, serializedData.readInt32(false), false);
this.previousCaption = serializedData.readString(false);
this.previousAttachPath = serializedData.readString(false);
int readInt32 = serializedData.readInt32(false);
this.previousCaptionEntities = new ArrayList<>(readInt32);
for (int i = 0; i < readInt32; i++) {
this.previousCaptionEntities.add(TLRPC.MessageEntity.TLdeserialize(serializedData, serializedData.readInt32(false), false));
}
serializedData.cleanup();
}
}
}
public void measureInlineBotButtons() {
int i;
CharSequence replaceEmoji;
this.wantedBotKeyboardWidth = 0;
if ((this.messageOwner.reply_markup instanceof TLRPC.TL_replyInlineMarkup) || (this.messageOwner.reactions != null && !this.messageOwner.reactions.results.isEmpty())) {
Theme.createChatResources(null, true);
StringBuilder sb = this.botButtonsLayout;
if (sb == null) {
this.botButtonsLayout = new StringBuilder();
} else {
sb.setLength(0);
}
}
if (this.messageOwner.reply_markup instanceof TLRPC.TL_replyInlineMarkup) {
for (int i2 = 0; i2 < this.messageOwner.reply_markup.rows.size(); i2++) {
TLRPC.TL_keyboardButtonRow tL_keyboardButtonRow = this.messageOwner.reply_markup.rows.get(i2);
int size = tL_keyboardButtonRow.buttons.size();
int i3 = 0;
for (int i4 = 0; i4 < size; i4++) {
TLRPC.KeyboardButton keyboardButton = tL_keyboardButtonRow.buttons.get(i4);
StringBuilder sb2 = this.botButtonsLayout;
sb2.append(i2);
sb2.append(i4);
if ((keyboardButton instanceof TLRPC.TL_keyboardButtonBuy) && (this.messageOwner.media.flags & 4) != 0) {
replaceEmoji = LocaleController.getString("PaymentReceipt", R.string.PaymentReceipt);
} else {
replaceEmoji = Emoji.replaceEmoji(keyboardButton.text, Theme.chat_msgBotButtonPaint.getFontMetricsInt(), AndroidUtilities.dp(15.0f), false);
}
StaticLayout staticLayout = new StaticLayout(replaceEmoji, Theme.chat_msgBotButtonPaint, AndroidUtilities.dp(2000.0f), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
if (staticLayout.getLineCount() > 0) {
float lineWidth = staticLayout.getLineWidth(0);
float lineLeft = staticLayout.getLineLeft(0);
if (lineLeft < lineWidth) {
lineWidth -= lineLeft;
}
i3 = Math.max(i3, ((int) Math.ceil(lineWidth)) + AndroidUtilities.dp(4.0f));
}
}
this.wantedBotKeyboardWidth = Math.max(this.wantedBotKeyboardWidth, ((i3 + AndroidUtilities.dp(12.0f)) * size) + (AndroidUtilities.dp(5.0f) * (size - 1)));
}
return;
}
if (this.messageOwner.reactions != null) {
int size2 = this.messageOwner.reactions.results.size();
for (int i5 = 0; i5 < size2; i5++) {
TLRPC.TL_reactionCount tL_reactionCount = this.messageOwner.reactions.results.get(i5);
StringBuilder sb3 = this.botButtonsLayout;
sb3.append(0);
sb3.append(i5);
StaticLayout staticLayout2 = new StaticLayout(Emoji.replaceEmoji(String.format("%d %s", Integer.valueOf(tL_reactionCount.count), tL_reactionCount.reaction), Theme.chat_msgBotButtonPaint.getFontMetricsInt(), AndroidUtilities.dp(15.0f), false), Theme.chat_msgBotButtonPaint, AndroidUtilities.dp(2000.0f), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
if (staticLayout2.getLineCount() > 0) {
float lineWidth2 = staticLayout2.getLineWidth(0);
float lineLeft2 = staticLayout2.getLineLeft(0);
if (lineLeft2 < lineWidth2) {
lineWidth2 -= lineLeft2;
}
i = Math.max(0, ((int) Math.ceil(lineWidth2)) + AndroidUtilities.dp(4.0f));
} else {
i = 0;
}
this.wantedBotKeyboardWidth = Math.max(this.wantedBotKeyboardWidth, ((i + AndroidUtilities.dp(12.0f)) * size2) + (AndroidUtilities.dp(5.0f) * (size2 - 1)));
}
}
}
public boolean isFcmMessage() {
return this.localType != 0;
}
public void setDelegate(Delegate delegate) {
this.delegate = delegate;
}
public String setMoneyFormat(String str) {
if (!NumberUtil.isNumber(str)) {
return "";
}
if (str.contains(".")) {
String[] split = str.split("\\.");
String str2 = split[0];
String str3 = split[1];
String formatToString = MoneyUtil.formatToString(new BigDecimal(String.valueOf(str2)).multiply(new BigDecimal("1")).toString(), 0);
if (str3.length() > 8) {
str3 = str3.substring(0, 8);
}
return formatToString + "." + str3;
}
return MoneyUtil.formatToString(new BigDecimal(String.valueOf(str)).multiply(new BigDecimal("1")).toString(), 0);
}
private void updateMessageText(AbstractMap<Integer, TLRPC.User> abstractMap, AbstractMap<Integer, TLRPC.Chat> abstractMap2, SparseArray<TLRPC.User> sparseArray, SparseArray<TLRPC.Chat> sparseArray2) {
TLRPC.User user;
TLRPC.User user2;
String str;
String str2;
TLRPC.User user3;
TLRPC.User user4;
String formatCallDuration;
String charSequence;
int indexOf;
TLRPC.Chat chat;
TLObject tLObject;
TLObject tLObject2;
TLRPC.User user5;
if (this.messageOwner.from_id > 0) {
if (abstractMap != null) {
user5 = abstractMap.get(Integer.valueOf(this.messageOwner.from_id));
} else {
user5 = sparseArray != null ? sparseArray.get(this.messageOwner.from_id) : null;
}
if (user5 == null) {
user5 = MessagesController.getInstance(this.currentAccount).getUser(Integer.valueOf(this.messageOwner.from_id));
}
user = user5;
} else {
user = null;
}
TLRPC.Message message = this.messageOwner;
char c = 0;
if (message instanceof TLRPC.TL_messageService) {
if (message.action != null) {
if (this.messageOwner.action instanceof TLRPCRedpacket.CL_messagesActionReceivedRpkTransfer) {
TLRPCRedpacket.CL_messagesActionReceivedRpkTransfer cL_messagesActionReceivedRpkTransfer = (TLRPCRedpacket.CL_messagesActionReceivedRpkTransfer) this.messageOwner.action;
MessagesController.getInstance(this.currentAccount).getUser(Integer.valueOf(cL_messagesActionReceivedRpkTransfer.receiver.user_id));
TLRPC.User user6 = MessagesController.getInstance(this.currentAccount).getUser(Integer.valueOf(cL_messagesActionReceivedRpkTransfer.sender.user_id));
RedpacketResponse redpacketResponse = (RedpacketResponse) TLJsonResolve.parse(cL_messagesActionReceivedRpkTransfer.data, (Class<?>) RedpacketResponse.class).model;
if (user != null) {
int parseInt = (cL_messagesActionReceivedRpkTransfer.sender.user_id != UserConfig.getInstance(UserConfig.selectedAccount).clientUserId || redpacketResponse == null || redpacketResponse.getRed() == null || TextUtils.isEmpty(redpacketResponse.getRed().getStatus()) || !isFromChat()) ? -1 : Integer.parseInt(redpacketResponse.getRed().getStatus());
if (isOut()) {
this.messageText = replaceWithLink(" 您领取了un的红包", "un", user6, parseInt, new ClickableSpan() {
@Override
public void onClick(View view) {
if (MessageObject.this.delegate != null) {
MessageObject.this.delegate.onClickRed();
}
}
@Override
public void updateDrawState(TextPaint textPaint) {
textPaint.setUnderlineText(false);
}
});
} else if (user6 != null && user6.id == UserConfig.getInstance(UserConfig.selectedAccount).clientUserId) {
this.messageText = replaceWithLink(" un领取了您的红包", "un", user, parseInt, new ClickableSpan() {
@Override
public void onClick(View view) {
if (MessageObject.this.delegate != null) {
MessageObject.this.delegate.onClickRed();
}
}
@Override
public void updateDrawState(TextPaint textPaint) {
textPaint.setUnderlineText(false);
}
});
} else {
CharSequence replaceWithLink = replaceWithLink(" un1领取了un2的红包", "un1", user, true);
this.messageText = replaceWithLink;
this.messageText = replaceWithLink(replaceWithLink, "un2", user6, parseInt, new ClickableSpan() {
@Override
public void onClick(View view) {
if (MessageObject.this.delegate != null) {
MessageObject.this.delegate.onClickRed();
}
}
@Override
public void updateDrawState(TextPaint textPaint) {
textPaint.setUnderlineText(false);
}
});
}
}
} else if (this.messageOwner.action instanceof TLRPC.TL_messageActionCustomAction) {
if ("MUTUALCONTACTS".equals(this.messageOwner.action.message)) {
this.messageText = LocaleController.getString("MutualContactsText", R.string.MutualContactsText);
} else {
this.messageText = this.messageOwner.action.message;
}
} else if (this.messageOwner.action instanceof TLRPC.TL_messageActionChatCreate) {
if (isOut()) {
this.messageText = LocaleController.getString("ActionYouCreateGroup", R.string.ActionYouCreateGroup);
} else {
this.messageText = replaceWithLink(LocaleController.getString("ActionCreateGroup", R.string.ActionCreateGroup), "un1", user);
}
} else if (this.messageOwner.action instanceof TLRPC.TL_messageActionChatDeleteUser) {
if (this.messageOwner.action.user_id == this.messageOwner.from_id) {
if (isOut()) {
this.messageText = LocaleController.getString("ActionYouLeftUser", R.string.ActionYouLeftUser);
} else {
this.messageText = replaceWithLink(LocaleController.getString("ActionLeftUser", R.string.ActionLeftUser), "un1", user);
}
} else {
if (abstractMap != null) {
tLObject2 = (TLRPC.User) abstractMap.get(Integer.valueOf(this.messageOwner.action.user_id));
} else {
tLObject2 = sparseArray != null ? (TLRPC.User) sparseArray.get(this.messageOwner.action.user_id) : null;
}
if (tLObject2 == null) {
tLObject2 = MessagesController.getInstance(this.currentAccount).getUser(Integer.valueOf(this.messageOwner.action.user_id));
}
if (isOut()) {
this.messageText = replaceWithLink(LocaleController.getString("ActionYouKickUser", R.string.ActionYouKickUser), "un2", tLObject2);
} else if (this.messageOwner.action.user_id == UserConfig.getInstance(this.currentAccount).getClientUserId()) {
this.messageText = replaceWithLink(LocaleController.getString("ActionKickUserYou", R.string.ActionKickUserYou), "un1", user);
} else {
CharSequence replaceWithLink2 = replaceWithLink(LocaleController.getString("ActionKickUser", R.string.ActionKickUser), "un2", tLObject2);
this.messageText = replaceWithLink2;
this.messageText = replaceWithLink(replaceWithLink2, "un1", user);
}
}
} else if (this.messageOwner.action instanceof TLRPC.TL_messageActionChatAddUser) {
int i = this.messageOwner.action.user_id;
if (i == 0 && this.messageOwner.action.users.size() == 1) {
i = this.messageOwner.action.users.get(0).intValue();
}
if (i != 0) {
if (abstractMap != null) {
tLObject = (TLRPC.User) abstractMap.get(Integer.valueOf(i));
} else {
tLObject = sparseArray != null ? (TLRPC.User) sparseArray.get(i) : null;
}
if (tLObject == null) {
tLObject = MessagesController.getInstance(this.currentAccount).getUser(Integer.valueOf(i));
}
if (i == this.messageOwner.from_id) {
if (this.messageOwner.to_id.channel_id != 0 && !isMegagroup()) {
this.messageText = LocaleController.getString("ChannelJoined", R.string.ChannelJoined);
} else if (this.messageOwner.to_id.channel_id != 0 && isMegagroup()) {
if (i == UserConfig.getInstance(this.currentAccount).getClientUserId()) {
this.messageText = LocaleController.getString("ChannelMegaJoined", R.string.ChannelMegaJoined);
} else {
this.messageText = replaceWithLink(LocaleController.getString("ActionAddUserSelfMega", R.string.ActionAddUserSelfMega), "un1", user);
}
} else if (isOut()) {
this.messageText = LocaleController.getString("ActionAddUserSelfYou", R.string.ActionAddUserSelfYou);
} else {
this.messageText = replaceWithLink(LocaleController.getString("ActionAddUserSelf", R.string.ActionAddUserSelf), "un1", user);
}
} else if (isOut()) {
this.messageText = replaceWithLink(LocaleController.getString("ActionYouAddUser", R.string.ActionYouAddUser), "un2", tLObject);
} else if (i == UserConfig.getInstance(this.currentAccount).getClientUserId()) {
if (this.messageOwner.to_id.channel_id != 0) {
if (isMegagroup()) {
this.messageText = replaceWithLink(LocaleController.getString("MegaAddedBy", R.string.MegaAddedBy), "un1", user);
} else {
this.messageText = replaceWithLink(LocaleController.getString("ChannelAddedBy", R.string.ChannelAddedBy), "un1", user);
}
} else {
this.messageText = replaceWithLink(LocaleController.getString("ActionAddUserYou", R.string.ActionAddUserYou), "un1", user);
}
} else {
CharSequence replaceWithLink3 = replaceWithLink(LocaleController.getString("ActionAddUser", R.string.ActionAddUser), "un2", tLObject);
this.messageText = replaceWithLink3;
this.messageText = replaceWithLink(replaceWithLink3, "un1", user);
}
} else if (isOut()) {
this.messageText = replaceWithLink(LocaleController.getString("ActionYouAddUser", R.string.ActionYouAddUser), "un2", this.messageOwner.action.users, abstractMap, sparseArray);
} else {
CharSequence replaceWithLink4 = replaceWithLink(LocaleController.getString("ActionAddUser", R.string.ActionAddUser), "un2", this.messageOwner.action.users, abstractMap, sparseArray);
this.messageText = replaceWithLink4;
this.messageText = replaceWithLink(replaceWithLink4, "un1", user);
}
} else if (this.messageOwner.action instanceof TLRPC.TL_messageActionChatJoinedByLink) {
if (isOut()) {
this.messageText = LocaleController.getString("ActionInviteYou", R.string.ActionInviteYou);
} else {
this.messageText = replaceWithLink(LocaleController.getString("ActionInviteUser", R.string.ActionInviteUser), "un1", user);
}
} else if (this.messageOwner.action instanceof TLRPC.TL_messageActionChatEditPhoto) {
if (this.messageOwner.to_id.channel_id != 0 && !isMegagroup()) {
this.messageText = LocaleController.getString("ActionChannelChangedPhoto", R.string.ActionChannelChangedPhoto);
} else if (isOut()) {
this.messageText = LocaleController.getString("ActionYouChangedPhoto", R.string.ActionYouChangedPhoto);
} else {
this.messageText = replaceWithLink(LocaleController.getString("ActionChangedPhoto", R.string.ActionChangedPhoto), "un1", user);
}
} else if (this.messageOwner.action instanceof TLRPC.TL_messageActionChatEditTitle) {
if (this.messageOwner.to_id.channel_id != 0 && !isMegagroup()) {
this.messageText = LocaleController.getString("ActionChannelChangedTitle", R.string.ActionChannelChangedTitle).replace("un2", this.messageOwner.action.title);
} else if (isOut()) {
this.messageText = LocaleController.getString("ActionYouChangedTitle", R.string.ActionYouChangedTitle).replace("un2", this.messageOwner.action.title);
} else {
this.messageText = replaceWithLink(LocaleController.getString("ActionChangedTitle", R.string.ActionChangedTitle).replace("un2", this.messageOwner.action.title), "un1", user);
}
} else if (this.messageOwner.action instanceof TLRPC.TL_messageActionChatDeletePhoto) {
if (this.messageOwner.to_id.channel_id != 0 && !isMegagroup()) {
this.messageText = LocaleController.getString("ActionChannelRemovedPhoto", R.string.ActionChannelRemovedPhoto);
} else if (isOut()) {
this.messageText = LocaleController.getString("ActionYouRemovedPhoto", R.string.ActionYouRemovedPhoto);
} else {
this.messageText = replaceWithLink(LocaleController.getString("ActionRemovedPhoto", R.string.ActionRemovedPhoto), "un1", user);
}
} else if (this.messageOwner.action instanceof TLRPC.TL_messageActionTTLChange) {
if (this.messageOwner.action.ttl != 0) {
if (isOut()) {
this.messageText = LocaleController.formatString("MessageLifetimeChangedOutgoing", R.string.MessageLifetimeChangedOutgoing, LocaleController.formatTTLString(this.messageOwner.action.ttl));
} else {
this.messageText = LocaleController.formatString("MessageLifetimeChanged", R.string.MessageLifetimeChanged, UserObject.getFirstName(user), LocaleController.formatTTLString(this.messageOwner.action.ttl));
}
} else if (isOut()) {
this.messageText = LocaleController.getString("MessageLifetimeYouRemoved", R.string.MessageLifetimeYouRemoved);
} else {
this.messageText = LocaleController.formatString("MessageLifetimeRemoved", R.string.MessageLifetimeRemoved, UserObject.getFirstName(user));
}
} else if (this.messageOwner.action instanceof TLRPC.TL_messageActionLoginUnknownLocation) {
long j = this.messageOwner.date * 1000;
String formatString = (LocaleController.getInstance().formatterDay == null || LocaleController.getInstance().formatterYear == null) ? "" + this.messageOwner.date : LocaleController.formatString("formatDateAtTime", R.string.formatDateAtTime, LocaleController.getInstance().formatterYear.format(j), LocaleController.getInstance().formatterDay.format(j));
TLRPC.User currentUser = UserConfig.getInstance(this.currentAccount).getCurrentUser();
if (currentUser == null) {
if (abstractMap != null) {
currentUser = abstractMap.get(Integer.valueOf(this.messageOwner.to_id.user_id));
} else if (sparseArray != null) {
currentUser = sparseArray.get(this.messageOwner.to_id.user_id);
}
if (currentUser == null) {
currentUser = MessagesController.getInstance(this.currentAccount).getUser(Integer.valueOf(this.messageOwner.to_id.user_id));
}
}
this.messageText = LocaleController.formatString("NotificationUnrecognizedDevice", R.string.NotificationUnrecognizedDevice, currentUser != null ? UserObject.getFirstName(currentUser) : "", formatString, this.messageOwner.action.title, this.messageOwner.action.address);
} else if ((this.messageOwner.action instanceof TLRPC.TL_messageActionUserJoined) || (this.messageOwner.action instanceof TLRPC.TL_messageActionContactSignUp)) {
this.messageText = LocaleController.formatString("NotificationContactJoined", R.string.NotificationContactJoined, UserObject.getName(user));
} else if (this.messageOwner.action instanceof TLRPC.TL_messageActionUserUpdatedPhoto) {
this.messageText = LocaleController.formatString("NotificationContactNewPhoto", R.string.NotificationContactNewPhoto, UserObject.getName(user));
} else if (this.messageOwner.action instanceof TLRPC.TL_messageEncryptedAction) {
if (this.messageOwner.action.encryptedAction instanceof TLRPC.TL_decryptedMessageActionScreenshotMessages) {
if (isOut()) {
this.messageText = LocaleController.formatString("ActionTakeScreenshootYou", R.string.ActionTakeScreenshootYou, new Object[0]);
} else {
this.messageText = replaceWithLink(LocaleController.getString("ActionTakeScreenshoot", R.string.ActionTakeScreenshoot), "un1", user);
}
} else if (this.messageOwner.action.encryptedAction instanceof TLRPC.TL_decryptedMessageActionSetMessageTTL) {
TLRPC.TL_decryptedMessageActionSetMessageTTL tL_decryptedMessageActionSetMessageTTL = (TLRPC.TL_decryptedMessageActionSetMessageTTL) this.messageOwner.action.encryptedAction;
if (tL_decryptedMessageActionSetMessageTTL.ttl_seconds != 0) {
if (isOut()) {
this.messageText = LocaleController.formatString("MessageLifetimeChangedOutgoing", R.string.MessageLifetimeChangedOutgoing, LocaleController.formatTTLString(tL_decryptedMessageActionSetMessageTTL.ttl_seconds));
} else {
this.messageText = LocaleController.formatString("MessageLifetimeChanged", R.string.MessageLifetimeChanged, UserObject.getFirstName(user), LocaleController.formatTTLString(tL_decryptedMessageActionSetMessageTTL.ttl_seconds));
}
} else if (isOut()) {
this.messageText = LocaleController.getString("MessageLifetimeYouRemoved", R.string.MessageLifetimeYouRemoved);
} else {
this.messageText = LocaleController.formatString("MessageLifetimeRemoved", R.string.MessageLifetimeRemoved, UserObject.getFirstName(user));
}
}
} else if (this.messageOwner.action instanceof TLRPC.TL_messageActionScreenshotTaken) {
if (isOut()) {
this.messageText = LocaleController.formatString("ActionTakeScreenshootYou", R.string.ActionTakeScreenshootYou, new Object[0]);
} else {
this.messageText = replaceWithLink(LocaleController.getString("ActionTakeScreenshoot", R.string.ActionTakeScreenshoot), "un1", user);
}
} else if (this.messageOwner.action instanceof TLRPC.TL_messageActionCreatedBroadcastList) {
this.messageText = LocaleController.formatString("YouCreatedBroadcastList", R.string.YouCreatedBroadcastList, new Object[0]);
} else if (this.messageOwner.action instanceof TLRPC.TL_messageActionChannelCreate) {
if (isMegagroup()) {
this.messageText = LocaleController.getString("ActionCreateMega", R.string.ActionCreateMega);
} else {
this.messageText = LocaleController.getString("ActionCreateChannel", R.string.ActionCreateChannel);
}
} else if (this.messageOwner.action instanceof TLRPC.TL_messageActionChatMigrateTo) {
this.messageText = LocaleController.getString("ActionMigrateFromGroup", R.string.ActionMigrateFromGroup);
} else if (this.messageOwner.action instanceof TLRPC.TL_messageActionChannelMigrateFrom) {
this.messageText = LocaleController.getString("ActionMigrateFromGroup", R.string.ActionMigrateFromGroup);
} else if (this.messageOwner.action instanceof TLRPC.TL_messageActionPinMessage) {
if (user == null) {
if (abstractMap2 != null) {
chat = abstractMap2.get(Integer.valueOf(this.messageOwner.to_id.channel_id));
} else if (sparseArray2 != null) {
chat = sparseArray2.get(this.messageOwner.to_id.channel_id);
}
generatePinMessageText(user, chat);
}
chat = null;
generatePinMessageText(user, chat);
} else if (this.messageOwner.action instanceof TLRPC.TL_messageActionLiveStart_layer105) {
TLRPC.TL_messageActionLiveStart_layer105 tL_messageActionLiveStart_layer105 = (TLRPC.TL_messageActionLiveStart_layer105) this.messageOwner.action;
TLRPC.User user7 = MessagesController.getInstance(this.currentAccount).getUser(Integer.valueOf(tL_messageActionLiveStart_layer105.live_user));
if (user7 != null) {
StringBuilder sb = new StringBuilder();
sb.append(user7.first_name.length() > 6 ? user7.first_name.substring(0, 6) + "..." : user7.first_name);
sb.append(LocaleController.getString(R.string.live_start_live));
sb.append(": ");
sb.append(tL_messageActionLiveStart_layer105.live_name);
this.messageText = sb.toString();
}
} else if (this.messageOwner.action instanceof TLRPC.TL_messageActionLiveStop_layer105) {
this.messageText = LocaleController.getString(R.string.live_end_live) + ": " + ((TLRPC.TL_messageActionLiveStop_layer105) this.messageOwner.action).live_name;
} else if (this.messageOwner.action instanceof TLRPC.TL_messageActionHistoryClear) {
this.messageText = LocaleController.getString("HistoryCleared", R.string.HistoryCleared);
} else if (this.messageOwner.action instanceof TLRPC.TL_messageActionGameScore) {
generateGameMessageText(user);
} else if (this.messageOwner.action instanceof TLRPC.TL_messageActionPhoneCall) {
TLRPC.TL_messageActionPhoneCall tL_messageActionPhoneCall = (TLRPC.TL_messageActionPhoneCall) this.messageOwner.action;
boolean z = tL_messageActionPhoneCall.reason instanceof TLRPC.TL_phoneCallDiscardReasonMissed;
if (this.messageOwner.from_id == UserConfig.getInstance(this.currentAccount).getClientUserId()) {
if (z) {
this.messageText = LocaleController.getString("CallMessageOutgoingMissed", R.string.CallMessageOutgoingMissed);
} else {
this.messageText = LocaleController.getString("CallMessageOutgoing", R.string.CallMessageOutgoing);
}
} else if (z) {
this.messageText = LocaleController.getString("CallMessageIncomingMissed", R.string.CallMessageIncomingMissed);
} else if (tL_messageActionPhoneCall.reason instanceof TLRPC.TL_phoneCallDiscardReasonBusy) {
this.messageText = LocaleController.getString("CallMessageIncomingDeclined", R.string.CallMessageIncomingDeclined);
} else {
this.messageText = LocaleController.getString("CallMessageIncoming", R.string.CallMessageIncoming);
}
if ((tL_messageActionPhoneCall.flags & 4) != 0) {
this.messageText = "[" + LocaleController.getString("AutoDownloadVideosOn", R.string.AutoDownloadVideosOn) + LocaleController.getString("Calls", R.string.Calls) + "]";
} else {
this.messageText = "[" + LocaleController.getString("visual_call_voice", R.string.visual_call_voice) + LocaleController.getString("Calls", R.string.Calls) + "]";
}
if (tL_messageActionPhoneCall.duration > 0 && (indexOf = (charSequence = this.messageText.toString()).indexOf((formatCallDuration = LocaleController.formatCallDuration(tL_messageActionPhoneCall.duration)))) != -1) {
SpannableString spannableString = new SpannableString(this.messageText);
int length = formatCallDuration.length() + indexOf;
if (indexOf > 0 && charSequence.charAt(indexOf - 1) == '(') {
indexOf--;
}
if (length < charSequence.length() && charSequence.charAt(length) == ')') {
length++;
}
spannableString.setSpan(new TypefaceSpan(Typeface.DEFAULT), indexOf, length, 0);
this.messageText = spannableString;
}
} else if (this.messageOwner.action instanceof TLRPC.TL_messageActionPaymentSent) {
int dialogId = (int) getDialogId();
if (abstractMap != null) {
user4 = abstractMap.get(Integer.valueOf(dialogId));
} else {
user4 = sparseArray != null ? sparseArray.get(dialogId) : null;
}
if (user4 == null) {
user4 = MessagesController.getInstance(this.currentAccount).getUser(Integer.valueOf(dialogId));
}
generatePaymentSentMessageText(user4);
} else if (this.messageOwner.action instanceof TLRPC.TL_messageActionBotAllowed) {
String str3 = ((TLRPC.TL_messageActionBotAllowed) this.messageOwner.action).domain;
String string = LocaleController.getString("ActionBotAllowed", R.string.ActionBotAllowed);
int indexOf2 = string.indexOf("%1$s");
SpannableString spannableString2 = new SpannableString(String.format(string, str3));
if (indexOf2 >= 0) {
spannableString2.setSpan(new URLSpanNoUnderlineBold("http://" + str3), indexOf2, str3.length() + indexOf2, 33);
}
this.messageText = spannableString2;
} else if (this.messageOwner.action instanceof TLRPC.TL_messageActionSecureValuesSent) {
TLRPC.TL_messageActionSecureValuesSent tL_messageActionSecureValuesSent = (TLRPC.TL_messageActionSecureValuesSent) this.messageOwner.action;
StringBuilder sb2 = new StringBuilder();
int size = tL_messageActionSecureValuesSent.types.size();
for (int i2 = 0; i2 < size; i2++) {
TLRPC.SecureValueType secureValueType = tL_messageActionSecureValuesSent.types.get(i2);
if (sb2.length() > 0) {
sb2.append(", ");
}
if (secureValueType instanceof TLRPC.TL_secureValueTypePhone) {
sb2.append(LocaleController.getString("ActionBotDocumentPhone", R.string.ActionBotDocumentPhone));
} else if (secureValueType instanceof TLRPC.TL_secureValueTypeEmail) {
sb2.append(LocaleController.getString("ActionBotDocumentEmail", R.string.ActionBotDocumentEmail));
} else if (secureValueType instanceof TLRPC.TL_secureValueTypeAddress) {
sb2.append(LocaleController.getString("ActionBotDocumentAddress", R.string.ActionBotDocumentAddress));
} else if (secureValueType instanceof TLRPC.TL_secureValueTypePersonalDetails) {
sb2.append(LocaleController.getString("ActionBotDocumentIdentity", R.string.ActionBotDocumentIdentity));
} else if (secureValueType instanceof TLRPC.TL_secureValueTypePassport) {
sb2.append(LocaleController.getString("ActionBotDocumentPassport", R.string.ActionBotDocumentPassport));
} else if (secureValueType instanceof TLRPC.TL_secureValueTypeDriverLicense) {
sb2.append(LocaleController.getString("ActionBotDocumentDriverLicence", R.string.ActionBotDocumentDriverLicence));
} else if (secureValueType instanceof TLRPC.TL_secureValueTypeIdentityCard) {
sb2.append(LocaleController.getString("ActionBotDocumentIdentityCard", R.string.ActionBotDocumentIdentityCard));
} else if (secureValueType instanceof TLRPC.TL_secureValueTypeUtilityBill) {
sb2.append(LocaleController.getString("ActionBotDocumentUtilityBill", R.string.ActionBotDocumentUtilityBill));
} else if (secureValueType instanceof TLRPC.TL_secureValueTypeBankStatement) {
sb2.append(LocaleController.getString("ActionBotDocumentBankStatement", R.string.ActionBotDocumentBankStatement));
} else if (secureValueType instanceof TLRPC.TL_secureValueTypeRentalAgreement) {
sb2.append(LocaleController.getString("ActionBotDocumentRentalAgreement", R.string.ActionBotDocumentRentalAgreement));
} else if (secureValueType instanceof TLRPC.TL_secureValueTypeInternalPassport) {
sb2.append(LocaleController.getString("ActionBotDocumentInternalPassport", R.string.ActionBotDocumentInternalPassport));
} else if (secureValueType instanceof TLRPC.TL_secureValueTypePassportRegistration) {
sb2.append(LocaleController.getString("ActionBotDocumentPassportRegistration", R.string.ActionBotDocumentPassportRegistration));
} else if (secureValueType instanceof TLRPC.TL_secureValueTypeTemporaryRegistration) {
sb2.append(LocaleController.getString("ActionBotDocumentTemporaryRegistration", R.string.ActionBotDocumentTemporaryRegistration));
}
}
if (this.messageOwner.to_id != null) {
if (abstractMap != null) {
user3 = abstractMap.get(Integer.valueOf(this.messageOwner.to_id.user_id));
} else {
user3 = sparseArray != null ? sparseArray.get(this.messageOwner.to_id.user_id) : null;
}
if (user3 == null) {
user3 = MessagesController.getInstance(this.currentAccount).getUser(Integer.valueOf(this.messageOwner.to_id.user_id));
}
} else {
user3 = null;
}
this.messageText = LocaleController.formatString("ActionBotDocuments", R.string.ActionBotDocuments, UserObject.getFirstName(user3), sb2.toString());
}
}
} else {
this.isRestrictedMessage = false;
String restrictionReason = MessagesController.getRestrictionReason(message.restriction_reason);
if (!TextUtils.isEmpty(restrictionReason)) {
this.messageText = restrictionReason;
this.isRestrictedMessage = true;
} else if (!isMediaEmpty()) {
if (this.messageOwner.media instanceof TLRPC.TL_messageMediaPoll) {
this.messageText = LocaleController.getString("Poll", R.string.Poll);
} else if (this.messageOwner.media instanceof TLRPC.TL_messageMediaPhoto) {
if (this.messageOwner.media.ttl_seconds != 0 && !(this.messageOwner instanceof TLRPC.TL_message_secret)) {
this.messageText = LocaleController.getString("AttachDestructingPhoto", R.string.AttachDestructingPhoto);
} else {
this.messageText = LocaleController.getString("AttachPhoto", R.string.AttachPhoto);
}
} else if (isVideo() || ((this.messageOwner.media instanceof TLRPC.TL_messageMediaDocument) && (getDocument() instanceof TLRPC.TL_documentEmpty) && this.messageOwner.media.ttl_seconds != 0)) {
if (this.messageOwner.media.ttl_seconds != 0 && !(this.messageOwner instanceof TLRPC.TL_message_secret)) {
this.messageText = LocaleController.getString("AttachDestructingVideo", R.string.AttachDestructingVideo);
} else {
this.messageText = LocaleController.getString("AttachVideo", R.string.AttachVideo);
}
} else if (isVoice()) {
this.messageText = LocaleController.getString("AttachAudio", R.string.AttachAudio);
} else if (isRoundVideo()) {
this.messageText = LocaleController.getString("AttachRound", R.string.AttachRound);
} else if ((this.messageOwner.media instanceof TLRPC.TL_messageMediaGeo) || (this.messageOwner.media instanceof TLRPC.TL_messageMediaVenue)) {
this.messageText = LocaleController.getString("AttachLocation", R.string.AttachLocation);
} else if (this.messageOwner.media instanceof TLRPC.TL_messageMediaGeoLive) {
this.messageText = LocaleController.getString("AttachLiveLocation", R.string.AttachLiveLocation);
} else if (this.messageOwner.media instanceof TLRPC.TL_messageMediaContact) {
this.messageText = LocaleController.getString("AttachContact", R.string.AttachContact);
if (!TextUtils.isEmpty(this.messageOwner.media.vcard)) {
this.vCardData = VCardData.parse(this.messageOwner.media.vcard);
}
} else if (this.messageOwner.media instanceof TLRPC.TL_messageMediaGame) {
this.messageText = this.messageOwner.message;
} else if (this.messageOwner.media instanceof TLRPC.TL_messageMediaInvoice) {
this.messageText = this.messageOwner.media.description;
} else if (this.messageOwner.media instanceof TLRPC.TL_messageMediaUnsupported) {
this.messageText = LocaleController.getString("UnsupportedMedia", R.string.UnsupportedMedia);
} else if (this.messageOwner.media instanceof TLRPC.TL_messageMediaDocument) {
if (isSticker() || isAnimatedSticker()) {
String strickerChar = getStrickerChar();
if (strickerChar == null || strickerChar.length() <= 0) {
this.messageText = LocaleController.getString("AttachSticker", R.string.AttachSticker);
} else {
this.messageText = String.format("%s %s", strickerChar, LocaleController.getString("AttachSticker", R.string.AttachSticker));
}
} else if (isMusic()) {
this.messageText = LocaleController.getString("AttachMusic", R.string.AttachMusic);
} else if (isGif()) {
this.messageText = LocaleController.getString("AttachGif", R.string.AttachGif);
} else {
String documentFileName = FileLoader.getDocumentFileName(getDocument());
if (documentFileName != null && documentFileName.length() > 0) {
this.messageText = documentFileName;
} else {
this.messageText = LocaleController.getString("AttachDocument", R.string.AttachDocument);
}
}
} else if (this.messageOwner.media instanceof TLRPCRedpacket.CL_messagesPayBillOverMedia) {
TLRPCRedpacket.CL_messagesPayBillOverMedia cL_messagesPayBillOverMedia = (TLRPCRedpacket.CL_messagesPayBillOverMedia) this.messageOwner.media;
PayBillOverBean payBillOverBean = (PayBillOverBean) GsonUtils.fromJson(TLJsonResolve.getData(cL_messagesPayBillOverMedia.data), PayBillOverBean.class);
if (payBillOverBean.coin_code.contains("-")) {
str = payBillOverBean.coin_code.split("-")[0];
} else {
str = payBillOverBean.coin_code;
}
switch (cL_messagesPayBillOverMedia.deal_code) {
case 1:
case 3:
case 4:
case 6:
StringBuilder sb3 = new StringBuilder();
sb3.append(LocaleController.getString("PayBillSuccessfullyTransferredOut", R.string.PayBillSuccessfullyTransferredOut));
sb3.append(TextUtils.isEmpty(payBillOverBean.deal_amount) ? "0" : payBillOverBean.deal_amount);
sb3.append(LocaleController.getString("PayBillA", R.string.PayBillA));
sb3.append(str);
sb3.append(LocaleController.getString("PayBillClickToView", R.string.PayBillClickToView));
str2 = sb3.toString();
break;
case 2:
case 7:
StringBuilder sb4 = new StringBuilder();
sb4.append(LocaleController.getString("PayBillRogerThat", R.string.PayBillRogerThat));
sb4.append(TextUtils.isEmpty(payBillOverBean.deal_amount) ? "0" : payBillOverBean.deal_amount);
sb4.append(LocaleController.getString("PayBillA", R.string.PayBillA));
sb4.append(str);
sb4.append(LocaleController.getString("PayBillTransferInView", R.string.PayBillTransferInView));
str2 = sb4.toString();
break;
case 5:
StringBuilder sb5 = new StringBuilder();
sb5.append(LocaleController.getString("PayBillRogerThat", R.string.PayBillRogerThat));
sb5.append(TextUtils.isEmpty(payBillOverBean.deal_amount) ? "0" : payBillOverBean.deal_amount);
sb5.append(LocaleController.getString("PayBillA", R.string.PayBillA));
sb5.append(str);
sb5.append(LocaleController.getString("PayBillReturnClickToView", R.string.PayBillReturnClickToView));
str2 = sb5.toString();
break;
case 8:
if (!TextUtils.isEmpty(payBillOverBean.deal_type)) {
String str4 = payBillOverBean.deal_type;
int hashCode = str4.hashCode();
if (hashCode == 49) {
break;
} else {
if (hashCode == 50 && str4.equals("2")) {
c = 1;
if (c == 0) {
if (c == 1) {
StringBuilder sb6 = new StringBuilder();
sb6.append(LocaleController.getString("PayBillCommissionBuy2", R.string.PayBillCommissionBuy2));
sb6.append(setMoneyFormat(TextUtils.isEmpty(payBillOverBean.deal_num) ? "0" : payBillOverBean.deal_num));
sb6.append(LocaleController.getString("PayBillA", R.string.PayBillA));
sb6.append(str);
sb6.append(LocaleController.getString("PayBillClickToView", R.string.PayBillClickToView));
str2 = sb6.toString();
break;
}
} else {
StringBuilder sb7 = new StringBuilder();
sb7.append(LocaleController.getString("PayBillCommissionBuy2", R.string.PayBillCommissionBuy2));
sb7.append(setMoneyFormat(TextUtils.isEmpty(payBillOverBean.deal_amount) ? "0" : payBillOverBean.deal_amount));
sb7.append(LocaleController.getString("PayBillA", R.string.PayBillA));
sb7.append(str);
sb7.append(LocaleController.getString("PayBillClickToView", R.string.PayBillClickToView));
str2 = sb7.toString();
break;
}
}
c = 65535;
if (c == 0) {
}
}
}
str2 = "";
break;
case 9:
StringBuilder sb8 = new StringBuilder();
sb8.append(LocaleController.getString("PayBillCommissionSell2", R.string.PayBillCommissionSell2));
sb8.append(setMoneyFormat(TextUtils.isEmpty(payBillOverBean.deal_num) ? "0" : payBillOverBean.deal_num));
sb8.append(LocaleController.getString("PayBillA", R.string.PayBillA));
sb8.append(str);
sb8.append(LocaleController.getString("PayBillClickToView", R.string.PayBillClickToView));
str2 = sb8.toString();
break;
case 10:
StringBuilder sb9 = new StringBuilder();
sb9.append(LocaleController.getString("PayBillCommissionReturn2", R.string.PayBillCommissionReturn2));
sb9.append(setMoneyFormat(TextUtils.isEmpty(payBillOverBean.deal_amount) ? "0" : payBillOverBean.deal_amount));
sb9.append(LocaleController.getString("PayBillA", R.string.PayBillA));
sb9.append(str);
sb9.append(LocaleController.getString("PayBillReturnClickToView", R.string.PayBillReturnClickToView));
str2 = sb9.toString();
break;
case 11:
StringBuilder sb10 = new StringBuilder();
sb10.append(LocaleController.getString("PayBillFiatCurrencyBuy2", R.string.PayBillFiatCurrencyBuy2));
sb10.append(TextUtils.isEmpty(payBillOverBean.deal_num) ? "0" : payBillOverBean.deal_num);
sb10.append(LocaleController.getString("PayBillA", R.string.PayBillA));
sb10.append(str);
sb10.append(LocaleController.getString("PayBillClickToView", R.string.PayBillClickToView));
str2 = sb10.toString();
break;
case 12:
StringBuilder sb11 = new StringBuilder();
sb11.append(LocaleController.getString("PayBillFiatCurrencySell2", R.string.PayBillFiatCurrencySell2));
sb11.append(TextUtils.isEmpty(payBillOverBean.deal_num) ? "0" : payBillOverBean.deal_num);
sb11.append(LocaleController.getString("PayBillA", R.string.PayBillA));
sb11.append(str);
sb11.append(LocaleController.getString("PayBillClickToView", R.string.PayBillClickToView));
str2 = sb11.toString();
break;
default:
str2 = "";
break;
}
this.messageText = str2;
} else if (this.messageOwner.media instanceof TLRPCRedpacket.CL_messagesRpkTransferMedia) {
TLRPCRedpacket.CL_messagesRpkTransferMedia cL_messagesRpkTransferMedia = (TLRPCRedpacket.CL_messagesRpkTransferMedia) this.messageOwner.media;
if (cL_messagesRpkTransferMedia.trans == 0) {
RedpacketResponse redpacketResponse2 = cL_messagesRpkTransferMedia.data != null ? (RedpacketResponse) TLJsonResolve.parse(cL_messagesRpkTransferMedia.data, (Class<?>) RedpacketResponse.class).model : null;
if (redpacketResponse2 != null) {
this.messageText = "[红包]" + redpacketResponse2.getRed().getRemarks();
} else {
this.messageText = "[红包]红包消息";
}
} else if (cL_messagesRpkTransferMedia.trans == 1 || cL_messagesRpkTransferMedia.trans == 2) {
TransferResponse transferResponse = cL_messagesRpkTransferMedia.data != null ? (TransferResponse) TLJsonResolve.parse(cL_messagesRpkTransferMedia.data, (Class<?>) TransferResponse.class).model : null;
if (transferResponse != null) {
TransferResponse.Status state = transferResponse.getState();
if (isOutOwner()) {
if (state == TransferResponse.Status.WAITING) {
this.messageText = "[彩币转账]等待对方收款";
} else if (state == TransferResponse.Status.RECEIVED) {
if (transferResponse.getInitiatorUserIdInt() == UserConfig.getInstance(UserConfig.selectedAccount).clientUserId) {
this.messageText = "[彩币转账]朋友已确认收款";
} else {
this.messageText = "[彩币转账]你已确认收款";
}
} else if (state == TransferResponse.Status.REFUSED) {
if (transferResponse.getInitiatorUserIdInt() == UserConfig.getInstance(UserConfig.selectedAccount).clientUserId) {
this.messageText = "[彩币转账]钱已被朋友退还";
} else {
this.messageText = "[彩币转账]你已将钱退还";
}
} else if (state == TransferResponse.Status.TIMEOUT) {
this.messageText = "[彩币转账]钱已退还";
}
} else if (state == TransferResponse.Status.WAITING) {
this.messageText = "[彩币转账]请你确认收款";
} else if (state == TransferResponse.Status.RECEIVED) {
if (transferResponse.getInitiatorUserIdInt() == UserConfig.getInstance(UserConfig.selectedAccount).clientUserId) {
this.messageText = "[彩币转账]朋友已确认收款";
} else {
this.messageText = "[彩币转账]你已确认收款";
}
} else if (state == TransferResponse.Status.REFUSED) {
if (transferResponse.getInitiatorUserIdInt() == UserConfig.getInstance(UserConfig.selectedAccount).clientUserId) {
this.messageText = "[彩币转账]钱已被朋友退还";
} else {
this.messageText = "[彩币转账]你已将钱退还";
}
} else if (state == TransferResponse.Status.TIMEOUT) {
this.messageText = "[彩币转账]钱已退还";
}
} else {
this.messageText = "[CG转账]转账消息";
}
}
} else if (this.messageOwner.media instanceof TLRPC.TL_messageMediaShareContact) {
TLRPC.TL_messageMediaShareContact tL_messageMediaShareContact = (TLRPC.TL_messageMediaShareContact) this.messageOwner.media;
TLRPC.User user8 = MessagesController.getInstance(this.currentAccount).getUser(Integer.valueOf(tL_messageMediaShareContact.user_id));
if (user8 != null) {
if (isOutOwner()) {
this.messageText = String.format(LocaleController.getString(R.string.share_contact_recomment) + "%s", user8.first_name);
} else {
this.messageText = String.format(LocaleController.getString(R.string.share_contact_recomment_to_you) + "%s", user8.first_name);
}
} else if (abstractMap != null && (user2 = abstractMap.get(Integer.valueOf(tL_messageMediaShareContact.user_id))) != null) {
if (isOutOwner()) {
this.messageText = String.format(LocaleController.getString(R.string.share_contact_recomment) + "%s", user2.first_name);
} else {
this.messageText = String.format(LocaleController.getString(R.string.share_contact_recomment_to_you) + "%s", user2.first_name);
}
}
} else {
boolean z2 = this.messageOwner.media instanceof TLRPC.TL_messageMediaShare;
}
} else {
this.messageText = this.messageOwner.message;
}
}
if (this.messageText == null) {
this.messageText = "";
}
}
public void setType() {
int i = this.type;
this.isRoundVideoCached = 0;
TLRPC.Message message = this.messageOwner;
if ((message instanceof TLRPC.TL_message) || (message instanceof TLRPC.TL_messageForwarded_old2)) {
if (this.isRestrictedMessage) {
this.type = 0;
} else if (this.emojiAnimatedSticker != null) {
if (isSticker()) {
this.type = 13;
} else {
this.type = 15;
}
} else if (isMediaEmpty()) {
this.type = 0;
if (TextUtils.isEmpty(this.messageText) && this.eventId == 0) {
this.messageText = "Empty message";
}
} else if (this.messageOwner.media.ttl_seconds != 0 && ((this.messageOwner.media.photo instanceof TLRPC.TL_photoEmpty) || (getDocument() instanceof TLRPC.TL_documentEmpty))) {
this.contentType = 1;
this.type = 10;
} else if (this.messageOwner.media instanceof TLRPC.TL_messageMediaPhoto) {
this.type = 1;
} else if ((this.messageOwner.media instanceof TLRPC.TL_messageMediaGeo) || (this.messageOwner.media instanceof TLRPC.TL_messageMediaVenue) || (this.messageOwner.media instanceof TLRPC.TL_messageMediaGeoLive)) {
this.type = 4;
} else if (isRoundVideo()) {
this.type = 5;
} else if (isVideo()) {
this.type = 3;
} else if (isVoice()) {
this.type = 2;
} else if (isMusic()) {
this.type = 14;
} else if (this.messageOwner.media instanceof TLRPC.TL_messageMediaContact) {
this.type = 12;
} else if (this.messageOwner.media instanceof TLRPC.TL_messageMediaPoll) {
this.type = 17;
} else if (this.messageOwner.media instanceof TLRPC.TL_messageMediaUnsupported) {
this.type = 0;
} else if (this.messageOwner.media instanceof TLRPC.TL_messageMediaDocument) {
TLRPC.Document document = getDocument();
if (document != null && document.mime_type != null) {
if (isGifDocument(document)) {
this.type = 8;
} else if (isSticker()) {
this.type = 13;
} else if (isAnimatedSticker()) {
this.type = 15;
} else {
this.type = 9;
}
} else {
this.type = 9;
}
} else if (this.messageOwner.media instanceof TLRPC.TL_messageMediaGame) {
this.type = 0;
} else if (this.messageOwner.media instanceof TLRPC.TL_messageMediaInvoice) {
this.type = 0;
} else if (this.messageOwner.media instanceof TLRPCRedpacket.CL_messagesRpkTransferMedia) {
TLRPCRedpacket.CL_messagesRpkTransferMedia cL_messagesRpkTransferMedia = (TLRPCRedpacket.CL_messagesRpkTransferMedia) this.messageOwner.media;
if (cL_messagesRpkTransferMedia.trans == 0) {
this.type = 101;
} else if (cL_messagesRpkTransferMedia.trans == 1 || cL_messagesRpkTransferMedia.trans == 2) {
this.type = 102;
}
} else if (this.messageOwner.media instanceof TLRPC.TL_messageMediaShareContact) {
this.type = 103;
} else if (this.messageOwner.media instanceof TLRPC.TL_messageMediaShare) {
this.type = TYPE_LIVE;
} else if (this.messageOwner.media instanceof TLRPCRedpacket.CL_messagesPayBillOverMedia) {
this.contentType = 5;
this.type = 104;
} else if (this.messageOwner.media instanceof TLRPCContacts.TL_messageMediaSysNotify) {
this.type = 105;
}
} else if (message instanceof TLRPC.TL_messageService) {
if (message.action instanceof TLRPC.TL_messageActionLoginUnknownLocation) {
this.type = 0;
} else if ((this.messageOwner.action instanceof TLRPC.TL_messageActionChatEditPhoto) || (this.messageOwner.action instanceof TLRPC.TL_messageActionUserUpdatedPhoto)) {
this.contentType = 1;
this.type = 11;
} else if (this.messageOwner.action instanceof TLRPC.TL_messageEncryptedAction) {
if ((this.messageOwner.action.encryptedAction instanceof TLRPC.TL_decryptedMessageActionScreenshotMessages) || (this.messageOwner.action.encryptedAction instanceof TLRPC.TL_decryptedMessageActionSetMessageTTL)) {
this.contentType = 1;
this.type = 10;
} else {
this.contentType = -1;
this.type = -1;
}
} else if (this.messageOwner.action instanceof TLRPC.TL_messageActionHistoryClear) {
this.contentType = -1;
this.type = -1;
} else if (this.messageOwner.action instanceof TLRPC.TL_messageActionPhoneCall) {
this.type = 16;
} else {
this.contentType = 1;
this.type = 10;
}
}
if (i == 1000 || i == this.type) {
return;
}
updateMessageText(MessagesController.getInstance(this.currentAccount).getUsers(), MessagesController.getInstance(this.currentAccount).getChats(), null, null);
if (isMediaEmpty()) {
this.messageText = updateMetionText(this.messageText, this.messageOwner.entities);
}
generateThumbs(false);
}
public boolean checkLayout() {
CharSequence charSequence;
TextPaint textPaint;
if (this.type == 0 && this.messageOwner.to_id != null && (charSequence = this.messageText) != null && charSequence.length() != 0) {
if (this.layoutCreated) {
if (Math.abs(this.generatedWithMinSize - (AndroidUtilities.isTablet() ? AndroidUtilities.getMinTabletSide() : AndroidUtilities.displaySize.x)) > AndroidUtilities.dp(52.0f) || this.generatedWithDensity != AndroidUtilities.density) {
this.layoutCreated = false;
}
}
if (!this.layoutCreated) {
this.layoutCreated = true;
TLRPC.User user = isFromUser() ? MessagesController.getInstance(this.currentAccount).getUser(Integer.valueOf(this.messageOwner.from_id)) : null;
if (this.messageOwner.media instanceof TLRPC.TL_messageMediaGame) {
textPaint = Theme.chat_msgGameTextPaint;
} else {
textPaint = Theme.chat_msgTextPaint;
}
int[] iArr = SharedConfig.allowBigEmoji ? new int[1] : null;
this.messageText = Emoji.replaceEmoji(this.messageText, textPaint.getFontMetricsInt(), AndroidUtilities.dp(20.0f), false, iArr);
checkEmojiOnly(iArr);
generateLayout(user);
return true;
}
}
return false;
}
public void resetLayout() {
this.layoutCreated = false;
}
public String getMimeType() {
TLRPC.Document document = getDocument();
if (document != null) {
return document.mime_type;
}
if (!(this.messageOwner.media instanceof TLRPC.TL_messageMediaInvoice)) {
return this.messageOwner.media instanceof TLRPC.TL_messageMediaPhoto ? "image/jpeg" : (!(this.messageOwner.media instanceof TLRPC.TL_messageMediaWebPage) || this.messageOwner.media.webpage.photo == null) ? "" : "image/jpeg";
}
TLRPC.WebDocument webDocument = ((TLRPC.TL_messageMediaInvoice) this.messageOwner.media).photo;
return webDocument != null ? webDocument.mime_type : "";
}
public boolean canPreviewDocument() {
return canPreviewDocument(getDocument());
}
public static boolean isGifDocument(WebFile webFile) {
return webFile != null && (webFile.mime_type.equals("image/gif") || isNewGifDocument(webFile));
}
public static boolean isGifDocument(TLRPC.Document document) {
return (document == null || document.mime_type == null || (!document.mime_type.equals("image/gif") && !isNewGifDocument(document))) ? false : true;
}
public static boolean isDocumentHasThumb(TLRPC.Document document) {
if (document != null && !document.thumbs.isEmpty()) {
int size = document.thumbs.size();
for (int i = 0; i < size; i++) {
TLRPC.PhotoSize photoSize = document.thumbs.get(i);
if (photoSize != null && !(photoSize instanceof TLRPC.TL_photoSizeEmpty) && !(photoSize.location instanceof TLRPC.TL_fileLocationUnavailable)) {
return true;
}
}
}
return false;
}
public static boolean canPreviewDocument(TLRPC.Document document) {
if (document != null && document.mime_type != null) {
String lowerCase = document.mime_type.toLowerCase();
if (isDocumentHasThumb(document) && (lowerCase.equals("image/png") || lowerCase.equals("image/jpg") || lowerCase.equals("image/jpeg"))) {
for (int i = 0; i < document.attributes.size(); i++) {
TLRPC.DocumentAttribute documentAttribute = document.attributes.get(i);
if (documentAttribute instanceof TLRPC.TL_documentAttributeImageSize) {
TLRPC.TL_documentAttributeImageSize tL_documentAttributeImageSize = (TLRPC.TL_documentAttributeImageSize) documentAttribute;
return tL_documentAttributeImageSize.w < 6000 && tL_documentAttributeImageSize.h < 6000;
}
}
} else if (BuildVars.DEBUG_PRIVATE_VERSION) {
String documentFileName = FileLoader.getDocumentFileName(document);
if (documentFileName.startsWith("tg_secret_sticker") && documentFileName.endsWith("json")) {
return true;
}
}
}
return false;
}
public static boolean isRoundVideoDocument(TLRPC.Document document) {
if (document != null && MimeTypes.VIDEO_MP4.equals(document.mime_type)) {
boolean z = false;
int i = 0;
int i2 = 0;
for (int i3 = 0; i3 < document.attributes.size(); i3++) {
TLRPC.DocumentAttribute documentAttribute = document.attributes.get(i3);
if (documentAttribute instanceof TLRPC.TL_documentAttributeVideo) {
i = documentAttribute.w;
i2 = documentAttribute.w;
z = documentAttribute.round_message;
}
}
if (z && i <= 1280 && i2 <= 1280) {
return true;
}
}
return false;
}
public static boolean isNewGifDocument(WebFile webFile) {
if (webFile != null && MimeTypes.VIDEO_MP4.equals(webFile.mime_type)) {
int i = 0;
int i2 = 0;
for (int i3 = 0; i3 < webFile.attributes.size(); i3++) {
TLRPC.DocumentAttribute documentAttribute = webFile.attributes.get(i3);
if (!(documentAttribute instanceof TLRPC.TL_documentAttributeAnimated) && (documentAttribute instanceof TLRPC.TL_documentAttributeVideo)) {
i = documentAttribute.w;
i2 = documentAttribute.w;
}
}
if (i <= 1280 && i2 <= 1280) {
return true;
}
}
return false;
}
public static boolean isNewGifDocument(TLRPC.Document document) {
if (document != null && MimeTypes.VIDEO_MP4.equals(document.mime_type)) {
boolean z = false;
int i = 0;
int i2 = 0;
for (int i3 = 0; i3 < document.attributes.size(); i3++) {
TLRPC.DocumentAttribute documentAttribute = document.attributes.get(i3);
if (documentAttribute instanceof TLRPC.TL_documentAttributeAnimated) {
z = true;
} else if (documentAttribute instanceof TLRPC.TL_documentAttributeVideo) {
i = documentAttribute.w;
i2 = documentAttribute.w;
}
}
if (z && i <= 1280 && i2 <= 1280) {
return true;
}
}
return false;
}
public void generateThumbs(boolean z) {
ArrayList<TLRPC.PhotoSize> arrayList;
ArrayList<TLRPC.PhotoSize> arrayList2;
ArrayList<TLRPC.PhotoSize> arrayList3;
ArrayList<TLRPC.PhotoSize> arrayList4;
ArrayList<TLRPC.PhotoSize> arrayList5;
ArrayList<TLRPC.PhotoSize> arrayList6;
TLRPC.Message message = this.messageOwner;
if (message instanceof TLRPC.TL_messageService) {
if (message.action instanceof TLRPC.TL_messageActionChatEditPhoto) {
TLRPC.Photo photo = this.messageOwner.action.photo;
if (!z) {
this.photoThumbs = new ArrayList<>(photo.sizes);
} else {
ArrayList<TLRPC.PhotoSize> arrayList7 = this.photoThumbs;
if (arrayList7 != null && !arrayList7.isEmpty()) {
for (int i = 0; i < this.photoThumbs.size(); i++) {
TLRPC.PhotoSize photoSize = this.photoThumbs.get(i);
int i2 = 0;
while (true) {
if (i2 < photo.sizes.size()) {
TLRPC.PhotoSize photoSize2 = photo.sizes.get(i2);
if (!(photoSize2 instanceof TLRPC.TL_photoSizeEmpty) && photoSize2.type.equals(photoSize.type)) {
photoSize.location = photoSize2.location;
break;
}
i2++;
}
}
}
}
}
if (photo.dc_id != 0) {
int size = this.photoThumbs.size();
for (int i3 = 0; i3 < size; i3++) {
TLRPC.FileLocation fileLocation = this.photoThumbs.get(i3).location;
fileLocation.dc_id = photo.dc_id;
fileLocation.file_reference = photo.file_reference;
}
}
this.photoThumbsObject = this.messageOwner.action.photo;
return;
}
return;
}
if (this.emojiAnimatedSticker != null) {
if (TextUtils.isEmpty(this.emojiAnimatedStickerColor) && isDocumentHasThumb(this.emojiAnimatedSticker)) {
if (!z || (arrayList6 = this.photoThumbs) == null) {
ArrayList<TLRPC.PhotoSize> arrayList8 = new ArrayList<>();
this.photoThumbs = arrayList8;
arrayList8.addAll(this.emojiAnimatedSticker.thumbs);
} else if (arrayList6 != null && !arrayList6.isEmpty()) {
updatePhotoSizeLocations(this.photoThumbs, this.emojiAnimatedSticker.thumbs);
}
this.photoThumbsObject = this.emojiAnimatedSticker;
return;
}
return;
}
if (message.media == null || (this.messageOwner.media instanceof TLRPC.TL_messageMediaEmpty)) {
return;
}
if (this.messageOwner.media instanceof TLRPC.TL_messageMediaPhoto) {
TLRPC.Photo photo2 = this.messageOwner.media.photo;
if (!z || ((arrayList5 = this.photoThumbs) != null && arrayList5.size() != photo2.sizes.size())) {
this.photoThumbs = new ArrayList<>(photo2.sizes);
} else {
ArrayList<TLRPC.PhotoSize> arrayList9 = this.photoThumbs;
if (arrayList9 != null && !arrayList9.isEmpty()) {
for (int i4 = 0; i4 < this.photoThumbs.size(); i4++) {
TLRPC.PhotoSize photoSize3 = this.photoThumbs.get(i4);
if (photoSize3 != null) {
int i5 = 0;
while (true) {
if (i5 >= photo2.sizes.size()) {
break;
}
TLRPC.PhotoSize photoSize4 = photo2.sizes.get(i5);
if (photoSize4 != null && !(photoSize4 instanceof TLRPC.TL_photoSizeEmpty) && photoSize4.type.equals(photoSize3.type)) {
photoSize3.location = photoSize4.location;
break;
}
i5++;
}
}
}
}
}
this.photoThumbsObject = this.messageOwner.media.photo;
return;
}
if (this.messageOwner.media instanceof TLRPC.TL_messageMediaDocument) {
TLRPC.Document document = getDocument();
if (isDocumentHasThumb(document)) {
if (!z || (arrayList4 = this.photoThumbs) == null) {
ArrayList<TLRPC.PhotoSize> arrayList10 = new ArrayList<>();
this.photoThumbs = arrayList10;
arrayList10.addAll(document.thumbs);
} else if (arrayList4 != null && !arrayList4.isEmpty()) {
updatePhotoSizeLocations(this.photoThumbs, document.thumbs);
}
this.photoThumbsObject = document;
return;
}
return;
}
if (this.messageOwner.media instanceof TLRPC.TL_messageMediaGame) {
TLRPC.Document document2 = this.messageOwner.media.game.document;
if (document2 != null && isDocumentHasThumb(document2)) {
if (!z) {
ArrayList<TLRPC.PhotoSize> arrayList11 = new ArrayList<>();
this.photoThumbs = arrayList11;
arrayList11.addAll(document2.thumbs);
} else {
ArrayList<TLRPC.PhotoSize> arrayList12 = this.photoThumbs;
if (arrayList12 != null && !arrayList12.isEmpty()) {
updatePhotoSizeLocations(this.photoThumbs, document2.thumbs);
}
}
this.photoThumbsObject = document2;
}
TLRPC.Photo photo3 = this.messageOwner.media.game.photo;
if (photo3 != null) {
if (!z || (arrayList3 = this.photoThumbs2) == null) {
this.photoThumbs2 = new ArrayList<>(photo3.sizes);
} else if (!arrayList3.isEmpty()) {
updatePhotoSizeLocations(this.photoThumbs2, photo3.sizes);
}
this.photoThumbsObject2 = photo3;
}
if (this.photoThumbs != null || (arrayList2 = this.photoThumbs2) == null) {
return;
}
this.photoThumbs = arrayList2;
this.photoThumbs2 = null;
this.photoThumbsObject = this.photoThumbsObject2;
this.photoThumbsObject2 = null;
return;
}
if (this.messageOwner.media instanceof TLRPC.TL_messageMediaWebPage) {
TLRPC.Photo photo4 = this.messageOwner.media.webpage.photo;
TLRPC.Document document3 = this.messageOwner.media.webpage.document;
if (photo4 != null) {
if (!z || (arrayList = this.photoThumbs) == null) {
this.photoThumbs = new ArrayList<>(photo4.sizes);
} else if (!arrayList.isEmpty()) {
updatePhotoSizeLocations(this.photoThumbs, photo4.sizes);
}
this.photoThumbsObject = photo4;
return;
}
if (document3 == null || !isDocumentHasThumb(document3)) {
return;
}
if (!z) {
ArrayList<TLRPC.PhotoSize> arrayList13 = new ArrayList<>();
this.photoThumbs = arrayList13;
arrayList13.addAll(document3.thumbs);
} else {
ArrayList<TLRPC.PhotoSize> arrayList14 = this.photoThumbs;
if (arrayList14 != null && !arrayList14.isEmpty()) {
updatePhotoSizeLocations(this.photoThumbs, document3.thumbs);
}
}
this.photoThumbsObject = document3;
}
}
private static void updatePhotoSizeLocations(ArrayList<TLRPC.PhotoSize> arrayList, ArrayList<TLRPC.PhotoSize> arrayList2) {
int size = arrayList.size();
for (int i = 0; i < size; i++) {
TLRPC.PhotoSize photoSize = arrayList.get(i);
int size2 = arrayList2.size();
int i2 = 0;
while (true) {
if (i2 < size2) {
TLRPC.PhotoSize photoSize2 = arrayList2.get(i2);
if (!(photoSize2 instanceof TLRPC.TL_photoSizeEmpty) && !(photoSize2 instanceof TLRPC.TL_photoCachedSize) && photoSize2.type.equals(photoSize.type)) {
photoSize.location = photoSize2.location;
break;
}
i2++;
}
}
}
}
public CharSequence replaceWithLink(CharSequence charSequence, String str, ArrayList<Integer> arrayList, AbstractMap<Integer, TLRPC.User> abstractMap, SparseArray<TLRPC.User> sparseArray) {
if (TextUtils.indexOf(charSequence, str) < 0) {
return charSequence;
}
SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder("");
for (int i = 0; i < arrayList.size(); i++) {
TLRPC.User user = null;
if (abstractMap != null) {
user = abstractMap.get(arrayList.get(i));
} else if (sparseArray != null) {
user = sparseArray.get(arrayList.get(i).intValue());
}
if (user == null) {
user = MessagesController.getInstance(this.currentAccount).getUser(arrayList.get(i));
}
if (user != null) {
String name = UserObject.getName(user);
int length = spannableStringBuilder.length();
if (spannableStringBuilder.length() != 0) {
spannableStringBuilder.append((CharSequence) ", ");
}
spannableStringBuilder.append((CharSequence) name);
spannableStringBuilder.setSpan(new URLSpanNoUnderlineBold("" + user.id), length, name.length() + length, 33);
}
}
return TextUtils.replace(charSequence, new String[]{str}, new CharSequence[]{spannableStringBuilder});
}
public CharSequence replaceWithLink(CharSequence charSequence, String str, TLObject tLObject, int i, ClickableSpan clickableSpan) {
String str2;
String str3;
int indexOf = TextUtils.indexOf(charSequence, str);
if (indexOf < 0) {
return charSequence;
}
if (tLObject instanceof TLRPC.User) {
TLRPC.User user = (TLRPC.User) tLObject;
if (user.id == UserConfig.getInstance(UserConfig.selectedAccount).clientUserId) {
str3 = LocaleController.getString("YouSelf", R.string.YouSelf);
} else {
str3 = UserObject.getName(user);
}
str2 = "" + user.id;
} else if (tLObject instanceof TLRPC.Chat) {
TLRPC.Chat chat = (TLRPC.Chat) tLObject;
str3 = chat.title;
str2 = "" + (-chat.id);
} else if (tLObject instanceof TLRPC.TL_game) {
str3 = ((TLRPC.TL_game) tLObject).title;
str2 = "game";
} else {
str2 = "0";
str3 = "";
}
String charSequence2 = TextUtils.ellipsize(str3.replace('\n', ' '), Theme.chat_actionTextPaint, AndroidUtilities.dp(150.0f), TextUtils.TruncateAt.END).toString();
SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(TextUtils.replace(charSequence, new String[]{str}, new String[]{charSequence2}));
Drawable drawable = Theme.chat_redpkgSamllIcon;
if (drawable == null) {
Theme.chat_redpkgSamllIcon = ApplicationLoader.applicationContext.getResources().getDrawable(R.mipmap.ic_red_small).mutate();
drawable = Theme.chat_redpkgSamllIcon;
}
drawable.setBounds(0, 0, AndroidUtilities.dp(16.0f), AndroidUtilities.dp(18.0f));
spannableStringBuilder.setSpan(new ImageSpan(drawable), 0, 1, 33);
spannableStringBuilder.setSpan(new URLSpanNoUnderlineBold("" + str2), indexOf, charSequence2.length() + indexOf, 33);
spannableStringBuilder.setSpan(new ForegroundColorSpan(Theme.getColor(Theme.key_chat_redpacketLinkServiceText)), indexOf, charSequence2.length() + indexOf, 33);
if (clickableSpan != null) {
spannableStringBuilder.setSpan(clickableSpan, spannableStringBuilder.length() - 2, spannableStringBuilder.length(), 33);
spannableStringBuilder.setSpan(new ForegroundColorSpan(Color.parseColor("#FFFE5548")), spannableStringBuilder.length() - 2, spannableStringBuilder.length(), 33);
}
if (i == 1) {
spannableStringBuilder.append((CharSequence) ",您的红包已被领完");
}
return spannableStringBuilder;
}
public CharSequence replaceWithLink(CharSequence charSequence, String str, TLObject tLObject) {
return replaceWithLink(charSequence, str, tLObject, false);
}
public CharSequence replaceWithLink(CharSequence charSequence, String str, TLObject tLObject, boolean z) {
String str2;
String str3;
if (charSequence == null) {
return "";
}
int indexOf = TextUtils.indexOf(charSequence, str);
if (indexOf < 0) {
return charSequence;
}
if (tLObject instanceof TLRPC.User) {
TLRPC.User user = (TLRPC.User) tLObject;
str3 = UserObject.getName(user);
str2 = "" + user.id;
} else if (tLObject instanceof TLRPC.Chat) {
TLRPC.Chat chat = (TLRPC.Chat) tLObject;
str3 = chat.title;
str2 = "" + (-chat.id);
} else if (tLObject instanceof TLRPC.TL_game) {
str3 = ((TLRPC.TL_game) tLObject).title;
str2 = "game";
} else {
str2 = "0";
str3 = "";
}
String replace = str3.replace('\n', ' ');
if (z) {
replace = TextUtils.ellipsize(replace, Theme.chat_actionTextPaint, AndroidUtilities.dp(150.0f), TextUtils.TruncateAt.END).toString();
}
SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(TextUtils.replace(charSequence, new String[]{str}, new String[]{replace}));
spannableStringBuilder.setSpan(new URLSpanNoUnderlineBold("" + str2), indexOf, replace.length() + indexOf, 33);
if (z) {
spannableStringBuilder.setSpan(new ForegroundColorSpan(Theme.getColor(Theme.key_chat_redpacketLinkServiceText)), indexOf, replace.length() + indexOf, 33);
}
return spannableStringBuilder;
}
public String getExtension() {
String fileName = getFileName();
int lastIndexOf = fileName.lastIndexOf(46);
String substring = lastIndexOf != -1 ? fileName.substring(lastIndexOf + 1) : null;
if (substring == null || substring.length() == 0) {
substring = getDocument().mime_type;
}
if (substring == null) {
substring = "";
}
return substring.toUpperCase();
}
public String getFileName() {
TLRPC.PhotoSize closestPhotoSizeWithSize;
if (this.messageOwner.media instanceof TLRPC.TL_messageMediaDocument) {
return FileLoader.getAttachFileName(getDocument());
}
if (!(this.messageOwner.media instanceof TLRPC.TL_messageMediaPhoto)) {
return this.messageOwner.media instanceof TLRPC.TL_messageMediaWebPage ? FileLoader.getAttachFileName(this.messageOwner.media.webpage.document) : "";
}
ArrayList<TLRPC.PhotoSize> arrayList = this.messageOwner.media.photo.sizes;
return (arrayList.size() <= 0 || (closestPhotoSizeWithSize = FileLoader.getClosestPhotoSizeWithSize(arrayList, AndroidUtilities.getPhotoSize())) == null) ? "" : FileLoader.getAttachFileName(closestPhotoSizeWithSize);
}
public int getFileType() {
if (isVideo()) {
return 2;
}
if (isVoice()) {
return 1;
}
if (this.messageOwner.media instanceof TLRPC.TL_messageMediaDocument) {
return 3;
}
return this.messageOwner.media instanceof TLRPC.TL_messageMediaPhoto ? 0 : 4;
}
private static boolean containsUrls(CharSequence charSequence) {
if (charSequence != null && charSequence.length() >= 2 && charSequence.length() <= 20480) {
int length = charSequence.length();
int i = 0;
int i2 = 0;
int i3 = 0;
int i4 = 0;
char c = 0;
while (i < length) {
char charAt = charSequence.charAt(i);
if (charAt >= '0' && charAt <= '9') {
i2++;
if (i2 >= 6) {
return true;
}
i3 = 0;
i4 = 0;
} else if (charAt == ' ' || i2 <= 0) {
i2 = 0;
}
if ((charAt != '@' && charAt != '#' && charAt != '/' && charAt != '$') || i != 0) {
if (i != 0) {
int i5 = i - 1;
if (charSequence.charAt(i5) != ' ') {
if (charSequence.charAt(i5) == '\n') {
}
}
}
if (charAt == ':') {
if (i3 == 0) {
i3 = 1;
}
i3 = 0;
} else if (charAt != '/') {
if (charAt == '.') {
if (i4 == 0 && c != ' ') {
i4++;
}
} else if (charAt != ' ' && c == '.' && i4 == 1) {
return true;
}
i4 = 0;
} else {
if (i3 == 2) {
return true;
}
if (i3 == 1) {
i3++;
}
i3 = 0;
}
i++;
c = charAt;
}
return true;
}
}
return false;
}
public void generateLinkDescription() {
int i;
if (this.linkDescription != null) {
return;
}
if ((this.messageOwner.media instanceof TLRPC.TL_messageMediaWebPage) && (this.messageOwner.media.webpage instanceof TLRPC.TL_webPage) && this.messageOwner.media.webpage.description != null) {
this.linkDescription = Spannable.Factory.getInstance().newSpannable(this.messageOwner.media.webpage.description);
String str = this.messageOwner.media.webpage.site_name;
if (str != null) {
str = str.toLowerCase();
}
if ("instagram".equals(str)) {
i = 1;
} else if ("twitter".equals(str)) {
i = 2;
}
if (TextUtils.isEmpty(this.linkDescription)) {
if (containsUrls(this.linkDescription)) {
try {
Linkify.addLinks((Spannable) this.linkDescription, 1);
} catch (Exception e) {
FileLog.e(e);
}
}
CharSequence replaceEmoji = Emoji.replaceEmoji(this.linkDescription, Theme.chat_msgTextPaint.getFontMetricsInt(), AndroidUtilities.dp(20.0f), false);
this.linkDescription = replaceEmoji;
if (i != 0) {
if (!(replaceEmoji instanceof Spannable)) {
this.linkDescription = new SpannableStringBuilder(this.linkDescription);
}
addUrlsByPattern(isOutOwner(), this.linkDescription, false, i, 0);
return;
}
return;
}
return;
}
if ((this.messageOwner.media instanceof TLRPC.TL_messageMediaGame) && this.messageOwner.media.game.description != null) {
this.linkDescription = Spannable.Factory.getInstance().newSpannable(this.messageOwner.media.game.description);
} else if ((this.messageOwner.media instanceof TLRPC.TL_messageMediaInvoice) && this.messageOwner.media.description != null) {
this.linkDescription = Spannable.Factory.getInstance().newSpannable(this.messageOwner.media.description);
}
i = 0;
if (TextUtils.isEmpty(this.linkDescription)) {
}
}
public void generateCaption() {
boolean z;
if (this.caption != null || isRoundVideo() || isMediaEmpty() || (this.messageOwner.media instanceof TLRPC.TL_messageMediaGame) || TextUtils.isEmpty(this.messageOwner.message)) {
return;
}
CharSequence replaceEmoji = Emoji.replaceEmoji(this.messageOwner.message, Theme.chat_msgTextPaint.getFontMetricsInt(), AndroidUtilities.dp(20.0f), false);
this.caption = replaceEmoji;
if (replaceEmoji != null) {
this.caption = updateMetionText(replaceEmoji, this.messageOwner.entities);
}
if (this.messageOwner.send_state != 0) {
int i = 0;
while (true) {
if (i >= this.messageOwner.entities.size()) {
z = false;
break;
} else {
if (!(this.messageOwner.entities.get(i) instanceof TLRPC.TL_inputMessageEntityMentionName)) {
z = true;
break;
}
i++;
}
}
} else {
z = !this.messageOwner.entities.isEmpty();
}
boolean z2 = !z && (this.eventId != 0 || (this.messageOwner.media instanceof TLRPC.TL_messageMediaPhoto_old) || (this.messageOwner.media instanceof TLRPC.TL_messageMediaPhoto_layer68) || (this.messageOwner.media instanceof TLRPC.TL_messageMediaPhoto_layer74) || (this.messageOwner.media instanceof TLRPC.TL_messageMediaDocument_old) || (this.messageOwner.media instanceof TLRPC.TL_messageMediaDocument_layer68) || (this.messageOwner.media instanceof TLRPC.TL_messageMediaDocument_layer74) || ((isOut() && this.messageOwner.send_state != 0) || this.messageOwner.id < 0));
if (z2) {
if (containsUrls(this.caption)) {
try {
Linkify.addLinks((Spannable) this.caption, 5);
} catch (Exception e) {
FileLog.e(e);
}
}
addUrlsByPattern(isOutOwner(), this.caption, true, 0, 0);
}
addEntitiesToText(this.caption, z2);
if (isVideo()) {
addUrlsByPattern(isOutOwner(), this.caption, true, 3, getDuration());
}
}
private static void addUrlsByPattern(boolean z, CharSequence charSequence, boolean z2, int i, int i2) {
Matcher matcher;
int i3 = 3;
try {
if (i == 3) {
if (videoTimeUrlPattern == null) {
videoTimeUrlPattern = Pattern.compile("\\b(?:(\\d{1,2}):)?(\\d{1,3}):([0-5][0-9])\\b");
}
matcher = videoTimeUrlPattern.matcher(charSequence);
} else if (i == 1) {
if (instagramUrlPattern == null) {
instagramUrlPattern = Pattern.compile("(^|\\s|\\()@[a-zA-Z\\d_.]{1,32}|(^|\\s|\\()#[\\w.]+");
}
matcher = instagramUrlPattern.matcher(charSequence);
} else {
if (urlPattern == null) {
urlPattern = Pattern.compile("");
}
matcher = urlPattern.matcher(charSequence);
}
Spannable spannable = (Spannable) charSequence;
while (matcher.find()) {
int start = matcher.start();
int end = matcher.end();
Object obj = null;
if (i == i3) {
URLSpan[] uRLSpanArr = (URLSpan[]) spannable.getSpans(start, end, URLSpan.class);
if (uRLSpanArr == null || uRLSpanArr.length <= 0) {
matcher.groupCount();
int start2 = matcher.start(1);
int end2 = matcher.end(1);
int start3 = matcher.start(2);
int end3 = matcher.end(2);
int start4 = matcher.start(i3);
int end4 = matcher.end(i3);
int intValue = Utilities.parseInt(charSequence.subSequence(start3, end3)).intValue();
int intValue2 = Utilities.parseInt(charSequence.subSequence(start4, end4)).intValue();
int intValue3 = (start2 < 0 || end2 < 0) ? -1 : Utilities.parseInt(charSequence.subSequence(start2, end2)).intValue();
int i4 = intValue2 + (intValue * 60);
if (intValue3 > 0) {
i4 += intValue3 * 60 * 60;
}
if (i4 <= i2) {
obj = new URLSpanNoUnderline("video?" + i4);
if (obj != null) {
spannable.setSpan(obj, start, end, 0);
}
i3 = 3;
}
}
} else {
char charAt = charSequence.charAt(start);
if (i != 0) {
if (charAt != '@' && charAt != '#') {
start++;
}
charAt = charSequence.charAt(start);
if (charAt != '@' && charAt != '#') {
}
} else if (charAt != '@' && charAt != '#' && charAt != '/' && charAt != '$') {
start++;
}
if (i == 1) {
if (charAt == '@') {
obj = new URLSpanNoUnderline("https://instagram.com/" + charSequence.subSequence(start + 1, end).toString());
} else if (charAt == '#') {
obj = new URLSpanNoUnderline("https://www.instagram.com/explore/tags/" + charSequence.subSequence(start + 1, end).toString());
}
} else if (i == 2) {
if (charAt == '@') {
obj = new URLSpanNoUnderline("https://twitter.com/" + charSequence.subSequence(start + 1, end).toString());
} else if (charAt == '#') {
obj = new URLSpanNoUnderline("https://twitter.com/hashtag/" + charSequence.subSequence(start + 1, end).toString());
}
} else if (charSequence.charAt(start) != '/') {
obj = new URLSpanNoUnderline(charSequence.subSequence(start, end).toString());
} else if (z2) {
obj = new URLSpanBotCommand(charSequence.subSequence(start, end).toString(), z ? 1 : 0);
}
if (obj != null) {
}
i3 = 3;
}
}
} catch (Exception e) {
FileLog.e(e);
}
}
public static int[] getWebDocumentWidthAndHeight(TLRPC.WebDocument webDocument) {
int i;
if (webDocument == null) {
return null;
}
int size = webDocument.attributes.size();
while (i < size) {
TLRPC.DocumentAttribute documentAttribute = webDocument.attributes.get(i);
i = ((documentAttribute instanceof TLRPC.TL_documentAttributeImageSize) || (documentAttribute instanceof TLRPC.TL_documentAttributeVideo)) ? 0 : i + 1;
return new int[]{documentAttribute.w, documentAttribute.h};
}
return null;
}
public static int getWebDocumentDuration(TLRPC.WebDocument webDocument) {
if (webDocument == null) {
return 0;
}
int size = webDocument.attributes.size();
for (int i = 0; i < size; i++) {
TLRPC.DocumentAttribute documentAttribute = webDocument.attributes.get(i);
if (documentAttribute instanceof TLRPC.TL_documentAttributeVideo) {
return documentAttribute.duration;
}
if (documentAttribute instanceof TLRPC.TL_documentAttributeAudio) {
return documentAttribute.duration;
}
}
return 0;
}
public static int[] getInlineResultWidthAndHeight(TLRPC.BotInlineResult botInlineResult) {
int[] webDocumentWidthAndHeight = getWebDocumentWidthAndHeight(botInlineResult.content);
if (webDocumentWidthAndHeight != null) {
return webDocumentWidthAndHeight;
}
int[] webDocumentWidthAndHeight2 = getWebDocumentWidthAndHeight(botInlineResult.thumb);
return webDocumentWidthAndHeight2 == null ? new int[]{0, 0} : webDocumentWidthAndHeight2;
}
public static int getInlineResultDuration(TLRPC.BotInlineResult botInlineResult) {
int webDocumentDuration = getWebDocumentDuration(botInlineResult.content);
return webDocumentDuration == 0 ? getWebDocumentDuration(botInlineResult.thumb) : webDocumentDuration;
}
public boolean hasValidGroupId() {
ArrayList<TLRPC.PhotoSize> arrayList;
return (getGroupId() == 0 || (arrayList = this.photoThumbs) == null || arrayList.isEmpty()) ? false : true;
}
public long getGroupIdForUse() {
long j = this.localSentGroupId;
return j != 0 ? j : this.messageOwner.grouped_id;
}
public long getGroupId() {
long j = this.localGroupId;
return j != 0 ? j : getGroupIdForUse();
}
public static void addLinks(boolean z, CharSequence charSequence) {
addLinks(z, charSequence, true);
}
public static void addLinks(boolean z, CharSequence charSequence, boolean z2) {
if ((charSequence instanceof Spannable) && containsUrls(charSequence)) {
if (charSequence.length() < 1000) {
try {
Linkify.addLinks((Spannable) charSequence, 5);
} catch (Exception e) {
FileLog.e(e);
}
} else {
try {
Linkify.addLinks((Spannable) charSequence, 1);
} catch (Exception e2) {
FileLog.e(e2);
}
}
addUrlsByPattern(z, charSequence, z2, 0, 0);
}
}
public void resetPlayingProgress() {
this.audioProgress = 0.0f;
this.audioProgressSec = 0;
this.bufferedProgress = 0.0f;
}
private boolean addEntitiesToText(CharSequence charSequence, boolean z) {
return addEntitiesToText(charSequence, false, z);
}
public boolean addEntitiesToText(CharSequence charSequence, boolean z, boolean z2) {
if (this.isRestrictedMessage) {
ArrayList arrayList = new ArrayList();
TLRPC.TL_messageEntityItalic tL_messageEntityItalic = new TLRPC.TL_messageEntityItalic();
tL_messageEntityItalic.offset = 0;
tL_messageEntityItalic.length = charSequence.length();
arrayList.add(tL_messageEntityItalic);
return addEntitiesToText(charSequence, arrayList, isOutOwner(), this.type, true, z, z2);
}
return addEntitiesToText(charSequence, this.entitiesCopy, isOutOwner(), this.type, true, z, z2);
}
public static boolean addEntitiesToText(CharSequence charSequence, ArrayList<TLRPC.MessageEntity> arrayList, boolean z, int i, boolean z2, boolean z3, boolean z4) {
int size;
int i2;
if (!(charSequence instanceof Spannable)) {
return false;
}
Spannable spannable = (Spannable) charSequence;
URLSpan[] uRLSpanArr = (URLSpan[]) spannable.getSpans(0, charSequence.length(), URLSpan.class);
boolean z5 = uRLSpanArr != null && uRLSpanArr.length > 0;
if (arrayList.isEmpty()) {
return z5;
}
byte b = z3 ? (byte) 2 : z ? (byte) 1 : (byte) 0;
ArrayList arrayList2 = new ArrayList();
ArrayList arrayList3 = new ArrayList(arrayList);
Collections.sort(arrayList3, new Comparator() {
@Override
public final int compare(Object obj, Object obj2) {
return MessageObject.lambda$addEntitiesToText$2((TLRPC.MessageEntity) obj, (TLRPC.MessageEntity) obj2);
}
});
int size2 = arrayList3.size();
for (int i3 = 0; i3 < size2; i3++) {
TLRPC.MessageEntity messageEntity = (TLRPC.MessageEntity) arrayList3.get(i3);
if (messageEntity.length > 0 && messageEntity.offset >= 0 && messageEntity.offset < charSequence.length()) {
if (messageEntity.offset + messageEntity.length > charSequence.length()) {
messageEntity.length = charSequence.length() - messageEntity.offset;
}
if ((!z4 || (messageEntity instanceof TLRPC.TL_messageEntityBold) || (messageEntity instanceof TLRPC.TL_messageEntityItalic) || (messageEntity instanceof TLRPC.TL_messageEntityStrike) || (messageEntity instanceof TLRPC.TL_messageEntityUnderline) || (messageEntity instanceof TLRPC.TL_messageEntityBlockquote) || (messageEntity instanceof TLRPC.TL_messageEntityCode) || (messageEntity instanceof TLRPC.TL_messageEntityPre) || (messageEntity instanceof TLRPC.TL_messageEntityMentionName) || (messageEntity instanceof TLRPC.TL_inputMessageEntityMentionName) || (messageEntity instanceof TLRPC.TL_messageEntityTextUrl)) && uRLSpanArr != null && uRLSpanArr.length > 0) {
for (int i4 = 0; i4 < uRLSpanArr.length; i4++) {
if (uRLSpanArr[i4] != null) {
int spanStart = spannable.getSpanStart(uRLSpanArr[i4]);
int spanEnd = spannable.getSpanEnd(uRLSpanArr[i4]);
if ((messageEntity.offset <= spanStart && messageEntity.offset + messageEntity.length >= spanStart) || (messageEntity.offset <= spanEnd && messageEntity.offset + messageEntity.length >= spanEnd)) {
spannable.removeSpan(uRLSpanArr[i4]);
uRLSpanArr[i4] = null;
}
}
}
}
TextStyleSpan.TextStyleRun textStyleRun = new TextStyleSpan.TextStyleRun();
textStyleRun.start = messageEntity.offset;
textStyleRun.end = textStyleRun.start + messageEntity.length;
if (messageEntity instanceof TLRPC.TL_messageEntityStrike) {
textStyleRun.flags = 8;
} else if (messageEntity instanceof TLRPC.TL_messageEntityUnderline) {
textStyleRun.flags = 16;
} else if (messageEntity instanceof TLRPC.TL_messageEntityBlockquote) {
textStyleRun.flags = 32;
} else if (messageEntity instanceof TLRPC.TL_messageEntityBold) {
textStyleRun.flags = 1;
} else {
if (messageEntity instanceof TLRPC.TL_messageEntityItalic) {
textStyleRun.flags = 2;
} else if ((messageEntity instanceof TLRPC.TL_messageEntityCode) || (messageEntity instanceof TLRPC.TL_messageEntityPre)) {
textStyleRun.flags = 4;
} else {
if (messageEntity instanceof TLRPC.TL_messageEntityMentionName) {
if (z2) {
textStyleRun.flags = 64;
textStyleRun.urlEntity = messageEntity;
}
} else if (messageEntity instanceof TLRPC.TL_inputMessageEntityMentionName) {
if (z2) {
textStyleRun.flags = 64;
textStyleRun.urlEntity = messageEntity;
}
} else if ((!z4 || (messageEntity instanceof TLRPC.TL_messageEntityTextUrl)) && (((!(messageEntity instanceof TLRPC.TL_messageEntityUrl) && !(messageEntity instanceof TLRPC.TL_messageEntityTextUrl)) || !Browser.isPassportUrl(messageEntity.url)) && (!(messageEntity instanceof TLRPC.TL_messageEntityMention) || z2))) {
textStyleRun.flags = 128;
textStyleRun.urlEntity = messageEntity;
}
}
size = arrayList2.size();
i2 = 0;
while (i2 < size) {
TextStyleSpan.TextStyleRun textStyleRun2 = (TextStyleSpan.TextStyleRun) arrayList2.get(i2);
if (textStyleRun.start > textStyleRun2.start) {
if (textStyleRun.start < textStyleRun2.end) {
if (textStyleRun.end < textStyleRun2.end) {
TextStyleSpan.TextStyleRun textStyleRun3 = new TextStyleSpan.TextStyleRun(textStyleRun);
textStyleRun3.merge(textStyleRun2);
int i5 = i2 + 1;
arrayList2.add(i5, textStyleRun3);
TextStyleSpan.TextStyleRun textStyleRun4 = new TextStyleSpan.TextStyleRun(textStyleRun2);
textStyleRun4.start = textStyleRun.end;
i2 = i5 + 1;
size = size + 1 + 1;
arrayList2.add(i2, textStyleRun4);
} else if (textStyleRun.end >= textStyleRun2.end) {
TextStyleSpan.TextStyleRun textStyleRun5 = new TextStyleSpan.TextStyleRun(textStyleRun);
textStyleRun5.merge(textStyleRun2);
textStyleRun5.end = textStyleRun2.end;
i2++;
size++;
arrayList2.add(i2, textStyleRun5);
}
int i6 = textStyleRun.start;
textStyleRun.start = textStyleRun2.end;
textStyleRun2.end = i6;
}
} else if (textStyleRun2.start < textStyleRun.end) {
int i7 = textStyleRun2.start;
if (textStyleRun.end == textStyleRun2.end) {
textStyleRun2.merge(textStyleRun);
} else if (textStyleRun.end < textStyleRun2.end) {
TextStyleSpan.TextStyleRun textStyleRun6 = new TextStyleSpan.TextStyleRun(textStyleRun2);
textStyleRun6.merge(textStyleRun);
textStyleRun6.end = textStyleRun.end;
i2++;
size++;
arrayList2.add(i2, textStyleRun6);
textStyleRun2.start = textStyleRun.end;
} else {
TextStyleSpan.TextStyleRun textStyleRun7 = new TextStyleSpan.TextStyleRun(textStyleRun);
textStyleRun7.start = textStyleRun2.end;
i2++;
size++;
arrayList2.add(i2, textStyleRun7);
textStyleRun2.merge(textStyleRun);
}
textStyleRun.end = i7;
}
i2++;
}
if (textStyleRun.start >= textStyleRun.end) {
arrayList2.add(textStyleRun);
}
}
size = arrayList2.size();
i2 = 0;
while (i2 < size) {
}
if (textStyleRun.start >= textStyleRun.end) {
}
}
}
int size3 = arrayList2.size();
for (int i8 = 0; i8 < size3; i8++) {
TextStyleSpan.TextStyleRun textStyleRun8 = (TextStyleSpan.TextStyleRun) arrayList2.get(i8);
String substring = textStyleRun8.urlEntity != null ? TextUtils.substring(charSequence, textStyleRun8.urlEntity.offset, textStyleRun8.urlEntity.offset + textStyleRun8.urlEntity.length) : null;
if (textStyleRun8.urlEntity instanceof TLRPC.TL_messageEntityBotCommand) {
spannable.setSpan(new URLSpanBotCommand(substring, b, textStyleRun8), textStyleRun8.start, textStyleRun8.end, 33);
} else {
if ((textStyleRun8.urlEntity instanceof TLRPC.TL_messageEntityHashtag) || (textStyleRun8.urlEntity instanceof TLRPC.TL_messageEntityMention) || (textStyleRun8.urlEntity instanceof TLRPC.TL_messageEntityCashtag)) {
spannable.setSpan(new URLSpanNoUnderline(substring, textStyleRun8), textStyleRun8.start, textStyleRun8.end, 33);
} else if (textStyleRun8.urlEntity instanceof TLRPC.TL_messageEntityEmail) {
spannable.setSpan(new URLSpanReplacement("mailto:" + substring, textStyleRun8), textStyleRun8.start, textStyleRun8.end, 33);
} else {
if (textStyleRun8.urlEntity instanceof TLRPC.TL_messageEntityUrl) {
if (!substring.toLowerCase().startsWith("http") && !substring.toLowerCase().startsWith("hchat://")) {
spannable.setSpan(new URLSpanBrowser("http://" + substring, textStyleRun8), textStyleRun8.start, textStyleRun8.end, 33);
} else {
spannable.setSpan(new URLSpanBrowser(substring, textStyleRun8), textStyleRun8.start, textStyleRun8.end, 33);
}
} else if (textStyleRun8.urlEntity instanceof TLRPC.TL_messageEntityPhone) {
String stripExceptNumbers = PhoneFormat.stripExceptNumbers(substring);
if (substring.startsWith(Marker.ANY_NON_NULL_MARKER)) {
stripExceptNumbers = Marker.ANY_NON_NULL_MARKER + stripExceptNumbers;
}
spannable.setSpan(new URLSpanBrowser("tel:" + stripExceptNumbers, textStyleRun8), textStyleRun8.start, textStyleRun8.end, 33);
} else if (textStyleRun8.urlEntity instanceof TLRPC.TL_messageEntityTextUrl) {
spannable.setSpan(new URLSpanReplacement(textStyleRun8.urlEntity.url, textStyleRun8), textStyleRun8.start, textStyleRun8.end, 33);
} else if (textStyleRun8.urlEntity instanceof TLRPC.TL_messageEntityMentionName) {
spannable.setSpan(new URLSpanUserMention("" + ((TLRPC.TL_messageEntityMentionName) textStyleRun8.urlEntity).user_id, b, textStyleRun8), textStyleRun8.start, textStyleRun8.end, 33);
} else if (textStyleRun8.urlEntity instanceof TLRPC.TL_inputMessageEntityMentionName) {
spannable.setSpan(new URLSpanUserMention("" + ((TLRPC.TL_inputMessageEntityMentionName) textStyleRun8.urlEntity).user_id.user_id, b, textStyleRun8), textStyleRun8.start, textStyleRun8.end, 33);
} else if ((textStyleRun8.flags & 4) != 0) {
spannable.setSpan(new URLSpanMono(spannable, textStyleRun8.start, textStyleRun8.end, b, textStyleRun8), textStyleRun8.start, textStyleRun8.end, 33);
} else {
spannable.setSpan(new TextStyleSpan(textStyleRun8), textStyleRun8.start, textStyleRun8.end, 33);
}
z5 = true;
}
}
}
return z5;
}
public static int lambda$addEntitiesToText$2(TLRPC.MessageEntity messageEntity, TLRPC.MessageEntity messageEntity2) {
if (messageEntity.offset > messageEntity2.offset) {
return 1;
}
return messageEntity.offset < messageEntity2.offset ? -1 : 0;
}
public boolean needDrawShareButton() {
int i;
TLRPC.Chat chat;
if (this.scheduled || this.eventId != 0) {
return false;
}
if (this.messageOwner.fwd_from != null && !isOutOwner() && this.messageOwner.fwd_from.saved_from_peer != null && getDialogId() == UserConfig.getInstance(this.currentAccount).getClientUserId()) {
return true;
}
int i2 = this.type;
if (i2 != 13 && i2 != 15) {
if (this.messageOwner.fwd_from != null && this.messageOwner.fwd_from.channel_id != 0 && !isOutOwner()) {
return true;
}
if (isFromUser()) {
if ((this.messageOwner.media instanceof TLRPC.TL_messageMediaEmpty) || this.messageOwner.media == null || ((this.messageOwner.media instanceof TLRPC.TL_messageMediaWebPage) && !(this.messageOwner.media.webpage instanceof TLRPC.TL_webPage))) {
return false;
}
TLRPC.User user = MessagesController.getInstance(this.currentAccount).getUser(Integer.valueOf(this.messageOwner.from_id));
if (user != null && user.bot) {
return true;
}
if (!isOut()) {
if ((this.messageOwner.media instanceof TLRPC.TL_messageMediaGame) || (this.messageOwner.media instanceof TLRPC.TL_messageMediaInvoice)) {
return true;
}
return (!isMegagroup() || (chat = MessagesController.getInstance(this.currentAccount).getChat(Integer.valueOf(this.messageOwner.to_id.channel_id))) == null || chat.username == null || chat.username.length() <= 0 || (this.messageOwner.media instanceof TLRPC.TL_messageMediaContact) || (this.messageOwner.media instanceof TLRPC.TL_messageMediaGeo)) ? false : true;
}
} else if ((this.messageOwner.from_id < 0 || this.messageOwner.post) && this.messageOwner.to_id.channel_id != 0 && ((this.messageOwner.via_bot_id == 0 && this.messageOwner.reply_to_msg_id == 0) || ((i = this.type) != 13 && i != 15))) {
return true;
}
}
return false;
}
public boolean isYouTubeVideo() {
return (this.messageOwner.media instanceof TLRPC.TL_messageMediaWebPage) && this.messageOwner.media.webpage != null && !TextUtils.isEmpty(this.messageOwner.media.webpage.embed_url) && "YouTube".equals(this.messageOwner.media.webpage.site_name);
}
public int getMaxMessageTextWidth() {
int dp;
if (AndroidUtilities.isTablet() && this.eventId != 0) {
this.generatedWithMinSize = AndroidUtilities.dp(530.0f);
} else {
this.generatedWithMinSize = AndroidUtilities.isTablet() ? AndroidUtilities.getMinTabletSide() : AndroidUtilities.displaySize.x;
}
this.generatedWithDensity = AndroidUtilities.density;
int i = 0;
if ((this.messageOwner.media instanceof TLRPC.TL_messageMediaWebPage) && this.messageOwner.media.webpage != null && "app_background".equals(this.messageOwner.media.webpage.type)) {
try {
Uri parse = Uri.parse(this.messageOwner.media.webpage.url);
if (parse.getQueryParameter("bg_color") != null) {
dp = AndroidUtilities.dp(220.0f);
} else if (parse.getLastPathSegment().length() == 6) {
dp = AndroidUtilities.dp(200.0f);
}
i = dp;
} catch (Exception unused) {
}
} else if (isAndroidTheme()) {
i = AndroidUtilities.dp(200.0f);
}
if (i != 0) {
return i;
}
int dp2 = this.generatedWithMinSize - AndroidUtilities.dp(147.0f);
if (needDrawShareButton() && !isOutOwner()) {
dp2 -= AndroidUtilities.dp(10.0f);
}
return this.messageOwner.media instanceof TLRPC.TL_messageMediaGame ? dp2 - AndroidUtilities.dp(10.0f) : dp2;
}
public void generateLayout(TLRPC.User user) {
boolean z;
StaticLayout staticLayout;
TextPaint textPaint;
int i;
TextPaint textPaint2;
StaticLayout staticLayout2;
StaticLayout staticLayout3;
int ceil;
int i2;
int min;
TextPaint textPaint3;
boolean z2;
StaticLayout staticLayout4;
int i3;
int i4;
int i5;
int i6;
StaticLayout staticLayout5;
TextLayoutBlock textLayoutBlock;
int i7;
int i8;
int i9;
int i10;
TextPaint textPaint4;
int i11;
int ceil2;
int i12;
int i13;
int i14;
float f;
float f2;
int i15;
int i16;
MessageObject messageObject;
int i17 = this.type;
if ((i17 != 0 && i17 != 2 && !TextUtils.isEmpty(this.messageOwner.trans)) || this.messageOwner.to_id == null || TextUtils.isEmpty(this.messageText)) {
return;
}
generateLinkDescription();
this.textLayoutBlocks = new ArrayList<>();
int i18 = 0;
this.textWidth = 0;
int i19 = 1;
try {
if (!(this.messageOwner.send_state != 0 ? false : !this.messageOwner.entities.isEmpty())) {
if (this.eventId == 0) {
TLRPC.Message message = this.messageOwner;
if (!(message instanceof TLRPC.TL_message_old)) {
if (!(message instanceof TLRPC.TL_message_old2)) {
if (!(message instanceof TLRPC.TL_message_old3)) {
if (!(message instanceof TLRPC.TL_message_old4)) {
if (!(message instanceof TLRPC.TL_messageForwarded_old)) {
if (!(message instanceof TLRPC.TL_messageForwarded_old2)) {
if (!(message instanceof TLRPC.TL_message_secret)) {
if (!(message.media instanceof TLRPC.TL_messageMediaInvoice)) {
if (isOut()) {
}
if (this.messageOwner.id >= 0) {
}
}
}
}
}
}
}
}
}
}
z = true;
if (!z) {
addLinks(isOutOwner(), this.messageText);
} else {
CharSequence charSequence = this.messageText;
if ((charSequence instanceof Spannable) && charSequence.length() < 1000) {
try {
Linkify.addLinks((Spannable) this.messageText, 4);
} catch (Throwable th) {
FileLog.e(th);
}
}
}
if (!isYouTubeVideo() || ((messageObject = this.replyMessageObject) != null && messageObject.isYouTubeVideo())) {
addUrlsByPattern(isOutOwner(), this.messageText, false, 3, Integer.MAX_VALUE);
} else {
MessageObject messageObject2 = this.replyMessageObject;
if (messageObject2 != null && messageObject2.isVideo()) {
addUrlsByPattern(isOutOwner(), this.messageText, false, 3, this.replyMessageObject.getDuration());
}
}
boolean addEntitiesToText = addEntitiesToText(this.messageText, z);
int maxMessageTextWidth = getMaxMessageTextWidth();
staticLayout = null;
if (!(this.messageOwner.media instanceof TLRPC.TL_messageMediaGame)) {
textPaint = Theme.chat_msgGameTextPaint;
} else {
textPaint = Theme.chat_msgTextPaint;
}
TextPaint textPaint5 = textPaint;
if (Build.VERSION.SDK_INT < 24) {
textPaint2 = textPaint5;
i = 24;
staticLayout2 = StaticLayout.Builder.obtain(this.messageText, 0, this.messageText.length(), textPaint5, maxMessageTextWidth).setBreakStrategy(1).setHyphenationFrequency(0).setAlignment(Layout.Alignment.ALIGN_NORMAL).build();
} else {
i = 24;
textPaint2 = textPaint5;
staticLayout2 = new StaticLayout(this.messageText, textPaint5, maxMessageTextWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
}
if (!TextUtils.isEmpty(this.messageOwner.trans)) {
if (Build.VERSION.SDK_INT >= i) {
staticLayout = StaticLayout.Builder.obtain(this.messageOwner.trans, 0, this.messageOwner.trans.length(), textPaint2, maxMessageTextWidth).setBreakStrategy(1).setHyphenationFrequency(0).setAlignment(Layout.Alignment.ALIGN_NORMAL).build();
} else {
staticLayout3 = staticLayout2;
staticLayout = new StaticLayout(this.messageOwner.trans, textPaint2, maxMessageTextWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
this.textHeight = staticLayout3.getHeight();
this.linesCount = staticLayout3.getLineCount();
if (staticLayout != null) {
this.transHeight = staticLayout.getHeight();
int lineCount = staticLayout.getLineCount();
for (int i20 = 0; i20 < lineCount; i20++) {
this.transWidth = (int) Math.max(this.transWidth, staticLayout.getLineMax(i20));
}
}
ceil = Build.VERSION.SDK_INT >= i ? 1 : (int) Math.ceil(this.linesCount / 10.0f);
float f3 = 0.0f;
int i21 = 0;
i2 = 0;
float f4 = 0.0f;
while (i2 < ceil) {
if (Build.VERSION.SDK_INT >= i) {
min = this.linesCount;
} else {
min = Math.min(10, this.linesCount - i21);
}
TextLayoutBlock textLayoutBlock2 = new TextLayoutBlock();
if (ceil == i19) {
StaticLayout staticLayout6 = staticLayout3;
textLayoutBlock2.textLayout = staticLayout6;
textLayoutBlock2.textYOffset = f3;
textLayoutBlock2.charactersOffset = i18;
int i22 = this.emojiOnlyCount;
if (i22 != 0) {
if (i22 == i19) {
this.textHeight -= AndroidUtilities.dp(5.3f);
textLayoutBlock2.textYOffset -= AndroidUtilities.dp(5.3f);
} else if (i22 == 2) {
this.textHeight -= AndroidUtilities.dp(4.5f);
textLayoutBlock2.textYOffset -= AndroidUtilities.dp(4.5f);
} else if (i22 == 3) {
this.textHeight -= AndroidUtilities.dp(4.2f);
textLayoutBlock2.textYOffset -= AndroidUtilities.dp(4.2f);
}
}
textLayoutBlock2.height = this.textHeight;
textPaint3 = textPaint2;
staticLayout5 = staticLayout6;
textLayoutBlock = textLayoutBlock2;
i7 = i21;
i4 = i2;
i5 = ceil;
i9 = maxMessageTextWidth;
i10 = min;
} else {
StaticLayout staticLayout7 = staticLayout3;
int lineStart = staticLayout7.getLineStart(i21);
int lineEnd = staticLayout7.getLineEnd((i21 + min) - i19);
if (lineEnd < lineStart) {
textPaint3 = textPaint2;
z2 = addEntitiesToText;
staticLayout4 = staticLayout7;
i3 = i21;
i4 = i2;
i5 = ceil;
i6 = maxMessageTextWidth;
} else {
textLayoutBlock2.charactersOffset = lineStart;
textLayoutBlock2.charactersEnd = lineEnd;
try {
try {
if (addEntitiesToText) {
try {
if (Build.VERSION.SDK_INT >= i) {
textLayoutBlock2.textLayout = StaticLayout.Builder.obtain(this.messageText, lineStart, lineEnd, textPaint2, maxMessageTextWidth + AndroidUtilities.dp(2.0f)).setBreakStrategy(i19).setHyphenationFrequency(i18).setAlignment(Layout.Alignment.ALIGN_NORMAL).build();
textPaint3 = textPaint2;
staticLayout5 = staticLayout7;
textLayoutBlock = textLayoutBlock2;
i7 = i21;
i8 = i2;
i5 = ceil;
i9 = maxMessageTextWidth;
textLayoutBlock.textYOffset = staticLayout5.getLineTop(i7);
i4 = i8;
if (i4 != 0) {
try {
textLayoutBlock.height = (int) (textLayoutBlock.textYOffset - f4);
} catch (Exception e) {
e = e;
i3 = i7;
z2 = addEntitiesToText;
staticLayout4 = staticLayout5;
i6 = i9;
FileLog.e(e);
i11 = i3;
i2 = i4 + 1;
i21 = i11;
ceil = i5;
maxMessageTextWidth = i6;
textPaint2 = textPaint3;
addEntitiesToText = z2;
staticLayout3 = staticLayout4;
i18 = 0;
i19 = 1;
i = 24;
f3 = 0.0f;
}
}
textLayoutBlock.height = Math.max(textLayoutBlock.height, textLayoutBlock.textLayout.getLineBottom(textLayoutBlock.textLayout.getLineCount() - 1));
float f5 = textLayoutBlock.textYOffset;
if (i4 != i5 - 1) {
i10 = Math.max(min, textLayoutBlock.textLayout.getLineCount());
try {
this.textHeight = Math.max(this.textHeight, (int) (textLayoutBlock.textYOffset + textLayoutBlock.textLayout.getHeight()));
} catch (Exception e2) {
FileLog.e(e2);
}
} else {
i10 = min;
}
f4 = f5;
}
} catch (Exception e3) {
e = e3;
textPaint3 = textPaint2;
z2 = addEntitiesToText;
staticLayout4 = staticLayout7;
i3 = i21;
i4 = i2;
i5 = ceil;
i6 = maxMessageTextWidth;
FileLog.e(e);
i11 = i3;
i2 = i4 + 1;
i21 = i11;
ceil = i5;
maxMessageTextWidth = i6;
textPaint2 = textPaint3;
addEntitiesToText = z2;
staticLayout3 = staticLayout4;
i18 = 0;
i19 = 1;
i = 24;
f3 = 0.0f;
}
}
textLayoutBlock.textYOffset = staticLayout5.getLineTop(i7);
i4 = i8;
if (i4 != 0) {
}
textLayoutBlock.height = Math.max(textLayoutBlock.height, textLayoutBlock.textLayout.getLineBottom(textLayoutBlock.textLayout.getLineCount() - 1));
float f52 = textLayoutBlock.textYOffset;
if (i4 != i5 - 1) {
}
f4 = f52;
} catch (Exception e4) {
e = e4;
i3 = i7;
z2 = addEntitiesToText;
staticLayout4 = staticLayout5;
i4 = i8;
i6 = i9;
FileLog.e(e);
i11 = i3;
i2 = i4 + 1;
i21 = i11;
ceil = i5;
maxMessageTextWidth = i6;
textPaint2 = textPaint3;
addEntitiesToText = z2;
staticLayout3 = staticLayout4;
i18 = 0;
i19 = 1;
i = 24;
f3 = 0.0f;
}
textLayoutBlock.textLayout = new StaticLayout(this.messageText, lineStart, lineEnd, textPaint4, maxMessageTextWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
staticLayout5 = staticLayout4;
} catch (Exception e5) {
e = e5;
i3 = i7;
z2 = addEntitiesToText;
i4 = i8;
i6 = i9;
FileLog.e(e);
i11 = i3;
i2 = i4 + 1;
i21 = i11;
ceil = i5;
maxMessageTextWidth = i6;
textPaint2 = textPaint3;
addEntitiesToText = z2;
staticLayout3 = staticLayout4;
i18 = 0;
i19 = 1;
i = 24;
f3 = 0.0f;
}
textLayoutBlock = textLayoutBlock2;
i7 = i21;
textPaint4 = textPaint2;
i8 = i2;
staticLayout4 = staticLayout7;
textPaint3 = textPaint2;
i5 = ceil;
i9 = maxMessageTextWidth;
}
i11 = i3;
i2 = i4 + 1;
i21 = i11;
ceil = i5;
maxMessageTextWidth = i6;
textPaint2 = textPaint3;
addEntitiesToText = z2;
staticLayout3 = staticLayout4;
i18 = 0;
i19 = 1;
i = 24;
f3 = 0.0f;
}
this.textLayoutBlocks.add(textLayoutBlock);
float f6 = textLayoutBlock.textLayout.getLineLeft(i10 - 1);
float f7 = 0.0f;
if (i4 == 0 && f6 >= 0.0f) {
try {
this.textXOffset = f6;
} catch (Exception e6) {
e = e6;
if (i4 == 0) {
this.textXOffset = f7;
}
FileLog.e(e);
f6 = 0.0f;
float f8 = textLayoutBlock.textLayout.getLineWidth(i10 - 1);
ceil2 = (int) Math.ceil(f8);
i6 = i9;
if (ceil2 > i6 + 80) {
}
i12 = i5 - 1;
if (i4 == i12) {
}
int ceil3 = (int) Math.ceil(f8 + f6);
if (i10 <= 1) {
}
i11 = i13 + i14;
i2 = i4 + 1;
i21 = i11;
ceil = i5;
maxMessageTextWidth = i6;
textPaint2 = textPaint3;
addEntitiesToText = z2;
staticLayout3 = staticLayout4;
i18 = 0;
i19 = 1;
i = 24;
f3 = 0.0f;
}
}
float f82 = textLayoutBlock.textLayout.getLineWidth(i10 - 1);
ceil2 = (int) Math.ceil(f82);
i6 = i9;
if (ceil2 > i6 + 80) {
ceil2 = i6;
}
i12 = i5 - 1;
if (i4 == i12) {
this.lastLineWidth = ceil2;
}
int ceil32 = (int) Math.ceil(f82 + f6);
if (i10 <= 1) {
z2 = addEntitiesToText;
int i23 = ceil32;
int i24 = 0;
float f9 = 0.0f;
float f10 = 0.0f;
boolean z3 = false;
while (i24 < i10) {
try {
f = textLayoutBlock.textLayout.getLineWidth(i24);
} catch (Exception e7) {
FileLog.e(e7);
f = 0.0f;
}
StaticLayout staticLayout8 = staticLayout5;
if (f > i6 + 20) {
f = i6;
}
float f11 = f;
try {
f2 = textLayoutBlock.textLayout.getLineLeft(i24);
} catch (Exception e8) {
FileLog.e(e8);
f2 = 0.0f;
}
if (f2 > 0.0f) {
i15 = i7;
this.textXOffset = Math.min(this.textXOffset, f2);
i16 = i10;
textLayoutBlock.directionFlags = (byte) (textLayoutBlock.directionFlags | 1);
this.hasRtl = true;
} else {
i15 = i7;
i16 = i10;
textLayoutBlock.directionFlags = (byte) (textLayoutBlock.directionFlags | 2);
}
if (!z3 && f2 == 0.0f) {
try {
if (textLayoutBlock.textLayout.getParagraphDirection(i24) != 1) {
}
} catch (Exception unused) {
}
z3 = true;
}
float max = Math.max(f9, f11);
float f12 = f2 + f11;
float max2 = Math.max(f10, f12);
ceil2 = Math.max(ceil2, (int) Math.ceil(f11));
i23 = Math.max(i23, (int) Math.ceil(f12));
i24++;
f9 = max;
f10 = max2;
i7 = i15;
i10 = i16;
staticLayout5 = staticLayout8;
}
i13 = i7;
staticLayout4 = staticLayout5;
i14 = i10;
if (!z3) {
if (i4 == i12) {
this.lastLineWidth = ceil2;
}
f10 = f9;
} else if (i4 == i12) {
this.lastLineWidth = ceil32;
}
this.textWidth = Math.max(this.textWidth, (int) Math.ceil(f10));
} else {
i13 = i7;
z2 = addEntitiesToText;
staticLayout4 = staticLayout5;
i14 = i10;
if (f6 > 0.0f) {
float min2 = Math.min(this.textXOffset, f6);
this.textXOffset = min2;
if (min2 == 0.0f) {
ceil2 = (int) (ceil2 + f6);
}
this.hasRtl = i5 != 1;
textLayoutBlock.directionFlags = (byte) (textLayoutBlock.directionFlags | 1);
} else {
textLayoutBlock.directionFlags = (byte) (textLayoutBlock.directionFlags | 2);
}
this.textWidth = Math.max(this.textWidth, Math.min(i6, ceil2));
}
i11 = i13 + i14;
i2 = i4 + 1;
i21 = i11;
ceil = i5;
maxMessageTextWidth = i6;
textPaint2 = textPaint3;
addEntitiesToText = z2;
staticLayout3 = staticLayout4;
i18 = 0;
i19 = 1;
i = 24;
f3 = 0.0f;
}
return;
}
}
staticLayout3 = staticLayout2;
this.textHeight = staticLayout3.getHeight();
this.linesCount = staticLayout3.getLineCount();
if (staticLayout != null) {
}
if (Build.VERSION.SDK_INT >= i) {
}
float f32 = 0.0f;
int i212 = 0;
i2 = 0;
float f42 = 0.0f;
while (i2 < ceil) {
}
return;
}
if (Build.VERSION.SDK_INT < 24) {
}
if (!TextUtils.isEmpty(this.messageOwner.trans)) {
}
staticLayout3 = staticLayout2;
this.textHeight = staticLayout3.getHeight();
this.linesCount = staticLayout3.getLineCount();
if (staticLayout != null) {
}
if (Build.VERSION.SDK_INT >= i) {
}
float f322 = 0.0f;
int i2122 = 0;
i2 = 0;
float f422 = 0.0f;
while (i2 < ceil) {
}
return;
} catch (Exception e9) {
FileLog.e(e9);
return;
}
z = false;
if (!z) {
}
if (!isYouTubeVideo()) {
}
addUrlsByPattern(isOutOwner(), this.messageText, false, 3, Integer.MAX_VALUE);
boolean addEntitiesToText2 = addEntitiesToText(this.messageText, z);
int maxMessageTextWidth2 = getMaxMessageTextWidth();
staticLayout = null;
if (!(this.messageOwner.media instanceof TLRPC.TL_messageMediaGame)) {
}
TextPaint textPaint52 = textPaint;
}
public boolean isOut() {
return this.messageOwner.out;
}
public boolean isOutOwner() {
if (!this.messageOwner.out || this.messageOwner.from_id <= 0 || this.messageOwner.post) {
return false;
}
if (this.messageOwner.fwd_from == null) {
return true;
}
int clientUserId = UserConfig.getInstance(this.currentAccount).getClientUserId();
return getDialogId() == ((long) clientUserId) ? (this.messageOwner.fwd_from.from_id == clientUserId && (this.messageOwner.fwd_from.saved_from_peer == null || this.messageOwner.fwd_from.saved_from_peer.user_id == clientUserId)) || (this.messageOwner.fwd_from.saved_from_peer != null && this.messageOwner.fwd_from.saved_from_peer.user_id == clientUserId) : this.messageOwner.fwd_from.saved_from_peer == null || this.messageOwner.fwd_from.saved_from_peer.user_id == clientUserId;
}
public boolean needDrawAvatar() {
return (!isFromUser() && this.eventId == 0 && (this.messageOwner.fwd_from == null || this.messageOwner.fwd_from.saved_from_peer == null)) ? false : true;
}
public boolean isNewSupport() {
TLRPC.Message message = this.messageOwner;
return (message == null || message.media == null || !(this.messageOwner.media instanceof TLRPCContacts.TL_messageMediaSysNotify)) ? false : true;
}
public boolean needDrawAvatarInternal() {
return ((!isFromChat() || !isFromUser()) && this.eventId == 0 && (this.messageOwner.fwd_from == null || this.messageOwner.fwd_from.saved_from_peer == null)) ? false : true;
}
public boolean isFromChat() {
TLRPC.Chat chat;
if (getDialogId() == UserConfig.getInstance(this.currentAccount).clientUserId || isMegagroup() || (this.messageOwner.to_id != null && this.messageOwner.to_id.chat_id != 0)) {
return true;
}
return (this.messageOwner.to_id == null || this.messageOwner.to_id.channel_id == 0 || (chat = MessagesController.getInstance(this.currentAccount).getChat(Integer.valueOf(this.messageOwner.to_id.channel_id))) == null || !chat.megagroup) ? false : true;
}
public boolean isFromUser() {
return this.messageOwner.from_id > 0 && !this.messageOwner.post;
}
public boolean isForwardedChannelPost() {
return (this.messageOwner.from_id > 0 || this.messageOwner.fwd_from == null || this.messageOwner.fwd_from.channel_post == 0) ? false : true;
}
public boolean isUnread() {
return this.messageOwner.unread;
}
public boolean isContentUnread() {
return this.messageOwner.media_unread;
}
public void setIsRead() {
this.messageOwner.unread = false;
}
public int getUnradFlags() {
return getUnreadFlags(this.messageOwner);
}
public static int getUnreadFlags(TLRPC.Message message) {
int i = !message.unread ? 1 : 0;
return !message.media_unread ? i | 2 : i;
}
public void setContentIsRead() {
this.messageOwner.media_unread = false;
}
public int getId() {
return this.messageOwner.id;
}
public String getTranslate() {
return this.messageOwner.trans;
}
public boolean isTranslating() {
return this.messageOwner.istransing;
}
public int getRealId() {
return this.messageOwner.realId != 0 ? this.messageOwner.realId : this.messageOwner.id;
}
public static int getMessageSize(TLRPC.Message message) {
TLRPC.Document document;
if (message.media instanceof TLRPC.TL_messageMediaWebPage) {
document = message.media.webpage.document;
} else if (message.media instanceof TLRPC.TL_messageMediaGame) {
document = message.media.game.document;
} else {
document = message.media != null ? message.media.document : null;
}
if (document != null) {
return document.size;
}
return 0;
}
public int getSize() {
return getMessageSize(this.messageOwner);
}
public long getIdWithChannel() {
long j = this.messageOwner.id;
return (this.messageOwner.to_id == null || this.messageOwner.to_id.channel_id == 0) ? j : j | (this.messageOwner.to_id.channel_id << 32);
}
public int getChannelId() {
if (this.messageOwner.to_id != null) {
return this.messageOwner.to_id.channel_id;
}
return 0;
}
public static boolean shouldEncryptPhotoOrVideo(TLRPC.Message message) {
return message instanceof TLRPC.TL_message_secret ? ((message.media instanceof TLRPC.TL_messageMediaPhoto) || isVideoMessage(message)) && message.ttl > 0 && message.ttl <= 60 : ((message.media instanceof TLRPC.TL_messageMediaPhoto) || (message.media instanceof TLRPC.TL_messageMediaDocument)) && message.media.ttl_seconds != 0;
}
public boolean shouldEncryptPhotoOrVideo() {
return shouldEncryptPhotoOrVideo(this.messageOwner);
}
public static boolean isSecretPhotoOrVideo(TLRPC.Message message) {
if (message instanceof TLRPC.TL_message_secret) {
return ((message.media instanceof TLRPC.TL_messageMediaPhoto) || isRoundVideoMessage(message) || isVideoMessage(message)) && message.ttl > 0 && message.ttl <= 60;
}
if (message instanceof TLRPC.TL_message) {
return ((message.media instanceof TLRPC.TL_messageMediaPhoto) || (message.media instanceof TLRPC.TL_messageMediaDocument)) && message.media.ttl_seconds != 0;
}
return false;
}
public static boolean isSecretMedia(TLRPC.Message message) {
if (message instanceof TLRPC.TL_message_secret) {
return ((message.media instanceof TLRPC.TL_messageMediaPhoto) || isRoundVideoMessage(message) || isVideoMessage(message)) && message.media.ttl_seconds != 0;
}
if (message instanceof TLRPC.TL_message) {
return ((message.media instanceof TLRPC.TL_messageMediaPhoto) || (message.media instanceof TLRPC.TL_messageMediaDocument)) && message.media.ttl_seconds != 0;
}
return false;
}
public boolean needDrawBluredPreview() {
TLRPC.Message message = this.messageOwner;
if (message instanceof TLRPC.TL_message_secret) {
int max = Math.max(message.ttl, this.messageOwner.media.ttl_seconds);
return max > 0 && ((((this.messageOwner.media instanceof TLRPC.TL_messageMediaPhoto) || isVideo() || isGif()) && max <= 60) || isRoundVideo());
}
if (message instanceof TLRPC.TL_message) {
return ((message.media instanceof TLRPC.TL_messageMediaPhoto) || (this.messageOwner.media instanceof TLRPC.TL_messageMediaDocument)) && this.messageOwner.media.ttl_seconds != 0;
}
return false;
}
public boolean isSecretMedia() {
TLRPC.Message message = this.messageOwner;
if (message instanceof TLRPC.TL_message_secret) {
return (((message.media instanceof TLRPC.TL_messageMediaPhoto) || isGif()) && this.messageOwner.ttl > 0 && this.messageOwner.ttl <= 60) || isVoice() || isRoundVideo() || isVideo();
}
if (message instanceof TLRPC.TL_message) {
return ((message.media instanceof TLRPC.TL_messageMediaPhoto) || (this.messageOwner.media instanceof TLRPC.TL_messageMediaDocument)) && this.messageOwner.media.ttl_seconds != 0;
}
return false;
}
public static void setUnreadFlags(TLRPC.Message message, int i) {
message.unread = (i & 1) == 0;
message.media_unread = (i & 2) == 0;
}
public static boolean isUnread(TLRPC.Message message) {
return message.unread;
}
public static boolean isContentUnread(TLRPC.Message message) {
return message.media_unread;
}
public boolean isMegagroup() {
return isMegagroup(this.messageOwner);
}
public boolean isSavedFromMegagroup() {
if (this.messageOwner.fwd_from == null || this.messageOwner.fwd_from.saved_from_peer == null || this.messageOwner.fwd_from.saved_from_peer.channel_id == 0) {
return false;
}
return ChatObject.isMegagroup(MessagesController.getInstance(this.currentAccount).getChat(Integer.valueOf(this.messageOwner.fwd_from.saved_from_peer.channel_id)));
}
public static boolean isMegagroup(TLRPC.Message message) {
return (message.flags & Integer.MIN_VALUE) != 0;
}
public static boolean isOut(TLRPC.Message message) {
return message.out;
}
public long getDialogId() {
return getDialogId(this.messageOwner);
}
public boolean canStreamVideo() {
TLRPC.Document document = getDocument();
if (document != null && !(document instanceof TLRPC.TL_documentEncrypted)) {
if (SharedConfig.streamAllVideo) {
return true;
}
for (int i = 0; i < document.attributes.size(); i++) {
TLRPC.DocumentAttribute documentAttribute = document.attributes.get(i);
if (documentAttribute instanceof TLRPC.TL_documentAttributeVideo) {
return documentAttribute.supports_streaming;
}
if ((documentAttribute instanceof TLRPC.TL_documentAttributeFilename) && document.mime_type.toLowerCase().startsWith("video/")) {
return true;
}
}
if (SharedConfig.streamMkv && "video/x-matroska".equals(document.mime_type)) {
return true;
}
}
return false;
}
public static long getDialogId(TLRPC.Message message) {
if (message.dialog_id == 0 && message.to_id != null) {
if (message.to_id.chat_id != 0) {
message.dialog_id = -message.to_id.chat_id;
} else if (message.to_id.channel_id != 0) {
message.dialog_id = -message.to_id.channel_id;
} else if (isOut(message)) {
message.dialog_id = message.to_id.user_id;
} else {
message.dialog_id = message.from_id;
}
}
return message.dialog_id;
}
public boolean isSending() {
return this.messageOwner.send_state == 1 && this.messageOwner.id < 0;
}
public boolean isEditing() {
return this.messageOwner.send_state == 3 && this.messageOwner.id > 0;
}
public boolean isSendError() {
return (this.messageOwner.send_state == 2 && this.messageOwner.id < 0) || (this.scheduled && this.messageOwner.id > 0 && this.messageOwner.date < ConnectionsManager.getInstance(this.currentAccount).getCurrentTime() + (-60));
}
public boolean isSent() {
return this.messageOwner.send_state == 0 || this.messageOwner.id > 0;
}
public int getSecretTimeLeft() {
return this.messageOwner.destroyTime != 0 ? Math.max(0, this.messageOwner.destroyTime - ConnectionsManager.getInstance(this.currentAccount).getCurrentTime()) : this.messageOwner.ttl;
}
public String getSecretTimeString() {
if (!isSecretMedia()) {
return null;
}
int secretTimeLeft = getSecretTimeLeft();
if (secretTimeLeft < 60) {
return secretTimeLeft + "s";
}
return (secretTimeLeft / 60) + "m";
}
public String getDocumentName() {
return FileLoader.getDocumentFileName(getDocument());
}
public static boolean isStickerDocument(TLRPC.Document document) {
if (document != null) {
for (int i = 0; i < document.attributes.size(); i++) {
if (document.attributes.get(i) instanceof TLRPC.TL_documentAttributeSticker) {
return "image/webp".equals(document.mime_type) || "application/x-tgsticker".equals(document.mime_type);
}
}
}
return false;
}
public static boolean isAnimatedStickerDocument(TLRPC.Document document) {
return (document == null || !"application/x-tgsticker".equals(document.mime_type) || document.thumbs.isEmpty()) ? false : true;
}
public static boolean canAutoplayAnimatedSticker(TLRPC.Document document) {
return isAnimatedStickerDocument(document) && SharedConfig.getDevicePerfomanceClass() != 0;
}
public static boolean isMaskDocument(TLRPC.Document document) {
if (document != null) {
for (int i = 0; i < document.attributes.size(); i++) {
TLRPC.DocumentAttribute documentAttribute = document.attributes.get(i);
if ((documentAttribute instanceof TLRPC.TL_documentAttributeSticker) && documentAttribute.mask) {
return true;
}
}
}
return false;
}
public static boolean isVoiceDocument(TLRPC.Document document) {
if (document != null) {
for (int i = 0; i < document.attributes.size(); i++) {
TLRPC.DocumentAttribute documentAttribute = document.attributes.get(i);
if (documentAttribute instanceof TLRPC.TL_documentAttributeAudio) {
return documentAttribute.voice;
}
}
}
return false;
}
public static boolean isVoiceWebDocument(WebFile webFile) {
return webFile != null && webFile.mime_type.equals("audio/ogg");
}
public static boolean isImageWebDocument(WebFile webFile) {
return (webFile == null || isGifDocument(webFile) || !webFile.mime_type.startsWith("image/")) ? false : true;
}
public static boolean isVideoWebDocument(WebFile webFile) {
return webFile != null && webFile.mime_type.startsWith("video/");
}
public static boolean isMusicDocument(TLRPC.Document document) {
if (document != null) {
for (int i = 0; i < document.attributes.size(); i++) {
if (document.attributes.get(i) instanceof TLRPC.TL_documentAttributeAudio) {
return !r2.voice;
}
}
if (!TextUtils.isEmpty(document.mime_type)) {
String lowerCase = document.mime_type.toLowerCase();
if (lowerCase.equals(MimeTypes.AUDIO_FLAC) || lowerCase.equals("audio/ogg") || lowerCase.equals(MimeTypes.AUDIO_OPUS) || lowerCase.equals("audio/x-opus+ogg") || (lowerCase.equals("application/octet-stream") && FileLoader.getDocumentFileName(document).endsWith(".opus"))) {
return true;
}
}
}
return false;
}
public static boolean isVideoDocument(TLRPC.Document document) {
if (document == null) {
return false;
}
boolean z = false;
int i = 0;
int i2 = 0;
boolean z2 = false;
for (int i3 = 0; i3 < document.attributes.size(); i3++) {
TLRPC.DocumentAttribute documentAttribute = document.attributes.get(i3);
if (documentAttribute instanceof TLRPC.TL_documentAttributeVideo) {
if (documentAttribute.round_message) {
return false;
}
i = documentAttribute.w;
i2 = documentAttribute.h;
z2 = true;
} else if (documentAttribute instanceof TLRPC.TL_documentAttributeAnimated) {
z = true;
}
}
if (z && (i > 1280 || i2 > 1280)) {
z = false;
}
if (SharedConfig.streamMkv && !z2 && "video/x-matroska".equals(document.mime_type)) {
z2 = true;
}
return z2 && !z;
}
public TLRPC.Document getDocument() {
TLRPC.Document document = this.emojiAnimatedSticker;
return document != null ? document : getDocument(this.messageOwner);
}
public static TLRPC.Document getDocument(TLRPC.Message message) {
if (message.media instanceof TLRPC.TL_messageMediaWebPage) {
return message.media.webpage.document;
}
if (message.media instanceof TLRPC.TL_messageMediaGame) {
return message.media.game.document;
}
if (message.media != null) {
return message.media.document;
}
return null;
}
public static TLRPC.Photo getPhoto(TLRPC.Message message) {
if (message.media instanceof TLRPC.TL_messageMediaWebPage) {
return message.media.webpage.photo;
}
if (message.media != null) {
return message.media.photo;
}
return null;
}
public static boolean isStickerMessage(TLRPC.Message message) {
return message.media != null && isStickerDocument(message.media.document);
}
public static boolean isAnimatedStickerMessage(TLRPC.Message message) {
return message.media != null && isAnimatedStickerDocument(message.media.document);
}
public static boolean isLocationMessage(TLRPC.Message message) {
return (message.media instanceof TLRPC.TL_messageMediaGeo) || (message.media instanceof TLRPC.TL_messageMediaGeoLive) || (message.media instanceof TLRPC.TL_messageMediaVenue);
}
public static boolean isMaskMessage(TLRPC.Message message) {
return message.media != null && isMaskDocument(message.media.document);
}
public static boolean isMusicMessage(TLRPC.Message message) {
if (message.media instanceof TLRPC.TL_messageMediaWebPage) {
return isMusicDocument(message.media.webpage.document);
}
return message.media != null && isMusicDocument(message.media.document);
}
public static boolean isGifMessage(TLRPC.Message message) {
if (message.media instanceof TLRPC.TL_messageMediaWebPage) {
return isGifDocument(message.media.webpage.document);
}
return message.media != null && isGifDocument(message.media.document);
}
public static boolean isRoundVideoMessage(TLRPC.Message message) {
if (message.media instanceof TLRPC.TL_messageMediaWebPage) {
return isRoundVideoDocument(message.media.webpage.document);
}
return message.media != null && isRoundVideoDocument(message.media.document);
}
public static boolean isPhoto(TLRPC.Message message) {
if (message.media instanceof TLRPC.TL_messageMediaWebPage) {
return (message.media.webpage.photo instanceof TLRPC.TL_photo) && !(message.media.webpage.document instanceof TLRPC.TL_document);
}
return message.media instanceof TLRPC.TL_messageMediaPhoto;
}
public static boolean isVoiceMessage(TLRPC.Message message) {
if (message.media instanceof TLRPC.TL_messageMediaWebPage) {
return isVoiceDocument(message.media.webpage.document);
}
return message.media != null && isVoiceDocument(message.media.document);
}
public static boolean isNewGifMessage(TLRPC.Message message) {
if (message.media instanceof TLRPC.TL_messageMediaWebPage) {
return isNewGifDocument(message.media.webpage.document);
}
return message.media != null && isNewGifDocument(message.media.document);
}
public static boolean isLiveLocationMessage(TLRPC.Message message) {
return message.media instanceof TLRPC.TL_messageMediaGeoLive;
}
public static boolean isVideoMessage(TLRPC.Message message) {
if (message.media instanceof TLRPC.TL_messageMediaWebPage) {
return isVideoDocument(message.media.webpage.document);
}
return message.media != null && isVideoDocument(message.media.document);
}
public static boolean isGameMessage(TLRPC.Message message) {
return message.media instanceof TLRPC.TL_messageMediaGame;
}
public static boolean isInvoiceMessage(TLRPC.Message message) {
return message.media instanceof TLRPC.TL_messageMediaInvoice;
}
public static TLRPC.InputStickerSet getInputStickerSet(TLRPC.Message message) {
if (message.media == null || message.media.document == null) {
return null;
}
return getInputStickerSet(message.media.document);
}
public static TLRPC.InputStickerSet getInputStickerSet(TLRPC.Document document) {
if (document == null) {
return null;
}
int size = document.attributes.size();
for (int i = 0; i < size; i++) {
TLRPC.DocumentAttribute documentAttribute = document.attributes.get(i);
if (documentAttribute instanceof TLRPC.TL_documentAttributeSticker) {
if (documentAttribute.stickerset instanceof TLRPC.TL_inputStickerSetEmpty) {
return null;
}
return documentAttribute.stickerset;
}
}
return null;
}
public static long getStickerSetId(TLRPC.Document document) {
if (document == null) {
return -1L;
}
for (int i = 0; i < document.attributes.size(); i++) {
TLRPC.DocumentAttribute documentAttribute = document.attributes.get(i);
if (documentAttribute instanceof TLRPC.TL_documentAttributeSticker) {
if (documentAttribute.stickerset instanceof TLRPC.TL_inputStickerSetEmpty) {
return -1L;
}
return documentAttribute.stickerset.id;
}
}
return -1L;
}
public String getStrickerChar() {
TLRPC.Document document = getDocument();
if (document == null) {
return null;
}
Iterator<TLRPC.DocumentAttribute> it = document.attributes.iterator();
while (it.hasNext()) {
TLRPC.DocumentAttribute next = it.next();
if (next instanceof TLRPC.TL_documentAttributeSticker) {
return next.alt;
}
}
return null;
}
public int getApproximateHeight() {
int i;
int i2;
int min;
int min2;
int i3 = this.type;
int i4 = 0;
if (i3 == 0) {
int i5 = this.textHeight;
if ((this.messageOwner.media instanceof TLRPC.TL_messageMediaWebPage) && (this.messageOwner.media.webpage instanceof TLRPC.TL_webPage)) {
i4 = AndroidUtilities.dp(100.0f);
}
int i6 = i5 + i4;
return isReply() ? i6 + AndroidUtilities.dp(42.0f) : i6;
}
if (i3 == 2) {
return AndroidUtilities.dp(72.0f);
}
if (i3 == 12) {
return AndroidUtilities.dp(71.0f);
}
if (i3 == 9) {
return AndroidUtilities.dp(100.0f);
}
if (i3 == 4) {
return AndroidUtilities.dp(114.0f);
}
if (i3 == 14) {
return AndroidUtilities.dp(82.0f);
}
if (i3 == 10) {
return AndroidUtilities.dp(30.0f);
}
if (i3 == 11) {
return AndroidUtilities.dp(50.0f);
}
if (i3 == 5) {
return AndroidUtilities.roundMessageSize;
}
if (i3 == 13 || i3 == 15) {
float f = AndroidUtilities.displaySize.y * 0.4f;
if (AndroidUtilities.isTablet()) {
i = AndroidUtilities.getMinTabletSide();
} else {
i = AndroidUtilities.displaySize.x;
}
float f2 = i * 0.5f;
TLRPC.Document document = getDocument();
int size = document.attributes.size();
int i7 = 0;
while (true) {
if (i7 >= size) {
i2 = 0;
break;
}
TLRPC.DocumentAttribute documentAttribute = document.attributes.get(i7);
if (documentAttribute instanceof TLRPC.TL_documentAttributeImageSize) {
i4 = documentAttribute.w;
i2 = documentAttribute.h;
break;
}
i7++;
}
if (i4 == 0) {
i2 = (int) f;
i4 = AndroidUtilities.dp(100.0f) + i2;
}
float f3 = i2;
if (f3 > f) {
i4 = (int) (i4 * (f / f3));
i2 = (int) f;
}
float f4 = i4;
if (f4 > f2) {
i2 = (int) (i2 * (f2 / f4));
}
return i2 + AndroidUtilities.dp(14.0f);
}
if (AndroidUtilities.isTablet()) {
min = AndroidUtilities.getMinTabletSide();
} else {
min = Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y);
}
int i8 = (int) (min * 0.7f);
int dp = AndroidUtilities.dp(100.0f) + i8;
if (i8 > AndroidUtilities.getPhotoSize()) {
i8 = AndroidUtilities.getPhotoSize();
}
if (dp > AndroidUtilities.getPhotoSize()) {
dp = AndroidUtilities.getPhotoSize();
}
if (FileLoader.getClosestPhotoSizeWithSize(this.photoThumbs, AndroidUtilities.getPhotoSize()) != null) {
int i9 = (int) (r3.h / (r3.w / i8));
if (i9 == 0) {
i9 = AndroidUtilities.dp(100.0f);
}
if (i9 <= dp) {
dp = i9 < AndroidUtilities.dp(120.0f) ? AndroidUtilities.dp(120.0f) : i9;
}
if (needDrawBluredPreview()) {
if (AndroidUtilities.isTablet()) {
min2 = AndroidUtilities.getMinTabletSide();
} else {
min2 = Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y);
}
dp = (int) (min2 * 0.5f);
}
}
return dp + AndroidUtilities.dp(14.0f);
}
public String getStickerEmoji() {
TLRPC.Document document = getDocument();
if (document == null) {
return null;
}
for (int i = 0; i < document.attributes.size(); i++) {
TLRPC.DocumentAttribute documentAttribute = document.attributes.get(i);
if (documentAttribute instanceof TLRPC.TL_documentAttributeSticker) {
if (documentAttribute.alt == null || documentAttribute.alt.length() <= 0) {
return null;
}
return documentAttribute.alt;
}
}
return null;
}
public boolean isAnimatedEmoji() {
return this.emojiAnimatedSticker != null;
}
public boolean isSticker() {
int i = this.type;
if (i != 1000) {
return i == 13;
}
return isStickerDocument(getDocument());
}
public boolean isAnimatedSticker() {
int i = this.type;
if (i != 1000) {
return i == 15;
}
return isAnimatedStickerDocument(getDocument());
}
public boolean isAnyKindOfSticker() {
int i = this.type;
return i == 13 || i == 15;
}
public boolean shouldDrawWithoutBackground() {
int i = this.type;
return i == 13 || i == 15 || i == 5;
}
public boolean isLocation() {
return isLocationMessage(this.messageOwner);
}
public boolean isMask() {
return isMaskMessage(this.messageOwner);
}
public boolean isMusic() {
return isMusicMessage(this.messageOwner);
}
public boolean isVoice() {
return isVoiceMessage(this.messageOwner);
}
public boolean isVideo() {
return isVideoMessage(this.messageOwner);
}
public boolean isPhoto() {
return isPhoto(this.messageOwner);
}
public boolean isLiveLocation() {
return isLiveLocationMessage(this.messageOwner);
}
public boolean isGame() {
return isGameMessage(this.messageOwner);
}
public boolean isInvoice() {
return isInvoiceMessage(this.messageOwner);
}
public boolean isRoundVideo() {
if (this.isRoundVideoCached == 0) {
this.isRoundVideoCached = (this.type == 5 || isRoundVideoMessage(this.messageOwner)) ? 1 : 2;
}
return this.isRoundVideoCached == 1;
}
public boolean hasPhotoStickers() {
return (this.messageOwner.media == null || this.messageOwner.media.photo == null || !this.messageOwner.media.photo.has_stickers) ? false : true;
}
public boolean isGif() {
return isGifMessage(this.messageOwner);
}
public boolean isWebpageDocument() {
return (!(this.messageOwner.media instanceof TLRPC.TL_messageMediaWebPage) || this.messageOwner.media.webpage.document == null || isGifDocument(this.messageOwner.media.webpage.document)) ? false : true;
}
public boolean isWebpage() {
return this.messageOwner.media instanceof TLRPC.TL_messageMediaWebPage;
}
public boolean isNewGif() {
return this.messageOwner.media != null && isNewGifDocument(this.messageOwner.media.document);
}
public boolean isAndroidTheme() {
if (this.messageOwner.media != null && this.messageOwner.media.webpage != null) {
ArrayList<TLRPC.Document> arrayList = this.messageOwner.media.webpage.documents;
int size = arrayList.size();
for (int i = 0; i < size; i++) {
if ("application/x-tgtheme-android".equals(arrayList.get(i).mime_type)) {
return true;
}
}
}
return false;
}
public String getMusicTitle() {
return getMusicTitle(true);
}
public String getMusicTitle(boolean z) {
TLRPC.Document document = getDocument();
if (document != null) {
for (int i = 0; i < document.attributes.size(); i++) {
TLRPC.DocumentAttribute documentAttribute = document.attributes.get(i);
if (documentAttribute instanceof TLRPC.TL_documentAttributeAudio) {
if (documentAttribute.voice) {
if (z) {
return LocaleController.formatDateAudio(this.messageOwner.date);
}
return null;
}
String str = documentAttribute.title;
if (str != null && str.length() != 0) {
return str;
}
String documentFileName = FileLoader.getDocumentFileName(document);
return (TextUtils.isEmpty(documentFileName) && z) ? LocaleController.getString("AudioUnknownTitle", R.string.AudioUnknownTitle) : documentFileName;
}
if ((documentAttribute instanceof TLRPC.TL_documentAttributeVideo) && documentAttribute.round_message) {
return LocaleController.formatDateAudio(this.messageOwner.date);
}
}
String documentFileName2 = FileLoader.getDocumentFileName(document);
if (!TextUtils.isEmpty(documentFileName2)) {
return documentFileName2;
}
}
return LocaleController.getString("AudioUnknownTitle", R.string.AudioUnknownTitle);
}
public int getDuration() {
TLRPC.Document document = getDocument();
if (document == null) {
return 0;
}
int i = this.audioPlayerDuration;
if (i > 0) {
return i;
}
for (int i2 = 0; i2 < document.attributes.size(); i2++) {
TLRPC.DocumentAttribute documentAttribute = document.attributes.get(i2);
if (documentAttribute instanceof TLRPC.TL_documentAttributeAudio) {
return documentAttribute.duration;
}
if (documentAttribute instanceof TLRPC.TL_documentAttributeVideo) {
return documentAttribute.duration;
}
}
return this.audioPlayerDuration;
}
public String getArtworkUrl(boolean z) {
TLRPC.Document document = getDocument();
if (document != null) {
int size = document.attributes.size();
for (int i = 0; i < size; i++) {
TLRPC.DocumentAttribute documentAttribute = document.attributes.get(i);
if (documentAttribute instanceof TLRPC.TL_documentAttributeAudio) {
if (documentAttribute.voice) {
return null;
}
String str = documentAttribute.performer;
String str2 = documentAttribute.title;
if (!TextUtils.isEmpty(str)) {
int i2 = 0;
while (true) {
String[] strArr = excludeWords;
if (i2 >= strArr.length) {
break;
}
str = str.replace(strArr[i2], " ");
i2++;
}
}
if (TextUtils.isEmpty(str) && TextUtils.isEmpty(str2)) {
return null;
}
try {
StringBuilder sb = new StringBuilder();
sb.append("athumb://itunes.apple.com/search?term=");
sb.append(URLEncoder.encode(str + " - " + str2, "UTF-8"));
sb.append("&entity=song&limit=4");
sb.append(z ? "&s=1" : "");
return sb.toString();
} catch (Exception unused) {
continue;
}
}
}
}
return null;
}
public String getMusicAuthor() {
return getMusicAuthor(true);
}
public String getMusicAuthor(boolean z) {
TLRPC.User user;
TLRPC.Chat chat;
TLRPC.Document document = getDocument();
if (document != null) {
boolean z2 = false;
for (int i = 0; i < document.attributes.size(); i++) {
TLRPC.DocumentAttribute documentAttribute = document.attributes.get(i);
if (documentAttribute instanceof TLRPC.TL_documentAttributeAudio) {
if (!documentAttribute.voice) {
String str = documentAttribute.performer;
return (TextUtils.isEmpty(str) && z) ? LocaleController.getString("AudioUnknownArtist", R.string.AudioUnknownArtist) : str;
}
} else {
if (documentAttribute instanceof TLRPC.TL_documentAttributeVideo) {
}
if (!z2) {
TLRPC.User user2 = null;
if (!z) {
return null;
}
if (isOutOwner() || (this.messageOwner.fwd_from != null && this.messageOwner.fwd_from.from_id == UserConfig.getInstance(this.currentAccount).getClientUserId())) {
return LocaleController.getString("FromYou", R.string.FromYou);
}
if (this.messageOwner.fwd_from != null && this.messageOwner.fwd_from.channel_id != 0) {
chat = MessagesController.getInstance(this.currentAccount).getChat(Integer.valueOf(this.messageOwner.fwd_from.channel_id));
} else {
if (this.messageOwner.fwd_from != null && this.messageOwner.fwd_from.from_id != 0) {
user = MessagesController.getInstance(this.currentAccount).getUser(Integer.valueOf(this.messageOwner.fwd_from.from_id));
} else {
if (this.messageOwner.fwd_from != null && this.messageOwner.fwd_from.from_name != null) {
return this.messageOwner.fwd_from.from_name;
}
if (this.messageOwner.from_id < 0) {
chat = MessagesController.getInstance(this.currentAccount).getChat(Integer.valueOf(-this.messageOwner.from_id));
} else if (this.messageOwner.from_id == 0 && this.messageOwner.to_id.channel_id != 0) {
chat = MessagesController.getInstance(this.currentAccount).getChat(Integer.valueOf(this.messageOwner.to_id.channel_id));
} else {
user = MessagesController.getInstance(this.currentAccount).getUser(Integer.valueOf(this.messageOwner.from_id));
}
}
TLRPC.User user3 = user;
chat = null;
user2 = user3;
}
if (user2 != null) {
return UserObject.getName(user2);
}
if (chat != null) {
return chat.title;
}
}
}
z2 = true;
if (!z2) {
}
}
}
return LocaleController.getString("AudioUnknownArtist", R.string.AudioUnknownArtist);
}
public TLRPC.InputStickerSet getInputStickerSet() {
return getInputStickerSet(this.messageOwner);
}
public boolean isForwarded() {
return isForwardedMessage(this.messageOwner);
}
public boolean needDrawForwarded() {
return ((this.messageOwner.flags & 4) == 0 || this.messageOwner.fwd_from == null || (this.messageOwner.fwd_from.saved_from_peer != null && this.messageOwner.fwd_from.saved_from_peer.channel_id == this.messageOwner.fwd_from.channel_id) || ((long) UserConfig.getInstance(this.currentAccount).getClientUserId()) == getDialogId()) ? false : true;
}
public static boolean isForwardedMessage(TLRPC.Message message) {
return ((message.flags & 4) == 0 || message.fwd_from == null) ? false : true;
}
public boolean isReply() {
MessageObject messageObject = this.replyMessageObject;
return (messageObject == null || !(messageObject.messageOwner instanceof TLRPC.TL_messageEmpty)) && !((this.messageOwner.reply_to_msg_id == 0 && this.messageOwner.reply_to_random_id == 0) || (this.messageOwner.flags & 8) == 0);
}
public boolean isMediaEmpty() {
return isMediaEmpty(this.messageOwner);
}
public boolean isMediaEmptyWebpage() {
return isMediaEmptyWebpage(this.messageOwner);
}
public static boolean isMediaEmpty(TLRPC.Message message) {
return message == null || message.media == null || (message.media instanceof TLRPC.TL_messageMediaEmpty) || (message.media instanceof TLRPC.TL_messageMediaWebPage);
}
public static boolean isMediaEmptyWebpage(TLRPC.Message message) {
return message == null || message.media == null || (message.media instanceof TLRPC.TL_messageMediaEmpty);
}
public boolean canEditMessage(TLRPC.Chat chat) {
return canEditMessage(this.currentAccount, this.messageOwner, chat, this.scheduled);
}
public boolean canEditMessageScheduleTime(TLRPC.Chat chat) {
return canEditMessageScheduleTime(this.currentAccount, this.messageOwner, chat);
}
public boolean canForwardMessage() {
int i;
return ((this.messageOwner instanceof TLRPC.TL_message_secret) || needDrawBluredPreview() || isLiveLocation() || (i = this.type) == 16 || i == 101 || i == 102) ? false : true;
}
public boolean canEditMedia() {
if (isSecretMedia()) {
return false;
}
if (this.messageOwner.media instanceof TLRPC.TL_messageMediaPhoto) {
return true;
}
return (!(this.messageOwner.media instanceof TLRPC.TL_messageMediaDocument) || isVoice() || isSticker() || isAnimatedSticker() || isRoundVideo()) ? false : true;
}
public boolean canEditMessageAnytime(TLRPC.Chat chat) {
return canEditMessageAnytime(this.currentAccount, this.messageOwner, chat);
}
public static boolean canEditMessageAnytime(int i, TLRPC.Message message, TLRPC.Chat chat) {
if (message != null && message.to_id != null && ((message.media == null || (!isRoundVideoDocument(message.media.document) && !isStickerDocument(message.media.document) && !isAnimatedStickerDocument(message.media.document))) && ((message.action == null || (message.action instanceof TLRPC.TL_messageActionEmpty)) && !isForwardedMessage(message) && message.via_bot_id == 0 && message.id >= 0))) {
if (message.from_id == message.to_id.user_id && message.from_id == UserConfig.getInstance(i).getClientUserId() && !isLiveLocationMessage(message)) {
return true;
}
if ((chat != null || message.to_id.channel_id == 0 || (chat = MessagesController.getInstance(UserConfig.selectedAccount).getChat(Integer.valueOf(message.to_id.channel_id))) != null) && message.out && chat != null && chat.megagroup && (chat.creator || (chat.admin_rights != null && chat.admin_rights.pin_messages))) {
return true;
}
}
return false;
}
public static boolean canEditMessageScheduleTime(int i, TLRPC.Message message, TLRPC.Chat chat) {
if (chat == null && message.to_id.channel_id != 0 && (chat = MessagesController.getInstance(i).getChat(Integer.valueOf(message.to_id.channel_id))) == null) {
return false;
}
if (!ChatObject.isChannel(chat) || chat.megagroup || chat.creator) {
return true;
}
return chat.admin_rights != null && (chat.admin_rights.edit_messages || message.out);
}
public static boolean canEditMessage(int i, TLRPC.Message message, TLRPC.Chat chat, boolean z) {
if (z && message.date < ConnectionsManager.getInstance(i).getCurrentTime() - 60) {
return false;
}
if ((chat == null || (!chat.left && !chat.kicked)) && message != null && message.to_id != null && ((message.media == null || (!isRoundVideoDocument(message.media.document) && !isStickerDocument(message.media.document) && !isAnimatedStickerDocument(message.media.document) && !isLocationMessage(message))) && ((message.action == null || (message.action instanceof TLRPC.TL_messageActionEmpty)) && !isForwardedMessage(message) && message.via_bot_id == 0 && message.id >= 0))) {
if (message.from_id == message.to_id.user_id && message.from_id == UserConfig.getInstance(i).getClientUserId() && !isLiveLocationMessage(message) && !(message.media instanceof TLRPC.TL_messageMediaContact)) {
return true;
}
if (chat == null && message.to_id.channel_id != 0 && (chat = MessagesController.getInstance(i).getChat(Integer.valueOf(message.to_id.channel_id))) == null) {
return false;
}
if (message.media != null && !(message.media instanceof TLRPC.TL_messageMediaEmpty) && !(message.media instanceof TLRPC.TL_messageMediaPhoto) && !(message.media instanceof TLRPC.TL_messageMediaDocument) && !(message.media instanceof TLRPC.TL_messageMediaWebPage)) {
return false;
}
if (message.out && chat != null && chat.megagroup && (chat.creator || (chat.admin_rights != null && chat.admin_rights.pin_messages))) {
return true;
}
if (!z && Math.abs(message.date - ConnectionsManager.getInstance(i).getCurrentTime()) > MessagesController.getInstance(i).maxEditTime) {
return false;
}
if (message.to_id.channel_id == 0) {
if (message.out || message.from_id == UserConfig.getInstance(i).getClientUserId()) {
return (message.media instanceof TLRPC.TL_messageMediaPhoto) || !(!(message.media instanceof TLRPC.TL_messageMediaDocument) || isStickerMessage(message) || isAnimatedStickerMessage(message)) || (message.media instanceof TLRPC.TL_messageMediaEmpty) || (message.media instanceof TLRPC.TL_messageMediaWebPage) || message.media == null;
}
return false;
}
if (((chat.megagroup && message.out) || (!chat.megagroup && ((chat.creator || (chat.admin_rights != null && (chat.admin_rights.edit_messages || (message.out && chat.admin_rights.post_messages)))) && message.post))) && ((message.media instanceof TLRPC.TL_messageMediaPhoto) || (((message.media instanceof TLRPC.TL_messageMediaDocument) && !isStickerMessage(message) && !isAnimatedStickerMessage(message)) || (message.media instanceof TLRPC.TL_messageMediaEmpty) || (message.media instanceof TLRPC.TL_messageMediaWebPage) || message.media == null))) {
return true;
}
}
return false;
}
public boolean canDeleteMessage(boolean z, TLRPC.Chat chat) {
return this.eventId == 0 && canDeleteMessage(this.currentAccount, z, this.messageOwner, chat);
}
public static boolean canDeleteMessage(int i, boolean z, TLRPC.Message message, TLRPC.Chat chat) {
if (message.id < 0) {
return true;
}
if (chat == null && message.to_id.channel_id != 0) {
chat = MessagesController.getInstance(i).getChat(Integer.valueOf(message.to_id.channel_id));
}
if (!ChatObject.isChannel(chat)) {
return z || isOut(message) || !ChatObject.isChannel(chat);
}
if (z && !chat.megagroup) {
if (chat.creator) {
return true;
}
return chat.admin_rights != null && (chat.admin_rights.delete_messages || message.out);
}
if (z) {
return true;
}
if (message.id != 1) {
if (chat.creator) {
return true;
}
if (chat.admin_rights != null) {
if (chat.admin_rights.delete_messages) {
return true;
}
if (message.out && (chat.megagroup || chat.admin_rights.post_messages)) {
return true;
}
}
if (chat.megagroup && message.out && message.from_id > 0) {
return true;
}
}
return false;
}
public String getForwardedName() {
if (this.messageOwner.fwd_from == null) {
return null;
}
if (this.messageOwner.fwd_from.channel_id != 0) {
TLRPC.Chat chat = MessagesController.getInstance(this.currentAccount).getChat(Integer.valueOf(this.messageOwner.fwd_from.channel_id));
if (chat != null) {
return chat.title;
}
return null;
}
if (this.messageOwner.fwd_from.from_id != 0) {
TLRPC.User user = MessagesController.getInstance(this.currentAccount).getUser(Integer.valueOf(this.messageOwner.fwd_from.from_id));
if (user != null) {
return UserObject.getName(user);
}
return null;
}
if (this.messageOwner.fwd_from.from_name != null) {
return this.messageOwner.fwd_from.from_name;
}
return null;
}
public int getFromId() {
if (this.messageOwner.fwd_from != null && this.messageOwner.fwd_from.saved_from_peer != null) {
if (this.messageOwner.fwd_from.saved_from_peer.user_id != 0) {
if (this.messageOwner.fwd_from.from_id != 0) {
return this.messageOwner.fwd_from.from_id;
}
return this.messageOwner.fwd_from.saved_from_peer.user_id;
}
if (this.messageOwner.fwd_from.saved_from_peer.channel_id != 0) {
if (isSavedFromMegagroup() && this.messageOwner.fwd_from.from_id != 0) {
return this.messageOwner.fwd_from.from_id;
}
if (this.messageOwner.fwd_from.channel_id != 0) {
return -this.messageOwner.fwd_from.channel_id;
}
return -this.messageOwner.fwd_from.saved_from_peer.channel_id;
}
if (this.messageOwner.fwd_from.saved_from_peer.chat_id == 0) {
return 0;
}
if (this.messageOwner.fwd_from.from_id != 0) {
return this.messageOwner.fwd_from.from_id;
}
if (this.messageOwner.fwd_from.channel_id != 0) {
return -this.messageOwner.fwd_from.channel_id;
}
return -this.messageOwner.fwd_from.saved_from_peer.chat_id;
}
if (this.messageOwner.from_id != 0) {
return this.messageOwner.from_id;
}
if (this.messageOwner.post) {
return this.messageOwner.to_id.channel_id;
}
return 0;
}
public boolean isWallpaper() {
return (this.messageOwner.media instanceof TLRPC.TL_messageMediaWebPage) && this.messageOwner.media.webpage != null && "app_background".equals(this.messageOwner.media.webpage.type);
}
public int getMediaExistanceFlags() {
int i = this.attachPathExists ? 1 : 0;
return this.mediaExists ? i | 2 : i;
}
public void applyMediaExistanceFlags(int i) {
if (i == -1) {
checkMediaExistance();
} else {
this.attachPathExists = (i & 1) != 0;
this.mediaExists = (i & 2) != 0;
}
}
public void checkMediaExistance() {
TLRPC.PhotoSize closestPhotoSizeWithSize;
this.attachPathExists = false;
this.mediaExists = false;
int i = this.type;
if (i == 1) {
if (FileLoader.getClosestPhotoSizeWithSize(this.photoThumbs, AndroidUtilities.getPhotoSize()) != null) {
File pathToMessage = FileLoader.getPathToMessage(this.messageOwner);
if (needDrawBluredPreview()) {
this.mediaExists = new File(pathToMessage.getAbsolutePath() + ".enc").exists();
}
if (this.mediaExists) {
return;
}
this.mediaExists = pathToMessage.exists();
return;
}
return;
}
if (i == 8 || i == 3 || i == 9 || i == 2 || i == 14 || i == 5) {
if (this.messageOwner.attachPath != null && this.messageOwner.attachPath.length() > 0) {
this.attachPathExists = new File(this.messageOwner.attachPath).exists();
}
if (this.attachPathExists) {
return;
}
File pathToMessage2 = FileLoader.getPathToMessage(this.messageOwner);
if (this.type == 3 && needDrawBluredPreview()) {
this.mediaExists = new File(pathToMessage2.getAbsolutePath() + ".enc").exists();
}
if (this.mediaExists) {
return;
}
this.mediaExists = pathToMessage2.exists();
return;
}
TLRPC.Document document = getDocument();
if (document != null) {
if (isWallpaper()) {
this.mediaExists = FileLoader.getPathToAttach(document, true).exists();
return;
} else {
this.mediaExists = FileLoader.getPathToAttach(document).exists();
return;
}
}
if (this.type != 0 || (closestPhotoSizeWithSize = FileLoader.getClosestPhotoSizeWithSize(this.photoThumbs, AndroidUtilities.getPhotoSize())) == null || closestPhotoSizeWithSize == null) {
return;
}
this.mediaExists = FileLoader.getPathToAttach(closestPhotoSizeWithSize, true).exists();
}
public boolean equals(MessageObject messageObject) {
return getId() == messageObject.getId() && getDialogId() == messageObject.getDialogId();
}
}