海恒集团 v1.0.0版本的 MD5 值为:f821a526990aefe38331f69a75f49814
以下内容为反编译后的 MessageObject.java 源代码,内容仅作参考
package im.kyamoybdkf.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.kyamoybdkf.javaBean.PayBillOverBean;
import im.kyamoybdkf.messenger.Emoji;
import im.kyamoybdkf.messenger.browser.Browser;
import im.kyamoybdkf.phoneformat.PhoneFormat;
import im.kyamoybdkf.tgnet.ConnectionsManager;
import im.kyamoybdkf.tgnet.SerializedData;
import im.kyamoybdkf.tgnet.TLApiModel;
import im.kyamoybdkf.tgnet.TLJsonResolve;
import im.kyamoybdkf.tgnet.TLObject;
import im.kyamoybdkf.tgnet.TLRPC;
import im.kyamoybdkf.tgnet.TLRPCContacts;
import im.kyamoybdkf.tgnet.TLRPCRedpacket;
import im.kyamoybdkf.ui.actionbar.BaseFragment;
import im.kyamoybdkf.ui.actionbar.Theme;
import im.kyamoybdkf.ui.components.TextStyleSpan;
import im.kyamoybdkf.ui.components.TypefaceSpan;
import im.kyamoybdkf.ui.components.URLSpanBotCommand;
import im.kyamoybdkf.ui.components.URLSpanBrowser;
import im.kyamoybdkf.ui.components.URLSpanMono;
import im.kyamoybdkf.ui.components.URLSpanNoUnderline;
import im.kyamoybdkf.ui.components.URLSpanNoUnderlineBold;
import im.kyamoybdkf.ui.components.URLSpanReplacement;
import im.kyamoybdkf.ui.components.URLSpanUserMention;
import im.kyamoybdkf.ui.hui.packet.bean.RedpacketBean;
import im.kyamoybdkf.ui.hui.packet.bean.RedpacketResponse;
import im.kyamoybdkf.ui.hui.sysnotify.SysNotifyAtTextClickableSpan;
import im.kyamoybdkf.ui.hui.transfer.bean.TransferResponse;
import im.kyamoybdkf.ui.utils.number.MoneyUtil;
import im.kyamoybdkf.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.Calendar;
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 static class VCardData {
private String company;
private ArrayList<String> emails = new ArrayList<>();
private ArrayList<String> phones = new ArrayList<>();
public static CharSequence parse(String data) {
String[] args;
boolean finished;
byte[] bytes;
try {
BufferedReader bufferedReader = new BufferedReader(new StringReader(data));
String pendingLine = null;
boolean finished2 = false;
VCardData currentData = null;
while (true) {
String originalLine = bufferedReader.readLine();
String line = originalLine;
if (originalLine != null) {
if (!originalLine.startsWith("PHOTO")) {
if (originalLine.indexOf(58) >= 0) {
if (originalLine.startsWith("BEGIN:VCARD")) {
currentData = new VCardData();
} else if (originalLine.startsWith("END:VCARD") && currentData != null) {
finished2 = true;
}
}
if (pendingLine != null) {
line = pendingLine + line;
pendingLine = null;
}
int i = 0;
if (line.contains("=QUOTED-PRINTABLE") && line.endsWith("=")) {
pendingLine = line.substring(0, line.length() - 1);
} else {
int idx = line.indexOf(LogUtils.COLON);
if (idx >= 0) {
args = new String[]{line.substring(0, idx), line.substring(idx + 1).trim()};
} else {
args = new String[]{line.trim()};
}
if (args.length < 2) {
finished = finished2;
} else if (currentData == null) {
finished = finished2;
} else if (args[0].startsWith("ORG")) {
String nameEncoding = null;
String nameCharset = null;
String[] params = args[0].split(";");
int length = params.length;
while (i < length) {
String param = params[i];
String[] args2 = param.split("=");
int idx2 = idx;
boolean finished3 = finished2;
if (args2.length == 2) {
if (args2[0].equals("CHARSET")) {
nameCharset = args2[1];
} else if (args2[0].equals("ENCODING")) {
nameEncoding = args2[1];
}
}
i++;
idx = idx2;
finished2 = finished3;
}
finished = finished2;
currentData.company = args[1];
if (nameEncoding != null && nameEncoding.equalsIgnoreCase("QUOTED-PRINTABLE") && (bytes = AndroidUtilities.decodeQuotedPrintable(AndroidUtilities.getStringBytes(currentData.company))) != null && bytes.length != 0) {
String decodedName = new String(bytes, nameCharset);
currentData.company = decodedName;
}
currentData.company = currentData.company.replace(';', ' ');
} else {
finished = finished2;
if (args[0].startsWith("TEL")) {
if (args[1].length() > 0) {
currentData.phones.add(args[1]);
}
} else if (args[0].startsWith("EMAIL")) {
String email = args[1];
if (email.length() > 0) {
currentData.emails.add(email);
}
}
}
finished2 = finished;
}
}
} else {
try {
break;
} catch (Exception e) {
FileLog.e(e);
}
}
}
bufferedReader.close();
if (finished2) {
StringBuilder result = new StringBuilder();
for (int a = 0; a < currentData.phones.size(); a++) {
if (result.length() > 0) {
result.append('\n');
}
String phone = currentData.phones.get(a);
if (!phone.contains("#") && !phone.contains("*")) {
result.append(PhoneFormat.getInstance().format(phone));
}
result.append(phone);
}
for (int a2 = 0; a2 < currentData.emails.size(); a2++) {
if (result.length() > 0) {
result.append('\n');
}
result.append(PhoneFormat.getInstance().format(currentData.emails.get(a2)));
}
if (!TextUtils.isEmpty(currentData.company)) {
if (result.length() > 0) {
result.append('\n');
}
result.append(currentData.company);
}
return result;
}
return null;
} catch (Throwable th) {
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 minX, int maxX, int minY, int maxY, int w, float h, int flags) {
this.minX = (byte) minX;
this.maxX = (byte) maxX;
this.minY = (byte) minY;
this.maxY = (byte) maxY;
this.pw = w;
this.spanSize = w;
this.ph = h;
this.flags = (byte) flags;
}
}
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 i1, int i2, float f1, float f2) {
this.lineCounts = new int[]{i1, i2};
this.heights = new float[]{f1, f2};
}
public MessageGroupedLayoutAttempt(int i1, int i2, int i3, float f1, float f2, float f3) {
this.lineCounts = new int[]{i1, i2, i3};
this.heights = new float[]{f1, f2, f3};
}
public MessageGroupedLayoutAttempt(int i1, int i2, int i3, int i4, float f1, float f2, float f3, float f4) {
this.lineCounts = new int[]{i1, i2, i3, i4};
this.heights = new float[]{f1, f2, f3, f4};
}
}
private float multiHeight(float[] array, int start, int end) {
float sum = 0.0f;
for (int a = start; a < end; a++) {
sum += array[a];
}
int a2 = this.maxSizeWidth;
return a2 / sum;
}
public void calculate() {
float minH;
float averageAspectRatio;
int maxX;
int count;
int paddingsWidth;
int a;
int count2;
int thirdLine;
float[] croppedRatios;
float maxSizeHeight;
int minHeight;
int minHeight2;
int paddingsWidth2;
int minHeight3;
int thirdLine2;
int count3;
float averageAspectRatio2;
float minH2;
int w1;
int maxX2;
float minH3;
float averageAspectRatio3;
this.posArray.clear();
this.positions.clear();
int count4 = this.messages.size();
if (count4 <= 1) {
return;
}
float maxSizeHeight2 = 814.0f;
StringBuilder proportions = new StringBuilder();
float averageAspectRatio4 = 1.0f;
int maxX3 = 0;
this.hasSibling = false;
int a2 = 0;
boolean isOut = false;
boolean forceCalc = false;
boolean needShare = false;
while (a2 < count4) {
MessageObject messageObject = this.messages.get(a2);
if (a2 == 0) {
boolean isOut2 = messageObject.isOutOwner();
isOut = isOut2;
needShare = !isOut2 && (!(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 photoSize = FileLoader.getClosestPhotoSizeWithSize(messageObject.photoThumbs, AndroidUtilities.getPhotoSize());
GroupedMessagePosition position = new GroupedMessagePosition();
position.last = a2 == count4 + (-1);
position.aspectRatio = photoSize == null ? 1.0f : photoSize.w / photoSize.h;
if (position.aspectRatio > 1.2f) {
proportions.append("w");
} else if (position.aspectRatio < 0.8f) {
proportions.append("n");
} else {
proportions.append("q");
}
averageAspectRatio4 += position.aspectRatio;
if (position.aspectRatio > 2.0f) {
forceCalc = true;
}
this.positions.put(messageObject, position);
this.posArray.add(position);
a2++;
}
if (needShare) {
this.maxSizeWidth -= 50;
this.firstSpanAdditionalSize += 50;
}
int minHeight4 = AndroidUtilities.dp(120.0f);
int minWidth = (int) (AndroidUtilities.dp(120.0f) / (Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y) / this.maxSizeWidth));
float dp = AndroidUtilities.dp(40.0f);
float min = Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y);
int i = this.maxSizeWidth;
int paddingsWidth3 = (int) (dp / (min / i));
float maxAspectRatio = i / 814.0f;
float averageAspectRatio5 = averageAspectRatio4 / count4;
float minH4 = AndroidUtilities.dp(100.0f) / 814.0f;
if (!forceCalc) {
if (count4 != 2 && count4 != 3 && count4 != 4) {
minH = minH4;
averageAspectRatio = averageAspectRatio5;
maxX = 0;
} else {
if (count4 == 2) {
GroupedMessagePosition position1 = this.posArray.get(0);
GroupedMessagePosition position2 = this.posArray.get(1);
String pString = proportions.toString();
if (pString.equals("ww")) {
minH3 = minH4;
averageAspectRatio3 = averageAspectRatio5;
if (averageAspectRatio5 > maxAspectRatio * 1.4d) {
position2 = position2;
if (position1.aspectRatio - position2.aspectRatio < 0.2d) {
float height = Math.round(Math.min(this.maxSizeWidth / position1.aspectRatio, Math.min(this.maxSizeWidth / position2.aspectRatio, 814.0f / 2.0f))) / 814.0f;
position1.set(0, 0, 0, 0, this.maxSizeWidth, height, 7);
position2.set(0, 0, 1, 1, this.maxSizeWidth, height, 11);
count = count4;
paddingsWidth = maxX3;
}
} else {
position2 = position2;
}
} else {
minH3 = minH4;
averageAspectRatio3 = averageAspectRatio5;
}
if (!pString.equals("ww") && !pString.equals("qq")) {
int i2 = this.maxSizeWidth;
float f = i2 * 0.4f;
float f2 = i2 / position1.aspectRatio;
float f3 = 1.0f / position1.aspectRatio;
float maxAspectRatio2 = position2.aspectRatio;
int secondWidth = (int) Math.max(f, Math.round(f2 / (f3 + (1.0f / maxAspectRatio2))));
int firstWidth = this.maxSizeWidth - secondWidth;
if (firstWidth < minWidth) {
int diff = minWidth - firstWidth;
firstWidth = minWidth;
secondWidth -= diff;
}
float height2 = Math.min(814.0f, Math.round(Math.min(firstWidth / position1.aspectRatio, secondWidth / position2.aspectRatio))) / 814.0f;
position1.set(0, 0, 0, 0, firstWidth, height2, 13);
position2.set(1, 1, 0, 0, secondWidth, height2, 14);
maxX3 = 1;
count = count4;
paddingsWidth = maxX3;
}
int width = this.maxSizeWidth / 2;
float height3 = Math.round(Math.min(width / position1.aspectRatio, Math.min(width / position2.aspectRatio, 814.0f))) / 814.0f;
position1.set(0, 0, 0, 0, width, height3, 13);
position2.set(1, 1, 0, 0, width, height3, 14);
maxX3 = 1;
count = count4;
paddingsWidth = maxX3;
} else if (count4 == 3) {
GroupedMessagePosition position12 = this.posArray.get(0);
GroupedMessagePosition position22 = this.posArray.get(1);
GroupedMessagePosition position3 = this.posArray.get(2);
if (proportions.charAt(0) != 'n') {
float firstHeight = Math.round(Math.min(this.maxSizeWidth / position12.aspectRatio, 0.66f * 814.0f)) / 814.0f;
position12.set(0, 1, 0, 0, this.maxSizeWidth, firstHeight, 7);
int width2 = this.maxSizeWidth / 2;
float secondHeight = Math.min(814.0f - firstHeight, Math.round(Math.min(width2 / position22.aspectRatio, width2 / position3.aspectRatio))) / 814.0f;
if (secondHeight < minH4) {
secondHeight = minH4;
}
float f4 = secondHeight;
position22.set(0, 0, 1, 1, width2, f4, 9);
position3.set(1, 1, 1, 1, width2, f4, 10);
maxX2 = 1;
} else {
float thirdHeight = Math.min(814.0f * 0.5f, Math.round((position22.aspectRatio * this.maxSizeWidth) / (position3.aspectRatio + position22.aspectRatio)));
float secondHeight2 = 814.0f - thirdHeight;
int rightWidth = (int) Math.max(minWidth, Math.min(this.maxSizeWidth * 0.5f, Math.round(Math.min(position3.aspectRatio * thirdHeight, position22.aspectRatio * secondHeight2))));
int leftWidth = Math.round(Math.min((position12.aspectRatio * 814.0f) + paddingsWidth3, this.maxSizeWidth - rightWidth));
position12.set(0, 0, 0, 1, leftWidth, 1.0f, 13);
position22.set(1, 1, 0, 0, rightWidth, secondHeight2 / 814.0f, 6);
position3.set(0, 1, 1, 1, rightWidth, thirdHeight / 814.0f, 10);
position3.spanSize = this.maxSizeWidth;
position12.siblingHeights = new float[]{thirdHeight / 814.0f, secondHeight2 / 814.0f};
if (isOut) {
position12.spanSize = this.maxSizeWidth - rightWidth;
} else {
position22.spanSize = this.maxSizeWidth - leftWidth;
position3.leftSpanOffset = leftWidth;
}
this.hasSibling = true;
maxX2 = 1;
}
count = count4;
paddingsWidth = maxX2;
} else if (count4 != 4) {
count = count4;
paddingsWidth = 0;
} else {
GroupedMessagePosition position13 = this.posArray.get(0);
GroupedMessagePosition position23 = this.posArray.get(1);
GroupedMessagePosition position32 = this.posArray.get(2);
GroupedMessagePosition position4 = this.posArray.get(3);
if (proportions.charAt(0) == 'w') {
float h0 = Math.round(Math.min(this.maxSizeWidth / position13.aspectRatio, 0.66f * 814.0f)) / 814.0f;
position13.set(0, 2, 0, 0, this.maxSizeWidth, h0, 7);
float h = Math.round(this.maxSizeWidth / ((position23.aspectRatio + position32.aspectRatio) + position4.aspectRatio));
int w0 = (int) Math.max(minWidth, Math.min(this.maxSizeWidth * 0.4f, position23.aspectRatio * h));
int w2 = (int) Math.max(Math.max(minWidth, this.maxSizeWidth * 0.33f), position4.aspectRatio * h);
int w12 = (this.maxSizeWidth - w0) - w2;
if (w12 < AndroidUtilities.dp(58.0f)) {
int diff2 = AndroidUtilities.dp(58.0f) - w12;
w12 = AndroidUtilities.dp(58.0f);
w0 -= diff2 / 2;
w2 -= diff2 - (diff2 / 2);
}
float h2 = Math.min(814.0f - h0, h) / 814.0f;
if (h2 < minH4) {
h2 = minH4;
}
float f5 = h2;
position23.set(0, 0, 1, 1, w0, f5, 9);
position32.set(1, 1, 1, 1, w12, f5, 8);
position4.set(2, 2, 1, 1, w2, f5, 10);
w1 = 2;
} else {
int w = Math.max(minWidth, Math.round(814.0f / (((1.0f / position23.aspectRatio) + (1.0f / position32.aspectRatio)) + (1.0f / position4.aspectRatio))));
float h02 = Math.min(0.33f, Math.max(minHeight4, w / position23.aspectRatio) / 814.0f);
float h1 = Math.min(0.33f, Math.max(minHeight4, w / position32.aspectRatio) / 814.0f);
float h22 = (1.0f - h02) - h1;
int w02 = Math.round(Math.min((position13.aspectRatio * 814.0f) + paddingsWidth3, this.maxSizeWidth - w));
position13.set(0, 0, 0, 2, w02, h02 + h1 + h22, 13);
position23.set(1, 1, 0, 0, w, h02, 6);
position32.set(0, 1, 1, 1, w, h1, 2);
position32.spanSize = this.maxSizeWidth;
position4.set(0, 1, 2, 2, w, h22, 10);
position4.spanSize = this.maxSizeWidth;
if (isOut) {
position13.spanSize = this.maxSizeWidth - w;
} else {
position23.spanSize = this.maxSizeWidth - w02;
position32.leftSpanOffset = w02;
position4.leftSpanOffset = w02;
}
position13.siblingHeights = new float[]{h02, h1, h22};
this.hasSibling = true;
w1 = 1;
}
count = count4;
paddingsWidth = w1;
}
a = 0;
while (true) {
count2 = count;
if (a >= count2) {
GroupedMessagePosition pos = this.posArray.get(a);
if (isOut) {
if (pos.minX == 0) {
pos.spanSize += this.firstSpanAdditionalSize;
}
if ((pos.flags & 2) != 0) {
pos.edge = true;
}
} else {
if (pos.maxX == paddingsWidth || (pos.flags & 2) != 0) {
pos.spanSize += this.firstSpanAdditionalSize;
}
if ((pos.flags & 1) != 0) {
pos.edge = true;
}
}
MessageObject messageObject2 = this.messages.get(a);
if (!isOut && messageObject2.needDrawAvatarInternal()) {
if (pos.edge) {
if (pos.spanSize != 1000) {
pos.spanSize += 108;
}
pos.pw += 108;
} else if ((pos.flags & 2) != 0) {
if (pos.spanSize != 1000) {
pos.spanSize -= 108;
} else if (pos.leftSpanOffset != 0) {
pos.leftSpanOffset += 108;
}
}
}
if (!isOut && messageObject2.needDrawAvatar()) {
if (pos.edge) {
if (pos.spanSize != 1000) {
pos.spanSize += 108;
}
pos.pw += 108;
} else if ((pos.flags & 2) != 0) {
if (pos.spanSize != 1000) {
pos.spanSize -= 108;
} else if (pos.leftSpanOffset != 0) {
pos.leftSpanOffset += 108;
}
}
} else if (isOut && messageObject2.needDrawAvatar()) {
if (pos.edge) {
if (pos.spanSize != 1000) {
pos.spanSize += 108;
}
pos.pw += 108;
} else if ((pos.flags & 1) != 0) {
if (pos.spanSize != 1000) {
pos.spanSize -= 108;
} else if (pos.leftSpanOffset != 0) {
pos.leftSpanOffset += 108;
}
}
}
a++;
count = count2;
} else {
return;
}
}
}
} else {
minH = minH4;
averageAspectRatio = averageAspectRatio5;
maxX = 0;
}
float[] croppedRatios2 = new float[this.posArray.size()];
for (int a3 = 0; a3 < count4; a3++) {
if (averageAspectRatio > 1.1f) {
croppedRatios2[a3] = Math.max(1.0f, this.posArray.get(a3).aspectRatio);
} else {
croppedRatios2[a3] = Math.min(1.0f, this.posArray.get(a3).aspectRatio);
}
croppedRatios2[a3] = Math.max(0.66667f, Math.min(1.7f, croppedRatios2[a3]));
}
ArrayList<MessageGroupedLayoutAttempt> attempts = new ArrayList<>();
int firstLine = 1;
while (firstLine < croppedRatios2.length) {
int secondLine = croppedRatios2.length - firstLine;
if (firstLine <= 3) {
if (secondLine > 3) {
count3 = count4;
averageAspectRatio2 = averageAspectRatio;
minH2 = minH;
} else {
count3 = count4;
minH2 = minH;
averageAspectRatio2 = averageAspectRatio;
attempts.add(new MessageGroupedLayoutAttempt(firstLine, secondLine, multiHeight(croppedRatios2, 0, firstLine), multiHeight(croppedRatios2, firstLine, croppedRatios2.length)));
}
} else {
count3 = count4;
averageAspectRatio2 = averageAspectRatio;
minH2 = minH;
}
firstLine++;
count4 = count3;
averageAspectRatio = averageAspectRatio2;
minH = minH2;
}
count = count4;
float averageAspectRatio6 = averageAspectRatio;
float minH5 = minH;
for (int firstLine2 = 1; firstLine2 < croppedRatios2.length - 1; firstLine2++) {
int secondLine2 = 1;
while (secondLine2 < croppedRatios2.length - firstLine2) {
int thirdLine3 = (croppedRatios2.length - firstLine2) - secondLine2;
if (firstLine2 <= 3) {
if (secondLine2 <= (averageAspectRatio6 < 0.85f ? 4 : 3)) {
if (thirdLine3 > 3) {
paddingsWidth2 = paddingsWidth3;
minHeight3 = minHeight4;
thirdLine2 = minWidth;
} else {
minHeight3 = minHeight4;
paddingsWidth2 = paddingsWidth3;
thirdLine2 = minWidth;
attempts.add(new MessageGroupedLayoutAttempt(firstLine2, secondLine2, thirdLine3, multiHeight(croppedRatios2, 0, firstLine2), multiHeight(croppedRatios2, firstLine2, firstLine2 + secondLine2), multiHeight(croppedRatios2, firstLine2 + secondLine2, croppedRatios2.length)));
}
secondLine2++;
minWidth = thirdLine2;
paddingsWidth3 = paddingsWidth2;
minHeight4 = minHeight3;
}
}
paddingsWidth2 = paddingsWidth3;
minHeight3 = minHeight4;
thirdLine2 = minWidth;
secondLine2++;
minWidth = thirdLine2;
paddingsWidth3 = paddingsWidth2;
minHeight4 = minHeight3;
}
}
int minWidth2 = minWidth;
int secondLine3 = minHeight4;
int firstLine3 = 1;
while (firstLine3 < croppedRatios2.length - 2) {
int secondLine4 = 1;
while (secondLine4 < croppedRatios2.length - firstLine3) {
int thirdLine4 = 1;
while (thirdLine4 < (croppedRatios2.length - firstLine3) - secondLine4) {
int fourthLine = ((croppedRatios2.length - firstLine3) - secondLine4) - thirdLine4;
if (firstLine3 > 3 || secondLine4 > 3 || thirdLine4 > 3) {
thirdLine = thirdLine4;
croppedRatios = croppedRatios2;
maxSizeHeight = maxSizeHeight2;
minHeight = secondLine3;
minHeight2 = secondLine4;
} else if (fourthLine > 3) {
thirdLine = thirdLine4;
croppedRatios = croppedRatios2;
maxSizeHeight = maxSizeHeight2;
minHeight = secondLine3;
minHeight2 = secondLine4;
} else {
maxSizeHeight = maxSizeHeight2;
thirdLine = thirdLine4;
minHeight = secondLine3;
minHeight2 = secondLine4;
croppedRatios = croppedRatios2;
attempts.add(new MessageGroupedLayoutAttempt(firstLine3, secondLine4, thirdLine4, fourthLine, multiHeight(croppedRatios2, 0, firstLine3), multiHeight(croppedRatios2, firstLine3, firstLine3 + secondLine4), multiHeight(croppedRatios2, firstLine3 + secondLine4, firstLine3 + secondLine4 + thirdLine4), multiHeight(croppedRatios2, firstLine3 + secondLine4 + thirdLine4, croppedRatios2.length)));
}
thirdLine4 = thirdLine + 1;
secondLine4 = minHeight2;
croppedRatios2 = croppedRatios;
maxSizeHeight2 = maxSizeHeight;
secondLine3 = minHeight;
}
secondLine4++;
secondLine3 = secondLine3;
croppedRatios2 = croppedRatios2;
}
firstLine3++;
secondLine3 = secondLine3;
croppedRatios2 = croppedRatios2;
}
float[] croppedRatios3 = croppedRatios2;
float maxSizeHeight3 = maxSizeHeight2;
MessageGroupedLayoutAttempt optimal = null;
float optimalDiff = 0.0f;
float maxHeight = (this.maxSizeWidth / 3) * 4;
for (int a4 = 0; a4 < attempts.size(); a4++) {
MessageGroupedLayoutAttempt attempt = attempts.get(a4);
float height4 = 0.0f;
float minLineHeight = Float.MAX_VALUE;
for (int b = 0; b < attempt.heights.length; b++) {
height4 += attempt.heights[b];
if (attempt.heights[b] < minLineHeight) {
minLineHeight = attempt.heights[b];
}
}
float diff3 = Math.abs(height4 - maxHeight);
if (attempt.lineCounts.length > 1) {
if (attempt.lineCounts[0] <= attempt.lineCounts[1]) {
if (attempt.lineCounts.length > 2) {
if (attempt.lineCounts[1] > attempt.lineCounts[2]) {
}
}
if (attempt.lineCounts.length > 3) {
}
}
diff3 *= 1.2f;
}
if (minLineHeight < minWidth2) {
diff3 *= 1.5f;
}
if (optimal == null || diff3 < optimalDiff) {
optimal = attempt;
optimalDiff = diff3;
}
}
if (optimal == null) {
return;
}
int index = 0;
float y = 0.0f;
int i3 = 0;
paddingsWidth = maxX;
while (i3 < optimal.lineCounts.length) {
int c = optimal.lineCounts[i3];
float lineHeight = optimal.heights[i3];
int spanLeft = this.maxSizeWidth;
GroupedMessagePosition posToFix = null;
paddingsWidth = Math.max(paddingsWidth, c - 1);
int k = 0;
while (k < c) {
float ratio = croppedRatios3[index];
float optimalDiff2 = optimalDiff;
float optimalDiff3 = ratio * lineHeight;
int width3 = (int) optimalDiff3;
spanLeft -= width3;
float maxHeight2 = maxHeight;
GroupedMessagePosition pos2 = this.posArray.get(index);
int flags = 0;
if (i3 == 0) {
flags = 0 | 4;
}
int maxX4 = paddingsWidth;
if (i3 == optimal.lineCounts.length - 1) {
flags |= 8;
}
if (k == 0) {
flags |= 1;
if (isOut) {
posToFix = pos2;
}
}
if (k == c - 1) {
flags |= 2;
if (!isOut) {
posToFix = pos2;
}
}
pos2.set(k, k, i3, i3, width3, Math.max(minH5, lineHeight / maxSizeHeight3), flags);
index++;
k++;
optimalDiff = optimalDiff2;
maxHeight = maxHeight2;
paddingsWidth = maxX4;
optimal = optimal;
}
posToFix.pw += spanLeft;
posToFix.spanSize += spanLeft;
y += lineHeight;
i3++;
optimalDiff = optimalDiff;
optimal = optimal;
}
a = 0;
while (true) {
count2 = count;
if (a >= count2) {
}
a++;
count = count2;
}
}
}
public MessageObject(int accountNum, TLRPC.Message message, String formattedMessage, String name, String userName, boolean localMessage, boolean isChannel, boolean edit) {
this.type = 1000;
this.forceSeekTo = -1.0f;
this.entitiesCopy = new ArrayList<>();
this.localType = localMessage ? 2 : 1;
this.currentAccount = accountNum;
this.localName = name;
this.localUserName = userName;
this.messageText = formattedMessage;
this.messageOwner = message;
this.localChannel = isChannel;
this.localEdit = edit;
}
public MessageObject(int accountNum, TLRPC.Message message, AbstractMap<Integer, TLRPC.User> users, boolean generateLayout) {
this(accountNum, message, users, (AbstractMap<Integer, TLRPC.Chat>) null, generateLayout);
}
public MessageObject(int accountNum, TLRPC.Message message, SparseArray<TLRPC.User> users, boolean generateLayout) {
this(accountNum, message, users, (SparseArray<TLRPC.Chat>) null, generateLayout);
}
public MessageObject(int accountNum, TLRPC.Message message, boolean generateLayout) {
this(accountNum, message, null, null, null, null, null, generateLayout, 0L);
}
public MessageObject(int accountNum, TLRPC.Message message, MessageObject replyToMessage, boolean generateLayout) {
this(accountNum, message, replyToMessage, null, null, null, null, generateLayout, 0L);
}
public MessageObject(int accountNum, TLRPC.Message message, AbstractMap<Integer, TLRPC.User> users, AbstractMap<Integer, TLRPC.Chat> chats, boolean generateLayout) {
this(accountNum, message, users, chats, generateLayout, 0L);
}
public MessageObject(int accountNum, TLRPC.Message message, SparseArray<TLRPC.User> users, SparseArray<TLRPC.Chat> chats, boolean generateLayout) {
this(accountNum, message, null, null, null, users, chats, generateLayout, 0L);
}
public MessageObject(int accountNum, TLRPC.Message message, AbstractMap<Integer, TLRPC.User> users, AbstractMap<Integer, TLRPC.Chat> chats, boolean generateLayout, long eid) {
this(accountNum, message, null, users, chats, null, null, generateLayout, eid);
}
public MessageObject(int accountNum, TLRPC.Message message, MessageObject replyToMessage, AbstractMap<Integer, TLRPC.User> users, AbstractMap<Integer, TLRPC.Chat> chats, SparseArray<TLRPC.User> sUsers, SparseArray<TLRPC.Chat> sChats, boolean generateLayout, long eid) {
TLRPC.User fromUser;
int[] iArr;
boolean z;
int i;
TextPaint paint;
this.type = 1000;
this.forceSeekTo = -1.0f;
this.entitiesCopy = new ArrayList<>();
Theme.createChatResources(null, true);
this.currentAccount = accountNum;
this.messageOwner = message;
this.replyMessageObject = replyToMessage;
this.eventId = eid;
if (message.replyMessage != null) {
this.replyMessageObject = new MessageObject(this.currentAccount, message.replyMessage, null, users, chats, sUsers, sChats, false, eid);
}
TLRPC.User fromUser2 = null;
if (message.from_id <= 0) {
fromUser = null;
} else {
if (users != null) {
TLRPC.User fromUser3 = users.get(Integer.valueOf(message.from_id));
fromUser2 = fromUser3;
} else if (sUsers != null) {
TLRPC.User fromUser4 = sUsers.get(message.from_id);
fromUser2 = fromUser4;
}
if (fromUser2 != null) {
fromUser = fromUser2;
} else {
TLRPC.User fromUser5 = MessagesController.getInstance(this.currentAccount).getUser(Integer.valueOf(message.from_id));
fromUser = fromUser5;
}
}
updateMessageText(users, chats, sUsers, sChats);
if (isMediaEmpty()) {
i = 1;
iArr = null;
z = generateLayout;
this.messageText = updateMetionText(this.messageText, this.messageOwner.entities, users, chats, sUsers, sChats);
} else {
iArr = null;
z = generateLayout;
i = 1;
}
setType();
measureInlineBotButtons();
Calendar rightNow = new GregorianCalendar();
rightNow.setTimeInMillis(this.messageOwner.date * 1000);
int dateDay = rightNow.get(6);
int dateYear = rightNow.get(i);
int dateMonth = rightNow.get(2);
Object[] objArr = new Object[3];
objArr[0] = Integer.valueOf(dateYear);
objArr[i] = Integer.valueOf(dateMonth);
objArr[2] = Integer.valueOf(dateDay);
this.dateKey = String.format("%d_%02d_%02d", objArr);
Object[] objArr2 = new Object[2];
objArr2[0] = Integer.valueOf(dateYear);
objArr2[i] = Integer.valueOf(dateMonth);
this.monthKey = String.format("%d_%02d", objArr2);
createMessageSendInfo();
generateCaption();
if (z) {
if (this.messageOwner.media instanceof TLRPC.TL_messageMediaGame) {
paint = Theme.chat_msgGameTextPaint;
} else {
paint = Theme.chat_msgTextPaint;
}
int[] emojiOnly = SharedConfig.allowBigEmoji ? new int[i] : iArr;
this.messageText = Emoji.replaceEmoji(this.messageText, paint.getFontMetricsInt(), AndroidUtilities.dp(20.0f), false, emojiOnly);
checkEmojiOnly(emojiOnly);
this.emojiAnimatedSticker = null;
if (this.emojiOnlyCount == 1 && !(message.media instanceof TLRPC.TL_messageMediaWebPage) && message.entities.isEmpty()) {
CharSequence emoji = this.messageText;
int index = TextUtils.indexOf(emoji, "🏻");
if (index >= 0) {
this.emojiAnimatedStickerColor = "_c1";
emoji = emoji.subSequence(0, index);
} else {
int index2 = TextUtils.indexOf(emoji, "🏼");
if (index2 >= 0) {
this.emojiAnimatedStickerColor = "_c2";
emoji = emoji.subSequence(0, index2);
} else {
int index3 = TextUtils.indexOf(emoji, "🏽");
if (index3 >= 0) {
this.emojiAnimatedStickerColor = "_c3";
emoji = emoji.subSequence(0, index3);
} else {
int index4 = TextUtils.indexOf(emoji, "🏾");
if (index4 >= 0) {
this.emojiAnimatedStickerColor = "_c4";
emoji = emoji.subSequence(0, index4);
} else {
int index5 = TextUtils.indexOf(emoji, "🏿");
if (index5 >= 0) {
this.emojiAnimatedStickerColor = "_c5";
emoji = emoji.subSequence(0, index5);
} else {
this.emojiAnimatedStickerColor = "";
}
}
}
}
}
this.emojiAnimatedSticker = MediaDataController.getInstance(this.currentAccount).getEmojiAnimatedSticker(emoji);
}
if (this.emojiAnimatedSticker != null) {
this.type = 1000;
if (isSticker()) {
this.type = 13;
} else if (isAnimatedSticker()) {
this.type = 15;
}
} else {
generateLayout(fromUser);
}
}
this.layoutCreated = z;
generateThumbs(false);
checkMediaExistance();
}
public void renderText() {
entityCopy(this.messageOwner.entities);
addEntitiesToText(this.messageText, false);
}
private void entityCopy(ArrayList<TLRPC.MessageEntity> entities) {
if (entities == null || entities.size() == 0) {
return;
}
this.entitiesCopy.clear();
Iterator<TLRPC.MessageEntity> it = entities.iterator();
while (it.hasNext()) {
TLRPC.MessageEntity entity = it.next();
if (entity instanceof TLRPC.TL_messageEntityTextUrl) {
TLRPC.TL_messageEntityTextUrl item = new TLRPC.TL_messageEntityTextUrl();
item.offset = entity.offset;
item.length = entity.length;
item.url = entity.url;
this.entitiesCopy.add(item);
} else if (entity instanceof TLRPC.TL_messageEntityBotCommand) {
TLRPC.TL_messageEntityBotCommand item2 = new TLRPC.TL_messageEntityBotCommand();
item2.offset = entity.offset;
item2.length = entity.length;
this.entitiesCopy.add(item2);
} else if (entity instanceof TLRPC.TL_messageEntityEmail) {
TLRPC.TL_messageEntityEmail item3 = new TLRPC.TL_messageEntityEmail();
item3.offset = entity.offset;
item3.length = entity.length;
this.entitiesCopy.add(item3);
} else if (entity instanceof TLRPC.TL_messageEntityPre) {
TLRPC.TL_messageEntityPre item4 = new TLRPC.TL_messageEntityPre();
item4.offset = entity.offset;
item4.length = entity.length;
item4.language = entity.language;
this.entitiesCopy.add(item4);
} else if (entity instanceof TLRPC.TL_messageEntityUnknown) {
TLRPC.TL_messageEntityUnknown item5 = new TLRPC.TL_messageEntityUnknown();
item5.offset = entity.offset;
item5.length = entity.length;
this.entitiesCopy.add(item5);
} else if (entity instanceof TLRPC.TL_messageEntityUrl) {
TLRPC.TL_messageEntityUrl item6 = new TLRPC.TL_messageEntityUrl();
item6.offset = entity.offset;
item6.length = entity.length;
this.entitiesCopy.add(item6);
} else if (entity instanceof TLRPC.TL_messageEntityItalic) {
TLRPC.TL_messageEntityItalic item7 = new TLRPC.TL_messageEntityItalic();
item7.offset = entity.offset;
item7.length = entity.length;
this.entitiesCopy.add(item7);
} else if (entity instanceof TLRPC.TL_messageEntityMention) {
TLRPC.TL_messageEntityMention item8 = new TLRPC.TL_messageEntityMention();
item8.offset = entity.offset;
item8.length = entity.length;
this.entitiesCopy.add(item8);
} else if (entity instanceof TLRPC.TL_messageEntityMentionName) {
TLRPC.TL_messageEntityMentionName item9 = new TLRPC.TL_messageEntityMentionName();
item9.offset = entity.offset;
item9.length = entity.length;
item9.user_id = ((TLRPC.TL_messageEntityMentionName) entity).user_id;
this.entitiesCopy.add(item9);
} else if (entity instanceof TLRPC.TL_inputMessageEntityMentionName) {
TLRPC.TL_inputMessageEntityMentionName item10 = new TLRPC.TL_inputMessageEntityMentionName();
item10.offset = entity.offset;
item10.length = entity.length;
item10.user_id = ((TLRPC.TL_inputMessageEntityMentionName) entity).user_id;
this.entitiesCopy.add(item10);
} else if (entity instanceof TLRPC.TL_messageEntityCashtag) {
TLRPC.TL_messageEntityCashtag item11 = new TLRPC.TL_messageEntityCashtag();
item11.offset = entity.offset;
item11.length = entity.length;
this.entitiesCopy.add(item11);
} else if (entity instanceof TLRPC.TL_messageEntityBold) {
TLRPC.TL_messageEntityBold item12 = new TLRPC.TL_messageEntityBold();
item12.offset = entity.offset;
item12.length = entity.length;
this.entitiesCopy.add(item12);
} else if (entity instanceof TLRPC.TL_messageEntityHashtag) {
TLRPC.TL_messageEntityHashtag item13 = new TLRPC.TL_messageEntityHashtag();
item13.offset = entity.offset;
item13.length = entity.length;
this.entitiesCopy.add(item13);
} else if (entity instanceof TLRPC.TL_messageEntityCode) {
TLRPC.TL_messageEntityCode item14 = new TLRPC.TL_messageEntityCode();
item14.offset = entity.offset;
item14.length = entity.length;
this.entitiesCopy.add(item14);
} else if (entity instanceof TLRPC.TL_messageEntityStrike) {
TLRPC.TL_messageEntityStrike item15 = new TLRPC.TL_messageEntityStrike();
item15.offset = entity.offset;
item15.length = entity.length;
this.entitiesCopy.add(item15);
} else if (entity instanceof TLRPC.TL_messageEntityBlockquote) {
TLRPC.TL_messageEntityBlockquote item16 = new TLRPC.TL_messageEntityBlockquote();
item16.offset = entity.offset;
item16.length = entity.length;
this.entitiesCopy.add(item16);
} else if (entity instanceof TLRPC.TL_messageEntityUnderline) {
TLRPC.TL_messageEntityUnderline item17 = new TLRPC.TL_messageEntityUnderline();
item17.offset = entity.offset;
item17.length = entity.length;
this.entitiesCopy.add(item17);
} else if (entity instanceof TLRPC.TL_messageEntityPhone) {
TLRPC.TL_messageEntityPhone item18 = new TLRPC.TL_messageEntityPhone();
item18.offset = entity.offset;
item18.length = entity.length;
this.entitiesCopy.add(item18);
}
}
}
public CharSequence updateMetionText(CharSequence text, ArrayList<TLRPC.MessageEntity> entities) {
return updateMetionText(text, entities, null, null, null, null);
}
public CharSequence updateMetionText(CharSequence text, ArrayList<TLRPC.MessageEntity> entities, AbstractMap<Integer, TLRPC.User> users, AbstractMap<Integer, TLRPC.Chat> chats, SparseArray<TLRPC.User> sUsers, SparseArray<TLRPC.Chat> sChats) {
byte t;
Spannable spannable;
SpannableString result;
SpannableString result2;
MessageObject messageObject = this;
AbstractMap<Integer, TLRPC.User> abstractMap = users;
SparseArray<TLRPC.User> sparseArray = sUsers;
if (entities == null || entities.isEmpty()) {
return text;
}
Spannable spannable2 = SpannableString.valueOf(text);
SpannableString result3 = new SpannableString("");
URLSpan[] spans = (URLSpan[]) spannable2.getSpans(0, text.length(), URLSpan.class);
ArrayList<TextStyleSpan.TextStyleRun> runs = new ArrayList<>();
messageObject.entityCopy(entities);
Collections.sort(messageObject.entitiesCopy, new Comparator() {
@Override
public final int compare(Object obj, Object obj2) {
return MessageObject.lambda$updateMetionText$0((TLRPC.MessageEntity) obj, (TLRPC.MessageEntity) obj2);
}
});
int a = 0;
int N = messageObject.entitiesCopy.size();
while (a < N) {
TLRPC.MessageEntity entity = messageObject.entitiesCopy.get(a);
if (entity.length <= 0 || entity.offset < 0) {
spannable = spannable2;
result = result3;
} else if (entity.offset >= text.length()) {
spannable = spannable2;
result = result3;
} else {
if (entity.offset + entity.length > text.length()) {
entity.length = text.length() - entity.offset;
}
if (((entity instanceof TLRPC.TL_messageEntityBold) || (entity instanceof TLRPC.TL_messageEntityItalic) || (entity instanceof TLRPC.TL_messageEntityStrike) || (entity instanceof TLRPC.TL_messageEntityUnderline) || (entity instanceof TLRPC.TL_messageEntityBlockquote) || (entity instanceof TLRPC.TL_messageEntityCode) || (entity instanceof TLRPC.TL_messageEntityPre) || (entity instanceof TLRPC.TL_messageEntityMentionName) || (entity instanceof TLRPC.TL_inputMessageEntityMentionName) || (entity instanceof TLRPC.TL_messageEntityTextUrl)) && spans != null && spans.length > 0) {
for (int b = 0; b < spans.length; b++) {
if (spans[b] != null) {
int start = spannable2.getSpanStart(spans[b]);
int end = spannable2.getSpanEnd(spans[b]);
if ((entity.offset <= start && entity.offset + entity.length >= start) || (entity.offset <= end && entity.offset + entity.length >= end)) {
spannable2.removeSpan(spans[b]);
spans[b] = null;
}
}
}
}
TextStyleSpan.TextStyleRun newRun = new TextStyleSpan.TextStyleRun();
newRun.start = entity.offset;
newRun.end = newRun.start + entity.length;
if (entity instanceof TLRPC.TL_messageEntityStrike) {
newRun.flags = 8;
} else if (entity instanceof TLRPC.TL_messageEntityUnderline) {
newRun.flags = 16;
} else if (entity instanceof TLRPC.TL_messageEntityBlockquote) {
newRun.flags = 32;
} else if (entity instanceof TLRPC.TL_messageEntityBold) {
newRun.flags = 1;
} else if (entity instanceof TLRPC.TL_messageEntityItalic) {
newRun.flags = 2;
} else if ((entity instanceof TLRPC.TL_messageEntityCode) || (entity instanceof TLRPC.TL_messageEntityPre)) {
newRun.flags = 4;
} else if (entity instanceof TLRPC.TL_messageEntityMentionName) {
newRun.flags = 64;
newRun.urlEntity = entity;
} else if (entity instanceof TLRPC.TL_inputMessageEntityMentionName) {
newRun.flags = 64;
newRun.urlEntity = entity;
}
int b2 = 0;
int N2 = runs.size();
while (b2 < N2) {
TextStyleSpan.TextStyleRun run = runs.get(b2);
Spannable spannable3 = spannable2;
if (newRun.start > run.start) {
if (newRun.start < run.end) {
if (newRun.end < run.end) {
TextStyleSpan.TextStyleRun r = new TextStyleSpan.TextStyleRun(newRun);
r.merge(run);
int b3 = b2 + 1;
runs.add(b3, r);
TextStyleSpan.TextStyleRun r2 = new TextStyleSpan.TextStyleRun(run);
r2.start = newRun.end;
b2 = b3 + 1;
N2 = N2 + 1 + 1;
runs.add(b2, r2);
} else if (newRun.end >= run.end) {
TextStyleSpan.TextStyleRun r3 = new TextStyleSpan.TextStyleRun(newRun);
r3.merge(run);
r3.end = run.end;
b2++;
N2++;
runs.add(b2, r3);
}
int temp = newRun.start;
newRun.start = run.end;
run.end = temp;
result2 = result3;
}
result2 = result3;
} else {
if (run.start < newRun.end) {
int temp2 = run.start;
result2 = result3;
if (newRun.end == run.end) {
run.merge(newRun);
} else if (newRun.end < run.end) {
TextStyleSpan.TextStyleRun r4 = new TextStyleSpan.TextStyleRun(run);
r4.merge(newRun);
r4.end = newRun.end;
b2++;
N2++;
runs.add(b2, r4);
run.start = newRun.end;
} else {
TextStyleSpan.TextStyleRun r5 = new TextStyleSpan.TextStyleRun(newRun);
r5.start = run.end;
b2++;
N2++;
runs.add(b2, r5);
run.merge(newRun);
}
newRun.end = temp2;
}
result2 = result3;
}
b2++;
spannable2 = spannable3;
result3 = result2;
}
spannable = spannable2;
result = result3;
if (newRun.start < newRun.end) {
runs.add(newRun);
}
}
a++;
spannable2 = spannable;
result3 = result;
}
Spannable spannable4 = spannable2;
SpannableString result4 = result3;
int count = runs.size();
byte t2 = 1;
int a2 = 0;
while (a2 < count) {
TextStyleSpan.TextStyleRun run2 = runs.get(a2);
if (!(run2.urlEntity instanceof TLRPC.TL_messageEntityMentionName)) {
t = t2;
} else {
int uid = ((TLRPC.TL_messageEntityMentionName) run2.urlEntity).user_id;
TLRPC.User user = null;
if (abstractMap != null || sparseArray != null) {
user = abstractMap != null ? abstractMap.get(Integer.valueOf(uid)) : sparseArray.get(uid);
}
if (user == null) {
MessagesController.getInstance(UserConfig.selectedAccount).getUser(Integer.valueOf(uid));
}
TLRPC.User user2 = MessagesController.getInstance(UserConfig.selectedAccount).getUser(Integer.valueOf(((TLRPC.TL_messageEntityMentionName) run2.urlEntity).user_id));
if (user2 != null) {
CharSequence content = text;
if (!TextUtils.isEmpty(result4)) {
content = result4;
}
SpannableStringBuilder builder = new SpannableStringBuilder(content);
String name = "@" + UserObject.getName(user2);
if (run2.start < 0) {
run2.start = 0;
}
builder.replace(run2.start, run2.end, (CharSequence) name);
int oriEnd = run2.end;
run2.end = run2.start + name.length();
int newOffset = oriEnd - run2.end;
int j = 0;
while (j < messageObject.entitiesCopy.size()) {
TLRPC.MessageEntity messageEntity = messageObject.entitiesCopy.get(j);
byte t3 = t2;
if (messageEntity.offset >= run2.start) {
if (messageEntity.offset == run2.start) {
messageEntity.length = name.length();
} else {
messageEntity.offset -= newOffset;
}
}
j++;
messageObject = this;
t2 = t3;
}
t = t2;
for (int j2 = a2; j2 < count; j2++) {
TextStyleSpan.TextStyleRun nextRun = runs.get(j2);
nextRun.start -= newOffset;
nextRun.end -= newOffset;
}
spannable4 = SpannableString.valueOf(builder);
} else {
t = t2;
FileLog.e(getClass().getSimpleName(), "load msg, u is null.");
}
result4 = SpannableString.valueOf(spannable4);
}
a2++;
messageObject = this;
abstractMap = users;
sparseArray = sUsers;
t2 = t;
}
if (TextUtils.isEmpty(result4) && !TextUtils.isEmpty(text)) {
SpannableString result5 = SpannableString.valueOf(text);
return result5;
}
return result4;
}
public static int lambda$updateMetionText$0(TLRPC.MessageEntity o1, TLRPC.MessageEntity o2) {
if (o1.offset > o2.offset) {
return 1;
}
if (o1.offset < o2.offset) {
return -1;
}
return 0;
}
public SpannableStringBuilder updateMetionText2(CharSequence text, ArrayList<TLRPC.MessageEntity> entities, BaseFragment baseFragment) {
Spannable spannable;
URLSpan[] spans;
byte t;
MessageObject messageObject = this;
if (entities != null && !entities.isEmpty()) {
Spannable spannable2 = SpannableString.valueOf(text);
SpannableStringBuilder result = new SpannableStringBuilder("");
URLSpan[] spans2 = (URLSpan[]) spannable2.getSpans(0, text.length(), URLSpan.class);
ArrayList<TextStyleSpan.TextStyleRun> runs = new ArrayList<>();
messageObject.entityCopy(entities);
Collections.sort(messageObject.entitiesCopy, new Comparator() {
@Override
public final int compare(Object obj, Object obj2) {
return MessageObject.lambda$updateMetionText2$1((TLRPC.MessageEntity) obj, (TLRPC.MessageEntity) obj2);
}
});
int N = messageObject.entitiesCopy.size();
for (int a = 0; a < N; a++) {
TLRPC.MessageEntity entity = messageObject.entitiesCopy.get(a);
if (entity.length > 0 && entity.offset >= 0 && entity.offset < text.length()) {
if (entity.offset + entity.length > text.length()) {
entity.length = text.length() - entity.offset;
}
if (((entity instanceof TLRPC.TL_messageEntityBold) || (entity instanceof TLRPC.TL_messageEntityItalic) || (entity instanceof TLRPC.TL_messageEntityStrike) || (entity instanceof TLRPC.TL_messageEntityUnderline) || (entity instanceof TLRPC.TL_messageEntityBlockquote) || (entity instanceof TLRPC.TL_messageEntityCode) || (entity instanceof TLRPC.TL_messageEntityPre) || (entity instanceof TLRPC.TL_messageEntityMentionName) || (entity instanceof TLRPC.TL_inputMessageEntityMentionName) || (entity instanceof TLRPC.TL_messageEntityTextUrl)) && spans2 != null && spans2.length > 0) {
for (int b = 0; b < spans2.length; b++) {
if (spans2[b] != null) {
int start = spannable2.getSpanStart(spans2[b]);
int end = spannable2.getSpanEnd(spans2[b]);
if ((entity.offset <= start && entity.offset + entity.length >= start) || (entity.offset <= end && entity.offset + entity.length >= end)) {
spannable2.removeSpan(spans2[b]);
spans2[b] = null;
}
}
}
}
TextStyleSpan.TextStyleRun newRun = new TextStyleSpan.TextStyleRun();
newRun.start = entity.offset;
newRun.end = newRun.start + entity.length;
if (entity instanceof TLRPC.TL_messageEntityStrike) {
newRun.flags = 8;
} else if (entity instanceof TLRPC.TL_messageEntityUnderline) {
newRun.flags = 16;
} else if (entity instanceof TLRPC.TL_messageEntityBlockquote) {
newRun.flags = 32;
} else if (entity instanceof TLRPC.TL_messageEntityBold) {
newRun.flags = 1;
} else if (entity instanceof TLRPC.TL_messageEntityItalic) {
newRun.flags = 2;
} else if ((entity instanceof TLRPC.TL_messageEntityCode) || (entity instanceof TLRPC.TL_messageEntityPre)) {
newRun.flags = 4;
} else if (entity instanceof TLRPC.TL_messageEntityMentionName) {
newRun.flags = 64;
newRun.urlEntity = entity;
} else if (entity instanceof TLRPC.TL_inputMessageEntityMentionName) {
newRun.flags = 64;
newRun.urlEntity = entity;
}
int b2 = 0;
int N2 = runs.size();
while (b2 < N2) {
TextStyleSpan.TextStyleRun run = runs.get(b2);
if (newRun.start > run.start) {
if (newRun.start < run.end) {
if (newRun.end < run.end) {
TextStyleSpan.TextStyleRun r = new TextStyleSpan.TextStyleRun(newRun);
r.merge(run);
int b3 = b2 + 1;
runs.add(b3, r);
TextStyleSpan.TextStyleRun r2 = new TextStyleSpan.TextStyleRun(run);
r2.start = newRun.end;
b2 = b3 + 1;
N2 = N2 + 1 + 1;
runs.add(b2, r2);
} else if (newRun.end >= run.end) {
TextStyleSpan.TextStyleRun r3 = new TextStyleSpan.TextStyleRun(newRun);
r3.merge(run);
r3.end = run.end;
b2++;
N2++;
runs.add(b2, r3);
}
int temp = newRun.start;
newRun.start = run.end;
run.end = temp;
}
} else if (run.start < newRun.end) {
int temp2 = run.start;
if (newRun.end == run.end) {
run.merge(newRun);
} else if (newRun.end < run.end) {
TextStyleSpan.TextStyleRun r4 = new TextStyleSpan.TextStyleRun(run);
r4.merge(newRun);
r4.end = newRun.end;
b2++;
N2++;
runs.add(b2, r4);
run.start = newRun.end;
} else {
TextStyleSpan.TextStyleRun r5 = new TextStyleSpan.TextStyleRun(newRun);
r5.start = run.end;
b2++;
N2++;
runs.add(b2, r5);
run.merge(newRun);
}
newRun.end = temp2;
}
b2++;
}
if (newRun.start < newRun.end) {
runs.add(newRun);
}
}
}
int count = runs.size();
byte t2 = 1;
int a2 = 0;
while (a2 < count) {
TextStyleSpan.TextStyleRun run2 = runs.get(a2);
if (run2.urlEntity instanceof TLRPC.TL_messageEntityMentionName) {
TLRPC.User user = MessagesController.getInstance(UserConfig.selectedAccount).getUser(Integer.valueOf(((TLRPC.TL_messageEntityMentionName) run2.urlEntity).user_id));
if (user != null) {
CharSequence content = text;
if (!TextUtils.isEmpty(result)) {
content = result;
}
SpannableStringBuilder builder = new SpannableStringBuilder(content);
String name = "@" + UserObject.getName(user) + " ";
builder.replace(run2.start, run2.end, (CharSequence) name);
int oriEnd = run2.end;
run2.end = run2.start + name.length();
spannable = spannable2;
spans = spans2;
builder.setSpan(new ForegroundColorSpan(-13915656), run2.start, run2.end, 33);
SysNotifyAtTextClickableSpan sysNotifyAtTextClickableSpan = new SysNotifyAtTextClickableSpan(user.id, baseFragment);
t = t2;
builder.setSpan(sysNotifyAtTextClickableSpan, run2.start, run2.end, 33);
int newOffset = oriEnd - run2.end;
int j = 0;
while (j < messageObject.entitiesCopy.size()) {
TLRPC.MessageEntity messageEntity = messageObject.entitiesCopy.get(j);
SysNotifyAtTextClickableSpan sysNotifyAtTextClickableSpan2 = sysNotifyAtTextClickableSpan;
if (messageEntity.offset >= run2.start) {
if (messageEntity.offset == run2.start) {
messageEntity.length = name.length();
} else {
messageEntity.offset -= newOffset;
}
}
j++;
messageObject = this;
sysNotifyAtTextClickableSpan = sysNotifyAtTextClickableSpan2;
}
for (int j2 = a2; j2 < count; j2++) {
TextStyleSpan.TextStyleRun nextRun = runs.get(j2);
nextRun.start -= newOffset;
nextRun.end -= newOffset;
}
result = builder;
} else {
spannable = spannable2;
spans = spans2;
t = t2;
}
} else {
spannable = spannable2;
spans = spans2;
t = t2;
}
a2++;
messageObject = this;
spannable2 = spannable;
spans2 = spans;
t2 = t;
}
if (TextUtils.isEmpty(result) && !TextUtils.isEmpty(text)) {
SpannableStringBuilder result2 = SpannableStringBuilder.valueOf(text);
return result2;
}
return result;
}
return new SpannableStringBuilder(text);
}
public static int lambda$updateMetionText2$1(TLRPC.MessageEntity o1, TLRPC.MessageEntity o2) {
if (o1.offset > o2.offset) {
return 1;
}
if (o1.offset < o2.offset) {
return -1;
}
return 0;
}
private void createDateArray(int accountNum, TLRPC.TL_channelAdminLogEvent event, ArrayList<MessageObject> messageObjects, HashMap<String, ArrayList<MessageObject>> messagesByDays) {
ArrayList<MessageObject> dayArray = messagesByDays.get(this.dateKey);
if (dayArray == null) {
ArrayList<MessageObject> dayArray2 = new ArrayList<>();
messagesByDays.put(this.dateKey, dayArray2);
TLRPC.TL_message dateMsg = new TLRPC.TL_message();
dateMsg.message = LocaleController.formatDateChat(event.date);
dateMsg.id = 0;
dateMsg.date = event.date;
MessageObject dateObj = new MessageObject(accountNum, dateMsg, false);
dateObj.type = 10;
dateObj.contentType = 1;
dateObj.isDateObject = true;
messageObjects.add(dateObj);
}
}
public void checkForScam() {
}
private void checkEmojiOnly(int[] emojiOnly) {
TextPaint emojiPaint;
int size;
if (emojiOnly != null && emojiOnly[0] >= 1 && emojiOnly[0] <= 3) {
int i = emojiOnly[0];
if (i == 1) {
emojiPaint = Theme.chat_msgTextPaintOneEmoji;
int size2 = AndroidUtilities.dp(32.0f);
this.emojiOnlyCount = 1;
size = size2;
} else if (i == 2) {
emojiPaint = Theme.chat_msgTextPaintTwoEmoji;
int size3 = AndroidUtilities.dp(28.0f);
this.emojiOnlyCount = 2;
size = size3;
} else {
emojiPaint = Theme.chat_msgTextPaintThreeEmoji;
size = AndroidUtilities.dp(24.0f);
this.emojiOnlyCount = 3;
}
CharSequence charSequence = this.messageText;
Emoji.EmojiSpan[] spans = (Emoji.EmojiSpan[]) ((Spannable) charSequence).getSpans(0, charSequence.length(), Emoji.EmojiSpan.class);
if (spans != null && spans.length > 0) {
for (Emoji.EmojiSpan emojiSpan : spans) {
emojiSpan.replaceFontMetrics(emojiPaint.getFontMetricsInt(), size);
}
}
}
}
public MessageObject(int accountNum, TLRPC.TL_channelAdminLogEvent event, ArrayList<MessageObject> messageObjects, HashMap<String, ArrayList<MessageObject>> messagesByDays, TLRPC.Chat chat, int[] mid) {
TLRPC.Message message;
String string;
TLRPC.Message message2;
boolean changedCaption;
boolean changedMedia;
String str;
StringBuilder bannedDuration;
char c;
char c2;
char c3;
char c4;
char c5;
char c6;
char c7;
char c8;
char c9;
String addStr;
int minutes;
int minutes2;
int days;
char c10;
char c11;
char c12;
char c13;
char c14;
char c15;
char c16;
char c17;
StringBuilder rights;
ArrayList<MessageObject> arrayList;
HashMap<String, ArrayList<MessageObject>> hashMap;
TextPaint paint;
this.type = 1000;
this.forceSeekTo = -1.0f;
this.entitiesCopy = new ArrayList<>();
this.currentEvent = event;
this.currentAccount = accountNum;
TLRPC.User fromUser = null;
if (event.user_id > 0 && 0 == 0) {
fromUser = MessagesController.getInstance(this.currentAccount).getUser(Integer.valueOf(event.user_id));
}
Calendar rightNow = new GregorianCalendar();
rightNow.setTimeInMillis(event.date * 1000);
int dateDay = rightNow.get(6);
int dateYear = rightNow.get(1);
int dateMonth = rightNow.get(2);
this.dateKey = String.format("%d_%02d_%02d", Integer.valueOf(dateYear), Integer.valueOf(dateMonth), Integer.valueOf(dateDay));
this.monthKey = String.format("%d_%02d", Integer.valueOf(dateYear), Integer.valueOf(dateMonth));
TLRPC.Peer to_id = new TLRPC.TL_peerChannel();
to_id.channel_id = chat.id;
if (event.action instanceof TLRPC.TL_channelAdminLogEventActionChangeTitle) {
String title = ((TLRPC.TL_channelAdminLogEventActionChangeTitle) event.action).new_value;
if (chat.megagroup) {
this.messageText = replaceWithLink(LocaleController.formatString("EventLogEditedGroupTitle", R.string.EventLogEditedGroupTitle, title), "un1", fromUser);
} else {
this.messageText = replaceWithLink(LocaleController.formatString("EventLogEditedChannelTitle", R.string.EventLogEditedChannelTitle, title), "un1", fromUser);
}
message = null;
} else if (event.action instanceof TLRPC.TL_channelAdminLogEventActionChangePhoto) {
this.messageOwner = new TLRPC.TL_messageService();
if (event.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", fromUser);
message = null;
} else {
this.messageText = replaceWithLink(LocaleController.getString("EventLogRemovedChannelPhoto", R.string.EventLogRemovedChannelPhoto), "un1", fromUser);
message = null;
}
} else {
this.messageOwner.action = new TLRPC.TL_messageActionChatEditPhoto();
this.messageOwner.action.photo = event.action.new_photo;
if (chat.megagroup) {
this.messageText = replaceWithLink(LocaleController.getString("EventLogEditedGroupPhoto", R.string.EventLogEditedGroupPhoto), "un1", fromUser);
message = null;
} else {
this.messageText = replaceWithLink(LocaleController.getString("EventLogEditedChannelPhoto", R.string.EventLogEditedChannelPhoto), "un1", fromUser);
message = null;
}
}
} else if (event.action instanceof TLRPC.TL_channelAdminLogEventActionParticipantJoin) {
if (chat.megagroup) {
this.messageText = replaceWithLink(LocaleController.getString("EventLogGroupJoined", R.string.EventLogGroupJoined), "un1", fromUser);
message = null;
} else {
this.messageText = replaceWithLink(LocaleController.getString("EventLogChannelJoined", R.string.EventLogChannelJoined), "un1", fromUser);
message = null;
}
} else if (event.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 = event.user_id;
if (chat.megagroup) {
this.messageText = replaceWithLink(LocaleController.getString("EventLogLeftGroup", R.string.EventLogLeftGroup), "un1", fromUser);
message = null;
} else {
this.messageText = replaceWithLink(LocaleController.getString("EventLogLeftChannel", R.string.EventLogLeftChannel), "un1", fromUser);
message = null;
}
} else if (event.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 whoUser = MessagesController.getInstance(this.currentAccount).getUser(Integer.valueOf(event.action.participant.user_id));
if (event.action.participant.user_id != this.messageOwner.from_id) {
CharSequence replaceWithLink = replaceWithLink(LocaleController.getString("EventLogAdded", R.string.EventLogAdded), "un2", whoUser);
this.messageText = replaceWithLink;
this.messageText = replaceWithLink(replaceWithLink, "un1", fromUser);
} else if (chat.megagroup) {
this.messageText = replaceWithLink(LocaleController.getString("EventLogGroupJoined", R.string.EventLogGroupJoined), "un1", fromUser);
} else {
this.messageText = replaceWithLink(LocaleController.getString("EventLogChannelJoined", R.string.EventLogChannelJoined), "un1", fromUser);
}
message = null;
} else if (event.action instanceof TLRPC.TL_channelAdminLogEventActionParticipantToggleAdmin) {
this.messageOwner = new TLRPC.TL_message();
TLRPC.User whoUser2 = MessagesController.getInstance(this.currentAccount).getUser(Integer.valueOf(event.action.prev_participant.user_id));
if (!(event.action.prev_participant instanceof TLRPC.TL_channelParticipantCreator) && (event.action.new_participant instanceof TLRPC.TL_channelParticipantCreator)) {
String str2 = LocaleController.getString("EventLogChangedOwnership", R.string.EventLogChangedOwnership);
int offset = str2.indexOf("%1$s");
rights = new StringBuilder(String.format(str2, getUserName(whoUser2, this.messageOwner.entities, offset)));
} else {
String str3 = LocaleController.getString("EventLogPromoted", R.string.EventLogPromoted);
int offset2 = str3.indexOf("%1$s");
StringBuilder rights2 = new StringBuilder(String.format(str3, getUserName(whoUser2, this.messageOwner.entities, offset2)));
rights2.append("\n");
TLRPC.TL_chatAdminRights o = event.action.prev_participant.admin_rights;
TLRPC.TL_chatAdminRights n = event.action.new_participant.admin_rights;
o = o == null ? new TLRPC.TL_chatAdminRights() : o;
n = n == null ? new TLRPC.TL_chatAdminRights() : n;
if (!TextUtils.equals(event.action.prev_participant.rank, event.action.new_participant.rank)) {
if (TextUtils.isEmpty(event.action.new_participant.rank)) {
rights2.append('\n');
rights2.append('-');
rights2.append(' ');
rights2.append(LocaleController.getString("EventLogPromotedRemovedTitle", R.string.EventLogPromotedRemovedTitle));
} else {
rights2.append('\n');
rights2.append('+');
rights2.append(' ');
rights2.append(LocaleController.formatString("EventLogPromotedTitle", R.string.EventLogPromotedTitle, event.action.new_participant.rank));
}
}
if (o.change_info != n.change_info) {
rights2.append('\n');
rights2.append(n.change_info ? '+' : '-');
rights2.append(' ');
rights2.append(chat.megagroup ? LocaleController.getString("EventLogPromotedChangeGroupInfo", R.string.EventLogPromotedChangeGroupInfo) : LocaleController.getString("EventLogPromotedChangeChannelInfo", R.string.EventLogPromotedChangeChannelInfo));
}
if (!chat.megagroup) {
if (o.post_messages != n.post_messages) {
rights2.append('\n');
rights2.append(n.post_messages ? '+' : '-');
rights2.append(' ');
rights2.append(LocaleController.getString("EventLogPromotedPostMessages", R.string.EventLogPromotedPostMessages));
}
if (o.edit_messages != n.edit_messages) {
rights2.append('\n');
rights2.append(n.edit_messages ? '+' : '-');
rights2.append(' ');
rights2.append(LocaleController.getString("EventLogPromotedEditMessages", R.string.EventLogPromotedEditMessages));
}
}
if (o.delete_messages != n.delete_messages) {
rights2.append('\n');
rights2.append(n.delete_messages ? '+' : '-');
rights2.append(' ');
rights2.append(LocaleController.getString("EventLogPromotedDeleteMessages", R.string.EventLogPromotedDeleteMessages));
}
if (o.add_admins != n.add_admins) {
rights2.append('\n');
rights2.append(n.add_admins ? '+' : '-');
rights2.append(' ');
rights2.append(LocaleController.getString("EventLogPromotedAddAdmins", R.string.EventLogPromotedAddAdmins));
}
if (chat.megagroup && o.ban_users != n.ban_users) {
rights2.append('\n');
rights2.append(n.ban_users ? '+' : '-');
rights2.append(' ');
rights2.append(LocaleController.getString("EventLogPromotedBanUsers", R.string.EventLogPromotedBanUsers));
}
if (o.invite_users != n.invite_users) {
rights2.append('\n');
rights2.append(n.invite_users ? '+' : '-');
rights2.append(' ');
rights2.append(LocaleController.getString("EventLogPromotedAddUsers", R.string.EventLogPromotedAddUsers));
}
if (chat.megagroup && o.pin_messages != n.pin_messages) {
rights2.append('\n');
rights2.append(n.pin_messages ? '+' : '-');
rights2.append(' ');
rights2.append(LocaleController.getString("EventLogPromotedPinMessages", R.string.EventLogPromotedPinMessages));
}
rights = rights2;
}
this.messageText = rights.toString();
message = null;
} else if (event.action instanceof TLRPC.TL_channelAdminLogEventActionDefaultBannedRights) {
TLRPC.TL_channelAdminLogEventActionDefaultBannedRights bannedRights = (TLRPC.TL_channelAdminLogEventActionDefaultBannedRights) event.action;
this.messageOwner = new TLRPC.TL_message();
TLRPC.TL_chatBannedRights o2 = bannedRights.prev_banned_rights;
TLRPC.TL_chatBannedRights n2 = bannedRights.new_banned_rights;
StringBuilder rights3 = new StringBuilder(LocaleController.getString("EventLogDefaultPermissions", R.string.EventLogDefaultPermissions));
boolean added = false;
o2 = o2 == null ? new TLRPC.TL_chatBannedRights() : o2;
n2 = n2 == null ? new TLRPC.TL_chatBannedRights() : n2;
if (o2.send_messages != n2.send_messages) {
if (0 != 0) {
c17 = '\n';
} else {
c17 = '\n';
rights3.append('\n');
added = true;
}
rights3.append(c17);
rights3.append(!n2.send_messages ? '+' : '-');
rights3.append(' ');
rights3.append(LocaleController.getString("EventLogRestrictedSendMessages", R.string.EventLogRestrictedSendMessages));
}
if (o2.send_stickers != n2.send_stickers || o2.send_inline != n2.send_inline || o2.send_gifs != n2.send_gifs || o2.send_games != n2.send_games) {
if (added) {
c10 = '\n';
} else {
c10 = '\n';
rights3.append('\n');
added = true;
}
rights3.append(c10);
rights3.append(!n2.send_stickers ? '+' : '-');
rights3.append(' ');
rights3.append(LocaleController.getString("EventLogRestrictedSendStickers", R.string.EventLogRestrictedSendStickers));
}
if (o2.send_media != n2.send_media) {
if (added) {
c16 = '\n';
} else {
c16 = '\n';
rights3.append('\n');
added = true;
}
rights3.append(c16);
rights3.append(!n2.send_media ? '+' : '-');
rights3.append(' ');
rights3.append(LocaleController.getString("EventLogRestrictedSendMedia", R.string.EventLogRestrictedSendMedia));
}
if (o2.send_polls != n2.send_polls) {
if (added) {
c15 = '\n';
} else {
c15 = '\n';
rights3.append('\n');
added = true;
}
rights3.append(c15);
rights3.append(!n2.send_polls ? '+' : '-');
rights3.append(' ');
rights3.append(LocaleController.getString("EventLogRestrictedSendPolls", R.string.EventLogRestrictedSendPolls));
}
if (o2.embed_links != n2.embed_links) {
if (added) {
c14 = '\n';
} else {
c14 = '\n';
rights3.append('\n');
added = true;
}
rights3.append(c14);
rights3.append(!n2.embed_links ? '+' : '-');
rights3.append(' ');
rights3.append(LocaleController.getString("EventLogRestrictedSendEmbed", R.string.EventLogRestrictedSendEmbed));
}
if (o2.change_info != n2.change_info) {
if (added) {
c13 = '\n';
} else {
c13 = '\n';
rights3.append('\n');
added = true;
}
rights3.append(c13);
rights3.append(!n2.change_info ? '+' : '-');
rights3.append(' ');
rights3.append(LocaleController.getString("EventLogRestrictedChangeInfo", R.string.EventLogRestrictedChangeInfo));
}
if (o2.invite_users != n2.invite_users) {
if (added) {
c12 = '\n';
} else {
c12 = '\n';
rights3.append('\n');
added = true;
}
rights3.append(c12);
rights3.append(!n2.invite_users ? '+' : '-');
rights3.append(' ');
rights3.append(LocaleController.getString("EventLogRestrictedInviteUsers", R.string.EventLogRestrictedInviteUsers));
}
if (o2.pin_messages != n2.pin_messages) {
if (added) {
c11 = '\n';
} else {
c11 = '\n';
rights3.append('\n');
}
rights3.append(c11);
rights3.append(!n2.pin_messages ? '+' : '-');
rights3.append(' ');
rights3.append(LocaleController.getString("EventLogRestrictedPinMessages", R.string.EventLogRestrictedPinMessages));
}
this.messageText = rights3.toString();
message = null;
} else if (event.action instanceof TLRPC.TL_channelAdminLogEventActionParticipantToggleBan) {
this.messageOwner = new TLRPC.TL_message();
TLRPC.User whoUser3 = MessagesController.getInstance(this.currentAccount).getUser(Integer.valueOf(event.action.prev_participant.user_id));
TLRPC.TL_chatBannedRights o3 = event.action.prev_participant.banned_rights;
TLRPC.TL_chatBannedRights n3 = event.action.new_participant.banned_rights;
if (!chat.megagroup) {
message = null;
} else if (n3 != null && n3.view_messages && (n3 == null || o3 == null || n3.until_date == o3.until_date)) {
message = null;
} else {
if (n3 == null || AndroidUtilities.isBannedForever(n3)) {
message = null;
bannedDuration = new StringBuilder(LocaleController.getString("UserRestrictionsUntilForever", R.string.UserRestrictionsUntilForever));
} else {
bannedDuration = new StringBuilder();
int duration = n3.until_date - event.date;
int days2 = ((duration / 60) / 60) / 24;
int duration2 = duration - (((days2 * 60) * 60) * 24);
message = null;
int hours = (duration2 / 60) / 60;
int count = (duration2 - ((hours * 60) * 60)) / 60;
int count2 = 0;
int duration3 = 0;
while (duration3 < 3) {
if (duration3 == 0) {
if (days2 != 0) {
String addStr2 = LocaleController.formatPluralString("Days", days2);
addStr = addStr2;
minutes = count;
minutes2 = count2 + 1;
if (addStr != null) {
days = days2;
} else {
if (bannedDuration.length() <= 0) {
days = days2;
} else {
days = days2;
bannedDuration.append(", ");
}
bannedDuration.append(addStr);
}
if (minutes2 != 2) {
break;
}
duration3++;
count2 = minutes2;
count = minutes;
days2 = days;
}
addStr = null;
minutes = count;
minutes2 = count2;
if (addStr != null) {
}
if (minutes2 != 2) {
}
} else if (duration3 == 1) {
if (hours != 0) {
String addStr3 = LocaleController.formatPluralString("Hours", hours);
addStr = addStr3;
minutes = count;
minutes2 = count2 + 1;
if (addStr != null) {
}
if (minutes2 != 2) {
}
}
addStr = null;
minutes = count;
minutes2 = count2;
if (addStr != null) {
}
if (minutes2 != 2) {
}
} else {
if (count != 0) {
String addStr4 = LocaleController.formatPluralString("Minutes", count);
addStr = addStr4;
minutes = count;
minutes2 = count2 + 1;
if (addStr != null) {
}
if (minutes2 != 2) {
}
}
addStr = null;
minutes = count;
minutes2 = count2;
if (addStr != null) {
}
if (minutes2 != 2) {
}
}
}
}
String str4 = LocaleController.getString("EventLogRestrictedUntil", R.string.EventLogRestrictedUntil);
int offset3 = str4.indexOf("%1$s");
StringBuilder rights4 = new StringBuilder(String.format(str4, getUserName(whoUser3, this.messageOwner.entities, offset3), bannedDuration.toString()));
boolean added2 = false;
o3 = o3 == null ? new TLRPC.TL_chatBannedRights() : o3;
n3 = n3 == null ? new TLRPC.TL_chatBannedRights() : n3;
if (o3.view_messages != n3.view_messages) {
if (0 != 0) {
c9 = '\n';
} else {
c9 = '\n';
rights4.append('\n');
added2 = true;
}
rights4.append(c9);
rights4.append(!n3.view_messages ? '+' : '-');
rights4.append(' ');
rights4.append(LocaleController.getString("EventLogRestrictedReadMessages", R.string.EventLogRestrictedReadMessages));
}
if (o3.send_messages != n3.send_messages) {
if (added2) {
c8 = '\n';
} else {
c8 = '\n';
rights4.append('\n');
added2 = true;
}
rights4.append(c8);
rights4.append(!n3.send_messages ? '+' : '-');
rights4.append(' ');
rights4.append(LocaleController.getString("EventLogRestrictedSendMessages", R.string.EventLogRestrictedSendMessages));
}
if (o3.send_stickers != n3.send_stickers || o3.send_inline != n3.send_inline || o3.send_gifs != n3.send_gifs || o3.send_games != n3.send_games) {
if (added2) {
c = '\n';
} else {
c = '\n';
rights4.append('\n');
added2 = true;
}
rights4.append(c);
rights4.append(!n3.send_stickers ? '+' : '-');
rights4.append(' ');
rights4.append(LocaleController.getString("EventLogRestrictedSendStickers", R.string.EventLogRestrictedSendStickers));
}
if (o3.send_media != n3.send_media) {
if (added2) {
c7 = '\n';
} else {
c7 = '\n';
rights4.append('\n');
added2 = true;
}
rights4.append(c7);
rights4.append(!n3.send_media ? '+' : '-');
rights4.append(' ');
rights4.append(LocaleController.getString("EventLogRestrictedSendMedia", R.string.EventLogRestrictedSendMedia));
}
if (o3.send_polls != n3.send_polls) {
if (added2) {
c6 = '\n';
} else {
c6 = '\n';
rights4.append('\n');
added2 = true;
}
rights4.append(c6);
rights4.append(!n3.send_polls ? '+' : '-');
rights4.append(' ');
rights4.append(LocaleController.getString("EventLogRestrictedSendPolls", R.string.EventLogRestrictedSendPolls));
}
if (o3.embed_links != n3.embed_links) {
if (added2) {
c5 = '\n';
} else {
c5 = '\n';
rights4.append('\n');
added2 = true;
}
rights4.append(c5);
rights4.append(!n3.embed_links ? '+' : '-');
rights4.append(' ');
rights4.append(LocaleController.getString("EventLogRestrictedSendEmbed", R.string.EventLogRestrictedSendEmbed));
}
if (o3.change_info != n3.change_info) {
if (added2) {
c4 = '\n';
} else {
c4 = '\n';
rights4.append('\n');
added2 = true;
}
rights4.append(c4);
rights4.append(!n3.change_info ? '+' : '-');
rights4.append(' ');
rights4.append(LocaleController.getString("EventLogRestrictedChangeInfo", R.string.EventLogRestrictedChangeInfo));
}
if (o3.invite_users != n3.invite_users) {
if (added2) {
c3 = '\n';
} else {
c3 = '\n';
rights4.append('\n');
added2 = true;
}
rights4.append(c3);
rights4.append(!n3.invite_users ? '+' : '-');
rights4.append(' ');
rights4.append(LocaleController.getString("EventLogRestrictedInviteUsers", R.string.EventLogRestrictedInviteUsers));
}
if (o3.pin_messages != n3.pin_messages) {
if (added2) {
c2 = '\n';
} else {
c2 = '\n';
rights4.append('\n');
}
rights4.append(c2);
rights4.append(!n3.pin_messages ? '+' : '-');
rights4.append(' ');
rights4.append(LocaleController.getString("EventLogRestrictedPinMessages", R.string.EventLogRestrictedPinMessages));
}
this.messageText = rights4.toString();
}
if (n3 != null && (o3 == null || n3.view_messages)) {
str = LocaleController.getString("EventLogChannelRestricted", R.string.EventLogChannelRestricted);
} else {
str = LocaleController.getString("EventLogChannelUnrestricted", R.string.EventLogChannelUnrestricted);
}
int offset4 = str.indexOf("%1$s");
this.messageText = String.format(str, getUserName(whoUser3, this.messageOwner.entities, offset4));
} else {
message = null;
if (event.action instanceof TLRPC.TL_channelAdminLogEventActionUpdatePinned) {
if (fromUser != null && fromUser.id == 136817688 && event.action.message.fwd_from != null) {
TLObject channel = MessagesController.getInstance(this.currentAccount).getChat(Integer.valueOf(event.action.message.fwd_from.channel_id));
if (event.action.message instanceof TLRPC.TL_messageEmpty) {
this.messageText = replaceWithLink(LocaleController.getString("EventLogUnpinnedMessages", R.string.EventLogUnpinnedMessages), "un1", channel);
} else {
this.messageText = replaceWithLink(LocaleController.getString("EventLogPinnedMessages", R.string.EventLogPinnedMessages), "un1", channel);
}
} else if (event.action.message instanceof TLRPC.TL_messageEmpty) {
this.messageText = replaceWithLink(LocaleController.getString("EventLogUnpinnedMessages", R.string.EventLogUnpinnedMessages), "un1", fromUser);
} else {
this.messageText = replaceWithLink(LocaleController.getString("EventLogPinnedMessages", R.string.EventLogPinnedMessages), "un1", fromUser);
}
} else if (event.action instanceof TLRPC.TL_channelAdminLogEventActionStopPoll) {
this.messageText = replaceWithLink(LocaleController.getString("EventLogStopPoll", R.string.EventLogStopPoll), "un1", fromUser);
} else if (event.action instanceof TLRPC.TL_channelAdminLogEventActionToggleSignatures) {
if (((TLRPC.TL_channelAdminLogEventActionToggleSignatures) event.action).new_value) {
this.messageText = replaceWithLink(LocaleController.getString("EventLogToggledSignaturesOn", R.string.EventLogToggledSignaturesOn), "un1", fromUser);
} else {
this.messageText = replaceWithLink(LocaleController.getString("EventLogToggledSignaturesOff", R.string.EventLogToggledSignaturesOff), "un1", fromUser);
}
} else if (event.action instanceof TLRPC.TL_channelAdminLogEventActionToggleInvites) {
if (((TLRPC.TL_channelAdminLogEventActionToggleInvites) event.action).new_value) {
this.messageText = replaceWithLink(LocaleController.getString("EventLogToggledInvitesOn", R.string.EventLogToggledInvitesOn), "un1", fromUser);
} else {
this.messageText = replaceWithLink(LocaleController.getString("EventLogToggledInvitesOff", R.string.EventLogToggledInvitesOff), "un1", fromUser);
}
} else if (event.action instanceof TLRPC.TL_channelAdminLogEventActionDeleteMessage) {
this.messageText = replaceWithLink(LocaleController.getString("EventLogDeletedMessages", R.string.EventLogDeletedMessages), "un1", fromUser);
} else if (event.action instanceof TLRPC.TL_channelAdminLogEventActionChangeLinkedChat) {
int newChatId = ((TLRPC.TL_channelAdminLogEventActionChangeLinkedChat) event.action).new_value;
int oldChatId = ((TLRPC.TL_channelAdminLogEventActionChangeLinkedChat) event.action).prev_value;
if (chat.megagroup) {
if (newChatId == 0) {
TLObject oldChat = MessagesController.getInstance(this.currentAccount).getChat(Integer.valueOf(oldChatId));
CharSequence replaceWithLink2 = replaceWithLink(LocaleController.getString("EventLogRemovedLinkedChannel", R.string.EventLogRemovedLinkedChannel), "un1", fromUser);
this.messageText = replaceWithLink2;
this.messageText = replaceWithLink(replaceWithLink2, "un2", oldChat);
} else {
TLObject newChat = MessagesController.getInstance(this.currentAccount).getChat(Integer.valueOf(newChatId));
CharSequence replaceWithLink3 = replaceWithLink(LocaleController.getString("EventLogChangedLinkedChannel", R.string.EventLogChangedLinkedChannel), "un1", fromUser);
this.messageText = replaceWithLink3;
this.messageText = replaceWithLink(replaceWithLink3, "un2", newChat);
}
} else if (newChatId == 0) {
TLObject oldChat2 = MessagesController.getInstance(this.currentAccount).getChat(Integer.valueOf(oldChatId));
CharSequence replaceWithLink4 = replaceWithLink(LocaleController.getString("EventLogRemovedLinkedGroup", R.string.EventLogRemovedLinkedGroup), "un1", fromUser);
this.messageText = replaceWithLink4;
this.messageText = replaceWithLink(replaceWithLink4, "un2", oldChat2);
} else {
TLObject newChat2 = MessagesController.getInstance(this.currentAccount).getChat(Integer.valueOf(newChatId));
CharSequence replaceWithLink5 = replaceWithLink(LocaleController.getString("EventLogChangedLinkedGroup", R.string.EventLogChangedLinkedGroup), "un1", fromUser);
this.messageText = replaceWithLink5;
this.messageText = replaceWithLink(replaceWithLink5, "un2", newChat2);
}
} else if (event.action instanceof TLRPC.TL_channelAdminLogEventActionTogglePreHistoryHidden) {
if (((TLRPC.TL_channelAdminLogEventActionTogglePreHistoryHidden) event.action).new_value) {
this.messageText = replaceWithLink(LocaleController.getString("EventLogToggledInvitesHistoryOff", R.string.EventLogToggledInvitesHistoryOff), "un1", fromUser);
} else {
this.messageText = replaceWithLink(LocaleController.getString("EventLogToggledInvitesHistoryOn", R.string.EventLogToggledInvitesHistoryOn), "un1", fromUser);
}
} else {
if (event.action instanceof TLRPC.TL_channelAdminLogEventActionChangeAbout) {
this.messageText = replaceWithLink(chat.megagroup ? LocaleController.getString("EventLogEditedGroupDescription", R.string.EventLogEditedGroupDescription) : LocaleController.getString("EventLogEditedChannelDescription", R.string.EventLogEditedChannelDescription), "un1", fromUser);
message2 = new TLRPC.TL_message();
message2.out = false;
message2.unread = false;
message2.from_id = event.user_id;
message2.to_id = to_id;
message2.date = event.date;
message2.message = ((TLRPC.TL_channelAdminLogEventActionChangeAbout) event.action).new_value;
if (!TextUtils.isEmpty(((TLRPC.TL_channelAdminLogEventActionChangeAbout) event.action).prev_value)) {
message2.media = new TLRPC.TL_messageMediaWebPage();
message2.media.webpage = new TLRPC.TL_webPage();
message2.media.webpage.flags = 10;
message2.media.webpage.display_url = "";
message2.media.webpage.url = "";
message2.media.webpage.site_name = LocaleController.getString("EventLogPreviousGroupDescription", R.string.EventLogPreviousGroupDescription);
message2.media.webpage.description = ((TLRPC.TL_channelAdminLogEventActionChangeAbout) event.action).prev_value;
} else {
message2.media = new TLRPC.TL_messageMediaEmpty();
}
} else if (event.action instanceof TLRPC.TL_channelAdminLogEventActionChangeUsername) {
String newLink = ((TLRPC.TL_channelAdminLogEventActionChangeUsername) event.action).new_value;
if (!TextUtils.isEmpty(newLink)) {
this.messageText = replaceWithLink(chat.megagroup ? LocaleController.getString("EventLogChangedGroupLink", R.string.EventLogChangedGroupLink) : LocaleController.getString("EventLogChangedChannelLink", R.string.EventLogChangedChannelLink), "un1", fromUser);
} else {
this.messageText = replaceWithLink(chat.megagroup ? LocaleController.getString("EventLogRemovedGroupLink", R.string.EventLogRemovedGroupLink) : LocaleController.getString("EventLogRemovedChannelLink", R.string.EventLogRemovedChannelLink), "un1", fromUser);
}
message2 = new TLRPC.TL_message();
message2.out = false;
message2.unread = false;
message2.from_id = event.user_id;
message2.to_id = to_id;
message2.date = event.date;
if (!TextUtils.isEmpty(newLink)) {
message2.message = "https://" + MessagesController.getInstance(this.currentAccount).linkPrefix + "/" + newLink;
} else {
message2.message = "";
}
TLRPC.TL_messageEntityUrl url = new TLRPC.TL_messageEntityUrl();
url.offset = 0;
url.length = message2.message.length();
message2.entities.add(url);
if (!TextUtils.isEmpty(((TLRPC.TL_channelAdminLogEventActionChangeUsername) event.action).prev_value)) {
message2.media = new TLRPC.TL_messageMediaWebPage();
message2.media.webpage = new TLRPC.TL_webPage();
message2.media.webpage.flags = 10;
message2.media.webpage.display_url = "";
message2.media.webpage.url = "";
message2.media.webpage.site_name = LocaleController.getString("EventLogPreviousLink", R.string.EventLogPreviousLink);
message2.media.webpage.description = "https://" + MessagesController.getInstance(this.currentAccount).linkPrefix + "/" + ((TLRPC.TL_channelAdminLogEventActionChangeUsername) event.action).prev_value;
} else {
message2.media = new TLRPC.TL_messageMediaEmpty();
}
} else if (event.action instanceof TLRPC.TL_channelAdminLogEventActionEditMessage) {
message2 = new TLRPC.TL_message();
message2.out = false;
message2.unread = false;
message2.from_id = event.user_id;
message2.to_id = to_id;
message2.date = event.date;
TLRPC.Message newMessage = ((TLRPC.TL_channelAdminLogEventActionEditMessage) event.action).new_message;
TLRPC.Message oldMessage = ((TLRPC.TL_channelAdminLogEventActionEditMessage) event.action).prev_message;
if (newMessage.media == null || (newMessage.media instanceof TLRPC.TL_messageMediaEmpty) || (newMessage.media instanceof TLRPC.TL_messageMediaWebPage)) {
this.messageText = replaceWithLink(LocaleController.getString("EventLogEditedMessages", R.string.EventLogEditedMessages), "un1", fromUser);
message2.message = newMessage.message;
message2.media = new TLRPC.TL_messageMediaWebPage();
message2.media.webpage = new TLRPC.TL_webPage();
message2.media.webpage.site_name = LocaleController.getString("EventLogOriginalMessages", R.string.EventLogOriginalMessages);
if (TextUtils.isEmpty(oldMessage.message)) {
message2.media.webpage.description = LocaleController.getString("EventLogOriginalCaptionEmpty", R.string.EventLogOriginalCaptionEmpty);
} else {
message2.media.webpage.description = oldMessage.message;
}
} else {
if (!TextUtils.equals(newMessage.message, oldMessage.message)) {
changedCaption = true;
} else {
changedCaption = false;
}
if (newMessage.media.getClass() != oldMessage.media.getClass() || ((newMessage.media.photo != null && oldMessage.media.photo != null && newMessage.media.photo.id != oldMessage.media.photo.id) || (newMessage.media.document != null && oldMessage.media.document != null && newMessage.media.document.id != oldMessage.media.document.id))) {
changedMedia = true;
} else {
changedMedia = false;
}
if (changedMedia && changedCaption) {
this.messageText = replaceWithLink(LocaleController.getString("EventLogEditedMediaCaption", R.string.EventLogEditedMediaCaption), "un1", fromUser);
} else if (changedCaption) {
this.messageText = replaceWithLink(LocaleController.getString("EventLogEditedCaption", R.string.EventLogEditedCaption), "un1", fromUser);
} else {
this.messageText = replaceWithLink(LocaleController.getString("EventLogEditedMedia", R.string.EventLogEditedMedia), "un1", fromUser);
}
message2.media = newMessage.media;
if (changedCaption) {
message2.media.webpage = new TLRPC.TL_webPage();
message2.media.webpage.site_name = LocaleController.getString("EventLogOriginalCaption", R.string.EventLogOriginalCaption);
if (TextUtils.isEmpty(oldMessage.message)) {
message2.media.webpage.description = LocaleController.getString("EventLogOriginalCaptionEmpty", R.string.EventLogOriginalCaptionEmpty);
} else {
message2.media.webpage.description = oldMessage.message;
}
}
}
message2.reply_markup = newMessage.reply_markup;
if (message2.media.webpage != null) {
message2.media.webpage.flags = 10;
message2.media.webpage.display_url = "";
message2.media.webpage.url = "";
}
} else if (event.action instanceof TLRPC.TL_channelAdminLogEventActionChangeStickerSet) {
TLRPC.InputStickerSet newStickerset = ((TLRPC.TL_channelAdminLogEventActionChangeStickerSet) event.action).new_stickerset;
TLRPC.InputStickerSet inputStickerSet = ((TLRPC.TL_channelAdminLogEventActionChangeStickerSet) event.action).new_stickerset;
if (newStickerset == null || (newStickerset instanceof TLRPC.TL_inputStickerSetEmpty)) {
this.messageText = replaceWithLink(LocaleController.getString("EventLogRemovedStickersSet", R.string.EventLogRemovedStickersSet), "un1", fromUser);
} else {
this.messageText = replaceWithLink(LocaleController.getString("EventLogChangedStickersSet", R.string.EventLogChangedStickersSet), "un1", fromUser);
}
} else if (event.action instanceof TLRPC.TL_channelAdminLogEventActionChangeLocation) {
TLRPC.TL_channelAdminLogEventActionChangeLocation location = (TLRPC.TL_channelAdminLogEventActionChangeLocation) event.action;
if (location.new_value instanceof TLRPC.TL_channelLocationEmpty) {
this.messageText = replaceWithLink(LocaleController.getString("EventLogRemovedLocation", R.string.EventLogRemovedLocation), "un1", fromUser);
} else {
TLRPC.TL_channelLocation channelLocation = (TLRPC.TL_channelLocation) location.new_value;
this.messageText = replaceWithLink(LocaleController.formatString("EventLogChangedLocation", R.string.EventLogChangedLocation, channelLocation.address), "un1", fromUser);
}
} else if (event.action instanceof TLRPC.TL_channelAdminLogEventActionToggleSlowMode) {
TLRPC.TL_channelAdminLogEventActionToggleSlowMode slowMode = (TLRPC.TL_channelAdminLogEventActionToggleSlowMode) event.action;
if (slowMode.new_value == 0) {
this.messageText = replaceWithLink(LocaleController.getString("EventLogToggledSlowmodeOff", R.string.EventLogToggledSlowmodeOff), "un1", fromUser);
} else {
if (slowMode.new_value < 60) {
string = LocaleController.formatPluralString("Seconds", slowMode.new_value);
} else if (slowMode.new_value < 3600) {
string = LocaleController.formatPluralString("Minutes", slowMode.new_value / 60);
} else {
string = LocaleController.formatPluralString("Hours", (slowMode.new_value / 60) / 60);
}
this.messageText = replaceWithLink(LocaleController.formatString("EventLogToggledSlowmodeOn", R.string.EventLogToggledSlowmodeOn, string), "un1", fromUser);
}
} else {
this.messageText = "unsupported " + event.action;
}
if (this.messageOwner == null) {
this.messageOwner = new TLRPC.TL_messageService();
}
this.messageOwner.message = this.messageText.toString();
this.messageOwner.from_id = event.user_id;
this.messageOwner.date = event.date;
TLRPC.Message message3 = this.messageOwner;
int i = mid[0];
mid[0] = i + 1;
message3.id = i;
this.eventId = event.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 (event.action.message != null && !(event.action.message instanceof TLRPC.TL_messageEmpty)) {
message2 = event.action.message;
}
if (message2 != null) {
arrayList = messageObjects;
hashMap = messagesByDays;
} else {
message2.out = false;
int i2 = mid[0];
mid[0] = i2 + 1;
message2.id = i2;
message2.reply_to_msg_id = 0;
message2.flags &= -32769;
if (chat.megagroup) {
message2.flags = Integer.MIN_VALUE | message2.flags;
}
MessageObject messageObject = new MessageObject(this.currentAccount, message2, (AbstractMap<Integer, TLRPC.User>) null, (AbstractMap<Integer, TLRPC.Chat>) null, true, this.eventId);
if (messageObject.contentType >= 0) {
if (mediaController.isPlayingMessage(messageObject)) {
MessageObject player = mediaController.getPlayingMessageObject();
messageObject.audioProgress = player.audioProgress;
messageObject.audioProgressSec = player.audioProgressSec;
}
arrayList = messageObjects;
hashMap = messagesByDays;
createDateArray(this.currentAccount, event, arrayList, hashMap);
arrayList.add(messageObjects.size() - 1, messageObject);
} else {
arrayList = messageObjects;
hashMap = messagesByDays;
this.contentType = -1;
}
}
if (this.contentType < 0) {
createDateArray(this.currentAccount, event, arrayList, hashMap);
arrayList.add(messageObjects.size() - 1, this);
if (this.messageText == null) {
this.messageText = "";
}
setType();
measureInlineBotButtons();
generateCaption();
if (this.messageOwner.media instanceof TLRPC.TL_messageMediaGame) {
paint = Theme.chat_msgGameTextPaint;
} else {
paint = Theme.chat_msgTextPaint;
}
int[] emojiOnly = SharedConfig.allowBigEmoji ? new int[1] : null;
this.messageText = Emoji.replaceEmoji(this.messageText, paint.getFontMetricsInt(), AndroidUtilities.dp(20.0f), false, emojiOnly);
checkEmojiOnly(emojiOnly);
if (mediaController.isPlayingMessage(this)) {
MessageObject player2 = mediaController.getPlayingMessageObject();
this.audioProgress = player2.audioProgress;
this.audioProgressSec = player2.audioProgressSec;
}
generateLayout(fromUser);
this.layoutCreated = true;
generateThumbs(false);
checkMediaExistance();
return;
}
return;
}
}
message2 = message;
if (this.messageOwner == null) {
}
this.messageOwner.message = this.messageText.toString();
this.messageOwner.from_id = event.user_id;
this.messageOwner.date = event.date;
TLRPC.Message message32 = this.messageOwner;
int i3 = mid[0];
mid[0] = i3 + 1;
message32.id = i3;
this.eventId = event.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 (event.action.message != null) {
message2 = event.action.message;
}
if (message2 != null) {
}
if (this.contentType < 0) {
}
}
private String getUserName(TLRPC.User user, ArrayList<TLRPC.MessageEntity> entities, int offset) {
String name;
if (user == null) {
name = "";
} else {
String name2 = user.first_name;
name = ContactsController.formatName(name2, user.last_name);
}
if (offset >= 0) {
TLRPC.TL_messageEntityMentionName entity = new TLRPC.TL_messageEntityMentionName();
entity.user_id = user.id;
entity.offset = offset;
entity.length = name.length();
entities.add(entity);
}
if (TextUtils.isEmpty(user.username)) {
return name;
}
if (offset >= 0) {
TLRPC.TL_messageEntityMentionName entity2 = new TLRPC.TL_messageEntityMentionName();
entity2.user_id = user.id;
entity2.offset = name.length() + offset + 2;
entity2.length = user.username.length() + 1;
entities.add(entity2);
}
return String.format("%1$s (@%2$s)", name, user.username);
}
public void applyNewText() {
TextPaint paint;
if (TextUtils.isEmpty(this.messageOwner.message)) {
return;
}
TLRPC.User fromUser = null;
if (isFromUser()) {
fromUser = MessagesController.getInstance(this.currentAccount).getUser(Integer.valueOf(this.messageOwner.from_id));
}
this.messageText = this.messageOwner.message;
if (this.messageOwner.media instanceof TLRPC.TL_messageMediaGame) {
paint = Theme.chat_msgGameTextPaint;
} else {
paint = Theme.chat_msgTextPaint;
}
int[] emojiOnly = SharedConfig.allowBigEmoji ? new int[1] : null;
this.messageText = Emoji.replaceEmoji(this.messageText, paint.getFontMetricsInt(), AndroidUtilities.dp(20.0f), false, emojiOnly);
checkEmojiOnly(emojiOnly);
generateLayout(fromUser);
}
public void generateGameMessageText(TLRPC.User fromUser) {
if (fromUser == null && this.messageOwner.from_id > 0) {
fromUser = MessagesController.getInstance(this.currentAccount).getUser(Integer.valueOf(this.messageOwner.from_id));
}
TLRPC.TL_game game = null;
MessageObject messageObject = this.replyMessageObject;
if (messageObject != null && messageObject.messageOwner.media != null && this.replyMessageObject.messageOwner.media.game != null) {
game = this.replyMessageObject.messageOwner.media.game;
}
if (game == null) {
if (fromUser == null || fromUser.id != UserConfig.getInstance(this.currentAccount).getClientUserId()) {
this.messageText = replaceWithLink(LocaleController.formatString("ActionUserScored", R.string.ActionUserScored, LocaleController.formatPluralString("Points", this.messageOwner.action.score)), "un1", fromUser);
return;
} else {
this.messageText = LocaleController.formatString("ActionYouScored", R.string.ActionYouScored, LocaleController.formatPluralString("Points", this.messageOwner.action.score));
return;
}
}
if (fromUser == null || fromUser.id != UserConfig.getInstance(this.currentAccount).getClientUserId()) {
this.messageText = replaceWithLink(LocaleController.formatString("ActionUserScoredInGame", R.string.ActionUserScoredInGame, LocaleController.formatPluralString("Points", this.messageOwner.action.score)), "un1", fromUser);
} else {
this.messageText = LocaleController.formatString("ActionYouScoredInGame", R.string.ActionYouScoredInGame, LocaleController.formatPluralString("Points", this.messageOwner.action.score));
}
this.messageText = replaceWithLink(this.messageText, "un2", 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 fromUser) {
String name;
if (fromUser == null) {
fromUser = MessagesController.getInstance(this.currentAccount).getUser(Integer.valueOf((int) getDialogId()));
}
if (fromUser != null) {
name = UserObject.getFirstName(fromUser);
} else {
name = "";
}
MessageObject messageObject = this.replyMessageObject;
if (messageObject != null && (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaInvoice)) {
this.messageText = LocaleController.formatString("PaymentSuccessfullyPaid", R.string.PaymentSuccessfullyPaid, LocaleController.getInstance().formatCurrencyString(this.messageOwner.action.total_amount, this.messageOwner.action.currency), name, this.replyMessageObject.messageOwner.media.title);
} else {
this.messageText = LocaleController.formatString("PaymentSuccessfullyPaidNoItem", R.string.PaymentSuccessfullyPaidNoItem, LocaleController.getInstance().formatCurrencyString(this.messageOwner.action.total_amount, this.messageOwner.action.currency), name);
}
}
public void generatePinMessageText(TLRPC.User fromUser, TLRPC.Chat chat) {
if (fromUser == null && chat == 0) {
if (this.messageOwner.from_id > 0) {
fromUser = MessagesController.getInstance(this.currentAccount).getUser(Integer.valueOf(this.messageOwner.from_id));
}
if (fromUser == 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()) {
if (!this.replyMessageObject.isVideo()) {
if (!this.replyMessageObject.isGif()) {
if (!this.replyMessageObject.isVoice()) {
if (!this.replyMessageObject.isRoundVideo()) {
if (!this.replyMessageObject.isSticker() && !this.replyMessageObject.isAnimatedSticker()) {
if (!(this.replyMessageObject.messageOwner.media instanceof TLRPC.TL_messageMediaDocument)) {
if (!(this.replyMessageObject.messageOwner.media instanceof TLRPC.TL_messageMediaGeo)) {
if (!(this.replyMessageObject.messageOwner.media instanceof TLRPC.TL_messageMediaGeoLive)) {
if (!(this.replyMessageObject.messageOwner.media instanceof TLRPC.TL_messageMediaContact)) {
if (!(this.replyMessageObject.messageOwner.media instanceof TLRPC.TL_messageMediaPoll)) {
if (!(this.replyMessageObject.messageOwner.media instanceof TLRPC.TL_messageMediaPhoto)) {
if (this.replyMessageObject.messageOwner.media instanceof TLRPC.TL_messageMediaGame) {
CharSequence replaceWithLink = replaceWithLink(LocaleController.formatString("ActionPinnedGame", R.string.ActionPinnedGame, "🎮 " + this.replyMessageObject.messageOwner.media.game.title), "un1", fromUser != null ? fromUser : chat);
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 mess = this.replyMessageObject.messageText;
if (mess.length() > 20) {
mess = ((Object) mess.subSequence(0, 20)) + "...";
}
this.messageText = replaceWithLink(LocaleController.formatString("ActionPinnedText", R.string.ActionPinnedText, Emoji.replaceEmoji(mess, Theme.chat_msgTextPaint.getFontMetricsInt(), AndroidUtilities.dp(20.0f), false)), "un1", fromUser != null ? fromUser : chat);
return;
}
this.messageText = replaceWithLink(LocaleController.getString("ActionPinnedNoText", R.string.ActionPinnedNoText), "un1", fromUser != null ? fromUser : chat);
return;
}
this.messageText = replaceWithLink(LocaleController.getString("ActionPinnedPhoto", R.string.ActionPinnedPhoto), "un1", fromUser != null ? fromUser : chat);
return;
}
this.messageText = replaceWithLink(LocaleController.getString("ActionPinnedPoll", R.string.ActionPinnedPoll), "un1", fromUser != null ? fromUser : chat);
return;
}
this.messageText = replaceWithLink(LocaleController.getString("ActionPinnedContact", R.string.ActionPinnedContact), "un1", fromUser != null ? fromUser : chat);
return;
}
this.messageText = replaceWithLink(LocaleController.getString("ActionPinnedGeoLive", R.string.ActionPinnedGeoLive), "un1", fromUser != null ? fromUser : chat);
return;
}
this.messageText = replaceWithLink(LocaleController.getString("ActionPinnedGeo", R.string.ActionPinnedGeo), "un1", fromUser != null ? fromUser : chat);
return;
}
this.messageText = replaceWithLink(LocaleController.getString("ActionPinnedFile", R.string.ActionPinnedFile), "un1", fromUser != null ? fromUser : chat);
return;
}
this.messageText = replaceWithLink(LocaleController.getString("ActionPinnedSticker", R.string.ActionPinnedSticker), "un1", fromUser != null ? fromUser : chat);
return;
}
this.messageText = replaceWithLink(LocaleController.getString("ActionPinnedRound", R.string.ActionPinnedRound), "un1", fromUser != null ? fromUser : chat);
return;
}
this.messageText = replaceWithLink(LocaleController.getString("ActionPinnedVoice", R.string.ActionPinnedVoice), "un1", fromUser != null ? fromUser : chat);
return;
}
this.messageText = replaceWithLink(LocaleController.getString("ActionPinnedGif", R.string.ActionPinnedGif), "un1", fromUser != null ? fromUser : chat);
return;
}
this.messageText = replaceWithLink(LocaleController.getString("ActionPinnedVideo", R.string.ActionPinnedVideo), "un1", fromUser != null ? fromUser : chat);
return;
}
this.messageText = replaceWithLink(LocaleController.getString("ActionPinnedMusic", R.string.ActionPinnedMusic), "un1", fromUser != null ? fromUser : chat);
return;
}
}
this.messageText = replaceWithLink(LocaleController.getString("ActionPinnedNoText", R.string.ActionPinnedNoText), "un1", fromUser != null ? fromUser : chat);
}
public static void updateReactions(TLRPC.Message message, TLRPC.TL_messageReactions reactions) {
if (message == null || reactions == null) {
return;
}
if (reactions.min && message.reactions != null) {
int a = 0;
int N = message.reactions.results.size();
while (true) {
if (a >= N) {
break;
}
TLRPC.TL_reactionCount reaction = message.reactions.results.get(a);
if (!reaction.chosen) {
a++;
} else {
int b = 0;
int N2 = reactions.results.size();
while (true) {
if (b >= N2) {
break;
}
TLRPC.TL_reactionCount newReaction = reactions.results.get(b);
if (!reaction.reaction.equals(newReaction.reaction)) {
b++;
} else {
newReaction.chosen = true;
break;
}
}
}
}
}
message.reactions = reactions;
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 media, TLRPC.TL_pollResults results) {
if ((results.flags & 2) != 0) {
byte[] chosen = null;
if (results.min && media.results.results != null) {
int b = 0;
int N2 = media.results.results.size();
while (true) {
if (b >= N2) {
break;
}
TLRPC.TL_pollAnswerVoters answerVoters = media.results.results.get(b);
if (!answerVoters.chosen) {
b++;
} else {
chosen = answerVoters.option;
break;
}
}
}
media.results.results = results.results;
if (chosen != null) {
int b2 = 0;
int N22 = media.results.results.size();
while (true) {
if (b2 >= N22) {
break;
}
TLRPC.TL_pollAnswerVoters answerVoters2 = media.results.results.get(b2);
if (!Arrays.equals(answerVoters2.option, chosen)) {
b2++;
} else {
answerVoters2.chosen = true;
break;
}
}
}
media.results.flags |= 2;
}
if ((results.flags & 4) != 0) {
media.results.total_voters = results.total_voters;
media.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 mediaPoll = (TLRPC.TL_messageMediaPoll) this.messageOwner.media;
if (mediaPoll.results == null || mediaPoll.results.results.isEmpty()) {
return false;
}
int N = mediaPoll.results.results.size();
for (int a = 0; a < N; a++) {
TLRPC.TL_pollAnswerVoters answer = mediaPoll.results.results.get(a);
if (answer.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 id) {
if (webPage == null || webPage.cached_page == null) {
return null;
}
if (webPage.photo != null && webPage.photo.id == id) {
return webPage.photo;
}
for (int a = 0; a < webPage.cached_page.photos.size(); a++) {
TLRPC.Photo photo = webPage.cached_page.photos.get(a);
if (photo.id == id) {
return photo;
}
}
return null;
}
private TLRPC.Document getDocumentWithId(TLRPC.WebPage webPage, long id) {
if (webPage == null || webPage.cached_page == null) {
return null;
}
if (webPage.document != null && webPage.document.id == id) {
return webPage.document;
}
for (int a = 0; a < webPage.cached_page.documents.size(); a++) {
TLRPC.Document document = webPage.cached_page.documents.get(a);
if (document.id == id) {
return document;
}
}
return null;
}
private MessageObject getMessageObjectForBlock(TLRPC.WebPage webPage, TLRPC.PageBlock pageBlock) {
TLRPC.TL_message message = null;
if (pageBlock instanceof TLRPC.TL_pageBlockPhoto) {
TLRPC.TL_pageBlockPhoto pageBlockPhoto = (TLRPC.TL_pageBlockPhoto) pageBlock;
TLRPC.Photo photo = getPhotoWithId(webPage, pageBlockPhoto.photo_id);
if (photo == webPage.photo) {
return this;
}
message = new TLRPC.TL_message();
message.media = new TLRPC.TL_messageMediaPhoto();
message.media.photo = photo;
} else if (pageBlock instanceof TLRPC.TL_pageBlockVideo) {
TLRPC.TL_pageBlockVideo pageBlockVideo = (TLRPC.TL_pageBlockVideo) pageBlock;
TLRPC.Document document = getDocumentWithId(webPage, pageBlockVideo.video_id);
if (document == webPage.document) {
return this;
}
message = new TLRPC.TL_message();
message.media = new TLRPC.TL_messageMediaDocument();
message.media.document = getDocumentWithId(webPage, pageBlockVideo.video_id);
}
message.message = "";
message.realId = getId();
message.id = Utilities.random.nextInt();
message.date = this.messageOwner.date;
message.to_id = this.messageOwner.to_id;
message.out = this.messageOwner.out;
message.from_id = this.messageOwner.from_id;
return new MessageObject(this.currentAccount, message, false);
}
public ArrayList<MessageObject> getWebPagePhotos(ArrayList<MessageObject> array, ArrayList<TLRPC.PageBlock> blocksToSearch) {
ArrayList<MessageObject> messageObjects = array == null ? new ArrayList<>() : array;
if (this.messageOwner.media == null || this.messageOwner.media.webpage == null) {
return messageObjects;
}
TLRPC.WebPage webPage = this.messageOwner.media.webpage;
if (webPage.cached_page == null) {
return messageObjects;
}
ArrayList<TLRPC.PageBlock> blocks = blocksToSearch == null ? webPage.cached_page.blocks : blocksToSearch;
for (int a = 0; a < blocks.size(); a++) {
TLRPC.PageBlock block = blocks.get(a);
if (block instanceof TLRPC.TL_pageBlockSlideshow) {
TLRPC.TL_pageBlockSlideshow slideshow = (TLRPC.TL_pageBlockSlideshow) block;
for (int b = 0; b < slideshow.items.size(); b++) {
messageObjects.add(getMessageObjectForBlock(webPage, slideshow.items.get(b)));
}
} else if (block instanceof TLRPC.TL_pageBlockCollage) {
TLRPC.TL_pageBlockCollage slideshow2 = (TLRPC.TL_pageBlockCollage) block;
for (int b2 = 0; b2 < slideshow2.items.size(); b2++) {
messageObjects.add(getMessageObjectForBlock(webPage, slideshow2.items.get(b2)));
}
}
}
return messageObjects;
}
public void createMessageSendInfo() {
String param;
if (this.messageOwner.message != null) {
if ((this.messageOwner.id < 0 || isEditing()) && this.messageOwner.params != null) {
String param2 = this.messageOwner.params.get("ve");
if (param2 != null && (isVideo() || isNewGif() || isRoundVideo())) {
VideoEditedInfo videoEditedInfo = new VideoEditedInfo();
this.videoEditedInfo = videoEditedInfo;
if (!videoEditedInfo.parseString(param2)) {
this.videoEditedInfo = null;
} else {
this.videoEditedInfo.roundVideo = isRoundVideo();
}
}
if (this.messageOwner.send_state == 3 && (param = this.messageOwner.params.get("prevMedia")) != null) {
SerializedData serializedData = new SerializedData(Base64.decode(param, 0));
int constructor = serializedData.readInt32(false);
this.previousMedia = TLRPC.MessageMedia.TLdeserialize(serializedData, constructor, false);
this.previousCaption = serializedData.readString(false);
this.previousAttachPath = serializedData.readString(false);
int count = serializedData.readInt32(false);
this.previousCaptionEntities = new ArrayList<>(count);
for (int a = 0; a < count; a++) {
int constructor2 = serializedData.readInt32(false);
TLRPC.MessageEntity entity = TLRPC.MessageEntity.TLdeserialize(serializedData, constructor2, false);
this.previousCaptionEntities.add(entity);
}
serializedData.cleanup();
}
}
}
}
public void measureInlineBotButtons() {
CharSequence text;
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);
}
}
float f = 2000.0f;
float f2 = 15.0f;
if (this.messageOwner.reply_markup instanceof TLRPC.TL_replyInlineMarkup) {
int a = 0;
while (a < this.messageOwner.reply_markup.rows.size()) {
TLRPC.TL_keyboardButtonRow row = this.messageOwner.reply_markup.rows.get(a);
int maxButtonSize = 0;
int size = row.buttons.size();
int b = 0;
while (b < size) {
TLRPC.KeyboardButton button = row.buttons.get(b);
StringBuilder sb2 = this.botButtonsLayout;
sb2.append(a);
sb2.append(b);
if ((button instanceof TLRPC.TL_keyboardButtonBuy) && (this.messageOwner.media.flags & 4) != 0) {
text = LocaleController.getString("PaymentReceipt", R.string.PaymentReceipt);
} else {
CharSequence text2 = button.text;
text = Emoji.replaceEmoji(text2, Theme.chat_msgBotButtonPaint.getFontMetricsInt(), AndroidUtilities.dp(f2), false);
}
StaticLayout staticLayout = new StaticLayout(text, Theme.chat_msgBotButtonPaint, AndroidUtilities.dp(f), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
if (staticLayout.getLineCount() > 0) {
float width = staticLayout.getLineWidth(0);
float left = staticLayout.getLineLeft(0);
if (left < width) {
width -= left;
}
maxButtonSize = Math.max(maxButtonSize, ((int) Math.ceil(width)) + AndroidUtilities.dp(4.0f));
}
b++;
f = 2000.0f;
f2 = 15.0f;
}
this.wantedBotKeyboardWidth = Math.max(this.wantedBotKeyboardWidth, ((AndroidUtilities.dp(12.0f) + maxButtonSize) * size) + (AndroidUtilities.dp(5.0f) * (size - 1)));
a++;
f = 2000.0f;
f2 = 15.0f;
}
return;
}
if (this.messageOwner.reactions != null) {
int size2 = this.messageOwner.reactions.results.size();
for (int a2 = 0; a2 < size2; a2++) {
TLRPC.TL_reactionCount reactionCount = this.messageOwner.reactions.results.get(a2);
int maxButtonSize2 = 0;
StringBuilder sb3 = this.botButtonsLayout;
sb3.append(0);
sb3.append(a2);
CharSequence text3 = Emoji.replaceEmoji(String.format("%d %s", Integer.valueOf(reactionCount.count), reactionCount.reaction), Theme.chat_msgBotButtonPaint.getFontMetricsInt(), AndroidUtilities.dp(15.0f), false);
StaticLayout staticLayout2 = new StaticLayout(text3, Theme.chat_msgBotButtonPaint, AndroidUtilities.dp(2000.0f), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
if (staticLayout2.getLineCount() > 0) {
float width2 = staticLayout2.getLineWidth(0);
float left2 = staticLayout2.getLineLeft(0);
if (left2 < width2) {
width2 -= left2;
}
maxButtonSize2 = Math.max(0, ((int) Math.ceil(width2)) + AndroidUtilities.dp(4.0f));
}
this.wantedBotKeyboardWidth = Math.max(this.wantedBotKeyboardWidth, ((AndroidUtilities.dp(12.0f) + maxButtonSize2) * 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 data) {
if (NumberUtil.isNumber(data)) {
if (data.contains(".")) {
String[] split = data.split("\\.");
String number1 = split[0];
String number2 = split[1];
String res = MoneyUtil.formatToString(new BigDecimal(String.valueOf(number1)).multiply(new BigDecimal("1")).toString(), 0);
if (number2.length() > 8) {
number2 = number2.substring(0, 8);
}
return res + "." + number2;
}
String res2 = MoneyUtil.formatToString(new BigDecimal(String.valueOf(data)).multiply(new BigDecimal("1")).toString(), 0);
return res2;
}
return "";
}
private void updateMessageText(AbstractMap<Integer, TLRPC.User> users, AbstractMap<Integer, TLRPC.Chat> chats, SparseArray<TLRPC.User> sUsers, SparseArray<TLRPC.Chat> sChats) {
TLRPC.User fromUser;
TLRPC.User user;
String commodity;
char c;
String duration;
String _messageText;
int start;
TLRPC.Chat chat;
int singleUserId;
int status;
TLRPC.User fromUser2 = null;
if (this.messageOwner.from_id <= 0) {
fromUser = null;
} else {
if (users != null) {
TLRPC.User fromUser3 = users.get(Integer.valueOf(this.messageOwner.from_id));
fromUser2 = fromUser3;
} else if (sUsers != null) {
TLRPC.User fromUser4 = sUsers.get(this.messageOwner.from_id);
fromUser2 = fromUser4;
}
if (fromUser2 == null) {
TLRPC.User fromUser5 = MessagesController.getInstance(this.currentAccount).getUser(Integer.valueOf(this.messageOwner.from_id));
fromUser = fromUser5;
} else {
fromUser = fromUser2;
}
}
int i = this.messageOwner.from_id;
TLRPC.Message message = this.messageOwner;
if (message instanceof TLRPC.TL_messageService) {
if (message.action != null) {
if (!(this.messageOwner.action instanceof TLRPCRedpacket.CL_messagesActionReceivedRpkTransfer)) {
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", fromUser);
}
} 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", fromUser);
}
} else {
TLObject whoUser = null;
if (users != null) {
TLObject whoUser2 = users.get(Integer.valueOf(this.messageOwner.action.user_id));
whoUser = (TLRPC.User) whoUser2;
} else if (sUsers != null) {
TLObject whoUser3 = sUsers.get(this.messageOwner.action.user_id);
whoUser = (TLRPC.User) whoUser3;
}
if (whoUser == null) {
whoUser = MessagesController.getInstance(this.currentAccount).getUser(Integer.valueOf(this.messageOwner.action.user_id));
}
if (isOut()) {
this.messageText = replaceWithLink(LocaleController.getString("ActionYouKickUser", R.string.ActionYouKickUser), "un2", whoUser);
} else if (this.messageOwner.action.user_id == UserConfig.getInstance(this.currentAccount).getClientUserId()) {
this.messageText = replaceWithLink(LocaleController.getString("ActionKickUserYou", R.string.ActionKickUserYou), "un1", fromUser);
} else {
CharSequence replaceWithLink = replaceWithLink(LocaleController.getString("ActionKickUser", R.string.ActionKickUser), "un2", whoUser);
this.messageText = replaceWithLink;
this.messageText = replaceWithLink(replaceWithLink, "un1", fromUser);
}
}
} else if (!(this.messageOwner.action instanceof TLRPC.TL_messageActionChatAddUser)) {
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", fromUser);
}
} 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", fromUser);
}
} 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", fromUser);
}
} 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", fromUser);
}
} 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(fromUser), 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(fromUser));
}
} else if (!(this.messageOwner.action instanceof TLRPC.TL_messageActionLoginUnknownLocation)) {
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(fromUser));
} else if (this.messageOwner.action instanceof TLRPC.TL_messageActionUserUpdatedPhoto) {
this.messageText = LocaleController.formatString("NotificationContactNewPhoto", R.string.NotificationContactNewPhoto, UserObject.getName(fromUser));
} 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", fromUser);
}
} else if (this.messageOwner.action.encryptedAction instanceof TLRPC.TL_decryptedMessageActionSetMessageTTL) {
TLRPC.TL_decryptedMessageActionSetMessageTTL action = (TLRPC.TL_decryptedMessageActionSetMessageTTL) this.messageOwner.action.encryptedAction;
if (action.ttl_seconds != 0) {
if (isOut()) {
this.messageText = LocaleController.formatString("MessageLifetimeChangedOutgoing", R.string.MessageLifetimeChangedOutgoing, LocaleController.formatTTLString(action.ttl_seconds));
} else {
this.messageText = LocaleController.formatString("MessageLifetimeChanged", R.string.MessageLifetimeChanged, UserObject.getFirstName(fromUser), LocaleController.formatTTLString(action.ttl_seconds));
}
} else if (isOut()) {
this.messageText = LocaleController.getString("MessageLifetimeYouRemoved", R.string.MessageLifetimeYouRemoved);
} else {
this.messageText = LocaleController.formatString("MessageLifetimeRemoved", R.string.MessageLifetimeRemoved, UserObject.getFirstName(fromUser));
}
}
} 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", fromUser);
}
} 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 (!(this.messageOwner.action instanceof TLRPC.TL_messageActionLiveStart_layer105)) {
if (!(this.messageOwner.action instanceof TLRPC.TL_messageActionLiveStop_layer105)) {
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(fromUser);
} else if (!(this.messageOwner.action instanceof TLRPC.TL_messageActionPhoneCall)) {
if (!(this.messageOwner.action instanceof TLRPC.TL_messageActionPaymentSent)) {
if (this.messageOwner.action instanceof TLRPC.TL_messageActionBotAllowed) {
String domain = ((TLRPC.TL_messageActionBotAllowed) this.messageOwner.action).domain;
String text = LocaleController.getString("ActionBotAllowed", R.string.ActionBotAllowed);
int start2 = text.indexOf("%1$s");
SpannableString str = new SpannableString(String.format(text, domain));
if (start2 >= 0) {
str.setSpan(new URLSpanNoUnderlineBold("http://" + domain), start2, domain.length() + start2, 33);
}
this.messageText = str;
} else if (this.messageOwner.action instanceof TLRPC.TL_messageActionSecureValuesSent) {
TLRPC.TL_messageActionSecureValuesSent valuesSent = (TLRPC.TL_messageActionSecureValuesSent) this.messageOwner.action;
StringBuilder str2 = new StringBuilder();
int size = valuesSent.types.size();
for (int a = 0; a < size; a++) {
TLRPC.SecureValueType type = valuesSent.types.get(a);
if (str2.length() > 0) {
str2.append(", ");
}
if (type instanceof TLRPC.TL_secureValueTypePhone) {
str2.append(LocaleController.getString("ActionBotDocumentPhone", R.string.ActionBotDocumentPhone));
} else if (type instanceof TLRPC.TL_secureValueTypeEmail) {
str2.append(LocaleController.getString("ActionBotDocumentEmail", R.string.ActionBotDocumentEmail));
} else if (type instanceof TLRPC.TL_secureValueTypeAddress) {
str2.append(LocaleController.getString("ActionBotDocumentAddress", R.string.ActionBotDocumentAddress));
} else if (type instanceof TLRPC.TL_secureValueTypePersonalDetails) {
str2.append(LocaleController.getString("ActionBotDocumentIdentity", R.string.ActionBotDocumentIdentity));
} else if (type instanceof TLRPC.TL_secureValueTypePassport) {
str2.append(LocaleController.getString("ActionBotDocumentPassport", R.string.ActionBotDocumentPassport));
} else if (type instanceof TLRPC.TL_secureValueTypeDriverLicense) {
str2.append(LocaleController.getString("ActionBotDocumentDriverLicence", R.string.ActionBotDocumentDriverLicence));
} else if (type instanceof TLRPC.TL_secureValueTypeIdentityCard) {
str2.append(LocaleController.getString("ActionBotDocumentIdentityCard", R.string.ActionBotDocumentIdentityCard));
} else if (type instanceof TLRPC.TL_secureValueTypeUtilityBill) {
str2.append(LocaleController.getString("ActionBotDocumentUtilityBill", R.string.ActionBotDocumentUtilityBill));
} else if (type instanceof TLRPC.TL_secureValueTypeBankStatement) {
str2.append(LocaleController.getString("ActionBotDocumentBankStatement", R.string.ActionBotDocumentBankStatement));
} else if (type instanceof TLRPC.TL_secureValueTypeRentalAgreement) {
str2.append(LocaleController.getString("ActionBotDocumentRentalAgreement", R.string.ActionBotDocumentRentalAgreement));
} else if (type instanceof TLRPC.TL_secureValueTypeInternalPassport) {
str2.append(LocaleController.getString("ActionBotDocumentInternalPassport", R.string.ActionBotDocumentInternalPassport));
} else if (type instanceof TLRPC.TL_secureValueTypePassportRegistration) {
str2.append(LocaleController.getString("ActionBotDocumentPassportRegistration", R.string.ActionBotDocumentPassportRegistration));
} else if (type instanceof TLRPC.TL_secureValueTypeTemporaryRegistration) {
str2.append(LocaleController.getString("ActionBotDocumentTemporaryRegistration", R.string.ActionBotDocumentTemporaryRegistration));
}
}
TLRPC.User user2 = null;
if (this.messageOwner.to_id != null) {
if (users != null) {
user2 = users.get(Integer.valueOf(this.messageOwner.to_id.user_id));
} else if (sUsers != null) {
user2 = sUsers.get(this.messageOwner.to_id.user_id);
}
if (user2 == null) {
user2 = MessagesController.getInstance(this.currentAccount).getUser(Integer.valueOf(this.messageOwner.to_id.user_id));
}
}
this.messageText = LocaleController.formatString("ActionBotDocuments", R.string.ActionBotDocuments, UserObject.getFirstName(user2), str2.toString());
}
} else {
TLRPC.User user3 = null;
int uid = (int) getDialogId();
if (users != null) {
user3 = users.get(Integer.valueOf(uid));
} else if (sUsers != null) {
user3 = sUsers.get(uid);
}
if (user3 == null) {
user3 = MessagesController.getInstance(this.currentAccount).getUser(Integer.valueOf(uid));
}
generatePaymentSentMessageText(user3);
}
} else {
TLRPC.TL_messageActionPhoneCall call = (TLRPC.TL_messageActionPhoneCall) this.messageOwner.action;
boolean isMissed = call.reason instanceof TLRPC.TL_phoneCallDiscardReasonMissed;
if (this.messageOwner.from_id == UserConfig.getInstance(this.currentAccount).getClientUserId()) {
if (isMissed) {
this.messageText = LocaleController.getString("CallMessageOutgoingMissed", R.string.CallMessageOutgoingMissed);
} else {
this.messageText = LocaleController.getString("CallMessageOutgoing", R.string.CallMessageOutgoing);
}
} else if (isMissed) {
this.messageText = LocaleController.getString("CallMessageIncomingMissed", R.string.CallMessageIncomingMissed);
} else if (call.reason instanceof TLRPC.TL_phoneCallDiscardReasonBusy) {
this.messageText = LocaleController.getString("CallMessageIncomingDeclined", R.string.CallMessageIncomingDeclined);
} else {
this.messageText = LocaleController.getString("CallMessageIncoming", R.string.CallMessageIncoming);
}
if ((call.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 (call.duration > 0 && (start = (_messageText = this.messageText.toString()).indexOf((duration = LocaleController.formatCallDuration(call.duration)))) != -1) {
SpannableString sp = new SpannableString(this.messageText);
int end = duration.length() + start;
if (start > 0 && _messageText.charAt(start - 1) == '(') {
start--;
}
if (end < _messageText.length() && _messageText.charAt(end) == ')') {
end++;
}
sp.setSpan(new TypefaceSpan(Typeface.DEFAULT), start, end, 0);
this.messageText = sp;
}
}
} else {
TLRPC.TL_messageActionLiveStop_layer105 LiveEnd = (TLRPC.TL_messageActionLiveStop_layer105) this.messageOwner.action;
this.messageText = LocaleController.getString(R.string.live_end_live) + ": " + LiveEnd.live_name;
}
} else {
TLRPC.TL_messageActionLiveStart_layer105 LiveStart = (TLRPC.TL_messageActionLiveStart_layer105) this.messageOwner.action;
TLRPC.User user4 = MessagesController.getInstance(this.currentAccount).getUser(Integer.valueOf(LiveStart.live_user));
if (user4 != null) {
StringBuilder sb = new StringBuilder();
sb.append(user4.first_name.length() > 6 ? user4.first_name.substring(0, 6) + "..." : user4.first_name);
sb.append(LocaleController.getString(R.string.live_start_live));
sb.append(": ");
sb.append(LiveStart.live_name);
this.messageText = sb.toString();
}
}
} else {
if (fromUser == null) {
if (chats != null) {
chat = chats.get(Integer.valueOf(this.messageOwner.to_id.channel_id));
} else if (sChats != null) {
chat = sChats.get(this.messageOwner.to_id.channel_id);
} else {
chat = null;
}
} else {
chat = null;
}
generatePinMessageText(fromUser, chat);
}
} else {
long time = this.messageOwner.date * 1000;
String date = (LocaleController.getInstance().formatterDay != null && LocaleController.getInstance().formatterYear != null) ? LocaleController.formatString("formatDateAtTime", R.string.formatDateAtTime, LocaleController.getInstance().formatterYear.format(time), LocaleController.getInstance().formatterDay.format(time)) : "" + this.messageOwner.date;
TLRPC.User to_user = UserConfig.getInstance(this.currentAccount).getCurrentUser();
if (to_user == null) {
if (users != null) {
to_user = users.get(Integer.valueOf(this.messageOwner.to_id.user_id));
} else if (sUsers != null) {
to_user = sUsers.get(this.messageOwner.to_id.user_id);
}
if (to_user == null) {
to_user = MessagesController.getInstance(this.currentAccount).getUser(Integer.valueOf(this.messageOwner.to_id.user_id));
}
}
this.messageText = LocaleController.formatString("NotificationUnrecognizedDevice", R.string.NotificationUnrecognizedDevice, to_user != null ? UserObject.getFirstName(to_user) : "", date, this.messageOwner.action.title, this.messageOwner.action.address);
}
} else {
int singleUserId2 = this.messageOwner.action.user_id;
if (singleUserId2 == 0 && this.messageOwner.action.users.size() == 1) {
singleUserId = this.messageOwner.action.users.get(0).intValue();
} else {
singleUserId = singleUserId2;
}
if (singleUserId != 0) {
TLObject whoUser4 = null;
if (users != null) {
TLObject whoUser5 = users.get(Integer.valueOf(singleUserId));
whoUser4 = (TLRPC.User) whoUser5;
} else if (sUsers != null) {
TLObject whoUser6 = sUsers.get(singleUserId);
whoUser4 = (TLRPC.User) whoUser6;
}
if (whoUser4 == null) {
whoUser4 = MessagesController.getInstance(this.currentAccount).getUser(Integer.valueOf(singleUserId));
}
if (singleUserId == 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 (singleUserId == UserConfig.getInstance(this.currentAccount).getClientUserId()) {
this.messageText = LocaleController.getString("ChannelMegaJoined", R.string.ChannelMegaJoined);
} else {
this.messageText = replaceWithLink(LocaleController.getString("ActionAddUserSelfMega", R.string.ActionAddUserSelfMega), "un1", fromUser);
}
} else if (isOut()) {
this.messageText = LocaleController.getString("ActionAddUserSelfYou", R.string.ActionAddUserSelfYou);
} else {
this.messageText = replaceWithLink(LocaleController.getString("ActionAddUserSelf", R.string.ActionAddUserSelf), "un1", fromUser);
}
} else if (isOut()) {
this.messageText = replaceWithLink(LocaleController.getString("ActionYouAddUser", R.string.ActionYouAddUser), "un2", whoUser4);
} else if (singleUserId != UserConfig.getInstance(this.currentAccount).getClientUserId()) {
CharSequence replaceWithLink2 = replaceWithLink(LocaleController.getString("ActionAddUser", R.string.ActionAddUser), "un2", whoUser4);
this.messageText = replaceWithLink2;
this.messageText = replaceWithLink(replaceWithLink2, "un1", fromUser);
} else if (this.messageOwner.to_id.channel_id == 0) {
this.messageText = replaceWithLink(LocaleController.getString("ActionAddUserYou", R.string.ActionAddUserYou), "un1", fromUser);
} else if (isMegagroup()) {
this.messageText = replaceWithLink(LocaleController.getString("MegaAddedBy", R.string.MegaAddedBy), "un1", fromUser);
} else {
this.messageText = replaceWithLink(LocaleController.getString("ChannelAddedBy", R.string.ChannelAddedBy), "un1", fromUser);
}
} else if (isOut()) {
this.messageText = replaceWithLink(LocaleController.getString("ActionYouAddUser", R.string.ActionYouAddUser), "un2", this.messageOwner.action.users, users, sUsers);
} else {
CharSequence replaceWithLink3 = replaceWithLink(LocaleController.getString("ActionAddUser", R.string.ActionAddUser), "un2", this.messageOwner.action.users, users, sUsers);
this.messageText = replaceWithLink3;
this.messageText = replaceWithLink(replaceWithLink3, "un1", fromUser);
}
}
} else {
TLRPCRedpacket.CL_messagesActionReceivedRpkTransfer redAction = (TLRPCRedpacket.CL_messagesActionReceivedRpkTransfer) this.messageOwner.action;
MessagesController.getInstance(this.currentAccount).getUser(Integer.valueOf(redAction.receiver.user_id));
TLRPC.User sender = MessagesController.getInstance(this.currentAccount).getUser(Integer.valueOf(redAction.sender.user_id));
TLApiModel<RedpacketResponse> parse = TLJsonResolve.parse(redAction.data, (Class<?>) RedpacketResponse.class);
RedpacketResponse bean = parse.model;
if (fromUser != null) {
if (redAction.sender.user_id == UserConfig.getInstance(UserConfig.selectedAccount).clientUserId && bean != null && bean.getRed() != null && !TextUtils.isEmpty(bean.getRed().getStatus()) && isFromChat()) {
int status2 = Integer.parseInt(bean.getRed().getStatus());
status = status2;
} else {
status = -1;
}
if (isOut()) {
CharSequence replaceRedStrWithLink = replaceRedStrWithLink(LocaleController.getString(R.string.YouReceivedPacketFrom), "un", sender, true);
this.messageText = replaceRedStrWithLink;
this.messageText = replaceRedStrWithLink(replaceRedStrWithLink, "rpk", sender, status, new ClickableSpan() {
@Override
public void onClick(View widget) {
if (MessageObject.this.delegate != null) {
MessageObject.this.delegate.onClickRed();
}
}
@Override
public void updateDrawState(TextPaint ds) {
ds.setUnderlineText(false);
}
});
} else if (sender == null || sender.id != UserConfig.getInstance(UserConfig.selectedAccount).clientUserId) {
CharSequence replaceRedStrWithLink2 = replaceRedStrWithLink(LocaleController.getString(R.string.WhoReceivedFromWho), "un1", fromUser, true);
this.messageText = replaceRedStrWithLink2;
CharSequence replaceRedStrWithLink3 = replaceRedStrWithLink(replaceRedStrWithLink2, "un2", sender, true);
this.messageText = replaceRedStrWithLink3;
this.messageText = replaceRedStrWithLink(replaceRedStrWithLink3, "rpk", sender, status, new ClickableSpan() {
@Override
public void onClick(View widget) {
if (MessageObject.this.delegate != null) {
MessageObject.this.delegate.onClickRed();
}
}
@Override
public void updateDrawState(TextPaint ds) {
ds.setUnderlineText(false);
}
});
} else {
CharSequence replaceRedStrWithLink4 = replaceRedStrWithLink(LocaleController.getString(R.string.WhoReceivedPacketFromYou), "un", fromUser, true);
this.messageText = replaceRedStrWithLink4;
this.messageText = replaceRedStrWithLink(replaceRedStrWithLink4, "rpk", fromUser, status, new ClickableSpan() {
@Override
public void onClick(View widget) {
if (MessageObject.this.delegate != null) {
MessageObject.this.delegate.onClickRed();
}
}
@Override
public void updateDrawState(TextPaint ds) {
ds.setUnderlineText(false);
}
});
}
}
}
}
} else {
this.isRestrictedMessage = false;
String restrictionReason = MessagesController.getRestrictionReason(message.restriction_reason);
if (!TextUtils.isEmpty(restrictionReason)) {
this.messageText = restrictionReason;
this.isRestrictedMessage = true;
} else if (isMediaEmpty()) {
this.messageText = this.messageOwner.message;
} else 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("AttachPhoto", R.string.AttachPhoto);
} else {
this.messageText = LocaleController.getString("AttachDestructingPhoto", R.string.AttachDestructingPhoto);
}
} else {
if (!isVideo() && (!(this.messageOwner.media instanceof TLRPC.TL_messageMediaDocument) || !(getDocument() instanceof TLRPC.TL_documentEmpty) || this.messageOwner.media.ttl_seconds == 0)) {
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)) {
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 sch = getStrickerChar();
if (sch == null || sch.length() <= 0) {
this.messageText = LocaleController.getString("AttachSticker", R.string.AttachSticker);
} else {
this.messageText = String.format("%s %s", sch, 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 name = FileLoader.getDocumentFileName(getDocument());
if (name == null || name.length() <= 0) {
this.messageText = LocaleController.getString("AttachDocument", R.string.AttachDocument);
} else {
this.messageText = name;
}
}
} else if (!(this.messageOwner.media instanceof TLRPCRedpacket.CL_messagesPayBillOverMedia)) {
if (!(this.messageOwner.media instanceof TLRPCRedpacket.CL_messagesRpkTransferMedia)) {
if (this.messageOwner.media instanceof TLRPC.TL_messageMediaShareContact) {
TLRPC.TL_messageMediaShareContact shareContact = (TLRPC.TL_messageMediaShareContact) this.messageOwner.media;
TLRPC.User user5 = MessagesController.getInstance(this.currentAccount).getUser(Integer.valueOf(shareContact.user_id));
if (user5 != null) {
if (isOutOwner()) {
this.messageText = String.format(LocaleController.getString(R.string.share_contact_recomment) + "%s", user5.first_name);
} else {
this.messageText = String.format(LocaleController.getString(R.string.share_contact_recomment_to_you) + "%s", user5.first_name);
}
} else if (users != null && (user = users.get(Integer.valueOf(shareContact.user_id))) != null) {
if (isOutOwner()) {
this.messageText = String.format(LocaleController.getString(R.string.share_contact_recomment) + "%s", user.first_name);
} else {
this.messageText = String.format(LocaleController.getString(R.string.share_contact_recomment_to_you) + "%s", user.first_name);
}
}
} else {
boolean z = this.messageOwner.media instanceof TLRPC.TL_messageMediaShare;
}
} else {
TLRPCRedpacket.CL_messagesRpkTransferMedia media = (TLRPCRedpacket.CL_messagesRpkTransferMedia) this.messageOwner.media;
if (media.trans == 0) {
RedpacketResponse bean2 = null;
if (media.data != null) {
TLApiModel<RedpacketResponse> parse2 = TLJsonResolve.parse(media.data, (Class<?>) RedpacketResponse.class);
RedpacketResponse bean3 = parse2.model;
bean2 = bean3;
}
if (bean2 == null) {
this.messageText = LocaleController.getString(R.string.RedPacketMessage);
} else {
RedpacketBean red = bean2.getRed();
StringBuilder sb2 = new StringBuilder();
sb2.append(LocaleController.getString(R.string.RedPacketRemarks));
sb2.append(TextUtils.isEmpty(red.getRemarks()) ? LocaleController.getString("redpacket_greetings_tip", R.string.redpacket_greetings_tip) : red.getRemarks());
this.messageText = sb2.toString();
}
} else if (media.trans == 1 || media.trans == 2) {
TransferResponse bean4 = null;
if (media.data != null) {
TLApiModel<TransferResponse> parse3 = TLJsonResolve.parse(media.data, (Class<?>) TransferResponse.class);
TransferResponse bean5 = parse3.model;
bean4 = bean5;
}
if (bean4 == null) {
this.messageText = LocaleController.getString(R.string.TransferMessages);
} else {
TransferResponse.Status state = bean4.getState();
if (isOutOwner()) {
if (state == TransferResponse.Status.WAITING) {
this.messageText = LocaleController.getString(R.string.TransferWaitingOtherCollect);
} else if (state == TransferResponse.Status.RECEIVED) {
int sender_id = bean4.getInitiatorUserIdInt();
if (sender_id == UserConfig.getInstance(UserConfig.selectedAccount).clientUserId) {
this.messageText = LocaleController.getString(R.string.TransferOtherHasCollected);
} else {
this.messageText = LocaleController.getString(R.string.YouHaveConfirmedReceipt);
}
} else if (state == TransferResponse.Status.REFUSED) {
int sender_id2 = bean4.getInitiatorUserIdInt();
if (sender_id2 == UserConfig.getInstance(UserConfig.selectedAccount).clientUserId) {
this.messageText = LocaleController.getString(R.string.TransferHasBeenReturned);
} else {
this.messageText = LocaleController.getString(R.string.YouHaveReturned);
}
} else if (state == TransferResponse.Status.TIMEOUT) {
this.messageText = LocaleController.getString(R.string.TransferHasReturned);
}
} else if (state == TransferResponse.Status.WAITING) {
this.messageText = LocaleController.getString(R.string.TransferPleaseConfirmReceipt);
} else if (state == TransferResponse.Status.RECEIVED) {
int sender_id3 = bean4.getInitiatorUserIdInt();
if (sender_id3 == UserConfig.getInstance(UserConfig.selectedAccount).clientUserId) {
this.messageText = LocaleController.getString(R.string.TransferOtherHasCollected);
} else {
this.messageText = LocaleController.getString(R.string.YouHaveConfirmedReceipt);
}
} else if (state == TransferResponse.Status.REFUSED) {
int sender_id4 = bean4.getInitiatorUserIdInt();
if (sender_id4 == UserConfig.getInstance(UserConfig.selectedAccount).clientUserId) {
this.messageText = LocaleController.getString(R.string.TransferHasBeenReturned);
} else {
this.messageText = LocaleController.getString(R.string.YouHaveReturned);
}
} else if (state == TransferResponse.Status.TIMEOUT) {
this.messageText = LocaleController.getString(R.string.TransferHasReturned);
}
}
}
}
} else {
TLRPCRedpacket.CL_messagesPayBillOverMedia media2 = (TLRPCRedpacket.CL_messagesPayBillOverMedia) this.messageOwner.media;
String data = TLJsonResolve.getData(media2.data);
PayBillOverBean bean6 = (PayBillOverBean) GsonUtils.fromJson(data, PayBillOverBean.class);
String message2 = "";
if (bean6.coin_code.contains("-")) {
String[] split = bean6.coin_code.split("-");
commodity = split[0];
} else {
commodity = bean6.coin_code;
}
switch (media2.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(bean6.deal_amount) ? "0" : bean6.deal_amount);
sb3.append(LocaleController.getString("PayBillA", R.string.PayBillA));
sb3.append(commodity);
sb3.append(LocaleController.getString("PayBillClickToView", R.string.PayBillClickToView));
message2 = sb3.toString();
break;
case 2:
case 7:
StringBuilder sb4 = new StringBuilder();
sb4.append(LocaleController.getString("PayBillRogerThat", R.string.PayBillRogerThat));
sb4.append(TextUtils.isEmpty(bean6.deal_amount) ? "0" : bean6.deal_amount);
sb4.append(LocaleController.getString("PayBillA", R.string.PayBillA));
sb4.append(commodity);
sb4.append(LocaleController.getString("PayBillTransferInView", R.string.PayBillTransferInView));
message2 = sb4.toString();
break;
case 5:
StringBuilder sb5 = new StringBuilder();
sb5.append(LocaleController.getString("PayBillRogerThat", R.string.PayBillRogerThat));
sb5.append(TextUtils.isEmpty(bean6.deal_amount) ? "0" : bean6.deal_amount);
sb5.append(LocaleController.getString("PayBillA", R.string.PayBillA));
sb5.append(commodity);
sb5.append(LocaleController.getString("PayBillReturnClickToView", R.string.PayBillReturnClickToView));
message2 = sb5.toString();
break;
case 8:
if (!TextUtils.isEmpty(bean6.deal_type)) {
String str3 = bean6.deal_type;
int hashCode = str3.hashCode();
if (hashCode != 49) {
if (hashCode == 50 && str3.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(bean6.deal_num) ? "0" : bean6.deal_num));
sb6.append(LocaleController.getString("PayBillA", R.string.PayBillA));
sb6.append(commodity);
sb6.append(LocaleController.getString("PayBillClickToView", R.string.PayBillClickToView));
message2 = sb6.toString();
break;
}
} else {
StringBuilder sb7 = new StringBuilder();
sb7.append(LocaleController.getString("PayBillCommissionBuy2", R.string.PayBillCommissionBuy2));
sb7.append(setMoneyFormat(TextUtils.isEmpty(bean6.deal_amount) ? "0" : bean6.deal_amount));
sb7.append(LocaleController.getString("PayBillA", R.string.PayBillA));
sb7.append(commodity);
sb7.append(LocaleController.getString("PayBillClickToView", R.string.PayBillClickToView));
message2 = sb7.toString();
break;
}
}
c = 65535;
if (c == 0) {
}
} else {
if (str3.equals("1")) {
c = 0;
if (c == 0) {
}
}
c = 65535;
if (c == 0) {
}
}
}
break;
case 9:
StringBuilder sb8 = new StringBuilder();
sb8.append(LocaleController.getString("PayBillCommissionSell2", R.string.PayBillCommissionSell2));
sb8.append(setMoneyFormat(TextUtils.isEmpty(bean6.deal_num) ? "0" : bean6.deal_num));
sb8.append(LocaleController.getString("PayBillA", R.string.PayBillA));
sb8.append(commodity);
sb8.append(LocaleController.getString("PayBillClickToView", R.string.PayBillClickToView));
message2 = sb8.toString();
break;
case 10:
StringBuilder sb9 = new StringBuilder();
sb9.append(LocaleController.getString("PayBillCommissionReturn2", R.string.PayBillCommissionReturn2));
sb9.append(setMoneyFormat(TextUtils.isEmpty(bean6.deal_amount) ? "0" : bean6.deal_amount));
sb9.append(LocaleController.getString("PayBillA", R.string.PayBillA));
sb9.append(commodity);
sb9.append(LocaleController.getString("PayBillReturnClickToView", R.string.PayBillReturnClickToView));
message2 = sb9.toString();
break;
case 11:
StringBuilder sb10 = new StringBuilder();
sb10.append(LocaleController.getString("PayBillFiatCurrencyBuy2", R.string.PayBillFiatCurrencyBuy2));
sb10.append(TextUtils.isEmpty(bean6.deal_num) ? "0" : bean6.deal_num);
sb10.append(LocaleController.getString("PayBillA", R.string.PayBillA));
sb10.append(commodity);
sb10.append(LocaleController.getString("PayBillClickToView", R.string.PayBillClickToView));
message2 = sb10.toString();
break;
case 12:
StringBuilder sb11 = new StringBuilder();
sb11.append(LocaleController.getString("PayBillFiatCurrencySell2", R.string.PayBillFiatCurrencySell2));
sb11.append(TextUtils.isEmpty(bean6.deal_num) ? "0" : bean6.deal_num);
sb11.append(LocaleController.getString("PayBillA", R.string.PayBillA));
sb11.append(commodity);
sb11.append(LocaleController.getString("PayBillClickToView", R.string.PayBillClickToView));
message2 = sb11.toString();
break;
}
this.messageText = message2;
}
}
this.messageText = LocaleController.getString("AttachLocation", R.string.AttachLocation);
}
}
if (this.messageOwner.media.ttl_seconds == 0 || (this.messageOwner instanceof TLRPC.TL_message_secret)) {
this.messageText = LocaleController.getString("AttachVideo", R.string.AttachVideo);
} else {
this.messageText = LocaleController.getString("AttachDestructingVideo", R.string.AttachDestructingVideo);
}
}
}
if (this.messageText == null) {
this.messageText = "";
}
}
public void setType() {
int oldType = 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 media = (TLRPCRedpacket.CL_messagesRpkTransferMedia) this.messageOwner.media;
if (media.trans == 0) {
this.type = 101;
} else if (media.trans == 1 || media.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 (oldType != 1000 && oldType != this.type) {
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 paint;
if (this.type != 0 || this.messageOwner.to_id == null || (charSequence = this.messageText) == null || charSequence.length() == 0) {
return false;
}
if (this.layoutCreated) {
int newMinSize = AndroidUtilities.isTablet() ? AndroidUtilities.getMinTabletSide() : AndroidUtilities.displaySize.x;
if (Math.abs(this.generatedWithMinSize - newMinSize) > AndroidUtilities.dp(52.0f) || this.generatedWithDensity != AndroidUtilities.density) {
this.layoutCreated = false;
}
}
if (this.layoutCreated) {
return false;
}
this.layoutCreated = true;
TLRPC.User fromUser = null;
if (isFromUser()) {
fromUser = MessagesController.getInstance(this.currentAccount).getUser(Integer.valueOf(this.messageOwner.from_id));
}
if (this.messageOwner.media instanceof TLRPC.TL_messageMediaGame) {
paint = Theme.chat_msgGameTextPaint;
} else {
paint = Theme.chat_msgTextPaint;
}
int[] emojiOnly = SharedConfig.allowBigEmoji ? new int[1] : null;
this.messageText = Emoji.replaceEmoji(this.messageText, paint.getFontMetricsInt(), AndroidUtilities.dp(20.0f), false, emojiOnly);
checkEmojiOnly(emojiOnly);
generateLayout(fromUser);
return true;
}
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 photo = ((TLRPC.TL_messageMediaInvoice) this.messageOwner.media).photo;
if (photo != null) {
return photo.mime_type;
}
return "";
}
public boolean canPreviewDocument() {
return canPreviewDocument(getDocument());
}
public static boolean isGifDocument(WebFile document) {
return document != null && (document.mime_type.equals("image/gif") || isNewGifDocument(document));
}
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()) {
return false;
}
int N = document.thumbs.size();
for (int a = 0; a < N; a++) {
TLRPC.PhotoSize photoSize = document.thumbs.get(a);
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 mime = document.mime_type.toLowerCase();
if (isDocumentHasThumb(document) && (mime.equals("image/png") || mime.equals("image/jpg") || mime.equals("image/jpeg"))) {
for (int a = 0; a < document.attributes.size(); a++) {
TLRPC.DocumentAttribute attribute = document.attributes.get(a);
if (attribute instanceof TLRPC.TL_documentAttributeImageSize) {
TLRPC.TL_documentAttributeImageSize size = (TLRPC.TL_documentAttributeImageSize) attribute;
return size.w < 6000 && size.h < 6000;
}
}
} else if (BuildVars.DEBUG_PRIVATE_VERSION) {
String fileName = FileLoader.getDocumentFileName(document);
if (fileName.startsWith("tg_secret_sticker") && fileName.endsWith("json")) {
return true;
}
}
}
return false;
}
public static boolean isRoundVideoDocument(TLRPC.Document document) {
if (document != null && MimeTypes.VIDEO_MP4.equals(document.mime_type)) {
int width = 0;
int height = 0;
boolean round = false;
for (int a = 0; a < document.attributes.size(); a++) {
TLRPC.DocumentAttribute attribute = document.attributes.get(a);
if (attribute instanceof TLRPC.TL_documentAttributeVideo) {
width = attribute.w;
height = attribute.w;
round = attribute.round_message;
}
}
if (round && width <= 1280 && height <= 1280) {
return true;
}
return false;
}
return false;
}
public static boolean isNewGifDocument(WebFile document) {
if (document != null && MimeTypes.VIDEO_MP4.equals(document.mime_type)) {
int width = 0;
int height = 0;
for (int a = 0; a < document.attributes.size(); a++) {
TLRPC.DocumentAttribute attribute = document.attributes.get(a);
if (!(attribute instanceof TLRPC.TL_documentAttributeAnimated) && (attribute instanceof TLRPC.TL_documentAttributeVideo)) {
width = attribute.w;
height = attribute.w;
}
}
if (width <= 1280 && height <= 1280) {
return true;
}
return false;
}
return false;
}
public static boolean isNewGifDocument(TLRPC.Document document) {
if (document != null && MimeTypes.VIDEO_MP4.equals(document.mime_type)) {
int width = 0;
int height = 0;
boolean animated = false;
for (int a = 0; a < document.attributes.size(); a++) {
TLRPC.DocumentAttribute attribute = document.attributes.get(a);
if (attribute instanceof TLRPC.TL_documentAttributeAnimated) {
animated = true;
} else if (attribute instanceof TLRPC.TL_documentAttributeVideo) {
width = attribute.w;
height = attribute.w;
}
}
if (animated && width <= 1280 && height <= 1280) {
return true;
}
return false;
}
return false;
}
public void generateThumbs(boolean update) {
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 (!update) {
this.photoThumbs = new ArrayList<>(photo.sizes);
} else {
ArrayList<TLRPC.PhotoSize> arrayList7 = this.photoThumbs;
if (arrayList7 != null && !arrayList7.isEmpty()) {
for (int a = 0; a < this.photoThumbs.size(); a++) {
TLRPC.PhotoSize photoObject = this.photoThumbs.get(a);
int b = 0;
while (true) {
if (b < photo.sizes.size()) {
TLRPC.PhotoSize size = photo.sizes.get(b);
if ((size instanceof TLRPC.TL_photoSizeEmpty) || !size.type.equals(photoObject.type)) {
b++;
} else {
photoObject.location = size.location;
break;
}
}
}
}
}
}
int a2 = photo.dc_id;
if (a2 != 0) {
int N = this.photoThumbs.size();
for (int a3 = 0; a3 < N; a3++) {
TLRPC.FileLocation location = this.photoThumbs.get(a3).location;
location.dc_id = photo.dc_id;
location.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 (!update || (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)) {
if (this.messageOwner.media instanceof TLRPC.TL_messageMediaPhoto) {
TLRPC.Photo photo2 = this.messageOwner.media.photo;
if (!update || ((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 a4 = 0; a4 < this.photoThumbs.size(); a4++) {
TLRPC.PhotoSize photoObject2 = this.photoThumbs.get(a4);
if (photoObject2 != null) {
int b2 = 0;
while (true) {
if (b2 >= photo2.sizes.size()) {
break;
}
TLRPC.PhotoSize size2 = photo2.sizes.get(b2);
if (size2 == null || (size2 instanceof TLRPC.TL_photoSizeEmpty) || !size2.type.equals(photoObject2.type)) {
b2++;
} else {
photoObject2.location = size2.location;
break;
}
}
}
}
}
}
this.photoThumbsObject = this.messageOwner.media.photo;
return;
}
if (this.messageOwner.media instanceof TLRPC.TL_messageMediaDocument) {
TLRPC.Document document = getDocument();
if (isDocumentHasThumb(document)) {
if (!update || (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 (!update) {
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 (!update || (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) {
this.photoThumbs = arrayList2;
this.photoThumbs2 = null;
this.photoThumbsObject = this.photoThumbsObject2;
this.photoThumbsObject2 = null;
return;
}
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 (!update || (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)) {
if (!update) {
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> o, ArrayList<TLRPC.PhotoSize> n) {
int N = o.size();
for (int a = 0; a < N; a++) {
TLRPC.PhotoSize photoObject = o.get(a);
int b = 0;
int N2 = n.size();
while (true) {
if (b < N2) {
TLRPC.PhotoSize size = n.get(b);
if ((size instanceof TLRPC.TL_photoSizeEmpty) || (size instanceof TLRPC.TL_photoCachedSize) || !size.type.equals(photoObject.type)) {
b++;
} else {
photoObject.location = size.location;
break;
}
}
}
}
}
public CharSequence replaceWithLink(CharSequence source, String param, ArrayList<Integer> uids, AbstractMap<Integer, TLRPC.User> usersDict, SparseArray<TLRPC.User> sUsersDict) {
if (TextUtils.indexOf(source, param) >= 0) {
SpannableStringBuilder names = new SpannableStringBuilder("");
for (int a = 0; a < uids.size(); a++) {
TLRPC.User user = null;
if (usersDict != null) {
TLRPC.User user2 = usersDict.get(uids.get(a));
user = user2;
} else if (sUsersDict != null) {
TLRPC.User user3 = sUsersDict.get(uids.get(a).intValue());
user = user3;
}
if (user == null) {
user = MessagesController.getInstance(this.currentAccount).getUser(uids.get(a));
}
if (user != null) {
String name = UserObject.getName(user);
int start = names.length();
if (names.length() != 0) {
names.append(", ");
}
names.append((CharSequence) name);
names.setSpan(new URLSpanNoUnderlineBold("" + user.id), start, name.length() + start, 33);
}
}
return TextUtils.replace(source, new String[]{param}, new CharSequence[]{names});
}
return source;
}
public CharSequence replaceWithLink(CharSequence source, String param, TLObject object, int status, ClickableSpan clickableSpan) {
String name;
String id;
int start = TextUtils.indexOf(source, param);
if (start < 0) {
return source;
}
if (object instanceof TLRPC.User) {
TLRPC.User user = (TLRPC.User) object;
if (user.id == UserConfig.getInstance(UserConfig.selectedAccount).clientUserId) {
name = LocaleController.getString("YouSelf", R.string.YouSelf);
} else {
name = UserObject.getName((TLRPC.User) object);
}
id = "" + user.id;
} else if (object instanceof TLRPC.Chat) {
name = ((TLRPC.Chat) object).title;
id = "" + (-((TLRPC.Chat) object).id);
} else if (object instanceof TLRPC.TL_game) {
TLRPC.TL_game game = (TLRPC.TL_game) object;
name = game.title;
id = "game";
} else {
name = "";
id = "0";
}
String name2 = TextUtils.ellipsize(name.replace('\n', ' '), Theme.chat_actionTextPaint, AndroidUtilities.dp(150.0f), TextUtils.TruncateAt.END).toString();
SpannableStringBuilder builder = new SpannableStringBuilder(TextUtils.replace(source, new String[]{param}, new String[]{name2}));
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));
ImageSpan ab = new ImageSpan(drawable);
builder.setSpan(ab, 0, 1, 33);
builder.setSpan(new URLSpanNoUnderlineBold("" + id), start, name2.length() + start, 33);
ForegroundColorSpan colorSpan = new ForegroundColorSpan(Theme.getColor(Theme.key_chat_redpacketLinkServiceText));
builder.setSpan(colorSpan, start, name2.length() + start, 33);
if (clickableSpan != null) {
builder.setSpan(clickableSpan, builder.length() - 2, builder.length(), 33);
ForegroundColorSpan foregroundColorSpan = new ForegroundColorSpan(Color.parseColor("#FFFE5548"));
builder.setSpan(foregroundColorSpan, builder.length() - 2, builder.length(), 33);
}
if (status == 1) {
builder.append((CharSequence) LocaleController.getString(R.string.YouPacketComplete));
}
return builder;
}
public CharSequence replaceWithLink(CharSequence source, String param, TLObject object) {
return replaceWithLink(source, param, object, false);
}
public CharSequence replaceWithLink(CharSequence source, String param, TLObject object, boolean forRedpacket) {
String name;
String id;
if (source == null) {
return "";
}
int start = TextUtils.indexOf(source, param);
if (start >= 0) {
if (object instanceof TLRPC.User) {
name = UserObject.getName((TLRPC.User) object);
id = "" + ((TLRPC.User) object).id;
} else if (object instanceof TLRPC.Chat) {
name = ((TLRPC.Chat) object).title;
id = "" + (-((TLRPC.Chat) object).id);
} else if (object instanceof TLRPC.TL_game) {
TLRPC.TL_game game = (TLRPC.TL_game) object;
String name2 = game.title;
id = "game";
name = name2;
} else {
name = "";
id = "0";
}
String name3 = name.replace('\n', ' ');
if (forRedpacket) {
name3 = TextUtils.ellipsize(name3, Theme.chat_actionTextPaint, AndroidUtilities.dp(150.0f), TextUtils.TruncateAt.END).toString();
}
SpannableStringBuilder builder = new SpannableStringBuilder(TextUtils.replace(source, new String[]{param}, new String[]{name3}));
builder.setSpan(new URLSpanNoUnderlineBold("" + id), start, name3.length() + start, 33);
if (forRedpacket) {
ForegroundColorSpan colorSpan = new ForegroundColorSpan(Theme.getColor(Theme.key_chat_redpacketLinkServiceText));
builder.setSpan(colorSpan, start, name3.length() + start, 33);
}
return builder;
}
return source;
}
public CharSequence replaceRedStrWithLink(CharSequence source, String param, TLObject object, boolean forRedpacket) {
String name;
String id;
if (source == null) {
return "";
}
int start = TextUtils.indexOf(source, param);
if (start >= 0) {
if (object instanceof TLRPC.User) {
TLRPC.User user = (TLRPC.User) object;
if (user.id == UserConfig.getInstance(UserConfig.selectedAccount).clientUserId) {
name = LocaleController.getString("YouSelf", R.string.YouSelf);
} else {
name = UserObject.getName((TLRPC.User) object);
}
id = "" + user.id;
} else if (object instanceof TLRPC.Chat) {
name = ((TLRPC.Chat) object).title;
id = "" + (-((TLRPC.Chat) object).id);
} else if (object instanceof TLRPC.TL_game) {
TLRPC.TL_game game = (TLRPC.TL_game) object;
name = game.title;
id = "game";
} else {
name = "";
id = "0";
}
String name2 = name.replace('\n', ' ');
if (forRedpacket) {
name2 = TextUtils.ellipsize(name2, Theme.chat_actionTextPaint, AndroidUtilities.dp(150.0f), TextUtils.TruncateAt.END).toString();
}
SpannableStringBuilder builder = new SpannableStringBuilder(TextUtils.replace(source, new String[]{param}, new String[]{name2}));
builder.setSpan(new URLSpanNoUnderlineBold("" + id), start, name2.length() + start, 33);
if (forRedpacket) {
ForegroundColorSpan colorSpan = new ForegroundColorSpan(Theme.getColor(Theme.key_chat_redpacketLinkServiceText));
builder.setSpan(colorSpan, start, name2.length() + start, 33);
}
return builder;
}
return source;
}
public CharSequence replaceRedStrWithLink(CharSequence source, String param, TLObject object, int status, ClickableSpan clickableSpan) {
int start = TextUtils.indexOf(source, param);
if (start >= 0) {
String name = LocaleController.getString(R.string.CgCoinRedpacket).replace('\n', ' ');
SpannableStringBuilder builder = new SpannableStringBuilder(TextUtils.replace(source, new String[]{param}, new String[]{name}));
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));
ImageSpan ab = new ImageSpan(drawable);
builder.setSpan(ab, 0, 1, 33);
if (clickableSpan != null) {
builder.setSpan(clickableSpan, start, name.length() + start, 33);
ForegroundColorSpan foregroundColorSpan = new ForegroundColorSpan(Color.parseColor("#FFFE5548"));
builder.setSpan(foregroundColorSpan, start, name.length() + start, 33);
}
if (status == 1) {
builder.append((CharSequence) LocaleController.getString(R.string.YouPacketComplete));
}
return builder;
}
return source;
}
public String getExtension() {
String fileName = getFileName();
int idx = fileName.lastIndexOf(46);
String ext = null;
if (idx != -1) {
ext = fileName.substring(idx + 1);
}
if (ext == null || ext.length() == 0) {
ext = getDocument().mime_type;
}
if (ext == null) {
ext = "";
}
return ext.toUpperCase();
}
public String getFileName() {
TLRPC.PhotoSize sizeFull;
if (this.messageOwner.media instanceof TLRPC.TL_messageMediaDocument) {
return FileLoader.getAttachFileName(getDocument());
}
if (this.messageOwner.media instanceof TLRPC.TL_messageMediaPhoto) {
ArrayList<TLRPC.PhotoSize> sizes = this.messageOwner.media.photo.sizes;
if (sizes.size() > 0 && (sizeFull = FileLoader.getClosestPhotoSizeWithSize(sizes, AndroidUtilities.getPhotoSize())) != null) {
return FileLoader.getAttachFileName(sizeFull);
}
return "";
}
if (this.messageOwner.media instanceof TLRPC.TL_messageMediaWebPage) {
return FileLoader.getAttachFileName(this.messageOwner.media.webpage.document);
}
return "";
}
public int getFileType() {
if (isVideo()) {
return 2;
}
if (isVoice()) {
return 1;
}
if (this.messageOwner.media instanceof TLRPC.TL_messageMediaDocument) {
return 3;
}
if (this.messageOwner.media instanceof TLRPC.TL_messageMediaPhoto) {
return 0;
}
return 4;
}
private static boolean containsUrls(CharSequence message) {
if (message == null || message.length() < 2 || message.length() > 20480) {
return false;
}
int length = message.length();
int digitsInRow = 0;
int schemeSequence = 0;
int dotSequence = 0;
char lastChar = 0;
for (int i = 0; i < length; i++) {
char c = message.charAt(i);
if (c >= '0' && c <= '9') {
digitsInRow++;
if (digitsInRow >= 6) {
return true;
}
schemeSequence = 0;
dotSequence = 0;
} else if (c == ' ' || digitsInRow <= 0) {
digitsInRow = 0;
}
if (((c == '@' || c == '#' || c == '/' || c == '$') && i == 0) || (i != 0 && (message.charAt(i - 1) == ' ' || message.charAt(i - 1) == '\n'))) {
return true;
}
if (c == ':') {
if (schemeSequence == 0) {
schemeSequence = 1;
} else {
schemeSequence = 0;
}
} else if (c == '/') {
if (schemeSequence == 2) {
return true;
}
if (schemeSequence == 1) {
schemeSequence++;
} else {
schemeSequence = 0;
}
} else if (c == '.') {
if (dotSequence == 0 && lastChar != ' ') {
dotSequence++;
} else {
dotSequence = 0;
}
} else {
if (c != ' ' && lastChar == '.' && dotSequence == 1) {
return true;
}
dotSequence = 0;
}
lastChar = c;
}
return false;
}
public void generateLinkDescription() {
if (this.linkDescription != null) {
return;
}
int hashtagsType = 0;
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 siteName = this.messageOwner.media.webpage.site_name;
if (siteName != null) {
siteName = siteName.toLowerCase();
}
if ("instagram".equals(siteName)) {
hashtagsType = 1;
} else if ("twitter".equals(siteName)) {
hashtagsType = 2;
}
} else 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);
}
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 (hashtagsType != 0) {
if (!(replaceEmoji instanceof Spannable)) {
this.linkDescription = new SpannableStringBuilder(this.linkDescription);
}
addUrlsByPattern(isOutOwner(), this.linkDescription, false, hashtagsType, 0);
}
}
}
public void generateCaption() {
boolean hasEntities;
if (this.caption == null && !isRoundVideo() && !isMediaEmpty() && !(this.messageOwner.media instanceof TLRPC.TL_messageMediaGame) && !TextUtils.isEmpty(this.messageOwner.message)) {
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) {
hasEntities = false;
int a = 0;
while (true) {
if (a >= this.messageOwner.entities.size()) {
break;
}
if (this.messageOwner.entities.get(a) instanceof TLRPC.TL_inputMessageEntityMentionName) {
a++;
} else {
hasEntities = true;
break;
}
}
} else {
hasEntities = !this.messageOwner.entities.isEmpty();
}
boolean useManualParse = !hasEntities && (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 (useManualParse) {
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, useManualParse);
if (isVideo()) {
addUrlsByPattern(isOutOwner(), this.caption, true, 3, getDuration());
}
}
}
private static void addUrlsByPattern(boolean isOut, CharSequence charSequence, boolean botCommands, int patternType, int duration) {
Matcher matcher;
int seconds;
Matcher matcher2;
URLSpanNoUnderline url;
int s3 = 3;
char ch = 1;
try {
if (patternType == 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 (patternType == 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();
if (patternType == s3) {
URLSpan[] spans = (URLSpan[]) spannable.getSpans(start, end, URLSpan.class);
if (spans == null || spans.length <= 0) {
matcher.groupCount();
int s1 = matcher.start(ch);
int e1 = matcher.end(ch);
int s2 = matcher.start(2);
int e2 = matcher.end(2);
int s32 = matcher.start(s3);
int e3 = matcher.end(s3);
int minutes = Utilities.parseInt(charSequence.subSequence(s2, e2)).intValue();
int seconds2 = Utilities.parseInt(charSequence.subSequence(s32, e3)).intValue();
int hours = (s1 < 0 || e1 < 0) ? -1 : Utilities.parseInt(charSequence.subSequence(s1, e1)).intValue();
int seconds3 = seconds2 + (minutes * 60);
if (hours <= 0) {
seconds = seconds3;
} else {
seconds = seconds3 + (hours * 60 * 60);
}
if (seconds > duration) {
s3 = 3;
ch = 1;
} else {
try {
matcher2 = matcher;
url = new URLSpanNoUnderline("video?" + seconds);
if (url != null) {
spannable.setSpan(url, start, end, 0);
}
matcher = matcher2;
s3 = 3;
ch = 1;
} catch (Exception e) {
e = e;
FileLog.e(e);
return;
}
}
}
} else {
matcher2 = matcher;
char ch2 = charSequence.charAt(start);
if (start >= charSequence.length()) {
url = null;
} else {
if (patternType != 0) {
if (ch2 != '@' && ch2 != '#') {
start++;
}
ch2 = charSequence.charAt(start);
if (ch2 != '@' && ch2 != '#') {
matcher = matcher2;
s3 = 3;
ch = 1;
}
} else if (ch2 != '@' && ch2 != '#' && ch2 != '/' && ch2 != '$') {
start++;
}
if (patternType == 1) {
if (ch2 == '@') {
url = new URLSpanNoUnderline("https://instagram.com/" + charSequence.subSequence(start + 1, end).toString());
} else {
if (ch2 == '#') {
url = new URLSpanNoUnderline("https://www.instagram.com/explore/tags/" + charSequence.subSequence(start + 1, end).toString());
}
url = null;
}
} else if (patternType == 2) {
if (ch2 == '@') {
url = new URLSpanNoUnderline("https://twitter.com/" + charSequence.subSequence(start + 1, end).toString());
} else {
if (ch2 == '#') {
url = new URLSpanNoUnderline("https://twitter.com/hashtag/" + charSequence.subSequence(start + 1, end).toString());
}
url = null;
}
} else {
if (end > start && start >= 0) {
if (charSequence.charAt(start) == '/') {
if (botCommands) {
url = new URLSpanBotCommand(charSequence.subSequence(start, end).toString(), isOut ? 1 : 0);
}
} else {
url = new URLSpanNoUnderline(charSequence.subSequence(start, end).toString());
}
}
url = null;
}
}
if (url != null) {
}
matcher = matcher2;
s3 = 3;
ch = 1;
}
}
} catch (Exception e4) {
e = e4;
}
}
public static int[] getWebDocumentWidthAndHeight(TLRPC.WebDocument document) {
if (document == null) {
return null;
}
int size = document.attributes.size();
for (int a = 0; a < size; a++) {
TLRPC.DocumentAttribute attribute = document.attributes.get(a);
if (attribute instanceof TLRPC.TL_documentAttributeImageSize) {
return new int[]{attribute.w, attribute.h};
}
if (attribute instanceof TLRPC.TL_documentAttributeVideo) {
return new int[]{attribute.w, attribute.h};
}
}
return null;
}
public static int getWebDocumentDuration(TLRPC.WebDocument document) {
if (document == null) {
return 0;
}
int size = document.attributes.size();
for (int a = 0; a < size; a++) {
TLRPC.DocumentAttribute attribute = document.attributes.get(a);
if (attribute instanceof TLRPC.TL_documentAttributeVideo) {
return attribute.duration;
}
if (attribute instanceof TLRPC.TL_documentAttributeAudio) {
return attribute.duration;
}
}
return 0;
}
public static int[] getInlineResultWidthAndHeight(TLRPC.BotInlineResult inlineResult) {
int[] result = getWebDocumentWidthAndHeight(inlineResult.content);
if (result == null) {
int[] result2 = getWebDocumentWidthAndHeight(inlineResult.thumb);
if (result2 == null) {
return new int[]{0, 0};
}
return result2;
}
return result;
}
public static int getInlineResultDuration(TLRPC.BotInlineResult inlineResult) {
int result = getWebDocumentDuration(inlineResult.content);
if (result == 0) {
return getWebDocumentDuration(inlineResult.thumb);
}
return result;
}
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 isOut, CharSequence messageText) {
addLinks(isOut, messageText, true);
}
public static void addLinks(boolean isOut, CharSequence messageText, boolean botCommands) {
if ((messageText instanceof Spannable) && containsUrls(messageText)) {
if (messageText.length() < 1000) {
try {
Linkify.addLinks((Spannable) messageText, 5);
} catch (Exception e) {
FileLog.e(e);
}
} else {
try {
Linkify.addLinks((Spannable) messageText, 1);
} catch (Exception e2) {
FileLog.e(e2);
}
}
addUrlsByPattern(isOut, messageText, botCommands, 0, 0);
}
}
public void resetPlayingProgress() {
this.audioProgress = 0.0f;
this.audioProgressSec = 0;
this.bufferedProgress = 0.0f;
}
private boolean addEntitiesToText(CharSequence text, boolean useManualParse) {
return addEntitiesToText(text, false, useManualParse);
}
public boolean addEntitiesToText(CharSequence text, boolean photoViewer, boolean useManualParse) {
if (!this.isRestrictedMessage) {
return addEntitiesToText(text, this.entitiesCopy, isOutOwner(), this.type, true, photoViewer, useManualParse);
}
ArrayList<TLRPC.MessageEntity> entities = new ArrayList<>();
TLRPC.TL_messageEntityItalic entityItalic = new TLRPC.TL_messageEntityItalic();
entityItalic.offset = 0;
entityItalic.length = text.length();
entities.add(entityItalic);
return addEntitiesToText(text, entities, isOutOwner(), this.type, true, photoViewer, useManualParse);
}
public static boolean addEntitiesToText(CharSequence text, ArrayList<TLRPC.MessageEntity> entities, boolean out, int type, boolean usernames, boolean photoViewer, boolean useManualParse) {
byte t;
String url;
TextStyleSpan.TextStyleRun run;
int i;
boolean hasUrls;
int N;
TLRPC.MessageEntity entity;
CharSequence charSequence = text;
boolean hasUrls2 = false;
if (!(charSequence instanceof Spannable)) {
return false;
}
Spannable spannable = (Spannable) charSequence;
URLSpan[] spans = (URLSpan[]) spannable.getSpans(0, text.length(), URLSpan.class);
if (spans != null && spans.length > 0) {
hasUrls2 = true;
}
if (entities.isEmpty()) {
return hasUrls2;
}
if (photoViewer) {
t = 2;
} else if (out) {
t = 1;
} else {
t = 0;
}
ArrayList<TextStyleSpan.TextStyleRun> runs = new ArrayList<>();
ArrayList<TLRPC.MessageEntity> entitiesCopy = new ArrayList<>(entities);
Collections.sort(entitiesCopy, new Comparator() {
@Override
public final int compare(Object obj, Object obj2) {
return MessageObject.lambda$addEntitiesToText$2((TLRPC.MessageEntity) obj, (TLRPC.MessageEntity) obj2);
}
});
int a = 0;
int N2 = entitiesCopy.size();
while (a < N2) {
TLRPC.MessageEntity entity2 = entitiesCopy.get(a);
if (entity2.length <= 0 || entity2.offset < 0) {
hasUrls = hasUrls2;
N = N2;
} else if (entity2.offset >= text.length()) {
hasUrls = hasUrls2;
N = N2;
} else {
if (entity2.offset + entity2.length > text.length()) {
entity2.length = text.length() - entity2.offset;
}
if ((!useManualParse || (entity2 instanceof TLRPC.TL_messageEntityBold) || (entity2 instanceof TLRPC.TL_messageEntityItalic) || (entity2 instanceof TLRPC.TL_messageEntityStrike) || (entity2 instanceof TLRPC.TL_messageEntityUnderline) || (entity2 instanceof TLRPC.TL_messageEntityBlockquote) || (entity2 instanceof TLRPC.TL_messageEntityCode) || (entity2 instanceof TLRPC.TL_messageEntityPre) || (entity2 instanceof TLRPC.TL_messageEntityMentionName) || (entity2 instanceof TLRPC.TL_inputMessageEntityMentionName) || (entity2 instanceof TLRPC.TL_messageEntityTextUrl)) && spans != null && spans.length > 0) {
for (int b = 0; b < spans.length; b++) {
if (spans[b] != null) {
int start = spannable.getSpanStart(spans[b]);
int end = spannable.getSpanEnd(spans[b]);
if ((entity2.offset <= start && entity2.offset + entity2.length >= start) || (entity2.offset <= end && entity2.offset + entity2.length >= end)) {
spannable.removeSpan(spans[b]);
spans[b] = null;
}
}
}
}
TextStyleSpan.TextStyleRun newRun = new TextStyleSpan.TextStyleRun();
newRun.start = entity2.offset;
newRun.end = newRun.start + entity2.length;
if (entity2 instanceof TLRPC.TL_messageEntityStrike) {
newRun.flags = 8;
} else if (entity2 instanceof TLRPC.TL_messageEntityUnderline) {
newRun.flags = 16;
} else if (entity2 instanceof TLRPC.TL_messageEntityBlockquote) {
newRun.flags = 32;
} else if (entity2 instanceof TLRPC.TL_messageEntityBold) {
newRun.flags = 1;
} else if (entity2 instanceof TLRPC.TL_messageEntityItalic) {
newRun.flags = 2;
} else if ((entity2 instanceof TLRPC.TL_messageEntityCode) || (entity2 instanceof TLRPC.TL_messageEntityPre)) {
newRun.flags = 4;
} else if (entity2 instanceof TLRPC.TL_messageEntityMentionName) {
if (!usernames) {
hasUrls = hasUrls2;
N = N2;
} else {
newRun.flags = 64;
newRun.urlEntity = entity2;
}
} else if (entity2 instanceof TLRPC.TL_inputMessageEntityMentionName) {
if (!usernames) {
hasUrls = hasUrls2;
N = N2;
} else {
newRun.flags = 64;
newRun.urlEntity = entity2;
}
} else if (useManualParse && !(entity2 instanceof TLRPC.TL_messageEntityTextUrl)) {
hasUrls = hasUrls2;
N = N2;
} else if (((entity2 instanceof TLRPC.TL_messageEntityUrl) || (entity2 instanceof TLRPC.TL_messageEntityTextUrl)) && Browser.isPassportUrl(entity2.url)) {
hasUrls = hasUrls2;
N = N2;
} else if ((entity2 instanceof TLRPC.TL_messageEntityMention) && !usernames) {
hasUrls = hasUrls2;
N = N2;
} else {
newRun.flags = 128;
newRun.urlEntity = entity2;
}
int b2 = 0;
int N22 = runs.size();
while (b2 < N22) {
TextStyleSpan.TextStyleRun run2 = runs.get(b2);
boolean hasUrls3 = hasUrls2;
int i2 = newRun.start;
int N3 = N2;
int N4 = run2.start;
if (i2 > N4) {
if (newRun.start < run2.end) {
if (newRun.end < run2.end) {
TextStyleSpan.TextStyleRun r = new TextStyleSpan.TextStyleRun(newRun);
r.merge(run2);
int b3 = b2 + 1;
runs.add(b3, r);
TextStyleSpan.TextStyleRun r2 = new TextStyleSpan.TextStyleRun(run2);
r2.start = newRun.end;
b2 = b3 + 1;
N22 = N22 + 1 + 1;
runs.add(b2, r2);
} else if (newRun.end >= run2.end) {
TextStyleSpan.TextStyleRun r3 = new TextStyleSpan.TextStyleRun(newRun);
r3.merge(run2);
r3.end = run2.end;
b2++;
N22++;
runs.add(b2, r3);
}
int temp = newRun.start;
newRun.start = run2.end;
run2.end = temp;
entity = entity2;
}
entity = entity2;
} else {
if (run2.start < newRun.end) {
int temp2 = run2.start;
entity = entity2;
if (newRun.end == run2.end) {
run2.merge(newRun);
} else if (newRun.end < run2.end) {
TextStyleSpan.TextStyleRun r4 = new TextStyleSpan.TextStyleRun(run2);
r4.merge(newRun);
r4.end = newRun.end;
b2++;
N22++;
runs.add(b2, r4);
run2.start = newRun.end;
} else {
TextStyleSpan.TextStyleRun r5 = new TextStyleSpan.TextStyleRun(newRun);
r5.start = run2.end;
b2++;
N22++;
runs.add(b2, r5);
run2.merge(newRun);
}
newRun.end = temp2;
}
entity = entity2;
}
b2++;
entity2 = entity;
hasUrls2 = hasUrls3;
N2 = N3;
}
hasUrls = hasUrls2;
N = N2;
int N5 = newRun.start;
if (N5 < newRun.end) {
runs.add(newRun);
}
}
a++;
hasUrls2 = hasUrls;
N2 = N;
}
boolean hasUrls4 = hasUrls2;
String str = null;
int count = runs.size();
int a2 = 0;
while (a2 < count) {
TextStyleSpan.TextStyleRun run3 = runs.get(a2);
String url2 = run3.urlEntity != null ? TextUtils.substring(charSequence, run3.urlEntity.offset, run3.urlEntity.offset + run3.urlEntity.length) : str;
if (run3.urlEntity instanceof TLRPC.TL_messageEntityBotCommand) {
spannable.setSpan(new URLSpanBotCommand(url2, t, run3), run3.start, run3.end, 33);
} else {
if ((run3.urlEntity instanceof TLRPC.TL_messageEntityHashtag) || (run3.urlEntity instanceof TLRPC.TL_messageEntityMention)) {
url = url2;
run = run3;
i = 33;
} else if (run3.urlEntity instanceof TLRPC.TL_messageEntityCashtag) {
url = url2;
run = run3;
i = 33;
} else if (run3.urlEntity instanceof TLRPC.TL_messageEntityEmail) {
spannable.setSpan(new URLSpanReplacement("mailto:" + url2, run3), run3.start, run3.end, 33);
} else if (run3.urlEntity instanceof TLRPC.TL_messageEntityUrl) {
if (!url2.toLowerCase().startsWith("http") && !url2.toLowerCase().startsWith("hchat://")) {
spannable.setSpan(new URLSpanBrowser("http://" + url2, run3), run3.start, run3.end, 33);
} else {
spannable.setSpan(new URLSpanBrowser(url2, run3), run3.start, run3.end, 33);
}
hasUrls4 = true;
} else if (run3.urlEntity instanceof TLRPC.TL_messageEntityPhone) {
String tel = PhoneFormat.stripExceptNumbers(url2);
if (url2.startsWith(Marker.ANY_NON_NULL_MARKER)) {
tel = Marker.ANY_NON_NULL_MARKER + tel;
}
spannable.setSpan(new URLSpanBrowser("tel:" + tel, run3), run3.start, run3.end, 33);
hasUrls4 = true;
} else if (run3.urlEntity instanceof TLRPC.TL_messageEntityTextUrl) {
spannable.setSpan(new URLSpanReplacement(run3.urlEntity.url, run3), run3.start, run3.end, 33);
} else if (run3.urlEntity instanceof TLRPC.TL_messageEntityMentionName) {
spannable.setSpan(new URLSpanUserMention("" + ((TLRPC.TL_messageEntityMentionName) run3.urlEntity).user_id, t, run3), run3.start, run3.end, 33);
} else if (run3.urlEntity instanceof TLRPC.TL_inputMessageEntityMentionName) {
spannable.setSpan(new URLSpanUserMention("" + ((TLRPC.TL_inputMessageEntityMentionName) run3.urlEntity).user_id.user_id, t, run3), run3.start, run3.end, 33);
} else if ((run3.flags & 4) != 0) {
spannable.setSpan(new URLSpanMono(spannable, run3.start, run3.end, t, run3), run3.start, run3.end, 33);
} else {
spannable.setSpan(new TextStyleSpan(run3), run3.start, run3.end, 33);
}
spannable.setSpan(new URLSpanNoUnderline(url, run), run.start, run.end, i);
}
a2++;
str = null;
charSequence = text;
}
return hasUrls4;
}
public static int lambda$addEntitiesToText$2(TLRPC.MessageEntity o1, TLRPC.MessageEntity o2) {
if (o1.offset > o2.offset) {
return 1;
}
if (o1.offset < o2.offset) {
return -1;
}
return 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) {
return false;
}
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 maxWidth;
int maxWidth2 = 0;
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;
if ((this.messageOwner.media instanceof TLRPC.TL_messageMediaWebPage) && this.messageOwner.media.webpage != null && "app_background".equals(this.messageOwner.media.webpage.type)) {
try {
Uri uri = Uri.parse(this.messageOwner.media.webpage.url);
if (uri.getQueryParameter("bg_color") != null) {
maxWidth2 = AndroidUtilities.dp(220.0f);
} else if (uri.getLastPathSegment().length() == 6) {
maxWidth2 = AndroidUtilities.dp(200.0f);
}
} catch (Exception e) {
}
} else if (isAndroidTheme()) {
maxWidth2 = AndroidUtilities.dp(200.0f);
}
if (maxWidth2 == 0) {
int maxWidth3 = this.generatedWithMinSize - AndroidUtilities.dp(147.0f);
if (needDrawShareButton() && !isOutOwner()) {
maxWidth = maxWidth3 - AndroidUtilities.dp(10.0f);
} else {
maxWidth = maxWidth3;
}
if (this.messageOwner.media instanceof TLRPC.TL_messageMediaGame) {
return maxWidth - AndroidUtilities.dp(10.0f);
}
return maxWidth;
}
return maxWidth2;
}
public void generateLayout(TLRPC.User fromUser) {
boolean z;
boolean useManualParse;
TextPaint paint;
TextPaint paint2;
int maxWidth;
int maxWidth2;
StaticLayout textLayout;
StaticLayout textLayout2;
StaticLayout textLayout3;
int transLineCount;
int blocksCount;
int a;
int currentBlockLinesCount;
StaticLayout textLayout4;
boolean hasEntities;
TextPaint paint3;
boolean useManualParse2;
StaticLayout textLayout5;
boolean hasUrls;
int a2;
int linesOffset;
int blocksCount2;
StaticLayout transLayout;
int maxWidth3;
TextLayoutBlock block;
int currentBlockLinesCount2;
int linesOffset2;
int linesOffset3;
int currentBlockLinesCount3;
float lineWidth;
float lineWidth2;
int currentBlockLinesCount4;
float lineLeft;
int maxWidth4;
MessageObject messageObject;
int i = this.type;
if ((i != 0 && i != 2 && !TextUtils.isEmpty(this.messageOwner.trans)) || this.messageOwner.to_id == null || TextUtils.isEmpty(this.messageText)) {
return;
}
generateLinkDescription();
this.textLayoutBlocks = new ArrayList<>();
int i2 = 0;
this.textWidth = 0;
boolean hasEntities2 = this.messageOwner.send_state != 0 ? false : !this.messageOwner.entities.isEmpty();
try {
if (!hasEntities2) {
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;
useManualParse = z;
if (!useManualParse) {
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 e) {
FileLog.e(e);
}
}
}
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 hasUrls2 = addEntitiesToText(this.messageText, useManualParse);
int maxWidth5 = getMaxMessageTextWidth();
if (!(this.messageOwner.media instanceof TLRPC.TL_messageMediaGame)) {
paint = Theme.chat_msgGameTextPaint;
} else {
TextPaint paint4 = Theme.chat_msgTextPaint;
paint = paint4;
}
if (Build.VERSION.SDK_INT < 24) {
try {
paint2 = paint;
maxWidth = maxWidth5;
maxWidth2 = 24;
textLayout = StaticLayout.Builder.obtain(this.messageText, 0, this.messageText.length(), paint, maxWidth5).setBreakStrategy(1).setHyphenationFrequency(0).setAlignment(Layout.Alignment.ALIGN_NORMAL).build();
} catch (Exception e2) {
e = e2;
FileLog.e(e);
return;
}
} else {
maxWidth2 = 24;
paint2 = paint;
maxWidth = maxWidth5;
try {
textLayout = new StaticLayout(this.messageText, paint, maxWidth5, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
} catch (Exception e3) {
e = e3;
FileLog.e(e);
return;
}
}
if (!TextUtils.isEmpty(this.messageOwner.trans)) {
textLayout2 = textLayout;
textLayout3 = null;
} else {
try {
if (Build.VERSION.SDK_INT >= maxWidth2) {
StaticLayout transLayout2 = StaticLayout.Builder.obtain(this.messageOwner.trans, 0, this.messageOwner.trans.length(), paint2, maxWidth).setBreakStrategy(1).setHyphenationFrequency(0).setAlignment(Layout.Alignment.ALIGN_NORMAL).build();
textLayout2 = textLayout;
textLayout3 = transLayout2;
} else {
textLayout2 = textLayout;
StaticLayout transLayout3 = new StaticLayout(this.messageOwner.trans, paint2, maxWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
textLayout3 = transLayout3;
}
} catch (Exception e4) {
e = e4;
FileLog.e(e);
return;
}
}
this.textHeight = textLayout2.getHeight();
this.linesCount = textLayout2.getLineCount();
if (textLayout3 != null) {
this.transHeight = textLayout3.getHeight();
int transLineCount2 = textLayout3.getLineCount();
for (int i3 = 0; i3 < transLineCount2; i3++) {
float lineWidth3 = textLayout3.getLineMax(i3);
this.transWidth = (int) Math.max(this.transWidth, lineWidth3);
}
}
transLineCount = Build.VERSION.SDK_INT;
if (transLineCount < maxWidth2) {
blocksCount = 1;
} else {
int blocksCount3 = this.linesCount;
blocksCount = (int) Math.ceil(blocksCount3 / 10.0f);
}
int linesMaxWidthWithLeft = 0;
float prevOffset = 0.0f;
a = 0;
while (a < blocksCount) {
if (Build.VERSION.SDK_INT >= maxWidth2) {
currentBlockLinesCount = this.linesCount;
} else {
currentBlockLinesCount = Math.min(10, this.linesCount - linesMaxWidthWithLeft);
}
TextLayoutBlock block2 = new TextLayoutBlock();
if (blocksCount == 1) {
textLayout4 = textLayout2;
block2.textLayout = textLayout4;
block2.textYOffset = 0.0f;
block2.charactersOffset = i2;
int i4 = this.emojiOnlyCount;
if (i4 != 0) {
if (i4 == 1) {
this.textHeight -= AndroidUtilities.dp(5.3f);
block2.textYOffset -= AndroidUtilities.dp(5.3f);
} else if (i4 == 2) {
this.textHeight -= AndroidUtilities.dp(4.5f);
block2.textYOffset -= AndroidUtilities.dp(4.5f);
} else if (i4 == 3) {
this.textHeight -= AndroidUtilities.dp(4.2f);
block2.textYOffset -= AndroidUtilities.dp(4.2f);
}
}
block2.height = this.textHeight;
paint3 = paint2;
hasEntities = hasEntities2;
useManualParse2 = useManualParse;
hasUrls = hasUrls2;
block = block2;
a2 = a;
linesOffset2 = linesMaxWidthWithLeft;
blocksCount2 = blocksCount;
transLayout = textLayout3;
} else {
textLayout4 = textLayout2;
int startCharacter = textLayout4.getLineStart(linesMaxWidthWithLeft);
int endCharacter = textLayout4.getLineEnd((linesMaxWidthWithLeft + currentBlockLinesCount) - 1);
if (endCharacter < startCharacter) {
paint3 = paint2;
hasEntities = hasEntities2;
useManualParse2 = useManualParse;
textLayout5 = textLayout4;
hasUrls = hasUrls2;
a2 = a;
linesOffset = linesMaxWidthWithLeft;
blocksCount2 = blocksCount;
transLayout = textLayout3;
maxWidth3 = maxWidth;
} else {
block2.charactersOffset = startCharacter;
block2.charactersEnd = endCharacter;
try {
if (hasUrls2) {
try {
hasEntities = hasEntities2;
if (Build.VERSION.SDK_INT >= 24) {
try {
block2.textLayout = StaticLayout.Builder.obtain(this.messageText, startCharacter, endCharacter, paint2, maxWidth + AndroidUtilities.dp(2.0f)).setBreakStrategy(1).setHyphenationFrequency(0).setAlignment(Layout.Alignment.ALIGN_NORMAL).build();
paint3 = paint2;
useManualParse2 = useManualParse;
hasUrls = hasUrls2;
block = block2;
currentBlockLinesCount2 = currentBlockLinesCount;
a2 = a;
linesOffset2 = linesMaxWidthWithLeft;
blocksCount2 = blocksCount;
transLayout = textLayout3;
block.textYOffset = textLayout4.getLineTop(linesOffset2);
if (a2 != 0) {
try {
block.height = (int) (block.textYOffset - prevOffset);
} catch (Exception e5) {
e = e5;
linesOffset = linesOffset2;
textLayout5 = textLayout4;
maxWidth3 = maxWidth;
FileLog.e(e);
linesMaxWidthWithLeft = linesOffset;
a = a2 + 1;
blocksCount = blocksCount2;
maxWidth = maxWidth3;
textLayout2 = textLayout5;
hasEntities2 = hasEntities;
useManualParse = useManualParse2;
hasUrls2 = hasUrls;
paint2 = paint3;
textLayout3 = transLayout;
i2 = 0;
maxWidth2 = 24;
}
}
block.height = Math.max(block.height, block.textLayout.getLineBottom(block.textLayout.getLineCount() - 1));
prevOffset = block.textYOffset;
if (a2 == blocksCount2 - 1) {
currentBlockLinesCount = currentBlockLinesCount2;
} else {
currentBlockLinesCount = Math.max(currentBlockLinesCount2, block.textLayout.getLineCount());
try {
this.textHeight = Math.max(this.textHeight, (int) (block.textYOffset + block.textLayout.getHeight()));
} catch (Exception e6) {
FileLog.e(e6);
}
}
} catch (Exception e7) {
e = e7;
paint3 = paint2;
useManualParse2 = useManualParse;
textLayout5 = textLayout4;
hasUrls = hasUrls2;
a2 = a;
linesOffset = linesMaxWidthWithLeft;
blocksCount2 = blocksCount;
transLayout = textLayout3;
maxWidth3 = maxWidth;
FileLog.e(e);
linesMaxWidthWithLeft = linesOffset;
a = a2 + 1;
blocksCount = blocksCount2;
maxWidth = maxWidth3;
textLayout2 = textLayout5;
hasEntities2 = hasEntities;
useManualParse = useManualParse2;
hasUrls2 = hasUrls;
paint2 = paint3;
textLayout3 = transLayout;
i2 = 0;
maxWidth2 = 24;
}
}
} catch (Exception e8) {
e = e8;
hasEntities = hasEntities2;
paint3 = paint2;
useManualParse2 = useManualParse;
textLayout5 = textLayout4;
hasUrls = hasUrls2;
a2 = a;
linesOffset = linesMaxWidthWithLeft;
blocksCount2 = blocksCount;
transLayout = textLayout3;
maxWidth3 = maxWidth;
}
} else {
hasEntities = hasEntities2;
}
block.height = Math.max(block.height, block.textLayout.getLineBottom(block.textLayout.getLineCount() - 1));
prevOffset = block.textYOffset;
if (a2 == blocksCount2 - 1) {
}
} catch (Exception e9) {
e = e9;
linesOffset = linesOffset2;
textLayout5 = textLayout4;
maxWidth3 = maxWidth;
FileLog.e(e);
linesMaxWidthWithLeft = linesOffset;
a = a2 + 1;
blocksCount = blocksCount2;
maxWidth = maxWidth3;
textLayout2 = textLayout5;
hasEntities2 = hasEntities;
useManualParse = useManualParse2;
hasUrls2 = hasUrls;
paint2 = paint3;
textLayout3 = transLayout;
i2 = 0;
maxWidth2 = 24;
}
useManualParse2 = useManualParse;
block = block2;
currentBlockLinesCount2 = currentBlockLinesCount;
hasUrls = hasUrls2;
a2 = a;
linesOffset2 = linesMaxWidthWithLeft;
TextPaint textPaint = paint2;
paint3 = paint2;
blocksCount2 = blocksCount;
int blocksCount4 = maxWidth;
transLayout = textLayout3;
block.textLayout = new StaticLayout(this.messageText, startCharacter, endCharacter, textPaint, blocksCount4, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
block.textYOffset = textLayout4.getLineTop(linesOffset2);
if (a2 != 0) {
}
}
linesMaxWidthWithLeft = linesOffset;
a = a2 + 1;
blocksCount = blocksCount2;
maxWidth = maxWidth3;
textLayout2 = textLayout5;
hasEntities2 = hasEntities;
useManualParse = useManualParse2;
hasUrls2 = hasUrls;
paint2 = paint3;
textLayout3 = transLayout;
i2 = 0;
maxWidth2 = 24;
}
this.textLayoutBlocks.add(block);
float lastLeft = block.textLayout.getLineLeft(currentBlockLinesCount - 1);
if (a2 == 0 && lastLeft >= 0.0f) {
this.textXOffset = lastLeft;
}
float lastLeft2 = lastLeft;
float lastLine = block.textLayout.getLineWidth(currentBlockLinesCount - 1);
float lastLine2 = lastLine;
int linesMaxWidth = (int) Math.ceil(lastLine2);
if (linesMaxWidth > maxWidth + 80) {
linesMaxWidth = maxWidth;
}
if (a2 == blocksCount2 - 1) {
this.lastLineWidth = linesMaxWidth;
}
int linesMaxWidthWithLeft2 = (int) Math.ceil(lastLine2 + lastLeft2);
if (currentBlockLinesCount > 1) {
int n = 0;
textLayout5 = textLayout4;
float textRealMaxWidthWithLeft = 0.0f;
float textRealMaxWidthWithLeft2 = 0.0f;
boolean hasNonRTL = false;
int linesMaxWidthWithLeft3 = linesMaxWidthWithLeft2;
int linesMaxWidth2 = linesMaxWidth;
while (n < currentBlockLinesCount) {
try {
lineWidth = block.textLayout.getLineWidth(n);
} catch (Exception e10) {
FileLog.e(e10);
lineWidth = 0.0f;
}
int linesOffset4 = linesOffset2;
int linesOffset5 = maxWidth + 20;
if (lineWidth <= linesOffset5) {
lineWidth2 = lineWidth;
} else {
float lineWidth4 = maxWidth;
lineWidth2 = lineWidth4;
}
try {
float lineLeft2 = block.textLayout.getLineLeft(n);
currentBlockLinesCount4 = currentBlockLinesCount;
lineLeft = lineLeft2;
} catch (Exception e11) {
FileLog.e(e11);
currentBlockLinesCount4 = currentBlockLinesCount;
lineLeft = 0.0f;
}
if (lineLeft > 0.0f) {
this.textXOffset = Math.min(this.textXOffset, lineLeft);
maxWidth4 = maxWidth;
block.directionFlags = (byte) (block.directionFlags | 1);
this.hasRtl = true;
} else {
maxWidth4 = maxWidth;
block.directionFlags = (byte) (block.directionFlags | 2);
}
if (!hasNonRTL && lineLeft == 0.0f) {
try {
if (block.textLayout.getParagraphDirection(n) == 1) {
hasNonRTL = true;
}
} catch (Exception e12) {
hasNonRTL = true;
}
}
float textRealMaxWidth = Math.max(textRealMaxWidthWithLeft2, lineWidth2);
textRealMaxWidthWithLeft = Math.max(textRealMaxWidthWithLeft, lineWidth2 + lineLeft);
linesMaxWidth2 = Math.max(linesMaxWidth2, (int) Math.ceil(lineWidth2));
linesMaxWidthWithLeft3 = Math.max(linesMaxWidthWithLeft3, (int) Math.ceil(lineWidth2 + lineLeft));
n++;
hasNonRTL = hasNonRTL;
textRealMaxWidthWithLeft2 = textRealMaxWidth;
linesOffset2 = linesOffset4;
currentBlockLinesCount = currentBlockLinesCount4;
maxWidth = maxWidth4;
}
linesOffset3 = linesOffset2;
int maxWidth6 = maxWidth;
currentBlockLinesCount3 = currentBlockLinesCount;
if (hasNonRTL) {
textRealMaxWidthWithLeft2 = textRealMaxWidthWithLeft;
if (a2 == blocksCount2 - 1) {
this.lastLineWidth = linesMaxWidthWithLeft2;
}
} else if (a2 == blocksCount2 - 1) {
this.lastLineWidth = linesMaxWidth2;
}
this.textWidth = Math.max(this.textWidth, (int) Math.ceil(textRealMaxWidthWithLeft2));
maxWidth3 = maxWidth6;
} else {
linesOffset3 = linesOffset2;
int maxWidth7 = maxWidth;
textLayout5 = textLayout4;
currentBlockLinesCount3 = currentBlockLinesCount;
if (lastLeft2 > 0.0f) {
float min = Math.min(this.textXOffset, lastLeft2);
this.textXOffset = min;
if (min == 0.0f) {
linesMaxWidth = (int) (linesMaxWidth + lastLeft2);
}
this.hasRtl = blocksCount2 != 1;
block.directionFlags = (byte) (block.directionFlags | 1);
} else {
block.directionFlags = (byte) (block.directionFlags | 2);
}
maxWidth3 = maxWidth7;
this.textWidth = Math.max(this.textWidth, Math.min(maxWidth3, linesMaxWidth));
}
linesMaxWidthWithLeft = linesOffset3 + currentBlockLinesCount3;
a = a2 + 1;
blocksCount = blocksCount2;
maxWidth = maxWidth3;
textLayout2 = textLayout5;
hasEntities2 = hasEntities;
useManualParse = useManualParse2;
hasUrls2 = hasUrls;
paint2 = paint3;
textLayout3 = transLayout;
i2 = 0;
maxWidth2 = 24;
}
return;
}
if (Build.VERSION.SDK_INT < 24) {
}
if (!TextUtils.isEmpty(this.messageOwner.trans)) {
}
this.textHeight = textLayout2.getHeight();
this.linesCount = textLayout2.getLineCount();
if (textLayout3 != null) {
}
transLineCount = Build.VERSION.SDK_INT;
if (transLineCount < maxWidth2) {
}
int linesMaxWidthWithLeft4 = 0;
float prevOffset2 = 0.0f;
a = 0;
while (a < blocksCount) {
}
return;
} catch (Exception e13) {
e = e13;
}
z = false;
useManualParse = z;
if (!useManualParse) {
}
if (!isYouTubeVideo()) {
}
addUrlsByPattern(isOutOwner(), this.messageText, false, 3, Integer.MAX_VALUE);
boolean hasUrls22 = addEntitiesToText(this.messageText, useManualParse);
int maxWidth52 = getMaxMessageTextWidth();
if (!(this.messageOwner.media instanceof TLRPC.TL_messageMediaGame)) {
}
}
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 selfUserId = UserConfig.getInstance(this.currentAccount).getClientUserId();
return getDialogId() == ((long) selfUserId) ? (this.messageOwner.fwd_from.from_id == selfUserId && (this.messageOwner.fwd_from.saved_from_peer == null || this.messageOwner.fwd_from.saved_from_peer.user_id == selfUserId)) || (this.messageOwner.fwd_from.saved_from_peer != null && this.messageOwner.fwd_from.saved_from_peer.user_id == selfUserId) : this.messageOwner.fwd_from.saved_from_peer == null || this.messageOwner.fwd_from.saved_from_peer.user_id == selfUserId;
}
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 flags = 0;
if (!message.unread) {
flags = 0 | 1;
}
if (!message.media_unread) {
return flags | 2;
}
return flags;
}
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 id = this.messageOwner.id;
if (this.messageOwner.to_id != null && this.messageOwner.to_id.channel_id != 0) {
return id | (this.messageOwner.to_id.channel_id << 32);
}
return id;
}
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 ttl = Math.max(message.ttl, this.messageOwner.media.ttl_seconds);
return ttl > 0 && ((((this.messageOwner.media instanceof TLRPC.TL_messageMediaPhoto) || isVideo() || isGif()) && ttl <= 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 flag) {
message.unread = (flag & 1) == 0;
message.media_unread = (flag & 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) {
TLRPC.Chat chat = MessagesController.getInstance(this.currentAccount).getChat(Integer.valueOf(this.messageOwner.fwd_from.saved_from_peer.channel_id));
return ChatObject.isMegagroup(chat);
}
return false;
}
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)) {
return false;
}
if (SharedConfig.streamAllVideo) {
return true;
}
for (int a = 0; a < document.attributes.size(); a++) {
TLRPC.DocumentAttribute attribute = document.attributes.get(a);
if (attribute instanceof TLRPC.TL_documentAttributeVideo) {
return attribute.supports_streaming;
}
if ((attribute instanceof TLRPC.TL_documentAttributeFilename) && document.mime_type.toLowerCase().startsWith("video/")) {
return true;
}
}
return SharedConfig.streamMkv && "video/x-matroska".equals(document.mime_type);
}
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() {
int secondsLeft = this.messageOwner.ttl;
if (this.messageOwner.destroyTime != 0) {
int secondsLeft2 = Math.max(0, this.messageOwner.destroyTime - ConnectionsManager.getInstance(this.currentAccount).getCurrentTime());
return secondsLeft2;
}
return secondsLeft;
}
public String getSecretTimeString() {
if (!isSecretMedia()) {
return null;
}
int secondsLeft = getSecretTimeLeft();
if (secondsLeft < 60) {
String str = secondsLeft + "s";
return str;
}
String str2 = (secondsLeft / 60) + "m";
return str2;
}
public String getDocumentName() {
return FileLoader.getDocumentFileName(getDocument());
}
public static boolean isStickerDocument(TLRPC.Document document) {
if (document != null) {
for (int a = 0; a < document.attributes.size(); a++) {
TLRPC.DocumentAttribute attribute = document.attributes.get(a);
if (attribute 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 a = 0; a < document.attributes.size(); a++) {
TLRPC.DocumentAttribute attribute = document.attributes.get(a);
if ((attribute instanceof TLRPC.TL_documentAttributeSticker) && attribute.mask) {
return true;
}
}
return false;
}
return false;
}
public static boolean isVoiceDocument(TLRPC.Document document) {
if (document != null) {
for (int a = 0; a < document.attributes.size(); a++) {
TLRPC.DocumentAttribute attribute = document.attributes.get(a);
if (attribute instanceof TLRPC.TL_documentAttributeAudio) {
return attribute.voice;
}
}
return false;
}
return false;
}
public static boolean isVoiceWebDocument(WebFile webDocument) {
return webDocument != null && webDocument.mime_type.equals("audio/ogg");
}
public static boolean isImageWebDocument(WebFile webDocument) {
return (webDocument == null || isGifDocument(webDocument) || !webDocument.mime_type.startsWith("image/")) ? false : true;
}
public static boolean isVideoWebDocument(WebFile webDocument) {
return webDocument != null && webDocument.mime_type.startsWith("video/");
}
public static boolean isMusicDocument(TLRPC.Document document) {
if (document != null) {
for (int a = 0; a < document.attributes.size(); a++) {
TLRPC.DocumentAttribute attribute = document.attributes.get(a);
if (attribute instanceof TLRPC.TL_documentAttributeAudio) {
return true ^ attribute.voice;
}
}
if (!TextUtils.isEmpty(document.mime_type)) {
String mime = document.mime_type.toLowerCase();
if (mime.equals(MimeTypes.AUDIO_FLAC) || mime.equals("audio/ogg") || mime.equals(MimeTypes.AUDIO_OPUS) || mime.equals("audio/x-opus+ogg")) {
return true;
}
return mime.equals("application/octet-stream") && FileLoader.getDocumentFileName(document).endsWith(".opus");
}
return false;
}
return false;
}
public static boolean isVideoDocument(TLRPC.Document document) {
if (document == null) {
return false;
}
boolean isAnimated = false;
boolean isVideo = false;
int width = 0;
int height = 0;
for (int a = 0; a < document.attributes.size(); a++) {
TLRPC.DocumentAttribute attribute = document.attributes.get(a);
if (attribute instanceof TLRPC.TL_documentAttributeVideo) {
if (attribute.round_message) {
return false;
}
isVideo = true;
width = attribute.w;
height = attribute.h;
} else if (attribute instanceof TLRPC.TL_documentAttributeAnimated) {
isAnimated = true;
}
}
if (isAnimated && (width > 1280 || height > 1280)) {
isAnimated = false;
}
if (SharedConfig.streamMkv && !isVideo && "video/x-matroska".equals(document.mime_type)) {
isVideo = true;
}
return isVideo && !isAnimated;
}
public TLRPC.Document getDocument() {
TLRPC.Document document = this.emojiAnimatedSticker;
if (document != null) {
return document;
}
return 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 getInputStickerSet(message.media.document);
}
return null;
}
public static TLRPC.InputStickerSet getInputStickerSet(TLRPC.Document document) {
if (document == null) {
return null;
}
int N = document.attributes.size();
for (int a = 0; a < N; a++) {
TLRPC.DocumentAttribute attribute = document.attributes.get(a);
if (attribute instanceof TLRPC.TL_documentAttributeSticker) {
if (attribute.stickerset instanceof TLRPC.TL_inputStickerSetEmpty) {
return null;
}
return attribute.stickerset;
}
}
return null;
}
public static long getStickerSetId(TLRPC.Document document) {
if (document == null) {
return -1L;
}
for (int a = 0; a < document.attributes.size(); a++) {
TLRPC.DocumentAttribute attribute = document.attributes.get(a);
if (attribute instanceof TLRPC.TL_documentAttributeSticker) {
if (attribute.stickerset instanceof TLRPC.TL_inputStickerSetEmpty) {
return -1L;
}
return attribute.stickerset.id;
}
}
return -1L;
}
public String getStrickerChar() {
TLRPC.Document document = getDocument();
if (document != null) {
Iterator<TLRPC.DocumentAttribute> it = document.attributes.iterator();
while (it.hasNext()) {
TLRPC.DocumentAttribute attribute = it.next();
if (attribute instanceof TLRPC.TL_documentAttributeSticker) {
return attribute.alt;
}
}
return null;
}
return null;
}
public int getApproximateHeight() {
float maxWidth;
int photoWidth;
int i = this.type;
if (i == 0) {
int height = this.textHeight + (((this.messageOwner.media instanceof TLRPC.TL_messageMediaWebPage) && (this.messageOwner.media.webpage instanceof TLRPC.TL_webPage)) ? AndroidUtilities.dp(100.0f) : 0);
if (isReply()) {
return height + AndroidUtilities.dp(42.0f);
}
return height;
}
if (i == 2) {
return AndroidUtilities.dp(72.0f);
}
if (i == 12) {
return AndroidUtilities.dp(71.0f);
}
if (i == 9) {
return AndroidUtilities.dp(100.0f);
}
if (i == 4) {
return AndroidUtilities.dp(114.0f);
}
if (i == 14) {
return AndroidUtilities.dp(82.0f);
}
if (i == 10) {
return AndroidUtilities.dp(30.0f);
}
if (i == 11) {
return AndroidUtilities.dp(50.0f);
}
if (i == 5) {
return AndroidUtilities.roundMessageSize;
}
if (i == 13 || i == 15) {
float maxHeight = AndroidUtilities.displaySize.y * 0.4f;
if (AndroidUtilities.isTablet()) {
maxWidth = AndroidUtilities.getMinTabletSide() * 0.5f;
} else {
maxWidth = AndroidUtilities.displaySize.x * 0.5f;
}
int photoHeight = 0;
int photoWidth2 = 0;
TLRPC.Document document = getDocument();
int a = 0;
int N = document.attributes.size();
while (true) {
if (a >= N) {
break;
}
TLRPC.DocumentAttribute attribute = document.attributes.get(a);
if (!(attribute instanceof TLRPC.TL_documentAttributeImageSize)) {
a++;
} else {
photoWidth2 = attribute.w;
photoHeight = attribute.h;
break;
}
}
if (photoWidth2 == 0) {
photoHeight = (int) maxHeight;
photoWidth2 = photoHeight + AndroidUtilities.dp(100.0f);
}
if (photoHeight > maxHeight) {
photoWidth2 = (int) (photoWidth2 * (maxHeight / photoHeight));
photoHeight = (int) maxHeight;
}
if (photoWidth2 > maxWidth) {
photoHeight = (int) (photoHeight * (maxWidth / photoWidth2));
}
return AndroidUtilities.dp(14.0f) + photoHeight;
}
if (AndroidUtilities.isTablet()) {
photoWidth = (int) (AndroidUtilities.getMinTabletSide() * 0.7f);
} else {
photoWidth = (int) (Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y) * 0.7f);
}
int photoHeight2 = AndroidUtilities.dp(100.0f) + photoWidth;
if (photoWidth > AndroidUtilities.getPhotoSize()) {
photoWidth = AndroidUtilities.getPhotoSize();
}
if (photoHeight2 > AndroidUtilities.getPhotoSize()) {
photoHeight2 = AndroidUtilities.getPhotoSize();
}
TLRPC.PhotoSize currentPhotoObject = FileLoader.getClosestPhotoSizeWithSize(this.photoThumbs, AndroidUtilities.getPhotoSize());
if (currentPhotoObject != null) {
float scale = currentPhotoObject.w / photoWidth;
int h = (int) (currentPhotoObject.h / scale);
if (h == 0) {
h = AndroidUtilities.dp(100.0f);
}
if (h > photoHeight2) {
h = photoHeight2;
} else if (h < AndroidUtilities.dp(120.0f)) {
h = AndroidUtilities.dp(120.0f);
}
if (needDrawBluredPreview()) {
if (AndroidUtilities.isTablet()) {
h = (int) (AndroidUtilities.getMinTabletSide() * 0.5f);
} else {
h = (int) (Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y) * 0.5f);
}
}
photoHeight2 = h;
}
return AndroidUtilities.dp(14.0f) + photoHeight2;
}
public String getStickerEmoji() {
TLRPC.Document document = getDocument();
if (document == null) {
return null;
}
for (int a = 0; a < document.attributes.size(); a++) {
TLRPC.DocumentAttribute attribute = document.attributes.get(a);
if (attribute instanceof TLRPC.TL_documentAttributeSticker) {
if (attribute.alt == null || attribute.alt.length() <= 0) {
return null;
}
return attribute.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> documents = this.messageOwner.media.webpage.documents;
int N = documents.size();
for (int a = 0; a < N; a++) {
TLRPC.Document document = documents.get(a);
if ("application/x-tgtheme-android".equals(document.mime_type)) {
return true;
}
}
return false;
}
return false;
}
public String getMusicTitle() {
return getMusicTitle(true);
}
public String getMusicTitle(boolean unknown) {
TLRPC.Document document = getDocument();
if (document != null) {
for (int a = 0; a < document.attributes.size(); a++) {
TLRPC.DocumentAttribute attribute = document.attributes.get(a);
if (attribute instanceof TLRPC.TL_documentAttributeAudio) {
if (attribute.voice) {
if (!unknown) {
return null;
}
return LocaleController.formatDateAudio(this.messageOwner.date);
}
String title = attribute.title;
if (title == null || title.length() == 0) {
String title2 = FileLoader.getDocumentFileName(document);
if (TextUtils.isEmpty(title2) && unknown) {
return LocaleController.getString("AudioUnknownTitle", R.string.AudioUnknownTitle);
}
return title2;
}
return title;
}
if ((attribute instanceof TLRPC.TL_documentAttributeVideo) && attribute.round_message) {
return LocaleController.formatDateAudio(this.messageOwner.date);
}
}
String fileName = FileLoader.getDocumentFileName(document);
if (!TextUtils.isEmpty(fileName)) {
return fileName;
}
}
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 a = 0; a < document.attributes.size(); a++) {
TLRPC.DocumentAttribute attribute = document.attributes.get(a);
if (attribute instanceof TLRPC.TL_documentAttributeAudio) {
return attribute.duration;
}
if (attribute instanceof TLRPC.TL_documentAttributeVideo) {
return attribute.duration;
}
}
int a2 = this.audioPlayerDuration;
return a2;
}
public String getArtworkUrl(boolean small) {
TLRPC.Document document = getDocument();
String str = null;
if (document != null) {
int N = document.attributes.size();
for (int i = 0; i < N; i++) {
TLRPC.DocumentAttribute attribute = document.attributes.get(i);
if (attribute instanceof TLRPC.TL_documentAttributeAudio) {
if (attribute.voice) {
return str;
}
String performer = attribute.performer;
String title = attribute.title;
if (!TextUtils.isEmpty(performer)) {
int a = 0;
while (true) {
String[] strArr = excludeWords;
if (a >= strArr.length) {
break;
}
performer = performer.replace(strArr[a], " ");
a++;
}
}
if (TextUtils.isEmpty(performer) && TextUtils.isEmpty(title)) {
return str;
}
try {
StringBuilder sb = new StringBuilder();
sb.append("athumb://itunes.apple.com/search?term=");
sb.append(URLEncoder.encode(performer + " - " + title, "UTF-8"));
sb.append("&entity=song&limit=4");
sb.append(small ? "&s=1" : "");
return sb.toString();
} catch (Exception e) {
}
}
}
}
return str;
}
public String getMusicAuthor() {
return getMusicAuthor(true);
}
public String getMusicAuthor(boolean unknown) {
TLRPC.Document document = getDocument();
if (document != null) {
boolean isVoice = false;
for (int a = 0; a < document.attributes.size(); a++) {
TLRPC.DocumentAttribute attribute = document.attributes.get(a);
if (attribute instanceof TLRPC.TL_documentAttributeAudio) {
if (attribute.voice) {
isVoice = true;
} else {
String performer = attribute.performer;
if (TextUtils.isEmpty(performer) && unknown) {
return LocaleController.getString("AudioUnknownArtist", R.string.AudioUnknownArtist);
}
return performer;
}
} else if ((attribute instanceof TLRPC.TL_documentAttributeVideo) && attribute.round_message) {
isVoice = true;
}
if (isVoice) {
if (!unknown) {
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);
}
TLRPC.User user = null;
TLRPC.Chat chat = null;
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));
}
}
if (user != null) {
return UserObject.getName(user);
}
if (chat != null) {
return chat.title;
}
}
}
}
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 currentAccount, 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))) {
return false;
}
if (message.from_id == message.to_id.user_id && message.from_id == UserConfig.getInstance(currentAccount).getClientUserId() && !isLiveLocationMessage(message)) {
return true;
}
return !(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));
}
public static boolean canEditMessageScheduleTime(int currentAccount, TLRPC.Message message, TLRPC.Chat chat) {
if (chat == null && message.to_id.channel_id != 0 && (chat = MessagesController.getInstance(currentAccount).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 currentAccount, TLRPC.Message message, TLRPC.Chat chat, boolean scheduled) {
if (scheduled && message.date < ConnectionsManager.getInstance(currentAccount).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))) {
return false;
}
if (message.from_id == message.to_id.user_id && message.from_id == UserConfig.getInstance(currentAccount).getClientUserId() && !isLiveLocationMessage(message) && !(message.media instanceof TLRPC.TL_messageMediaContact)) {
return true;
}
if (chat == null && message.to_id.channel_id != 0 && (chat = MessagesController.getInstance(currentAccount).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 (!scheduled && Math.abs(message.date - ConnectionsManager.getInstance(currentAccount).getCurrentTime()) > MessagesController.getInstance(currentAccount).maxEditTime) {
return false;
}
if (message.to_id.channel_id != 0) {
return ((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));
}
if (message.out || message.from_id == UserConfig.getInstance(currentAccount).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;
}
public boolean canDeleteMessage(boolean inScheduleMode, TLRPC.Chat chat) {
return this.eventId == 0 && canDeleteMessage(this.currentAccount, inScheduleMode, this.messageOwner, chat);
}
public static boolean canDeleteMessage(int currentAccount, boolean inScheduleMode, TLRPC.Message message, TLRPC.Chat chat) {
if (message.id < 0) {
return true;
}
if (chat == null && message.to_id.channel_id != 0) {
chat = MessagesController.getInstance(currentAccount).getChat(Integer.valueOf(message.to_id.channel_id));
}
if (!ChatObject.isChannel(chat)) {
return inScheduleMode || isOut(message) || !ChatObject.isChannel(chat);
}
if (inScheduleMode && !chat.megagroup) {
if (chat.creator) {
return true;
}
return chat.admin_rights != null && (chat.admin_rights.delete_messages || message.out);
}
if (inScheduleMode) {
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) {
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;
}
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) {
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;
}
return 0;
}
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 flags = 0;
if (this.attachPathExists) {
flags = 0 | 1;
}
if (this.mediaExists) {
return flags | 2;
}
return flags;
}
public void applyMediaExistanceFlags(int flags) {
if (flags == -1) {
checkMediaExistance();
} else {
this.attachPathExists = (flags & 1) != 0;
this.mediaExists = (flags & 2) != 0;
}
}
public void checkMediaExistance() {
TLRPC.PhotoSize currentPhotoObject;
this.attachPathExists = false;
this.mediaExists = false;
int i = this.type;
if (i == 1) {
if (FileLoader.getClosestPhotoSizeWithSize(this.photoThumbs, AndroidUtilities.getPhotoSize()) != null) {
File file = FileLoader.getPathToMessage(this.messageOwner);
if (needDrawBluredPreview()) {
this.mediaExists = new File(file.getAbsolutePath() + ".enc").exists();
}
if (!this.mediaExists) {
this.mediaExists = file.exists();
return;
}
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) {
File f = new File(this.messageOwner.attachPath);
this.attachPathExists = f.exists();
}
if (!this.attachPathExists) {
File file2 = FileLoader.getPathToMessage(this.messageOwner);
if (this.type == 3 && needDrawBluredPreview()) {
this.mediaExists = new File(file2.getAbsolutePath() + ".enc").exists();
}
if (!this.mediaExists) {
this.mediaExists = file2.exists();
return;
}
return;
}
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 && (currentPhotoObject = FileLoader.getClosestPhotoSizeWithSize(this.photoThumbs, AndroidUtilities.getPhotoSize())) != null && currentPhotoObject != null) {
this.mediaExists = FileLoader.getPathToAttach(currentPhotoObject, true).exists();
}
}
public boolean equals(MessageObject obj) {
return getId() == obj.getId() && getDialogId() == obj.getDialogId();
}
}