Skip to content

Commit 017f019

Browse files
committed
update to 10.2.6 (4082)
1 parent c319639 commit 017f019

File tree

67 files changed

+1832
-484
lines changed

Some content is hidden

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

67 files changed

+1832
-484
lines changed

TMessagesProj/src/main/assets/darkblue.attheme

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,4 +429,11 @@ chat_searchPanelText=-8796932
429429
chat_inContactIcon=-1
430430
code_comment=-2130706433
431431
chat_outCodeBackground=857487708
432-
chat_inCodeBackground=856033549
432+
chat_inCodeBackground=856033549
433+
code_keyword=-27776
434+
code_constant=-27776
435+
code_function=-27776
436+
code_string=-7806088
437+
code_operator=2147483647
438+
code_number=-10887465
439+
code_comment=2147483647

TMessagesProj/src/main/assets/fonts/rmono.ttf

100755100644
-26.7 KB
Binary file not shown.

TMessagesProj/src/main/assets/night.attheme

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,4 +454,11 @@ chat_searchPanelText=-10767620
454454
chat_inContactIcon=-1
455455
code_comment=-2130706433
456456
chat_outCodeBackground=859062986
457-
chat_inCodeBackground=855638016
457+
chat_inCodeBackground=855638016
458+
code_keyword=-27776
459+
code_constant=-27776
460+
code_function=-27776
461+
code_string=-7806088
462+
code_operator=2147483647
463+
code_number=-10887465
464+
code_comment=2147483647

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

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,35 @@ public void updateDrawState(TextPaint textPaint) {
515515
return spannableStringBuilder;
516516
}
517517

518+
public static SpannableStringBuilder replaceSingleLink(String str, int color) {
519+
int startIndex = str.indexOf("**");
520+
int endIndex = str.indexOf("**", startIndex + 1);
521+
str = str.replace("**", "");
522+
int index = -1;
523+
int len = 0;
524+
if (startIndex >= 0 && endIndex >= 0 && endIndex - startIndex > 2) {
525+
len = endIndex - startIndex - 2;
526+
index = startIndex;
527+
}
528+
SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(str);
529+
if (index >= 0) {
530+
spannableStringBuilder.setSpan(new ClickableSpan() {
531+
@Override
532+
public void updateDrawState(@NonNull TextPaint ds) {
533+
super.updateDrawState(ds);
534+
ds.setUnderlineText(false);
535+
ds.setColor(color);
536+
}
537+
538+
@Override
539+
public void onClick(@NonNull View view) {
540+
541+
}
542+
}, index, index + len, 0);
543+
}
544+
return spannableStringBuilder;
545+
}
546+
518547
public static void recycleBitmaps(List<Bitmap> bitmapToRecycle) {
519548
if (Build.VERSION.SDK_INT <= 23) {
520549
// cause to crash:
@@ -2941,6 +2970,9 @@ public static void shakeViewSpring(View view, Runnable endCallback) {
29412970
}
29422971

29432972
public static void shakeViewSpring(View view, float shiftDp, Runnable endCallback) {
2973+
if (view == null) {
2974+
return;
2975+
}
29442976
int shift = dp(shiftDp);
29452977
if (view.getTag(R.id.spring_tag) != null) {
29462978
((SpringAnimation) view.getTag(R.id.spring_tag)).cancel();

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 = 4075;
28-
public static String BUILD_VERSION_STRING = "10.2.3";
27+
public static int BUILD_VERSION = 4082;
28+
public static String BUILD_VERSION_STRING = "10.2.6";
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: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
package org.telegram.messenger;
22

3+
import static org.telegram.messenger.AndroidUtilities.dp;
4+
35
import android.content.Context;
6+
import android.graphics.Canvas;
47
import android.graphics.Paint;
58
import android.graphics.Typeface;
69
import android.text.Editable;
10+
import android.text.Layout;
711
import android.text.Spannable;
812
import android.text.SpannableString;
913
import android.text.SpannableStringBuilder;
@@ -12,6 +16,7 @@
1216
import android.text.TextPaint;
1317
import android.text.TextUtils;
1418
import android.text.style.CharacterStyle;
19+
import android.text.style.LeadingMarginSpan;
1520
import android.text.style.LineHeightSpan;
1621
import android.text.style.MetricAffectingSpan;
1722
import android.util.Log;
@@ -52,7 +57,13 @@ public class CodeHighlighting {
5257
public static final int MATCH_COMMENT = 6;
5358
public static final int MATCH_FUNCTION = 7;
5459

55-
public static class Span extends MetricAffectingSpan {
60+
public static int getTextSizeDecrement(int codeLength) {
61+
if (codeLength > 120) return 5;
62+
if (codeLength > 50) return 3;
63+
return 2;
64+
}
65+
66+
public static class Span extends CharacterStyle {
5667

5768
public final String lng;
5869
public final String code;
@@ -67,36 +78,15 @@ public Span(boolean smallerSize, int type, TextStyleSpan.TextStyleRun style, Str
6778

6879
this.lng = lng;
6980
this.code = code;
70-
if (code == null) {
71-
this.decrementSize = 2;
72-
} else if (code.length() > 120) {
73-
this.decrementSize = 5;
74-
} else if (code.length() > 50) {
75-
this.decrementSize = 3;
76-
} else {
77-
this.decrementSize = 2;
78-
}
81+
this.decrementSize = getTextSizeDecrement(code == null ? 0 : code.length());
7982
this.currentType = type;
8083
this.style = style;
8184
}
8285

83-
@Override
84-
public void updateMeasureState(TextPaint p) {
85-
if (smallerSize) {
86-
p.setTextSize(AndroidUtilities.dp(SharedConfig.fontSize - decrementSize));
87-
}
88-
p.setFlags(p.getFlags() | Paint.SUBPIXEL_TEXT_FLAG);
89-
if (style != null) {
90-
style.applyStyle(p);
91-
} else {
92-
p.setTypeface(Typeface.MONOSPACE);
93-
}
94-
}
95-
9686
@Override
9787
public void updateDrawState(TextPaint p) {
9888
if (smallerSize) {
99-
p.setTextSize(AndroidUtilities.dp(SharedConfig.fontSize - decrementSize));
89+
p.setTextSize(dp(SharedConfig.fontSize - decrementSize));
10090
}
10191
if (currentType == 2) {
10292
p.setColor(0xffffffff);

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1384,6 +1384,14 @@ public static int migrate(MessagesStorage messagesStorage, int version) throws E
13841384
version = 135;
13851385
}
13861386

1387+
if (version == 135) {
1388+
// database.executeFast("DROP TABLE stickersets").stepThis().dispose();
1389+
database.executeFast("CREATE TABLE stickersets2(id INTEGER PRIMATE KEY, data BLOB, hash INTEGER, date INTEGER);").stepThis().dispose();
1390+
database.executeFast("CREATE INDEX IF NOT EXISTS stickersets2_id_index ON stickersets2(id);").stepThis().dispose();
1391+
database.executeFast("PRAGMA user_version = 136").stepThis().dispose();
1392+
version = 136;
1393+
}
1394+
13871395
return version;
13881396
}
13891397

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ private static void checkGson() {
170170
//exclude file loading
171171
excludeRequests = new HashSet<>();
172172
excludeRequests.add("TL_upload_getFile");
173-
excludeRequests.add("TL_upload_a");
173+
excludeRequests.add("TL_upload_getWebFile");
174174

175175
ExclusionStrategy strategy = new ExclusionStrategy() {
176176

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

Lines changed: 78 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1244,34 +1244,52 @@ public TLRPC.TL_messages_stickerSet getStickerSet(TLRPC.InputStickerSet inputSti
12441244
return null;
12451245
}
12461246

1247+
private boolean cleanedupStickerSetCache;
1248+
private void cleanupStickerSetCache() {
1249+
if (cleanedupStickerSetCache) {
1250+
return;
1251+
}
1252+
cleanedupStickerSetCache = true;
1253+
getMessagesStorage().getStorageQueue().postRunnable(() -> {
1254+
try {
1255+
final long minDate = (System.currentTimeMillis() - 1000 * 60 * 60 * 24 * 7);
1256+
getMessagesStorage().getDatabase().executeFast("DELETE FROM stickersets2 WHERE date < " + minDate).stepThis().dispose();
1257+
} catch (Exception e) {
1258+
FileLog.e(e);
1259+
}
1260+
});
1261+
}
1262+
12471263
private void saveStickerSetIntoCache(TLRPC.TL_messages_stickerSet set) {
12481264
if (set == null || set.set == null) {
12491265
return;
12501266
}
12511267
getMessagesStorage().getStorageQueue().postRunnable(() -> {
12521268
try {
1253-
SQLitePreparedStatement state = getMessagesStorage().getDatabase().executeFast("REPLACE INTO stickersets VALUES(?, ?, ?)");
1269+
SQLitePreparedStatement state = getMessagesStorage().getDatabase().executeFast("REPLACE INTO stickersets2 VALUES(?, ?, ?, ?)");
12541270
state.requery();
12551271
NativeByteBuffer data = new NativeByteBuffer(set.getObjectSize());
12561272
set.serializeToStream(data);
12571273
state.bindLong(1, set.set.id);
12581274
state.bindByteBuffer(2, data);
12591275
state.bindInteger(3, set.set.hash);
1276+
state.bindLong(4, System.currentTimeMillis());
12601277
state.step();
12611278
data.reuse();
12621279
state.dispose();
12631280
} catch (Exception e) {
12641281
FileLog.e(e);
12651282
}
12661283
});
1284+
cleanupStickerSetCache();
12671285
}
12681286

12691287
private TLRPC.TL_messages_stickerSet getCachedStickerSetInternal(long id, Integer hash) {
12701288
TLRPC.TL_messages_stickerSet set = null;
12711289
SQLiteCursor cursor = null;
12721290
NativeByteBuffer data = null;
12731291
try {
1274-
cursor = getMessagesStorage().getDatabase().queryFinalized("SELECT data, hash FROM stickersets WHERE id = " + id + " LIMIT 1");
1292+
cursor = getMessagesStorage().getDatabase().queryFinalized("SELECT data, hash FROM stickersets2 WHERE id = " + id + " LIMIT 1");
12751293
if (cursor.next() && !cursor.isNull(0)) {
12761294
data = cursor.byteBufferValue(0);
12771295
if (data != null) {
@@ -6283,11 +6301,15 @@ public ArrayList<TLRPC.MessageEntity> getEntities(CharSequence[] message, boolea
62836301
content = substring(content, 0, content.length() - 1);
62846302
}
62856303
if (!TextUtils.isEmpty(content)) {
6304+
if (content.length() > 1 && content.charAt(0) == '\n') {
6305+
content = content.subSequence(1, content.length());
6306+
index--;
6307+
}
62866308
message[0] = AndroidUtilities.concat(startMessage, content, endMessage);
62876309
TLRPC.TL_messageEntityPre entity = new TLRPC.TL_messageEntityPre();
62886310
entity.offset = start + (replacedFirst ? 0 : 1);
62896311
entity.length = index - start - 3 - (language.length() + (!language.isEmpty() ? 1 : 0)) + (replacedFirst ? 0 : 1);
6290-
entity.language = language;
6312+
entity.language = TextUtils.isEmpty(language) || language.trim().length() == 0 ? "" : language;
62916313
entities.add(entity);
62926314
lastIndex -= 6;
62936315
}
@@ -6630,10 +6652,13 @@ public void saveDraft(long dialogId, int threadId, CharSequence message, ArrayLi
66306652
TLRPC.Peer peer2 = getMessagesController().getPeer(dialogId);
66316653
TLRPC.Peer thisPeer = quote.message.messageOwner.peer_id;
66326654
if (peer2 != null && !MessageObject.peersEqual(peer2, thisPeer)) {
6633-
draftMessage.reply_to.flags |= 1;
6634-
draftMessage.reply_to.reply_to_peer_id = getMessagesController().getInputPeer(peer2);
6655+
draftMessage.reply_to.flags |= 2;
6656+
draftMessage.reply_to.reply_to_peer_id = getMessagesController().getInputPeer(thisPeer);
66356657
}
66366658
}
6659+
} else if (dialogId != MessageObject.getDialogId(replyToMessage)) {
6660+
draftMessage.reply_to.flags |= 2;
6661+
draftMessage.reply_to.reply_to_peer_id = getMessagesController().getInputPeer(getMessagesController().getPeer(MessageObject.getDialogId(replyToMessage)));
66376662
}
66386663
}
66396664
if (entities != null && !entities.isEmpty()) {
@@ -6644,10 +6669,20 @@ public void saveDraft(long dialogId, int threadId, CharSequence message, ArrayLi
66446669
SparseArray<TLRPC.DraftMessage> threads = drafts.get(dialogId);
66456670
TLRPC.DraftMessage currentDraft = threads == null ? null : threads.get(threadId);
66466671
if (!clean) {
6647-
if (
6648-
currentDraft != null && currentDraft.message.equals(draftMessage.message) && replyToEquals(currentDraft.reply_to, draftMessage.reply_to) && currentDraft.no_webpage == draftMessage.no_webpage ||
6649-
currentDraft == null && TextUtils.isEmpty(draftMessage.message) && (draftMessage.reply_to == null || draftMessage.reply_to.reply_to_msg_id == 0)
6650-
) {
6672+
boolean sameDraft;
6673+
if (currentDraft != null) {
6674+
sameDraft = (
6675+
currentDraft.message.equals(draftMessage.message) &&
6676+
replyToEquals(currentDraft.reply_to, draftMessage.reply_to) &&
6677+
currentDraft.no_webpage == draftMessage.no_webpage
6678+
);
6679+
} else {
6680+
sameDraft = (
6681+
TextUtils.isEmpty(draftMessage.message) &&
6682+
(draftMessage.reply_to == null || draftMessage.reply_to.reply_to_msg_id == 0)
6683+
);
6684+
}
6685+
if (sameDraft) {
66516686
return;
66526687
}
66536688
}
@@ -6791,7 +6826,7 @@ public void saveDraft(long dialogId, int threadId, TLRPC.DraftMessage draft, TLR
67916826
if (threads != null) {
67926827
replyToMessage = threads.get(threadId);
67936828
}
6794-
if (replyToMessage == null || replyToMessage.id != draft.reply_to.reply_to_msg_id || !MessageObject.peersEqual(replyToMessage.peer_id, getMessagesController().getPeer(draft.reply_to.reply_to_msg_id))) {
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)) {
67956830
replyToMessage = null;
67966831
}
67976832
} else if (draft != null && draft.reply_to == null) {
@@ -6823,13 +6858,14 @@ public void saveDraft(long dialogId, int threadId, TLRPC.DraftMessage draft, TLR
68236858
}
68246859
editor.commit();
68256860
if (fromServer && (threadId == 0 || getMessagesController().isForum(dialogId))) {
6826-
if (draft != null && draft.reply_to != null && draft.reply_to.reply_to_msg_id != 0 && replyToMessage == null) {
6861+
if (draft != null && draft.reply_to != null && draft.reply_to.reply_to_msg_id != 0 && (replyToMessage == null || replyToMessage.reply_to instanceof TLRPC.TL_messageReplyHeader && replyToMessage.replyMessage == null)) {
6862+
final long replyDialogId = (draft.reply_to.flags & 2) != 0 ? DialogObject.getPeerDialogId(draft.reply_to.reply_to_peer_id) : dialogId;
68276863
TLRPC.User user = null;
68286864
TLRPC.Chat chat = null;
6829-
if (DialogObject.isUserDialog(dialogId)) {
6830-
user = getMessagesController().getUser(dialogId);
6865+
if (DialogObject.isUserDialog(replyDialogId)) {
6866+
user = getMessagesController().getUser(replyDialogId);
68316867
} else {
6832-
chat = getMessagesController().getChat(-dialogId);
6868+
chat = getMessagesController().getChat(-replyDialogId);
68336869
}
68346870
if (user != null || chat != null) {
68356871
long channelId = ChatObject.isChannel(chat) ? chat.id : 0;
@@ -6838,14 +6874,41 @@ public void saveDraft(long dialogId, int threadId, TLRPC.DraftMessage draft, TLR
68386874
getMessagesStorage().getStorageQueue().postRunnable(() -> {
68396875
try {
68406876
TLRPC.Message message = null;
6841-
SQLiteCursor cursor = getMessagesStorage().getDatabase().queryFinalized(String.format(Locale.US, "SELECT data FROM messages_v2 WHERE mid = %d and uid = %d", messageId, dialogId));
6877+
SQLiteCursor cursor = getMessagesStorage().getDatabase().queryFinalized(String.format(Locale.US, "SELECT data, replydata FROM messages_v2 WHERE mid = %d and uid = %d", messageId, replyDialogId));
68426878
if (cursor.next()) {
68436879
NativeByteBuffer data = cursor.byteBufferValue(0);
68446880
if (data != null) {
68456881
message = TLRPC.Message.TLdeserialize(data, data.readInt32(false), false);
68466882
message.readAttachPath(data, getUserConfig().clientUserId);
68476883
data.reuse();
68486884
}
6885+
if (message != null) {
6886+
ArrayList<Long> usersToLoad = new ArrayList<>();
6887+
ArrayList<Long> chatsToLoad = new ArrayList<>();
6888+
LongSparseArray<SparseArray<ArrayList<TLRPC.Message>>> replyMessageOwners = new LongSparseArray<>();
6889+
LongSparseArray<ArrayList<Integer>> dialogReplyMessagesIds = new LongSparseArray<>();
6890+
try {
6891+
if (message.reply_to != null && message.reply_to.reply_to_msg_id != 0) {
6892+
if (!cursor.isNull(1)) {
6893+
NativeByteBuffer data2 = cursor.byteBufferValue(1);
6894+
if (data2 != null) {
6895+
message.replyMessage = TLRPC.Message.TLdeserialize(data2, data2.readInt32(false), false);
6896+
message.replyMessage.readAttachPath(data2, getUserConfig().clientUserId);
6897+
data2.reuse();
6898+
if (message.replyMessage != null) {
6899+
MessagesStorage.addUsersAndChatsFromMessage(message.replyMessage, usersToLoad, chatsToLoad, null);
6900+
}
6901+
}
6902+
}
6903+
if (message.replyMessage == null) {
6904+
MessagesStorage.addReplyMessages(message, replyMessageOwners, dialogReplyMessagesIds);
6905+
}
6906+
}
6907+
} catch (Exception e) {
6908+
getMessagesStorage().checkSQLException(e);
6909+
}
6910+
getMessagesStorage().loadReplyMessages(replyMessageOwners, dialogReplyMessagesIds, usersToLoad, chatsToLoad, false);
6911+
}
68496912
}
68506913
cursor.dispose();
68516914
if (message == null) {

0 commit comments

Comments
 (0)