Skip to content

Commit 7e6d40a

Browse files
committed
update to 9.5.7
1 parent bab9943 commit 7e6d40a

Some content is hidden

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

50 files changed

+1388
-429
lines changed

‎TMessagesProj/jni/rlottie/src/lottie/lottiemodel.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,9 @@ class LottieColor
9898

9999
inline void getColorReplacement(std::map<int32_t, int32_t> *colorMap, const LottieColor &c, float &r, float &g, float &b) {
100100
if (colorMap != nullptr && !colorMap->empty()) {
101-
int32_t rr = (int32_t) (c.r * 255);
102-
int32_t gg = (int32_t) (c.g * 255);
103-
int32_t bb = (int32_t) (c.b * 255);
101+
int32_t rr = (int32_t) round(c.r * 255);
102+
int32_t gg = (int32_t) round(c.g * 255);
103+
int32_t bb = (int32_t) round(c.b * 255);
104104
int32_t cc = (int32_t) (((bb & 0xff) << 16) | ((gg & 0xff) << 8) | (rr & 0xff));
105105
std::map<int32_t, int32_t>::iterator iter = colorMap->find(cc);
106106
if (iter != colorMap->end()) {

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

+9-11
Original file line numberDiff line numberDiff line change
@@ -1949,20 +1949,18 @@ public static File getCacheDir() {
19491949
FileLog.d("external dir mounted");
19501950
try {
19511951
File file;
1952-
if (Build.VERSION.SDK_INT >= 19) {
1953-
File[] dirs = ApplicationLoader.applicationContext.getExternalCacheDirs();
1954-
file = dirs[0];
1955-
if (!TextUtils.isEmpty(SharedConfig.storageCacheDir)) {
1956-
for (int a = 0; a < dirs.length; a++) {
1957-
if (dirs[a] != null && dirs[a].getAbsolutePath().startsWith(SharedConfig.storageCacheDir)) {
1958-
file = dirs[a];
1959-
break;
1960-
}
1952+
1953+
File[] dirs = ApplicationLoader.applicationContext.getExternalCacheDirs();
1954+
file = dirs[0];
1955+
if (!TextUtils.isEmpty(SharedConfig.storageCacheDir)) {
1956+
for (int a = 0; a < dirs.length; a++) {
1957+
if (dirs[a] != null && dirs[a].getAbsolutePath().startsWith(SharedConfig.storageCacheDir)) {
1958+
file = dirs[a];
1959+
break;
19611960
}
19621961
}
1963-
} else {
1964-
file = ApplicationLoader.applicationContext.getExternalCacheDir();
19651962
}
1963+
19661964
FileLog.d("check dir " + (file == null ? null : file.getPath()) + " ");
19671965
if (file != null && (file.exists() || file.mkdirs()) && file.canWrite()) {
19681966
// boolean canWrite = true;

‎TMessagesProj/src/main/java/org/telegram/messenger/AutoDeleteMediaTask.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class AutoDeleteMediaTask {
1414

1515
public static void run() {
1616
int time = (int) (System.currentTimeMillis() / 1000);
17-
if (!BuildVars.DEBUG_PRIVATE_VERSION && Math.abs(time - SharedConfig.lastKeepMediaCheckTime) < 24 * 60 * 60) {
17+
if (Math.abs(time - SharedConfig.lastKeepMediaCheckTime) < 24 * 60 * 60) {
1818
return;
1919
}
2020
SharedConfig.lastKeepMediaCheckTime = time;

‎TMessagesProj/src/main/java/org/telegram/messenger/BillingController.java

+1
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,7 @@ public void onBillingServiceDisconnected() {
315315

316316
@Override
317317
public void onBillingSetupFinished(@NonNull BillingResult setupBillingResult) {
318+
FileLog.d("Billing setup finished with result " + setupBillingResult);
318319
if (setupBillingResult.getResponseCode() == BillingClient.BillingResponseCode.OK) {
319320
queryProductDetails(Collections.singletonList(PREMIUM_PRODUCT), (billingResult, list) -> {
320321
if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK) {

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

+2-2
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 = 3237;
28-
public static String BUILD_VERSION_STRING = "9.5.6";
27+
public static int BUILD_VERSION = 3249;
28+
public static String BUILD_VERSION_STRING = "9.5.7";
2929
public static int APP_ID = 4;
3030
public static String APP_HASH = "014b35b6184100b085b0d0572f9b5103";
3131

‎TMessagesProj/src/main/java/org/telegram/messenger/ContactsController.java

+131-78
Large diffs are not rendered by default.

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

+7
Original file line numberDiff line numberDiff line change
@@ -1247,6 +1247,13 @@ public static int migrate(MessagesStorage messagesStorage, int version) throws E
12471247
database.executeFast("PRAGMA user_version = 115").stepThis().dispose();
12481248
version = 115;
12491249
}
1250+
if (version == 115) {
1251+
database.executeFast("CREATE INDEX IF NOT EXISTS idx_to_reply_messages_v2 ON messages_v2(reply_to_message_id, mid);").stepThis().dispose();
1252+
database.executeFast("CREATE INDEX IF NOT EXISTS idx_to_reply_scheduled_messages_v2 ON scheduled_messages_v2(reply_to_message_id, mid);").stepThis().dispose();
1253+
database.executeFast("CREATE INDEX IF NOT EXISTS idx_to_reply_messages_topics ON messages_topics(reply_to_message_id, mid);").stepThis().dispose();
1254+
database.executeFast("PRAGMA user_version = 116").stepThis().dispose();
1255+
version = 116;
1256+
}
12501257
return version;
12511258
}
12521259

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -801,7 +801,7 @@ private FileLoadOperation loadFileInternal(final TLRPC.Document document, final
801801
public void didPreFinishLoading(FileLoadOperation operation, File finalFile) {
802802
FileLoaderPriorityQueue queue = operation.getQueue();
803803
fileLoaderQueue.postRunnable(() -> {
804-
FileLoadOperation currentOperation = loadOperationPaths.remove(fileName);
804+
FileLoadOperation currentOperation = loadOperationPaths.get(fileName);
805805
if (currentOperation != null) {
806806
currentOperation.preFinished = true;
807807
queue.checkLoadingOperations();

‎TMessagesProj/src/main/java/org/telegram/messenger/FileLoaderPriorityQueue.java

-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package org.telegram.messenger;
22

3-
import org.telegram.tgnet.ConnectionsManager;
4-
53
import java.util.ArrayList;
64

75
public class FileLoaderPriorityQueue {
@@ -85,10 +83,6 @@ public void remove(FileLoadOperation operation) {
8583
if (operation == null) {
8684
return;
8785
}
88-
ConnectionsManager connectionsManager = ConnectionsManager.getInstance(operation.currentAccount);
89-
if (connectionsManager != null && connectionsManager.getConnectionState() == ConnectionsManager.ConnectionStateWaitingForNetwork) {
90-
operation.cancel();
91-
}
9286
allOperations.remove(operation);
9387
}
9488

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

+7-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
package org.telegram.messenger;
1010

11+
import android.content.Context;
12+
import android.content.res.ColorStateList;
1113
import android.util.Log;
1214

1315
import com.google.gson.ExclusionStrategy;
@@ -116,7 +118,7 @@ public static void dumpResponseAndRequest(TLObject request, TLObject response, T
116118
}
117119

118120
public static void dumpUnparsedMessage(TLObject message, long messageId) {
119-
if (!BuildVars.DEBUG_PRIVATE_VERSION || !BuildVars.LOGS_ENABLED || message == null) {
121+
if (!BuildVars.DEBUG_PRIVATE_VERSION || !BuildVars.LOGS_ENABLED || message == null || SharedConfig.getDevicePerformanceClass() == SharedConfig.PERFORMANCE_CLASS_LOW) {
120122
return;
121123
}
122124
try {
@@ -160,6 +162,7 @@ private static void checkGson() {
160162

161163
privateFields.add("networkType");
162164
privateFields.add("disableFree");
165+
privateFields.add("mContext");
163166

164167
//exclude file loading
165168
excludeRequests = new HashSet<>();
@@ -178,6 +181,9 @@ public boolean shouldSkipField(FieldAttributes f) {
178181

179182
@Override
180183
public boolean shouldSkipClass(Class<?> clazz) {
184+
if (clazz.isInstance(ColorStateList.class) || clazz.isInstance(Context.class)) {
185+
return true;
186+
}
181187
return false;
182188
}
183189
}).create();

‎TMessagesProj/src/main/java/org/telegram/messenger/ImageLoader.java

+17-1
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ protected Boolean doInBackground(Void... voids) {
582582
}
583583
}
584584
} catch (Exception e) {
585-
FileLog.e(e);
585+
FileLog.e(e, false);
586586
}
587587
if (imageSize == 0 && httpConnection != null) {
588588
try {
@@ -2230,6 +2230,8 @@ public SparseArray<File> createMediaPaths() {
22302230
FileLog.d("cache path = " + cachePath);
22312231
}
22322232

2233+
FileLog.d("selected SD card = " + SharedConfig.storageCacheDir);
2234+
22332235
try {
22342236
if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
22352237
File path = Environment.getExternalStorageDirectory();
@@ -2238,14 +2240,28 @@ public SparseArray<File> createMediaPaths() {
22382240
if (dirs != null) {
22392241
for (int a = 0, N = dirs.size(); a < N; a++) {
22402242
File dir = dirs.get(a);
2243+
FileLog.d("root dir " + a + " " + dir);
22412244
if (dir.getAbsolutePath().startsWith(SharedConfig.storageCacheDir)) {
22422245
path = dir;
22432246
break;
22442247
}
22452248
}
22462249
}
2250+
if (!path.getAbsolutePath().startsWith(SharedConfig.storageCacheDir)) {
2251+
File[] dirsDebug = ApplicationLoader.applicationContext.getExternalFilesDirs(null);
2252+
if (dirsDebug != null) {
2253+
for (int a = 0; a < dirsDebug.length; a++) {
2254+
if (dirsDebug[a] == null) {
2255+
continue;
2256+
}
2257+
FileLog.d("dirsDebug " + a + " " + dirsDebug[a]);
2258+
}
2259+
}
2260+
}
22472261
}
22482262

2263+
FileLog.d("external storage = " + path);
2264+
22492265
File publicMediaDir = null;
22502266
if (Build.VERSION.SDK_INT >= 30) {
22512267
File newPath;

‎TMessagesProj/src/main/java/org/telegram/messenger/LinkifyPort.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ public class LinkifyPort {
162162
+ "\\.\\+\\!\\*\\'\\(\\)\\,\\;\\?\\&\\=]|(?:\\%[a-fA-F0-9]{2})){1,25})?\\@";
163163
private static final String PORT_NUMBER = "\\:\\d{1,5}";
164164
private static final String PATH_AND_QUERY = "[/\\?](?:(?:[" + LABEL_CHAR + ";/\\?:@&=#~" + "\\-\\.\\+!\\*'\\(\\),_\\$])|(?:%[a-fA-F0-9]{2}))*";
165-
private static final String RELAXED_DOMAIN_NAME = "(?:" + "(?:" + IRI_LABEL + "(?:\\.(?=\\S))" + "?)+" + "|" + IP_ADDRESS_STRING + ")";
165+
private static final String RELAXED_DOMAIN_NAME = "(?:" + "(?:" + IRI_LABEL + "(?:\\.(?=\\S))" + ")*" + "(?:" + IRI_LABEL + "(?:\\.(?=\\S))" + "?)" + "|" + IP_ADDRESS_STRING + ")";
166166

167167
private static final String WEB_URL_WITHOUT_PROTOCOL = "("
168168
+ WORD_BOUNDARY

‎TMessagesProj/src/main/java/org/telegram/messenger/LiteMode.java

+4-6
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55
import android.content.SharedPreferences;
66
import android.os.BatteryManager;
77
import android.os.Build;
8-
import android.os.PowerManager;
9-
import android.util.SparseArray;
10-
import android.util.SparseIntArray;
118

129
import androidx.annotation.RequiresApi;
1310
import androidx.core.math.MathUtils;
@@ -20,9 +17,6 @@
2017
import java.util.HashSet;
2118
import java.util.Iterator;
2219

23-
import org.telegram.ui.ActionBar.Theme;
24-
import org.telegram.ui.Components.AnimatedEmojiDrawable;
25-
2620
public class LiteMode {
2721

2822
public static final int FLAG_ANIMATED_STICKERS_KEYBOARD = 1;
@@ -138,6 +132,10 @@ private static int preprocessFlag(int flag) {
138132
}
139133

140134
public static boolean isEnabled(int flag) {
135+
if (flag == FLAG_CHAT_FORUM_TWOCOLUMN && AndroidUtilities.isTablet()) {
136+
// always enabled for tablets
137+
return true;
138+
}
141139
return (getValue() & preprocessFlag(flag)) > 0;
142140
}
143141

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

+71-5
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import android.text.style.CharacterStyle;
3535
import android.text.style.URLSpan;
3636
import android.text.util.Linkify;
37+
import android.util.Log;
3738
import android.util.Pair;
3839
import android.util.SparseArray;
3940

@@ -4291,26 +4292,66 @@ public void buildShortcuts() {
42914292
}
42924293
}
42934294
}
4295+
boolean recreateShortcuts = Build.VERSION.SDK_INT >= 30;
42944296
Utilities.globalQueue.postRunnable(() -> {
42954297
try {
42964298
if (SharedConfig.directShareHash == null) {
42974299
SharedConfig.directShareHash = UUID.randomUUID().toString();
42984300
ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE).edit().putString("directShareHash2", SharedConfig.directShareHash).commit();
42994301
}
43004302

4301-
ShortcutManagerCompat.removeAllDynamicShortcuts(ApplicationLoader.applicationContext);
4303+
ArrayList<String> shortcutsToUpdate = new ArrayList<>();
4304+
ArrayList<String> newShortcutsIds = new ArrayList<>();
4305+
ArrayList<String> shortcutsToDelete = new ArrayList<>();
43024306

4307+
if (recreateShortcuts) {
4308+
ShortcutManagerCompat.removeAllDynamicShortcuts(ApplicationLoader.applicationContext);
4309+
} else {
4310+
List<ShortcutInfoCompat> currentShortcuts = ShortcutManagerCompat.getDynamicShortcuts(ApplicationLoader.applicationContext);
4311+
if (currentShortcuts != null && !currentShortcuts.isEmpty()) {
4312+
newShortcutsIds.add("compose");
4313+
for (int a = 0; a < hintsFinal.size(); a++) {
4314+
TLRPC.TL_topPeer hint = hintsFinal.get(a);
4315+
newShortcutsIds.add("did3_" + MessageObject.getPeerId(hint.peer));
4316+
}
4317+
for (int a = 0; a < currentShortcuts.size(); a++) {
4318+
String id = currentShortcuts.get(a).getId();
4319+
if (!newShortcutsIds.remove(id)) {
4320+
shortcutsToDelete.add(id);
4321+
}
4322+
shortcutsToUpdate.add(id);
4323+
}
4324+
if (newShortcutsIds.isEmpty() && shortcutsToDelete.isEmpty()) {
4325+
return;
4326+
}
4327+
}
4328+
4329+
if (!shortcutsToDelete.isEmpty()) {
4330+
ShortcutManagerCompat.removeDynamicShortcuts(ApplicationLoader.applicationContext, shortcutsToDelete);
4331+
}
4332+
}
43034333

43044334
Intent intent = new Intent(ApplicationLoader.applicationContext, LaunchActivity.class);
43054335
intent.setAction("new_dialog");
43064336
ArrayList<ShortcutInfoCompat> arrayList = new ArrayList<>();
4307-
ShortcutManagerCompat.pushDynamicShortcut(ApplicationLoader.applicationContext, new ShortcutInfoCompat.Builder(ApplicationLoader.applicationContext, "compose")
4337+
ShortcutInfoCompat shortcut = new ShortcutInfoCompat.Builder(ApplicationLoader.applicationContext, "compose")
43084338
.setShortLabel(LocaleController.getString("NewConversationShortcut", R.string.NewConversationShortcut))
43094339
.setLongLabel(LocaleController.getString("NewConversationShortcut", R.string.NewConversationShortcut))
43104340
.setIcon(IconCompat.createWithResource(ApplicationLoader.applicationContext, R.drawable.shortcut_compose))
43114341
.setRank(0)
43124342
.setIntent(intent)
4313-
.build());
4343+
.build();
4344+
if (recreateShortcuts) {
4345+
ShortcutManagerCompat.pushDynamicShortcut(ApplicationLoader.applicationContext, shortcut);
4346+
} else {
4347+
arrayList.add(shortcut);
4348+
if (shortcutsToUpdate.contains("compose")) {
4349+
ShortcutManagerCompat.updateShortcuts(ApplicationLoader.applicationContext, arrayList);
4350+
} else {
4351+
ShortcutManagerCompat.addDynamicShortcuts(ApplicationLoader.applicationContext, arrayList);
4352+
}
4353+
arrayList.clear();
4354+
}
43144355

43154356

43164357
HashSet<String> category = new HashSet<>(1);
@@ -4405,7 +4446,18 @@ public void buildShortcuts() {
44054446
} else {
44064447
builder.setIcon(IconCompat.createWithResource(ApplicationLoader.applicationContext, R.drawable.shortcut_user));
44074448
}
4408-
ShortcutManagerCompat.pushDynamicShortcut(ApplicationLoader.applicationContext, builder.build());
4449+
4450+
if (recreateShortcuts) {
4451+
ShortcutManagerCompat.pushDynamicShortcut(ApplicationLoader.applicationContext, builder.build());
4452+
} else {
4453+
arrayList.add(builder.build());
4454+
if (shortcutsToUpdate.contains(id)) {
4455+
ShortcutManagerCompat.updateShortcuts(ApplicationLoader.applicationContext, arrayList);
4456+
} else {
4457+
ShortcutManagerCompat.addDynamicShortcuts(ApplicationLoader.applicationContext, arrayList);
4458+
}
4459+
arrayList.clear();
4460+
}
44094461
}
44104462
} catch (Throwable ignore) {
44114463

@@ -6211,7 +6263,7 @@ public ArrayList<TLRPC.MessageEntity> getEntities(CharSequence[] message, boolea
62116263
return entities;
62126264
}
62136265

6214-
private CharSequence parsePattern(CharSequence cs, Pattern pattern, List<TLRPC.MessageEntity> entities, GenericProvider<Void, TLRPC.MessageEntity> entityProvider) {
6266+
private CharSequence parsePattern(CharSequence cs, Pattern pattern, ArrayList<TLRPC.MessageEntity> entities, GenericProvider<Void, TLRPC.MessageEntity> entityProvider) {
62156267
Matcher m = pattern.matcher(cs);
62166268
int offset = 0;
62176269
while (m.find()) {
@@ -6231,6 +6283,8 @@ private CharSequence parsePattern(CharSequence cs, Pattern pattern, List<TLRPC.M
62316283
TLRPC.MessageEntity entity = entityProvider.provide(null);
62326284
entity.offset = m.start() - offset;
62336285
entity.length = gr.length();
6286+
6287+
removeOffset4After(entity.offset, entity.offset + entity.length, entities);
62346288
entities.add(entity);
62356289
}
62366290

@@ -6239,6 +6293,18 @@ private CharSequence parsePattern(CharSequence cs, Pattern pattern, List<TLRPC.M
62396293
return cs;
62406294
}
62416295

6296+
private static void removeOffset4After(int start, int end, ArrayList<TLRPC.MessageEntity> entities) {
6297+
int count = entities.size();
6298+
for (int a = 0; a < count; a++) {
6299+
TLRPC.MessageEntity entity = entities.get(a);
6300+
if (entity.offset > end) {
6301+
entity.offset -= 4;
6302+
} else if (entity.offset > start) {
6303+
entity.offset -= 2;
6304+
}
6305+
}
6306+
}
6307+
62426308
//---------------- MESSAGES END ----------------
62436309

62446310
private LongSparseArray<Integer> draftsFolderIds = new LongSparseArray<>();

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

+5-1
Original file line numberDiff line numberDiff line change
@@ -3329,7 +3329,11 @@ private void updateMessageText(AbstractMap<Long, TLRPC.User> users, AbstractMap<
33293329
int i = messageText.toString().indexOf("un2");
33303330
if (i != -1) {
33313331
SpannableStringBuilder sb = SpannableStringBuilder.valueOf(messageText);
3332-
messageText = sb.replace(i, i + 3, BillingController.getInstance().formatCurrency(messageOwner.action.amount, messageOwner.action.currency));
3332+
CharSequence price = BillingController.getInstance().formatCurrency(messageOwner.action.amount, messageOwner.action.currency);
3333+
if ((messageOwner.action.flags & 1) != 0) {
3334+
price = String.format("%.2f", (messageOwner.action.cryptoAmount * Math.pow(10, -9))) + " " + messageOwner.action.cryptoCurrency + " (~ " + price + ")";
3335+
}
3336+
messageText = sb.replace(i, i + 3, price);
33333337
}
33343338
} else if (messageOwner.action instanceof TLRPC.TL_messageActionSuggestProfilePhoto) {
33353339
if (messageOwner.action.photo != null && messageOwner.action.photo.video_sizes != null && !messageOwner.action.photo.video_sizes.isEmpty()) {

0 commit comments

Comments
 (0)