Skip to content

Commit

Permalink
update to 10.2.9 (4087)
Browse files Browse the repository at this point in the history
  • Loading branch information
dkaraush committed Nov 15, 2023
1 parent 017f019 commit 220f6b4
Show file tree
Hide file tree
Showing 60 changed files with 848 additions and 359 deletions.
7 changes: 5 additions & 2 deletions TMessagesProj/jni/tgnet/ConnectionsManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2256,7 +2256,9 @@ void ConnectionsManager::processRequestQueue(uint32_t connectionTypes, uint32_t

switch (request->connectionType & 0x0000ffff) {
case ConnectionTypeGeneric:
genericRunningRequestCount++;
if (!request->failedByFloodWait) {
genericRunningRequestCount++;
}
break;
case ConnectionTypeDownload: {
auto map = request->isCancelRequest() ? downloadCancelRunningRequestCount : downloadRunningRequestCount;
Expand Down Expand Up @@ -2593,7 +2595,8 @@ void ConnectionsManager::processRequestQueue(uint32_t connectionTypes, uint32_t
case ConnectionTypeGenericMedia:
if (!canUseUnboundKey && genericRunningRequestCount >= 60) {
iter++;
DEBUG_D("skip queue, token = %d: generic type: running generic requests >= 60", request->requestToken);
if (LOGS_ENABLED)
DEBUG_D("skip queue, token = %d: generic type: running generic requests >= 60", request->requestToken);
continue;
}
genericRunningRequestCount++;
Expand Down
4 changes: 2 additions & 2 deletions TMessagesProj/src/main/assets/arctic.attheme
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ chat_outViewsSelected=-1258291201
chat_outInstant=-1
actionBarDefaultSearchPlaceholder=-2005173381
chat_outForwardedNameText=-1
dialogRoundCheckBox=-15033089
dialogRoundCheckBox=-13653259
actionBarTabLine=-13655305
chats_nameMessageArchived_threeLines=-7237231
chat_outSiteNameText=-1
Expand Down Expand Up @@ -251,7 +251,6 @@ inappPlayerClose=-7563878
chat_outMediaIcon=-13332255
chat_outAudioCacheSeekbar=738197503
chats_sentClock=2066650878
dialogFloatingButton=-15033089
chats_archiveBackground=-11294989
chat_inPreviewInstantText=-15299362
chat_outLoaderSelected=-1
Expand Down Expand Up @@ -281,3 +280,4 @@ chat_outReplyMediaMessageSelectedText=-1056964609
chat_serviceText=-1
chats_attachMessage=-13268780
chat_outSentClock=1895825407
chat_editMediaButton=-15033089
4 changes: 2 additions & 2 deletions TMessagesProj/src/main/assets/day.attheme
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ chat_outViewsSelected=-3676417
chat_outInstant=-1
actionBarDefaultSearchPlaceholder=-2005173381
chat_outForwardedNameText=-1
dialogRoundCheckBox=-15033089
dialogRoundCheckBox=-13653259
actionBarTabLine=-13655305
chats_nameMessageArchived_threeLines=-7237231
chat_outSiteNameText=-1
Expand Down Expand Up @@ -272,7 +272,6 @@ chat_outMediaIcon=-14707997
chat_outAudioCacheSeekbar=738197503
chats_sentClock=2073474246
chat_inAudioSeekbar=-2762017
dialogFloatingButton=-15033089
chats_archiveBackground=-11294989
chat_inPreviewInstantText=-15300135
chat_inViews=-274882397
Expand Down Expand Up @@ -306,3 +305,4 @@ chat_outReplyMediaMessageSelectedText=-3676417
chat_serviceText=-13092808
chats_attachMessage=-14321214
chat_outSentClock=1895825407
chat_editMediaButton=-15033089
2 changes: 1 addition & 1 deletion TMessagesProj/src/main/assets/night.attheme
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ actionBarDefaultSearchPlaceholder=-2097152001
profile_tabSelector=268435455
actionBarActionModeDefaultSelector=520093695
chat_outForwardedNameText=-5448193
dialogRoundCheckBox=-15033089
dialogRoundCheckBox=-10177041
chat_emojiPanelTrendingTitle=-1
actionBarTabLine=-12339201
chat_stickersHintPanel=-14606046
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ public class BuildVars {
public static boolean USE_CLOUD_STRINGS = true;
public static boolean CHECK_UPDATES = true;
public static boolean NO_SCOPED_STORAGE = Build.VERSION.SDK_INT <= 29;
public static int BUILD_VERSION = 4082;
public static String BUILD_VERSION_STRING = "10.2.6";
public static int BUILD_VERSION = 4087;
public static String BUILD_VERSION_STRING = "10.2.9";
public static int APP_ID = 4;
public static String APP_HASH = "014b35b6184100b085b0d0572f9b5103";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ public static void highlight(Spannable text, int start, int end, String lng, int
long S = System.currentTimeMillis();
final StringToken[][] tokens = new StringToken[1][];
try {
tokens[0] = tokenize(text.subSequence(start, end).toString(), compiledPatterns == null ? null : compiledPatterns.get(lng)).toArray();
tokens[0] = tokenize(text.subSequence(start, end).toString(), compiledPatterns == null ? null : compiledPatterns.get(lng), 0).toArray();
} catch (Exception e) {
FileLog.e(e);
}
Expand Down Expand Up @@ -289,15 +289,15 @@ public CachedToSpan(int group, int start, int end) {
}
}

private static LinkedList tokenize(String text, TokenPattern[] grammar) {
return tokenize(text, grammar, null);
private static LinkedList tokenize(String text, TokenPattern[] grammar, int depth) {
return tokenize(text, grammar, null, depth);
}

private static LinkedList tokenize(String text, TokenPattern[] grammar, TokenPattern ignorePattern) {
private static LinkedList tokenize(String text, TokenPattern[] grammar, TokenPattern ignorePattern, int depth) {
LinkedList list = new LinkedList();
list.addAfter(list.head, new StringToken(text));
grammar = flatRest(grammar);
matchGrammar(text, list, grammar, list.head, 0, null, ignorePattern);
matchGrammar(text, list, grammar, list.head, 0, null, ignorePattern, depth);
return list;
}

Expand Down Expand Up @@ -327,8 +327,8 @@ private static TokenPattern[] flatRest(TokenPattern[] patterns) {
return patterns;
}

private static void matchGrammar(String text, LinkedList tokenList, TokenPattern[] grammar, Node startNode, int startPos, RematchOptions rematch, TokenPattern ignorePattern) {
if (grammar == null) {
private static void matchGrammar(String text, LinkedList tokenList, TokenPattern[] grammar, Node startNode, int startPos, RematchOptions rematch, TokenPattern ignorePattern, int depth) {
if (grammar == null || depth > 20) {
return;
}
for (TokenPattern pattern : grammar) {
Expand Down Expand Up @@ -420,9 +420,9 @@ private static void matchGrammar(String text, LinkedList tokenList, TokenPattern

StringToken wrapped;
if (pattern.insideTokenPatterns != null) {
wrapped = new StringToken(pattern.group, tokenize(match.string, pattern.insideTokenPatterns), match.length);
wrapped = new StringToken(pattern.group, tokenize(match.string, pattern.insideTokenPatterns, depth + 1), match.length);
} else if (pattern.insideLanguage != null) {
wrapped = new StringToken(pattern.group, tokenize(match.string, compiledPatterns.get(pattern.insideLanguage), pattern), match.length);
wrapped = new StringToken(pattern.group, tokenize(match.string, compiledPatterns.get(pattern.insideLanguage), pattern, depth + 1), match.length);
} else {
wrapped = new StringToken(pattern.group, match.string);
}
Expand All @@ -436,7 +436,7 @@ private static void matchGrammar(String text, LinkedList tokenList, TokenPattern
RematchOptions nestedRematch = new RematchOptions();
nestedRematch.cause = pattern;
nestedRematch.reach = reach;
matchGrammar(text, tokenList, grammar, currentNode.prev, pos, nestedRematch, ignorePattern);
matchGrammar(text, tokenList, grammar, currentNode.prev, pos, nestedRematch, ignorePattern, depth + 1);

if (rematch != null && nestedRematch.reach > rematch.reach) {
rematch.reach = nestedRematch.reach;
Expand All @@ -447,7 +447,7 @@ private static void matchGrammar(String text, LinkedList tokenList, TokenPattern
}

private static Match matchPattern(TokenPattern pattern, int pos, String text) {
Matcher matcher = pattern.pattern.getPattern().matcher(text);
Matcher matcher = pattern.pattern.getPattern(). matcher(text);
matcher.region(pos, text.length());
if (!matcher.find()) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public static void dumpUnparsedMessage(TLObject message, long messageId) {
try {
checkGson();
getInstance().dateFormat.format(System.currentTimeMillis());
String messageStr = "receive message -> " + message.getClass().getSimpleName() + " : " + gson.toJson(message);
String messageStr = "receive message -> " + message.getClass().getSimpleName() + " : " + (gsonDisabled ? message : gson.toJson(message));
String res = "null";
long time = System.currentTimeMillis();
FileLog.getInstance().logQueue.postRunnable(() -> {
Expand All @@ -150,6 +150,11 @@ public static void dumpUnparsedMessage(TLObject message, long messageId) {
}
}

private static boolean gsonDisabled;
public static void disableGson(boolean disable) {
gsonDisabled = disable;
}

private static void checkGson() {
if (gson == null) {
HashSet<String> privateFields = new HashSet<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ public MediaDataController(int num) {
} else {
draftPreferences = ApplicationLoader.applicationContext.getSharedPreferences("drafts" + currentAccount, Activity.MODE_PRIVATE);
}
final ArrayList<TLRPC.Message> replyMessageOwners = new ArrayList<>();
Map<String, ?> values = draftPreferences.getAll();
for (Map.Entry<String, ?> entry : values.entrySet()) {
try {
Expand All @@ -163,6 +164,9 @@ public MediaDataController(int num) {
}
int threadId = isThread ? Utilities.parseInt(key.substring(key.lastIndexOf('_') + 1)) : 0;
threads.put(threadId, message);
if (message.reply_to != null) {
replyMessageOwners.add(message);
}
}
} else {
TLRPC.DraftMessage draftMessage = TLRPC.DraftMessage.TLdeserialize(serializedData, serializedData.readInt32(true), true);
Expand All @@ -181,6 +185,7 @@ public MediaDataController(int num) {
//igonre
}
}
loadRepliesOfDraftReplies(replyMessageOwners);

loadStickersByEmojiOrName(AndroidUtilities.STICKERS_PLACEHOLDER_PACK_NAME, false, true);
loadEmojiThemes();
Expand All @@ -192,6 +197,30 @@ public MediaDataController(int num) {
menuBotsUpdateDate = getMessagesController().getMainSettings().getInt("menuBotsUpdateDate", 0);
}

private void loadRepliesOfDraftReplies(final ArrayList<TLRPC.Message> messages) {
if (messages == null || messages.isEmpty()) {
return;
}
getMessagesStorage().getStorageQueue().postRunnable(() -> {
try {
ArrayList<Long> usersToLoad = new ArrayList<>();
ArrayList<Long> chatsToLoad = new ArrayList<>();
LongSparseArray<SparseArray<ArrayList<TLRPC.Message>>> replyMessageOwners = new LongSparseArray<>();
LongSparseArray<ArrayList<Integer>> dialogReplyMessagesIds = new LongSparseArray<>();
for (int i = 0; i < messages.size(); ++i) {
try {
MessagesStorage.addReplyMessages(messages.get(i), replyMessageOwners, dialogReplyMessagesIds);
} catch (Exception e) {
getMessagesStorage().checkSQLException(e);
}
}
getMessagesStorage().loadReplyMessages(replyMessageOwners, dialogReplyMessagesIds, usersToLoad, chatsToLoad, false);
} catch (Exception e) {
FileLog.e(e);
}
});
}

public static final int TYPE_IMAGE = 0;
public static final int TYPE_MASK = 1;
public static final int TYPE_FAVE = 2;
Expand Down Expand Up @@ -6641,12 +6670,12 @@ public void saveDraft(long dialogId, int threadId, CharSequence message, ArrayLi
if (quote != null) {
draftMessage.reply_to.quote_text = quote.getText();
if (draftMessage.reply_to.quote_text != null) {
draftMessage.reply_to.flags |= 64;
draftMessage.reply_to.flags |= 4;
}
draftMessage.reply_to.quote_entities = quote.getEntities();
if (draftMessage.reply_to.quote_entities != null && !draftMessage.reply_to.quote_entities.isEmpty()) {
draftMessage.reply_to.quote_entities = new ArrayList<>(draftMessage.reply_to.quote_entities);
draftMessage.reply_to.flags |= 128;
draftMessage.reply_to.flags |= 8;
}
if (quote.message != null && quote.message.messageOwner != null) {
TLRPC.Peer peer2 = getMessagesController().getPeer(dialogId);
Expand Down Expand Up @@ -6826,9 +6855,9 @@ public void saveDraft(long dialogId, int threadId, TLRPC.DraftMessage draft, TLR
if (threads != null) {
replyToMessage = threads.get(threadId);
}
if (replyToMessage == null || replyToMessage.id != draft.reply_to.reply_to_msg_id || !MessageObject.peersEqual(draft.reply_to.reply_to_peer_id, replyToMessage.peer_id)) {
replyToMessage = null;
}
// if (replyToMessage == null || replyToMessage.id != draft.reply_to.reply_to_msg_id || !MessageObject.peersEqual(draft.reply_to.reply_to_peer_id, replyToMessage.peer_id)) {
// replyToMessage = null;
// }
} else if (draft != null && draft.reply_to == null) {
replyToMessage = null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -689,8 +689,8 @@ public static class TextLayoutBlock {
public Drawable copySelector;
public Paint copySeparator;

public void layoutCode(String lng, int codeLength) {
hasCodeCopyButton = codeLength >= 75;
public void layoutCode(String lng, int codeLength, boolean noforwards) {
hasCodeCopyButton = codeLength >= 75 && !noforwards;
if (hasCodeCopyButton) {
copyText = new Text(LocaleController.getString(R.string.CopyCode).toUpperCase(), SharedConfig.fontSize - 3, AndroidUtilities.getTypeface(AndroidUtilities.TYPEFACE_ROBOTO_MEDIUM));
copyIcon = ApplicationLoader.applicationContext.getResources().getDrawable(R.drawable.msg_copy).mutate();
Expand Down Expand Up @@ -4210,7 +4210,7 @@ private void updateMessageText(AbstractMap<Long, TLRPC.User> users, AbstractMap<
} else if (!isMediaEmpty()) {
// messageText = getMediaTitle(getMedia(messageOwner)); // I'm afraid doing this
if (getMedia(messageOwner) instanceof TLRPC.TL_messageMediaGiveaway) {
messageText = LocaleController.getString("BoostingGiveaway", R.string.BoostingGiveaway);
messageText = LocaleController.getString("BoostingGiveawayChannelStarted", R.string.BoostingGiveawayChannelStarted);
} else if (getMedia(messageOwner) instanceof TLRPC.TL_messageMediaStory) {
if (getMedia(messageOwner).via_mention) {
TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(getMedia(messageOwner).user_id);
Expand Down Expand Up @@ -6036,6 +6036,11 @@ public void generateLayout(TLRPC.User fromUser) {
return;
}
boolean hasUrls = applyEntities();
boolean noforwards = messageOwner != null && messageOwner.noforwards;
if (!noforwards) {
TLRPC.Chat chat = MessagesController.getInstance(currentAccount).getChat(-getDialogId());
noforwards = chat != null && chat.noforwards;
}

textLayoutBlocks = new ArrayList<>();
textWidth = 0;
Expand Down Expand Up @@ -6184,7 +6189,7 @@ public void generateLayout(TLRPC.User fromUser) {
block.padBottom = dp(7);
}
} else if (block.code) {
block.layoutCode(range.language, range.end - range.start);
block.layoutCode(range.language, range.end - range.start, noforwards);
block.padTop = dp(4) + block.languageHeight + (block.first ? 0 : dp(5));
block.padBottom = dp(4) + (block.last ? 0 : dp(7)) + (block.hasCodeCopyButton ? dp(38) : 0);
}
Expand Down Expand Up @@ -6459,6 +6464,11 @@ public static class TextLayoutBlocks {
public TextLayoutBlocks(MessageObject messageObject, @NonNull CharSequence text, TextPaint textPaint, int width) {
this.text = text;
textWidth = 0;
boolean noforwards = messageObject != null && messageObject.messageOwner != null && messageObject.messageOwner.noforwards;
if (messageObject != null && !noforwards) {
TLRPC.Chat chat = MessagesController.getInstance(messageObject.currentAccount).getChat(-messageObject.getDialogId());
noforwards = chat != null && chat.noforwards;
}

hasCode = text instanceof Spanned && ((Spanned) text).getSpans(0, text.length(), CodeHighlighting.Span.class).length > 0;
hasQuote = text instanceof Spanned && ((Spanned) text).getSpans(0, text.length(), QuoteSpan.QuoteStyleSpan.class).length > 0;
Expand Down Expand Up @@ -6581,7 +6591,7 @@ public TextLayoutBlocks(MessageObject messageObject, @NonNull CharSequence text,
block.padBottom = dp(7);
}
} else if (block.code) {
block.layoutCode(range.language, range.end - range.start);
block.layoutCode(range.language, range.end - range.start, noforwards);
block.padTop = dp(4) + block.languageHeight + (block.first ? 0 : dp(5));
block.padBottom = dp(4) + (block.last ? 0 : dp(7)) + (block.hasCodeCopyButton ? dp(38) : 0);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5243,6 +5243,9 @@ protected void clearFullUsers() {
loadedFullChats.clear();
}

private final LongSparseArray<Long> peerDialogsRequested = new LongSparseArray<Long>();
private final long peerDialogRequestTimeout = 1000 * 60 * 4;

private void reloadDialogsReadValue(ArrayList<TLRPC.Dialog> dialogs, long did) {
if (did == 0 && (dialogs == null || dialogs.isEmpty())) {
return;
Expand All @@ -5256,7 +5259,12 @@ private void reloadDialogsReadValue(ArrayList<TLRPC.Dialog> dialogs, long did) {
}
TLRPC.TL_inputDialogPeer inputDialogPeer = new TLRPC.TL_inputDialogPeer();
inputDialogPeer.peer = inputPeer;
req.peers.add(inputDialogPeer);
final long _did = DialogObject.getPeerDialogId(inputPeer);
Long lastRequest = peerDialogsRequested.get(_did);
if (lastRequest == null || System.currentTimeMillis() - lastRequest > peerDialogRequestTimeout) {
req.peers.add(inputDialogPeer);
peerDialogsRequested.put(_did, System.currentTimeMillis());
}
}
} else {
TLRPC.InputPeer inputPeer = getInputPeer(did);
Expand All @@ -5265,7 +5273,12 @@ private void reloadDialogsReadValue(ArrayList<TLRPC.Dialog> dialogs, long did) {
}
TLRPC.TL_inputDialogPeer inputDialogPeer = new TLRPC.TL_inputDialogPeer();
inputDialogPeer.peer = inputPeer;
req.peers.add(inputDialogPeer);
final long _did = DialogObject.getPeerDialogId(inputPeer);
Long lastRequest = peerDialogsRequested.get(_did);
if (lastRequest == null || System.currentTimeMillis() - lastRequest > peerDialogRequestTimeout) {
req.peers.add(inputDialogPeer);
peerDialogsRequested.put(_did, System.currentTimeMillis());
}
}
if (req.peers.isEmpty()) {
return;
Expand Down
Loading

0 comments on commit 220f6b4

Please sign in to comment.