Skip to content

Commit

Permalink
update to 10.2.6 (4082)
Browse files Browse the repository at this point in the history
  • Loading branch information
dkaraush authored and 030 committed Nov 25, 2023
1 parent 3764bcd commit 67e8802
Show file tree
Hide file tree
Showing 66 changed files with 1,795 additions and 455 deletions.
9 changes: 8 additions & 1 deletion TMessagesProj/src/main/assets/darkblue.attheme
Original file line number Diff line number Diff line change
Expand Up @@ -429,4 +429,11 @@ chat_searchPanelText=-8796932
chat_inContactIcon=-1
code_comment=-2130706433
chat_outCodeBackground=857487708
chat_inCodeBackground=856033549
chat_inCodeBackground=856033549
code_keyword=-27776
code_constant=-27776
code_function=-27776
code_string=-7806088
code_operator=2147483647
code_number=-10887465
code_comment=2147483647
Binary file modified TMessagesProj/src/main/assets/fonts/rmono.ttf
Binary file not shown.
9 changes: 8 additions & 1 deletion TMessagesProj/src/main/assets/night.attheme
Original file line number Diff line number Diff line change
Expand Up @@ -454,4 +454,11 @@ chat_searchPanelText=-10767620
chat_inContactIcon=-1
code_comment=-2130706433
chat_outCodeBackground=859062986
chat_inCodeBackground=855638016
chat_inCodeBackground=855638016
code_keyword=-27776
code_constant=-27776
code_function=-27776
code_string=-7806088
code_operator=2147483647
code_number=-10887465
code_comment=2147483647
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,35 @@ public void updateDrawState(TextPaint textPaint) {
return spannableStringBuilder;
}

public static SpannableStringBuilder replaceSingleLink(String str, int color) {
int startIndex = str.indexOf("**");
int endIndex = str.indexOf("**", startIndex + 1);
str = str.replace("**", "");
int index = -1;
int len = 0;
if (startIndex >= 0 && endIndex >= 0 && endIndex - startIndex > 2) {
len = endIndex - startIndex - 2;
index = startIndex;
}
SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(str);
if (index >= 0) {
spannableStringBuilder.setSpan(new ClickableSpan() {
@Override
public void updateDrawState(@NonNull TextPaint ds) {
super.updateDrawState(ds);
ds.setUnderlineText(false);
ds.setColor(color);
}

@Override
public void onClick(@NonNull View view) {

}
}, index, index + len, 0);
}
return spannableStringBuilder;
}

public static void recycleBitmaps(List<Bitmap> bitmapToRecycle) {
if (Build.VERSION.SDK_INT <= 23) {
// cause to crash:
Expand Down Expand Up @@ -2944,6 +2973,9 @@ public static void shakeViewSpring(View view, Runnable endCallback) {
}

public static void shakeViewSpring(View view, float shiftDp, Runnable endCallback) {
if (view == null) {
return;
}
int shift = dp(shiftDp);
if (view.getTag(R.id.spring_tag) != null) {
((SpringAnimation) view.getTag(R.id.spring_tag)).cancel();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ public class BuildVars {
public static boolean LOGS_ENABLED = DEBUG_PRIVATE_VERSION;
public static boolean USE_CLOUD_STRINGS = true;
public static boolean NO_SCOPED_STORAGE = Build.VERSION.SDK_INT <= 29;
public static int BUILD_VERSION = 4075;
public static String BUILD_VERSION_STRING = "10.2.3";
public static int BUILD_VERSION = 4082;
public static String BUILD_VERSION_STRING = "10.2.6";
public static int APP_ID = 4;
public static String APP_HASH = "014b35b6184100b085b0d0572f9b5103";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
package org.telegram.messenger;

import static org.telegram.messenger.AndroidUtilities.dp;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Typeface;
import android.text.Editable;
import android.text.Layout;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.SpannableStringBuilder;
Expand All @@ -12,6 +16,7 @@
import android.text.TextPaint;
import android.text.TextUtils;
import android.text.style.CharacterStyle;
import android.text.style.LeadingMarginSpan;
import android.text.style.LineHeightSpan;
import android.text.style.MetricAffectingSpan;
import android.util.Log;
Expand Down Expand Up @@ -52,7 +57,13 @@ public class CodeHighlighting {
public static final int MATCH_COMMENT = 6;
public static final int MATCH_FUNCTION = 7;

public static class Span extends MetricAffectingSpan {
public static int getTextSizeDecrement(int codeLength) {
if (codeLength > 120) return 5;
if (codeLength > 50) return 3;
return 2;
}

public static class Span extends CharacterStyle {

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

this.lng = lng;
this.code = code;
if (code == null) {
this.decrementSize = 2;
} else if (code.length() > 120) {
this.decrementSize = 5;
} else if (code.length() > 50) {
this.decrementSize = 3;
} else {
this.decrementSize = 2;
}
this.decrementSize = getTextSizeDecrement(code == null ? 0 : code.length());
this.currentType = type;
this.style = style;
}

@Override
public void updateMeasureState(TextPaint p) {
if (smallerSize) {
p.setTextSize(AndroidUtilities.dp(SharedConfig.fontSize - decrementSize));
}
p.setFlags(p.getFlags() | Paint.SUBPIXEL_TEXT_FLAG);
if (style != null) {
style.applyStyle(p);
} else {
p.setTypeface(Typeface.MONOSPACE);
}
}

@Override
public void updateDrawState(TextPaint p) {
if (smallerSize) {
p.setTextSize(AndroidUtilities.dp(SharedConfig.fontSize - decrementSize));
p.setTextSize(dp(SharedConfig.fontSize - decrementSize));
}
if (currentType == 2) {
p.setColor(0xffffffff);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1384,6 +1384,14 @@ public static int migrate(MessagesStorage messagesStorage, int version) throws E
version = 135;
}

if (version == 135) {
// database.executeFast("DROP TABLE stickersets").stepThis().dispose();
database.executeFast("CREATE TABLE stickersets2(id INTEGER PRIMATE KEY, data BLOB, hash INTEGER, date INTEGER);").stepThis().dispose();
database.executeFast("CREATE INDEX IF NOT EXISTS stickersets2_id_index ON stickersets2(id);").stepThis().dispose();
database.executeFast("PRAGMA user_version = 136").stepThis().dispose();
version = 136;
}

return version;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ private static void checkGson() {
//exclude file loading
excludeRequests = new HashSet<>();
excludeRequests.add("TL_upload_getFile");
excludeRequests.add("TL_upload_a");
excludeRequests.add("TL_upload_getWebFile");

ExclusionStrategy strategy = new ExclusionStrategy() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1192,34 +1192,52 @@ public TLRPC.TL_messages_stickerSet getStickerSet(TLRPC.InputStickerSet inputSti
return null;
}

private boolean cleanedupStickerSetCache;
private void cleanupStickerSetCache() {
if (cleanedupStickerSetCache) {
return;
}
cleanedupStickerSetCache = true;
getMessagesStorage().getStorageQueue().postRunnable(() -> {
try {
final long minDate = (System.currentTimeMillis() - 1000 * 60 * 60 * 24 * 7);
getMessagesStorage().getDatabase().executeFast("DELETE FROM stickersets2 WHERE date < " + minDate).stepThis().dispose();
} catch (Exception e) {
FileLog.e(e);
}
});
}

private void saveStickerSetIntoCache(TLRPC.TL_messages_stickerSet set) {
if (set == null || set.set == null) {
return;
}
getMessagesStorage().getStorageQueue().postRunnable(() -> {
try {
SQLitePreparedStatement state = getMessagesStorage().getDatabase().executeFast("REPLACE INTO stickersets VALUES(?, ?, ?)");
SQLitePreparedStatement state = getMessagesStorage().getDatabase().executeFast("REPLACE INTO stickersets2 VALUES(?, ?, ?, ?)");
state.requery();
NativeByteBuffer data = new NativeByteBuffer(set.getObjectSize());
set.serializeToStream(data);
state.bindLong(1, set.set.id);
state.bindByteBuffer(2, data);
state.bindInteger(3, set.set.hash);
state.bindLong(4, System.currentTimeMillis());
state.step();
data.reuse();
state.dispose();
} catch (Exception e) {
FileLog.e(e);
}
});
cleanupStickerSetCache();
}

private TLRPC.TL_messages_stickerSet getCachedStickerSetInternal(long id, Integer hash) {
TLRPC.TL_messages_stickerSet set = null;
SQLiteCursor cursor = null;
NativeByteBuffer data = null;
try {
cursor = getMessagesStorage().getDatabase().queryFinalized("SELECT data, hash FROM stickersets WHERE id = " + id + " LIMIT 1");
cursor = getMessagesStorage().getDatabase().queryFinalized("SELECT data, hash FROM stickersets2 WHERE id = " + id + " LIMIT 1");
if (cursor.next() && !cursor.isNull(0)) {
data = cursor.byteBufferValue(0);
if (data != null) {
Expand Down Expand Up @@ -6272,11 +6290,15 @@ public ArrayList<TLRPC.MessageEntity> getEntities(CharSequence[] message, boolea
content = substring(content, 0, content.length() - 1);
}
if (!TextUtils.isEmpty(content)) {
if (content.length() > 1 && content.charAt(0) == '\n') {
content = content.subSequence(1, content.length());
index--;
}
message[0] = AndroidUtilities.concat(startMessage, content, endMessage);
TLRPC.TL_messageEntityPre entity = new TLRPC.TL_messageEntityPre();
entity.offset = start + (replacedFirst ? 0 : 1);
entity.length = index - start - 3 - (language.length() + (!language.isEmpty() ? 1 : 0)) + (replacedFirst ? 0 : 1);
entity.language = language;
entity.language = TextUtils.isEmpty(language) || language.trim().length() == 0 ? "" : language;
entities.add(entity);
lastIndex -= 6;
}
Expand Down Expand Up @@ -6619,10 +6641,13 @@ public void saveDraft(long dialogId, int threadId, CharSequence message, ArrayLi
TLRPC.Peer peer2 = getMessagesController().getPeer(dialogId);
TLRPC.Peer thisPeer = quote.message.messageOwner.peer_id;
if (peer2 != null && !MessageObject.peersEqual(peer2, thisPeer)) {
draftMessage.reply_to.flags |= 1;
draftMessage.reply_to.reply_to_peer_id = getMessagesController().getInputPeer(peer2);
draftMessage.reply_to.flags |= 2;
draftMessage.reply_to.reply_to_peer_id = getMessagesController().getInputPeer(thisPeer);
}
}
} else if (dialogId != MessageObject.getDialogId(replyToMessage)) {
draftMessage.reply_to.flags |= 2;
draftMessage.reply_to.reply_to_peer_id = getMessagesController().getInputPeer(getMessagesController().getPeer(MessageObject.getDialogId(replyToMessage)));
}
}
if (entities != null && !entities.isEmpty()) {
Expand All @@ -6633,10 +6658,20 @@ public void saveDraft(long dialogId, int threadId, CharSequence message, ArrayLi
SparseArray<TLRPC.DraftMessage> threads = drafts.get(dialogId);
TLRPC.DraftMessage currentDraft = threads == null ? null : threads.get(threadId);
if (!clean) {
if (
currentDraft != null && currentDraft.message.equals(draftMessage.message) && replyToEquals(currentDraft.reply_to, draftMessage.reply_to) && currentDraft.no_webpage == draftMessage.no_webpage ||
currentDraft == null && TextUtils.isEmpty(draftMessage.message) && (draftMessage.reply_to == null || draftMessage.reply_to.reply_to_msg_id == 0)
) {
boolean sameDraft;
if (currentDraft != null) {
sameDraft = (
currentDraft.message.equals(draftMessage.message) &&
replyToEquals(currentDraft.reply_to, draftMessage.reply_to) &&
currentDraft.no_webpage == draftMessage.no_webpage
);
} else {
sameDraft = (
TextUtils.isEmpty(draftMessage.message) &&
(draftMessage.reply_to == null || draftMessage.reply_to.reply_to_msg_id == 0)
);
}
if (sameDraft) {
return;
}
}
Expand Down Expand Up @@ -6780,7 +6815,7 @@ 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(replyToMessage.peer_id, getMessagesController().getPeer(draft.reply_to.reply_to_msg_id))) {
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) {
Expand Down Expand Up @@ -6812,13 +6847,14 @@ public void saveDraft(long dialogId, int threadId, TLRPC.DraftMessage draft, TLR
}
editor.apply();
if (fromServer && (threadId == 0 || getMessagesController().isForum(dialogId))) {
if (draft != null && draft.reply_to != null && draft.reply_to.reply_to_msg_id != 0 && replyToMessage == null) {
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)) {
final long replyDialogId = (draft.reply_to.flags & 2) != 0 ? DialogObject.getPeerDialogId(draft.reply_to.reply_to_peer_id) : dialogId;
TLRPC.User user = null;
TLRPC.Chat chat = null;
if (DialogObject.isUserDialog(dialogId)) {
user = getMessagesController().getUser(dialogId);
if (DialogObject.isUserDialog(replyDialogId)) {
user = getMessagesController().getUser(replyDialogId);
} else {
chat = getMessagesController().getChat(-dialogId);
chat = getMessagesController().getChat(-replyDialogId);
}
if (user != null || chat != null) {
long channelId = ChatObject.isChannel(chat) ? chat.id : 0;
Expand All @@ -6827,14 +6863,41 @@ public void saveDraft(long dialogId, int threadId, TLRPC.DraftMessage draft, TLR
getMessagesStorage().getStorageQueue().postRunnable(() -> {
try {
TLRPC.Message message = null;
SQLiteCursor cursor = getMessagesStorage().getDatabase().queryFinalized(String.format(Locale.US, "SELECT data FROM messages_v2 WHERE mid = %d and uid = %d", messageId, dialogId));
SQLiteCursor cursor = getMessagesStorage().getDatabase().queryFinalized(String.format(Locale.US, "SELECT data, replydata FROM messages_v2 WHERE mid = %d and uid = %d", messageId, replyDialogId));
if (cursor.next()) {
NativeByteBuffer data = cursor.byteBufferValue(0);
if (data != null) {
message = TLRPC.Message.TLdeserialize(data, data.readInt32(false), false);
message.readAttachPath(data, getUserConfig().clientUserId);
data.reuse();
}
if (message != null) {
ArrayList<Long> usersToLoad = new ArrayList<>();
ArrayList<Long> chatsToLoad = new ArrayList<>();
LongSparseArray<SparseArray<ArrayList<TLRPC.Message>>> replyMessageOwners = new LongSparseArray<>();
LongSparseArray<ArrayList<Integer>> dialogReplyMessagesIds = new LongSparseArray<>();
try {
if (message.reply_to != null && message.reply_to.reply_to_msg_id != 0) {
if (!cursor.isNull(1)) {
NativeByteBuffer data2 = cursor.byteBufferValue(1);
if (data2 != null) {
message.replyMessage = TLRPC.Message.TLdeserialize(data2, data2.readInt32(false), false);
message.replyMessage.readAttachPath(data2, getUserConfig().clientUserId);
data2.reuse();
if (message.replyMessage != null) {
MessagesStorage.addUsersAndChatsFromMessage(message.replyMessage, usersToLoad, chatsToLoad, null);
}
}
}
if (message.replyMessage == null) {
MessagesStorage.addReplyMessages(message, replyMessageOwners, dialogReplyMessagesIds);
}
}
} catch (Exception e) {
getMessagesStorage().checkSQLException(e);
}
getMessagesStorage().loadReplyMessages(replyMessageOwners, dialogReplyMessagesIds, usersToLoad, chatsToLoad, false);
}
}
cursor.dispose();
if (message == null) {
Expand Down
Loading

0 comments on commit 67e8802

Please sign in to comment.