Skip to content

Commit 12caa1e

Browse files
committed
Update to 5.13.0 (1823)
1 parent 4e55e97 commit 12caa1e

20 files changed

+181
-95
lines changed

TMessagesProj/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ android {
283283
}
284284
}
285285

286-
defaultConfig.versionCode = 1821
286+
defaultConfig.versionCode = 1823
287287

288288
applicationVariants.all { variant ->
289289
variant.outputs.all { output ->

TMessagesProj/jni/tgnet/ConnectionsManager.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1434,7 +1434,7 @@ void ConnectionsManager::processServerResponse(TLObject *message, int64_t messag
14341434
int64_t time = (int64_t) (messageId / 4294967296.0 * 1000);
14351435
int64_t currentTime = getCurrentTimeMillis();
14361436
timeDifference = (int32_t) ((time - currentTime) / 1000 - currentPingTime / 2);
1437-
lastOutgoingMessageId = messageId > (lastOutgoingMessageId ? messageId : lastOutgoingMessageId);
1437+
lastOutgoingMessageId = (messageId > lastOutgoingMessageId ? messageId : lastOutgoingMessageId);
14381438
}
14391439
if ((connection->getConnectionType() & ConnectionTypeDownload) == 0 || !datacenter->containsServerSalt(messageSalt, media)) {
14401440
TL_bad_server_salt *response = (TL_bad_server_salt *) message;
@@ -2186,7 +2186,7 @@ void ConnectionsManager::processRequestQueue(uint32_t connectionTypes, uint32_t
21862186

21872187
bool forceThisRequest = (connectionTypes & requestConnectionType) && requestDatacenter->getDatacenterId() == dc;
21882188

2189-
if (typeInfo == typeid(TL_get_future_salts) || typeInfo == typeid(TL_destroy_session)) {
2189+
if (typeInfo == typeid(TL_get_future_salts)) {
21902190
if (request->messageId != 0) {
21912191
request->addRespondMessageId(request->messageId);
21922192
}

TMessagesProj/jni/tgnet/Datacenter.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,8 @@ void Datacenter::mergeServerSalts(TL_future_salts *futureSalts, bool media) {
688688
std::vector<std::unique_ptr<TL_future_salt>> &salts = media ? mediaServerSalts : serverSalts;
689689

690690
int32_t date = ConnectionsManager::getInstance(instanceNum).getCurrentTime();
691-
std::vector<int64_t> existingSalts(salts.size());
691+
std::vector<int64_t> existingSalts;
692+
existingSalts.reserve(salts.size());
692693
size_t size = salts.size();
693694
for (uint32_t a = 0; a < size; a++) {
694695
existingSalts.push_back(salts[a]->salt);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public class BuildVars {
1919
public static boolean USE_CLOUD_STRINGS = true;
2020
public static boolean CHECK_UPDATES = true;
2121
public static boolean TON_WALLET_STANDALONE = false;
22-
public static int BUILD_VERSION = 1821;
22+
public static int BUILD_VERSION = 1823;
2323
public static String BUILD_VERSION_STRING = "5.13.0";
2424
public static int APP_ID = 4;
2525
public static String APP_HASH = "014b35b6184100b085b0d0572f9b5103";

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ private void cancelLoadFile(final TLRPC.Document document, final SecureDocument
446446
}
447447

448448
public boolean isLoadingFile(final String fileName) {
449-
return loadOperationPathsUI.containsKey(fileName);
449+
return fileName != null && loadOperationPathsUI.containsKey(fileName);
450450
}
451451

452452
public float getBufferedProgressFromPosition(final float position, final String fileName) {

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

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4523,7 +4523,10 @@ private TLRPC.TL_dialogFolder ensureFolderDialogExists(int folderId, boolean[] f
45234523
for (int a = 0; a < allDialogs.size(); a++) {
45244524
TLRPC.Dialog d = allDialogs.get(a);
45254525
if (!d.pinned) {
4526-
break;
4526+
if (d.id != proxyDialogId) {
4527+
break;
4528+
}
4529+
continue;
45274530
}
45284531
maxPinnedNum = Math.max(d.pinnedNum, maxPinnedNum);
45294532
}
@@ -8196,7 +8199,10 @@ public void reorderPinnedDialogs(int folderId, ArrayList<TLRPC.InputDialogPeer>
81968199
continue;
81978200
}
81988201
if (!dialog.pinned) {
8199-
break;
8202+
if (dialog.id != proxyDialogId) {
8203+
break;
8204+
}
8205+
continue;
82008206
}
82018207
getMessagesStorage().setDialogPinned(dialog.id, dialog.pinnedNum);
82028208
if ((int) dialog.id != 0) {
@@ -8250,7 +8256,10 @@ public boolean pinDialog(long did, boolean pin, TLRPC.InputPeer peer, long taskI
82508256
continue;
82518257
}
82528258
if (!d.pinned) {
8253-
break;
8259+
if (d.id != proxyDialogId) {
8260+
break;
8261+
}
8262+
continue;
82548263
}
82558264
maxPinnedNum = Math.max(d.pinnedNum, maxPinnedNum);
82568265
}
@@ -8413,7 +8422,10 @@ public void loadPinnedDialogs(final int folderId, final long newDialogId, final
84138422
continue;
84148423
}
84158424
if (!dialog.pinned) {
8416-
break;
8425+
if (dialog.id != proxyDialogId) {
8426+
break;
8427+
}
8428+
continue;
84178429
}
84188430
maxPinnedNum = Math.max(dialog.pinnedNum, maxPinnedNum);
84198431
dialog.pinned = false;

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

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7261,16 +7261,14 @@ public void putMessages(final TLRPC.messages_Messages messages, final long dialo
72617261
message.attachPath = oldMessage.attachPath;
72627262
message.ttl = cursor.intValue(2);
72637263
}
7264-
if (!message.out) {
7265-
boolean sameMedia = false; //TODO check
7266-
if (oldMessage.media instanceof TLRPC.TL_messageMediaPhoto && message.media instanceof TLRPC.TL_messageMediaPhoto && oldMessage.media.photo != null && message.media.photo != null) {
7267-
sameMedia = oldMessage.media.photo.id == message.media.photo.id;
7268-
} else if (oldMessage.media instanceof TLRPC.TL_messageMediaDocument && message.media instanceof TLRPC.TL_messageMediaDocument && oldMessage.media.document != null && message.media.document != null) {
7269-
sameMedia = oldMessage.media.document.id == message.media.document.id;
7270-
}
7271-
if (!sameMedia) {
7272-
addFilesToDelete(oldMessage, filesToDelete, false);
7273-
}
7264+
boolean sameMedia = false;
7265+
if (oldMessage.media instanceof TLRPC.TL_messageMediaPhoto && message.media instanceof TLRPC.TL_messageMediaPhoto && oldMessage.media.photo != null && message.media.photo != null) {
7266+
sameMedia = oldMessage.media.photo.id == message.media.photo.id;
7267+
} else if (oldMessage.media instanceof TLRPC.TL_messageMediaDocument && message.media instanceof TLRPC.TL_messageMediaDocument && oldMessage.media.document != null && message.media.document != null) {
7268+
sameMedia = oldMessage.media.document.id == message.media.document.id;
7269+
}
7270+
if (!sameMedia) {
7271+
addFilesToDelete(oldMessage, filesToDelete, false);
72747272
}
72757273
}
72767274
boolean oldMention = cursor.intValue(3) != 0;

TMessagesProj/src/main/java/org/telegram/ui/ActionBar/Theme.java

Lines changed: 64 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -486,34 +486,7 @@ private Bitmap createWallpaperForAccent(Bitmap patternBitmap, boolean svg, File
486486
if (svg) {
487487
patternBitmap = SvgHelper.getBitmap(patternPath, AndroidUtilities.dp(360), AndroidUtilities.dp(640), false);
488488
} else {
489-
BitmapFactory.Options opts = new BitmapFactory.Options();
490-
opts.inSampleSize = 1;
491-
opts.inJustDecodeBounds = true;
492-
BitmapFactory.decodeFile(patternPath.getAbsolutePath(), opts);
493-
float photoW = opts.outWidth;
494-
float photoH = opts.outHeight;
495-
float scaleFactor;
496-
int w_filter = AndroidUtilities.dp(360);
497-
int h_filter = AndroidUtilities.dp(640);
498-
if (w_filter >= h_filter && photoW > photoH) {
499-
scaleFactor = Math.max(photoW / w_filter, photoH / h_filter);
500-
} else {
501-
scaleFactor = Math.min(photoW / w_filter, photoH / h_filter);
502-
}
503-
if (scaleFactor < 1.2f) {
504-
scaleFactor = 1;
505-
}
506-
opts.inJustDecodeBounds = false;
507-
if (scaleFactor > 1.0f && (photoW > w_filter || photoH > h_filter)) {
508-
int sample = 1;
509-
do {
510-
sample *= 2;
511-
} while (sample * 2 < scaleFactor);
512-
opts.inSampleSize = sample;
513-
} else {
514-
opts.inSampleSize = (int) scaleFactor;
515-
}
516-
patternBitmap = BitmapFactory.decodeFile(patternPath.getAbsolutePath(), opts);
489+
patternBitmap = loadScreenSizedBitmap(new FileInputStream(patternPath), 0);
517490
}
518491
}
519492

@@ -7180,38 +7153,31 @@ public void onSizeReady(int width, int height) {
71807153
}
71817154
isCustomTheme = true;
71827155
} else if (themedWallpaperLink != null) {
7183-
File pathToWallpaper = new File(ApplicationLoader.getFilesDirFixed(), Utilities.MD5(themedWallpaperLink) + ".wp");
7184-
Bitmap bitmap = BitmapFactory.decodeFile(pathToWallpaper.getAbsolutePath());
7185-
if (bitmap != null) {
7186-
themedWallpaper = wallpaper = new BitmapDrawable(bitmap);
7187-
isCustomTheme = true;
7156+
try {
7157+
File pathToWallpaper = new File(ApplicationLoader.getFilesDirFixed(), Utilities.MD5(themedWallpaperLink) + ".wp");
7158+
Bitmap bitmap = loadScreenSizedBitmap(new FileInputStream(pathToWallpaper), 0);
7159+
if (bitmap != null) {
7160+
themedWallpaper = wallpaper = new BitmapDrawable(bitmap);
7161+
isCustomTheme = true;
7162+
}
7163+
} catch (Exception e) {
7164+
FileLog.e(e);
71887165
}
71897166
} else if (themedWallpaperFileOffset > 0 && (currentTheme.pathToFile != null || currentTheme.assetName != null)) {
7190-
FileInputStream stream = null;
71917167
try {
71927168
File file;
71937169
if (currentTheme.assetName != null) {
71947170
file = getAssetFile(currentTheme.assetName);
71957171
} else {
71967172
file = new File(currentTheme.pathToFile);
71977173
}
7198-
stream = new FileInputStream(file);
7199-
stream.getChannel().position(themedWallpaperFileOffset);
7200-
Bitmap bitmap = BitmapFactory.decodeStream(stream);
7174+
Bitmap bitmap = loadScreenSizedBitmap(new FileInputStream(file), themedWallpaperFileOffset);
72017175
if (bitmap != null) {
72027176
themedWallpaper = wallpaper = new BitmapDrawable(bitmap);
72037177
isCustomTheme = true;
72047178
}
72057179
} catch (Throwable e) {
72067180
FileLog.e(e);
7207-
} finally {
7208-
try {
7209-
if (stream != null) {
7210-
stream.close();
7211-
}
7212-
} catch (Exception e) {
7213-
FileLog.e(e);
7214-
}
72157181
}
72167182
}
72177183
}
@@ -7244,11 +7210,14 @@ public void onSizeReady(int width, int height) {
72447210
}
72457211
} else {
72467212
File toFile = new File(ApplicationLoader.getFilesDirFixed(), overrideWallpaper.fileName);
7247-
long len = toFile.length();
72487213
if (toFile.exists()) {
7249-
wallpaper = Drawable.createFromPath(toFile.getAbsolutePath());
7250-
isCustomTheme = true;
7251-
} else {
7214+
Bitmap bitmap = loadScreenSizedBitmap(new FileInputStream(toFile), 0);
7215+
if (bitmap != null) {
7216+
wallpaper = new BitmapDrawable(bitmap);
7217+
isCustomTheme = true;
7218+
}
7219+
}
7220+
if (wallpaper == null) {
72527221
wallpaper = ApplicationLoader.applicationContext.getResources().getDrawable(R.drawable.background_hd);
72537222
isCustomTheme = false;
72547223
}
@@ -7273,6 +7242,52 @@ public void onSizeReady(int width, int height) {
72737242
});
72747243
}
72757244

7245+
private static Bitmap loadScreenSizedBitmap(FileInputStream stream, int offset) {
7246+
try {
7247+
BitmapFactory.Options opts = new BitmapFactory.Options();
7248+
opts.inSampleSize = 1;
7249+
opts.inJustDecodeBounds = true;
7250+
stream.getChannel().position(offset);
7251+
BitmapFactory.decodeStream(stream, null, opts);
7252+
float photoW = opts.outWidth;
7253+
float photoH = opts.outHeight;
7254+
float scaleFactor;
7255+
int w_filter = AndroidUtilities.dp(360);
7256+
int h_filter = AndroidUtilities.dp(640);
7257+
if (w_filter >= h_filter && photoW > photoH) {
7258+
scaleFactor = Math.max(photoW / w_filter, photoH / h_filter);
7259+
} else {
7260+
scaleFactor = Math.min(photoW / w_filter, photoH / h_filter);
7261+
}
7262+
if (scaleFactor < 1.2f) {
7263+
scaleFactor = 1;
7264+
}
7265+
opts.inJustDecodeBounds = false;
7266+
if (scaleFactor > 1.0f && (photoW > w_filter || photoH > h_filter)) {
7267+
int sample = 1;
7268+
do {
7269+
sample *= 2;
7270+
} while (sample * 2 < scaleFactor);
7271+
opts.inSampleSize = sample;
7272+
} else {
7273+
opts.inSampleSize = (int) scaleFactor;
7274+
}
7275+
stream.getChannel().position(offset);
7276+
return BitmapFactory.decodeStream(stream, null, opts);
7277+
} catch (Exception e) {
7278+
FileLog.e(e);
7279+
} finally {
7280+
try {
7281+
if (stream != null) {
7282+
stream.close();
7283+
}
7284+
} catch (Exception ignore) {
7285+
7286+
}
7287+
}
7288+
return null;
7289+
}
7290+
72767291
public static Drawable getThemedWallpaper(boolean thumb, View ownerView) {
72777292
Integer backgroundColor = currentColors.get(key_chat_wallpaper);
72787293
File file = null;

TMessagesProj/src/main/java/org/telegram/ui/Adapters/DialogsSearchAdapter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1049,7 +1049,7 @@ public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType
10491049
@Override
10501050
public boolean onInterceptTouchEvent(MotionEvent e) {
10511051
if (getParent() != null && getParent().getParent() != null) {
1052-
getParent().getParent().requestDisallowInterceptTouchEvent(true);
1052+
getParent().getParent().requestDisallowInterceptTouchEvent(canScrollHorizontally(-1));
10531053
}
10541054
return super.onInterceptTouchEvent(e);
10551055
}

TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4746,6 +4746,9 @@ private void setMessageContent(MessageObject messageObject, MessageObject.Groupe
47464746
radialProgress.setIcon(getIconForCurrentState(), false, false);
47474747
}
47484748

4749+
if (delegate != null && delegate.getTextSelectionHelper() != null && !messageIdChanged && messageChanged && messageObject != null) {
4750+
delegate.getTextSelectionHelper().checkDataChanged(messageObject);
4751+
}
47494752
accessibilityVirtualViewBounds.clear();
47504753
}
47514754

0 commit comments

Comments
 (0)