Skip to content

Commit 8558775

Browse files
committed
update to 11.1.3 (5243)
1 parent cc50db9 commit 8558775

File tree

58 files changed

+532
-198
lines changed

Some content is hidden

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

58 files changed

+532
-198
lines changed

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

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ public static Typeface bold() {
272272
public static float density = 1;
273273
public static Point displaySize = new Point();
274274
public static float screenRefreshRate = 60;
275+
public static float screenMaxRefreshRate = 60;
275276
public static float screenRefreshTime = 1000 / screenRefreshRate;
276277
public static int roundMessageSize;
277278
public static int roundPlayingMessageSize;
@@ -2565,6 +2566,17 @@ public static void checkDisplaySize(Context context, Configuration newConfigurat
25652566
display.getMetrics(displayMetrics);
25662567
display.getSize(displaySize);
25672568
screenRefreshRate = display.getRefreshRate();
2569+
screenMaxRefreshRate = screenRefreshRate;
2570+
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
2571+
float[] rates = display.getSupportedRefreshRates();
2572+
if (rates != null) {
2573+
for (int i = 0; i < rates.length; ++i) {
2574+
if (rates[i] > screenMaxRefreshRate) {
2575+
screenMaxRefreshRate = rates[i];
2576+
}
2577+
}
2578+
}
2579+
}
25682580
screenRefreshTime = 1000 / screenRefreshRate;
25692581
}
25702582
}
@@ -2601,6 +2613,35 @@ public static void checkDisplaySize(Context context, Configuration newConfigurat
26012613
}
26022614
}
26032615

2616+
public static void setPreferredMaxRefreshRate(Window window) {
2617+
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) return;
2618+
if (window == null) return;
2619+
final WindowManager wm = window.getWindowManager();
2620+
if (wm == null) return;
2621+
WindowManager.LayoutParams params = window.getAttributes();
2622+
params.preferredRefreshRate = screenMaxRefreshRate;
2623+
try {
2624+
wm.updateViewLayout(window.getDecorView(), params);
2625+
} catch (Exception e) {
2626+
FileLog.e(e);
2627+
}
2628+
}
2629+
2630+
public static void setPreferredMaxRefreshRate(WindowManager wm, View windowView, WindowManager.LayoutParams params) {
2631+
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) return;
2632+
if (wm == null) return;
2633+
if (Math.abs(params.preferredRefreshRate - screenMaxRefreshRate) > 0.2) {
2634+
params.preferredRefreshRate = screenMaxRefreshRate;
2635+
if (windowView.isAttachedToWindow()) {
2636+
try {
2637+
wm.updateViewLayout(windowView, params);
2638+
} catch (Exception e) {
2639+
FileLog.e(e);
2640+
}
2641+
}
2642+
}
2643+
}
2644+
26042645
public static double fixLocationCoord(double value) {
26052646
return ((long) (value * 1000000)) / 1000000.0;
26062647
}
@@ -3505,6 +3546,9 @@ public static CharSequence generateSearchName(String name, String name2, String
35053546
} else if (name2 != null && name2.length() != 0) {
35063547
wholeString += " " + name2;
35073548
}
3549+
if (wholeString == null) {
3550+
return "";
3551+
}
35083552
wholeString = wholeString.trim();
35093553
String lower = " " + wholeString.toLowerCase();
35103554

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1516,6 +1516,12 @@ public static int migrate(MessagesStorage messagesStorage, int version) throws E
15161516
version = 155;
15171517
}
15181518

1519+
if (version == 155) {
1520+
database.executeFast("CREATE TABLE popular_bots(uid INTEGER PRIMARY KEY, time INTEGER, offset TEXT);").stepThis().dispose();
1521+
database.executeFast("PRAGMA user_version = 156").stepThis().dispose();
1522+
version = 156;
1523+
}
1524+
15191525
return version;
15201526
}
15211527

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import android.telephony.TelephonyManager;
2020
import android.text.TextUtils;
2121
import android.text.format.DateFormat;
22-
import android.util.Log;
2322
import android.util.Xml;
2423

2524
import androidx.annotation.StringRes;
@@ -32,13 +31,10 @@
3231
import org.telegram.ui.RestrictedLanguagesSelectActivity;
3332
import org.xmlpull.v1.XmlPullParser;
3433

35-
import java.io.BufferedReader;
3634
import java.io.BufferedWriter;
3735
import java.io.File;
3836
import java.io.FileInputStream;
39-
import java.io.FileReader;
4037
import java.io.FileWriter;
41-
import java.io.IOException;
4238
import java.text.NumberFormat;
4339
import java.util.ArrayList;
4440
import java.util.Calendar;
@@ -1468,6 +1464,14 @@ public static String formatPluralStringComma(String key, int plural) {
14681464
return formatPluralStringComma(key, plural, ',');
14691465
}
14701466

1467+
public static String formatPluralStringSpaced(String key, int plural) {
1468+
return formatPluralStringComma(key, plural, ' ');
1469+
}
1470+
1471+
public static String formatPluralStringSpaced(String key, int plural, Object... args) {
1472+
return formatPluralStringComma(key, plural, ' ', args);
1473+
}
1474+
14711475
public static String formatPluralStringComma(String key, int plural, Object... args) {
14721476
return formatPluralStringComma(key, plural, ',', args);
14731477
}

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

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
import android.os.Environment;
5151
import android.os.PowerManager;
5252
import android.os.SystemClock;
53-
import android.provider.DocumentsContract;
5453
import android.provider.MediaStore;
5554
import android.provider.OpenableColumns;
5655
import android.telephony.PhoneStateListener;
@@ -65,8 +64,6 @@
6564
import android.webkit.MimeTypeMap;
6665
import android.widget.FrameLayout;
6766

68-
import androidx.core.content.FileProvider;
69-
7067
import com.google.android.exoplayer2.C;
7168
import com.google.android.exoplayer2.ExoPlayer;
7269
import com.google.android.exoplayer2.ui.AspectRatioFrameLayout;
@@ -3884,7 +3881,7 @@ public void setReplyingMessage(MessageObject replyToMsg, MessageObject replyToTo
38843881
recordReplyingStory = storyItem;
38853882
}
38863883

3887-
public void requestAudioFocus(boolean request) {
3884+
public void requestRecordAudioFocus(boolean request) {
38883885
if (request) {
38893886
if (!hasRecordAudioFocus && SharedConfig.pauseMusicOnRecord) {
38903887
int result = NotificationsController.audioManager.requestAudioFocus(audioRecordFocusChangedListener, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN_TRANSIENT);
@@ -3902,7 +3899,7 @@ public void requestAudioFocus(boolean request) {
39023899

39033900
public void prepareResumedRecording(int currentAccount, MediaDataController.DraftVoice draft, long dialogId, MessageObject replyToMsg, MessageObject replyToTopMsg, TL_stories.StoryItem replyStory, int guid, String query_shortcut, int query_shortcut_id) {
39043901
manualRecording = false;
3905-
requestAudioFocus(true);
3902+
requestRecordAudioFocus(true);
39063903
recordQueue.cancelRunnable(recordStartRunnable);
39073904
recordQueue.postRunnable(() -> {
39083905
setBluetoothScoOn(true);
@@ -4033,6 +4030,7 @@ public void toggleRecordingPause(boolean voiceOnce) {
40334030
audioToSend.attributes.add(attributeAudio);
40344031
NotificationCenter.getInstance(recordingCurrentAccount).postNotificationName(NotificationCenter.recordPaused);
40354032
NotificationCenter.getInstance(recordingCurrentAccount).postNotificationName(NotificationCenter.audioDidSent, recordingGuid, audioToSend, recordingAudioFileToSend.getAbsolutePath());
4033+
requestRecordAudioFocus(false);
40364034
});
40374035
});
40384036
} else {
@@ -4050,6 +4048,7 @@ public void toggleRecordingPause(boolean voiceOnce) {
40504048
}
40514049

40524050
AndroidUtilities.runOnUIThread(() -> {
4051+
requestRecordAudioFocus(true);
40534052
MediaDataController.getInstance(recordingCurrentAccount).pushDraftVoiceMessage(recordDialogId, recordTopicId, null);
40544053

40554054
audioRecorder = new AudioRecord(MediaRecorder.AudioSource.DEFAULT, sampleRate, AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_16BIT, recordBufferSize);
@@ -4071,7 +4070,7 @@ public void startRecording(int currentAccount, long dialogId, MessageObject repl
40714070
paused = true;
40724071
}
40734072
manualRecording = manual;
4074-
requestAudioFocus(true);
4073+
requestRecordAudioFocus(true);
40754074

40764075
try {
40774076
feedbackView.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
@@ -4280,15 +4279,15 @@ private void stopRecordingInternal(final int send, boolean notify, int scheduleD
42804279
recordingAudioFileToSend.delete();
42814280
}
42824281
}
4283-
requestAudioFocus(false);
4282+
requestRecordAudioFocus(false);
42844283
});
42854284
});
42864285
} else {
42874286
AutoDeleteMediaTask.unlockFile(recordingAudioFile);
42884287
if (recordingAudioFile != null) {
42894288
recordingAudioFile.delete();
42904289
}
4291-
requestAudioFocus(false);
4290+
requestRecordAudioFocus(false);
42924291
}
42934292
try {
42944293
if (audioRecorder != null) {
@@ -4423,7 +4422,11 @@ public void start() {
44234422
if (cancelled) {
44244423
break;
44254424
}
4426-
if (sourceFile.exists()) {
4425+
if (!sourceFile.exists()) {
4426+
sourceFile = FileLoader.getInstance(currentAccount.getCurrentAccount()).getPathToAttach(message.messageOwner, true);
4427+
FileLog.d("saving file: correcting path from " + path + " to " + (sourceFile == null ? null : sourceFile.getAbsolutePath()));
4428+
}
4429+
if (sourceFile != null && sourceFile.exists()) {
44274430
saveFileInternal(isMusic ? 3 : 2, sourceFile, name);
44284431
copiedFiles++;
44294432
}
@@ -4519,7 +4522,7 @@ private void addMessageToLoad(MessageObject messageObject) {
45194522
}
45204523
String fileName = FileLoader.getAttachFileName(document);
45214524
loadingMessageObjects.put(fileName, messageObject);
4522-
currentAccount.getFileLoader().loadFile(document, messageObject, FileLoader.PRIORITY_LOW, messageObject.shouldEncryptPhotoOrVideo() ? 2 : 0);
4525+
currentAccount.getFileLoader().loadFile(document, messageObject, FileLoader.PRIORITY_HIGH, messageObject.shouldEncryptPhotoOrVideo() ? 2 : 0);
45234526
});
45244527
}
45254528

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3609,7 +3609,6 @@ public static void updateReactions(TLRPC.Message message, TLRPC.TL_messageReacti
36093609
}
36103610
message.reactions = reactions;
36113611
message.flags |= 1048576;
3612-
FileLog.d("msg#"+message.id+" updateReactions out=" + message.out);
36133612
}
36143613

36153614
public boolean hasReactions() {

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public class MessagesStorage extends BaseController {
105105
}
106106
}
107107

108-
public final static int LAST_DB_VERSION = 155;
108+
public final static int LAST_DB_VERSION = 156;
109109
private boolean databaseMigrationInProgress;
110110
public boolean showClearDatabaseAlert;
111111
private LongSparseIntArray dialogIsForum = new LongSparseIntArray();
@@ -724,6 +724,7 @@ public static void createTables(SQLiteDatabase database) throws SQLiteException
724724

725725
database.executeFast("CREATE TABLE business_links(data BLOB, order_value INTEGER);").stepThis().dispose();
726726
database.executeFast("CREATE TABLE fact_checks(hash INTEGER PRIMARY KEY, data BLOB, expires INTEGER);").stepThis().dispose();
727+
database.executeFast("CREATE TABLE popular_bots(uid INTEGER PRIMARY KEY, time INTEGER, offset TEXT);").stepThis().dispose();
727728

728729
database.executeFast("PRAGMA user_version = " + MessagesStorage.LAST_DB_VERSION).stepThis().dispose();
729730

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@ public void onReceive(Context context, Intent intent) {
3030
} else if (intent.hasExtra("storyReaction") && intent.getBooleanExtra("storyReaction", false)) {
3131
NotificationsController.getInstance(currentAccount).processIgnoreStoryReactions();
3232
} else if (dialogId == 0) {
33+
FileLog.d("set dismissDate of global to " + date);
3334
MessagesController.getNotificationsSettings(currentAccount).edit().putInt("dismissDate", date).commit();
3435
} else {
36+
FileLog.d("set dismissDate of " + dialogId + " to " + date);
3537
MessagesController.getNotificationsSettings(currentAccount).edit().putInt("dismissDate" + dialogId, date).commit();
3638
}
3739
}

0 commit comments

Comments
 (0)