Skip to content

Commit 220f6b4

Browse files
committed
update to 10.2.9 (4087)
1 parent 017f019 commit 220f6b4

File tree

60 files changed

+848
-359
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+848
-359
lines changed

TMessagesProj/jni/tgnet/ConnectionsManager.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2256,7 +2256,9 @@ void ConnectionsManager::processRequestQueue(uint32_t connectionTypes, uint32_t
22562256

22572257
switch (request->connectionType & 0x0000ffff) {
22582258
case ConnectionTypeGeneric:
2259-
genericRunningRequestCount++;
2259+
if (!request->failedByFloodWait) {
2260+
genericRunningRequestCount++;
2261+
}
22602262
break;
22612263
case ConnectionTypeDownload: {
22622264
auto map = request->isCancelRequest() ? downloadCancelRunningRequestCount : downloadRunningRequestCount;
@@ -2593,7 +2595,8 @@ void ConnectionsManager::processRequestQueue(uint32_t connectionTypes, uint32_t
25932595
case ConnectionTypeGenericMedia:
25942596
if (!canUseUnboundKey && genericRunningRequestCount >= 60) {
25952597
iter++;
2596-
DEBUG_D("skip queue, token = %d: generic type: running generic requests >= 60", request->requestToken);
2598+
if (LOGS_ENABLED)
2599+
DEBUG_D("skip queue, token = %d: generic type: running generic requests >= 60", request->requestToken);
25972600
continue;
25982601
}
25992602
genericRunningRequestCount++;

TMessagesProj/src/main/assets/arctic.attheme

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ chat_outViewsSelected=-1258291201
132132
chat_outInstant=-1
133133
actionBarDefaultSearchPlaceholder=-2005173381
134134
chat_outForwardedNameText=-1
135-
dialogRoundCheckBox=-15033089
135+
dialogRoundCheckBox=-13653259
136136
actionBarTabLine=-13655305
137137
chats_nameMessageArchived_threeLines=-7237231
138138
chat_outSiteNameText=-1
@@ -251,7 +251,6 @@ inappPlayerClose=-7563878
251251
chat_outMediaIcon=-13332255
252252
chat_outAudioCacheSeekbar=738197503
253253
chats_sentClock=2066650878
254-
dialogFloatingButton=-15033089
255254
chats_archiveBackground=-11294989
256255
chat_inPreviewInstantText=-15299362
257256
chat_outLoaderSelected=-1
@@ -281,3 +280,4 @@ chat_outReplyMediaMessageSelectedText=-1056964609
281280
chat_serviceText=-1
282281
chats_attachMessage=-13268780
283282
chat_outSentClock=1895825407
283+
chat_editMediaButton=-15033089

TMessagesProj/src/main/assets/day.attheme

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ chat_outViewsSelected=-3676417
142142
chat_outInstant=-1
143143
actionBarDefaultSearchPlaceholder=-2005173381
144144
chat_outForwardedNameText=-1
145-
dialogRoundCheckBox=-15033089
145+
dialogRoundCheckBox=-13653259
146146
actionBarTabLine=-13655305
147147
chats_nameMessageArchived_threeLines=-7237231
148148
chat_outSiteNameText=-1
@@ -272,7 +272,6 @@ chat_outMediaIcon=-14707997
272272
chat_outAudioCacheSeekbar=738197503
273273
chats_sentClock=2073474246
274274
chat_inAudioSeekbar=-2762017
275-
dialogFloatingButton=-15033089
276275
chats_archiveBackground=-11294989
277276
chat_inPreviewInstantText=-15300135
278277
chat_inViews=-274882397
@@ -306,3 +305,4 @@ chat_outReplyMediaMessageSelectedText=-3676417
306305
chat_serviceText=-13092808
307306
chats_attachMessage=-14321214
308307
chat_outSentClock=1895825407
308+
chat_editMediaButton=-15033089

TMessagesProj/src/main/assets/night.attheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ actionBarDefaultSearchPlaceholder=-2097152001
214214
profile_tabSelector=268435455
215215
actionBarActionModeDefaultSelector=520093695
216216
chat_outForwardedNameText=-5448193
217-
dialogRoundCheckBox=-15033089
217+
dialogRoundCheckBox=-10177041
218218
chat_emojiPanelTrendingTitle=-1
219219
actionBarTabLine=-12339201
220220
chat_stickersHintPanel=-14606046

TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ public class BuildVars {
2424
public static boolean USE_CLOUD_STRINGS = true;
2525
public static boolean CHECK_UPDATES = true;
2626
public static boolean NO_SCOPED_STORAGE = Build.VERSION.SDK_INT <= 29;
27-
public static int BUILD_VERSION = 4082;
28-
public static String BUILD_VERSION_STRING = "10.2.6";
27+
public static int BUILD_VERSION = 4087;
28+
public static String BUILD_VERSION_STRING = "10.2.9";
2929
public static int APP_ID = 4;
3030
public static String APP_HASH = "014b35b6184100b085b0d0572f9b5103";
3131

TMessagesProj/src/main/java/org/telegram/messenger/CodeHighlighting.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ public static void highlight(Spannable text, int start, int end, String lng, int
214214
long S = System.currentTimeMillis();
215215
final StringToken[][] tokens = new StringToken[1][];
216216
try {
217-
tokens[0] = tokenize(text.subSequence(start, end).toString(), compiledPatterns == null ? null : compiledPatterns.get(lng)).toArray();
217+
tokens[0] = tokenize(text.subSequence(start, end).toString(), compiledPatterns == null ? null : compiledPatterns.get(lng), 0).toArray();
218218
} catch (Exception e) {
219219
FileLog.e(e);
220220
}
@@ -289,15 +289,15 @@ public CachedToSpan(int group, int start, int end) {
289289
}
290290
}
291291

292-
private static LinkedList tokenize(String text, TokenPattern[] grammar) {
293-
return tokenize(text, grammar, null);
292+
private static LinkedList tokenize(String text, TokenPattern[] grammar, int depth) {
293+
return tokenize(text, grammar, null, depth);
294294
}
295295

296-
private static LinkedList tokenize(String text, TokenPattern[] grammar, TokenPattern ignorePattern) {
296+
private static LinkedList tokenize(String text, TokenPattern[] grammar, TokenPattern ignorePattern, int depth) {
297297
LinkedList list = new LinkedList();
298298
list.addAfter(list.head, new StringToken(text));
299299
grammar = flatRest(grammar);
300-
matchGrammar(text, list, grammar, list.head, 0, null, ignorePattern);
300+
matchGrammar(text, list, grammar, list.head, 0, null, ignorePattern, depth);
301301
return list;
302302
}
303303

@@ -327,8 +327,8 @@ private static TokenPattern[] flatRest(TokenPattern[] patterns) {
327327
return patterns;
328328
}
329329

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

421421
StringToken wrapped;
422422
if (pattern.insideTokenPatterns != null) {
423-
wrapped = new StringToken(pattern.group, tokenize(match.string, pattern.insideTokenPatterns), match.length);
423+
wrapped = new StringToken(pattern.group, tokenize(match.string, pattern.insideTokenPatterns, depth + 1), match.length);
424424
} else if (pattern.insideLanguage != null) {
425-
wrapped = new StringToken(pattern.group, tokenize(match.string, compiledPatterns.get(pattern.insideLanguage), pattern), match.length);
425+
wrapped = new StringToken(pattern.group, tokenize(match.string, compiledPatterns.get(pattern.insideLanguage), pattern, depth + 1), match.length);
426426
} else {
427427
wrapped = new StringToken(pattern.group, match.string);
428428
}
@@ -436,7 +436,7 @@ private static void matchGrammar(String text, LinkedList tokenList, TokenPattern
436436
RematchOptions nestedRematch = new RematchOptions();
437437
nestedRematch.cause = pattern;
438438
nestedRematch.reach = reach;
439-
matchGrammar(text, tokenList, grammar, currentNode.prev, pos, nestedRematch, ignorePattern);
439+
matchGrammar(text, tokenList, grammar, currentNode.prev, pos, nestedRematch, ignorePattern, depth + 1);
440440

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

449449
private static Match matchPattern(TokenPattern pattern, int pos, String text) {
450-
Matcher matcher = pattern.pattern.getPattern().matcher(text);
450+
Matcher matcher = pattern.pattern.getPattern(). matcher(text);
451451
matcher.region(pos, text.length());
452452
if (!matcher.find()) {
453453
return null;

TMessagesProj/src/main/java/org/telegram/messenger/FileLog.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ public static void dumpUnparsedMessage(TLObject message, long messageId) {
126126
try {
127127
checkGson();
128128
getInstance().dateFormat.format(System.currentTimeMillis());
129-
String messageStr = "receive message -> " + message.getClass().getSimpleName() + " : " + gson.toJson(message);
129+
String messageStr = "receive message -> " + message.getClass().getSimpleName() + " : " + (gsonDisabled ? message : gson.toJson(message));
130130
String res = "null";
131131
long time = System.currentTimeMillis();
132132
FileLog.getInstance().logQueue.postRunnable(() -> {
@@ -150,6 +150,11 @@ public static void dumpUnparsedMessage(TLObject message, long messageId) {
150150
}
151151
}
152152

153+
private static boolean gsonDisabled;
154+
public static void disableGson(boolean disable) {
155+
gsonDisabled = disable;
156+
}
157+
153158
private static void checkGson() {
154159
if (gson == null) {
155160
HashSet<String> privateFields = new HashSet<>();

TMessagesProj/src/main/java/org/telegram/messenger/MediaDataController.java

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ public MediaDataController(int num) {
144144
} else {
145145
draftPreferences = ApplicationLoader.applicationContext.getSharedPreferences("drafts" + currentAccount, Activity.MODE_PRIVATE);
146146
}
147+
final ArrayList<TLRPC.Message> replyMessageOwners = new ArrayList<>();
147148
Map<String, ?> values = draftPreferences.getAll();
148149
for (Map.Entry<String, ?> entry : values.entrySet()) {
149150
try {
@@ -163,6 +164,9 @@ public MediaDataController(int num) {
163164
}
164165
int threadId = isThread ? Utilities.parseInt(key.substring(key.lastIndexOf('_') + 1)) : 0;
165166
threads.put(threadId, message);
167+
if (message.reply_to != null) {
168+
replyMessageOwners.add(message);
169+
}
166170
}
167171
} else {
168172
TLRPC.DraftMessage draftMessage = TLRPC.DraftMessage.TLdeserialize(serializedData, serializedData.readInt32(true), true);
@@ -181,6 +185,7 @@ public MediaDataController(int num) {
181185
//igonre
182186
}
183187
}
188+
loadRepliesOfDraftReplies(replyMessageOwners);
184189

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

200+
private void loadRepliesOfDraftReplies(final ArrayList<TLRPC.Message> messages) {
201+
if (messages == null || messages.isEmpty()) {
202+
return;
203+
}
204+
getMessagesStorage().getStorageQueue().postRunnable(() -> {
205+
try {
206+
ArrayList<Long> usersToLoad = new ArrayList<>();
207+
ArrayList<Long> chatsToLoad = new ArrayList<>();
208+
LongSparseArray<SparseArray<ArrayList<TLRPC.Message>>> replyMessageOwners = new LongSparseArray<>();
209+
LongSparseArray<ArrayList<Integer>> dialogReplyMessagesIds = new LongSparseArray<>();
210+
for (int i = 0; i < messages.size(); ++i) {
211+
try {
212+
MessagesStorage.addReplyMessages(messages.get(i), replyMessageOwners, dialogReplyMessagesIds);
213+
} catch (Exception e) {
214+
getMessagesStorage().checkSQLException(e);
215+
}
216+
}
217+
getMessagesStorage().loadReplyMessages(replyMessageOwners, dialogReplyMessagesIds, usersToLoad, chatsToLoad, false);
218+
} catch (Exception e) {
219+
FileLog.e(e);
220+
}
221+
});
222+
}
223+
195224
public static final int TYPE_IMAGE = 0;
196225
public static final int TYPE_MASK = 1;
197226
public static final int TYPE_FAVE = 2;
@@ -6641,12 +6670,12 @@ public void saveDraft(long dialogId, int threadId, CharSequence message, ArrayLi
66416670
if (quote != null) {
66426671
draftMessage.reply_to.quote_text = quote.getText();
66436672
if (draftMessage.reply_to.quote_text != null) {
6644-
draftMessage.reply_to.flags |= 64;
6673+
draftMessage.reply_to.flags |= 4;
66456674
}
66466675
draftMessage.reply_to.quote_entities = quote.getEntities();
66476676
if (draftMessage.reply_to.quote_entities != null && !draftMessage.reply_to.quote_entities.isEmpty()) {
66486677
draftMessage.reply_to.quote_entities = new ArrayList<>(draftMessage.reply_to.quote_entities);
6649-
draftMessage.reply_to.flags |= 128;
6678+
draftMessage.reply_to.flags |= 8;
66506679
}
66516680
if (quote.message != null && quote.message.messageOwner != null) {
66526681
TLRPC.Peer peer2 = getMessagesController().getPeer(dialogId);
@@ -6826,9 +6855,9 @@ public void saveDraft(long dialogId, int threadId, TLRPC.DraftMessage draft, TLR
68266855
if (threads != null) {
68276856
replyToMessage = threads.get(threadId);
68286857
}
6829-
if (replyToMessage == null || replyToMessage.id != draft.reply_to.reply_to_msg_id || !MessageObject.peersEqual(draft.reply_to.reply_to_peer_id, replyToMessage.peer_id)) {
6830-
replyToMessage = null;
6831-
}
6858+
// if (replyToMessage == null || replyToMessage.id != draft.reply_to.reply_to_msg_id || !MessageObject.peersEqual(draft.reply_to.reply_to_peer_id, replyToMessage.peer_id)) {
6859+
// replyToMessage = null;
6860+
// }
68326861
} else if (draft != null && draft.reply_to == null) {
68336862
replyToMessage = null;
68346863
}

TMessagesProj/src/main/java/org/telegram/messenger/MessageObject.java

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -689,8 +689,8 @@ public static class TextLayoutBlock {
689689
public Drawable copySelector;
690690
public Paint copySeparator;
691691

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

60406045
textLayoutBlocks = new ArrayList<>();
60416046
textWidth = 0;
@@ -6184,7 +6189,7 @@ public void generateLayout(TLRPC.User fromUser) {
61846189
block.padBottom = dp(7);
61856190
}
61866191
} else if (block.code) {
6187-
block.layoutCode(range.language, range.end - range.start);
6192+
block.layoutCode(range.language, range.end - range.start, noforwards);
61886193
block.padTop = dp(4) + block.languageHeight + (block.first ? 0 : dp(5));
61896194
block.padBottom = dp(4) + (block.last ? 0 : dp(7)) + (block.hasCodeCopyButton ? dp(38) : 0);
61906195
}
@@ -6459,6 +6464,11 @@ public static class TextLayoutBlocks {
64596464
public TextLayoutBlocks(MessageObject messageObject, @NonNull CharSequence text, TextPaint textPaint, int width) {
64606465
this.text = text;
64616466
textWidth = 0;
6467+
boolean noforwards = messageObject != null && messageObject.messageOwner != null && messageObject.messageOwner.noforwards;
6468+
if (messageObject != null && !noforwards) {
6469+
TLRPC.Chat chat = MessagesController.getInstance(messageObject.currentAccount).getChat(-messageObject.getDialogId());
6470+
noforwards = chat != null && chat.noforwards;
6471+
}
64626472

64636473
hasCode = text instanceof Spanned && ((Spanned) text).getSpans(0, text.length(), CodeHighlighting.Span.class).length > 0;
64646474
hasQuote = text instanceof Spanned && ((Spanned) text).getSpans(0, text.length(), QuoteSpan.QuoteStyleSpan.class).length > 0;
@@ -6581,7 +6591,7 @@ public TextLayoutBlocks(MessageObject messageObject, @NonNull CharSequence text,
65816591
block.padBottom = dp(7);
65826592
}
65836593
} else if (block.code) {
6584-
block.layoutCode(range.language, range.end - range.start);
6594+
block.layoutCode(range.language, range.end - range.start, noforwards);
65856595
block.padTop = dp(4) + block.languageHeight + (block.first ? 0 : dp(5));
65866596
block.padBottom = dp(4) + (block.last ? 0 : dp(7)) + (block.hasCodeCopyButton ? dp(38) : 0);
65876597
}

TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5243,6 +5243,9 @@ protected void clearFullUsers() {
52435243
loadedFullChats.clear();
52445244
}
52455245

5246+
private final LongSparseArray<Long> peerDialogsRequested = new LongSparseArray<Long>();
5247+
private final long peerDialogRequestTimeout = 1000 * 60 * 4;
5248+
52465249
private void reloadDialogsReadValue(ArrayList<TLRPC.Dialog> dialogs, long did) {
52475250
if (did == 0 && (dialogs == null || dialogs.isEmpty())) {
52485251
return;
@@ -5256,7 +5259,12 @@ private void reloadDialogsReadValue(ArrayList<TLRPC.Dialog> dialogs, long did) {
52565259
}
52575260
TLRPC.TL_inputDialogPeer inputDialogPeer = new TLRPC.TL_inputDialogPeer();
52585261
inputDialogPeer.peer = inputPeer;
5259-
req.peers.add(inputDialogPeer);
5262+
final long _did = DialogObject.getPeerDialogId(inputPeer);
5263+
Long lastRequest = peerDialogsRequested.get(_did);
5264+
if (lastRequest == null || System.currentTimeMillis() - lastRequest > peerDialogRequestTimeout) {
5265+
req.peers.add(inputDialogPeer);
5266+
peerDialogsRequested.put(_did, System.currentTimeMillis());
5267+
}
52605268
}
52615269
} else {
52625270
TLRPC.InputPeer inputPeer = getInputPeer(did);
@@ -5265,7 +5273,12 @@ private void reloadDialogsReadValue(ArrayList<TLRPC.Dialog> dialogs, long did) {
52655273
}
52665274
TLRPC.TL_inputDialogPeer inputDialogPeer = new TLRPC.TL_inputDialogPeer();
52675275
inputDialogPeer.peer = inputPeer;
5268-
req.peers.add(inputDialogPeer);
5276+
final long _did = DialogObject.getPeerDialogId(inputPeer);
5277+
Long lastRequest = peerDialogsRequested.get(_did);
5278+
if (lastRequest == null || System.currentTimeMillis() - lastRequest > peerDialogRequestTimeout) {
5279+
req.peers.add(inputDialogPeer);
5280+
peerDialogsRequested.put(_did, System.currentTimeMillis());
5281+
}
52695282
}
52705283
if (req.peers.isEmpty()) {
52715284
return;

0 commit comments

Comments
 (0)