Skip to content

Commit

Permalink
update to 11.1.3 (5243)
Browse files Browse the repository at this point in the history
  • Loading branch information
dkaraush committed Sep 10, 2024
1 parent cc50db9 commit 8558775
Show file tree
Hide file tree
Showing 58 changed files with 532 additions and 198 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ public static Typeface bold() {
public static float density = 1;
public static Point displaySize = new Point();
public static float screenRefreshRate = 60;
public static float screenMaxRefreshRate = 60;
public static float screenRefreshTime = 1000 / screenRefreshRate;
public static int roundMessageSize;
public static int roundPlayingMessageSize;
Expand Down Expand Up @@ -2565,6 +2566,17 @@ public static void checkDisplaySize(Context context, Configuration newConfigurat
display.getMetrics(displayMetrics);
display.getSize(displaySize);
screenRefreshRate = display.getRefreshRate();
screenMaxRefreshRate = screenRefreshRate;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
float[] rates = display.getSupportedRefreshRates();
if (rates != null) {
for (int i = 0; i < rates.length; ++i) {
if (rates[i] > screenMaxRefreshRate) {
screenMaxRefreshRate = rates[i];
}
}
}
}
screenRefreshTime = 1000 / screenRefreshRate;
}
}
Expand Down Expand Up @@ -2601,6 +2613,35 @@ public static void checkDisplaySize(Context context, Configuration newConfigurat
}
}

public static void setPreferredMaxRefreshRate(Window window) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) return;
if (window == null) return;
final WindowManager wm = window.getWindowManager();
if (wm == null) return;
WindowManager.LayoutParams params = window.getAttributes();
params.preferredRefreshRate = screenMaxRefreshRate;
try {
wm.updateViewLayout(window.getDecorView(), params);
} catch (Exception e) {
FileLog.e(e);
}
}

public static void setPreferredMaxRefreshRate(WindowManager wm, View windowView, WindowManager.LayoutParams params) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) return;
if (wm == null) return;
if (Math.abs(params.preferredRefreshRate - screenMaxRefreshRate) > 0.2) {
params.preferredRefreshRate = screenMaxRefreshRate;
if (windowView.isAttachedToWindow()) {
try {
wm.updateViewLayout(windowView, params);
} catch (Exception e) {
FileLog.e(e);
}
}
}
}

public static double fixLocationCoord(double value) {
return ((long) (value * 1000000)) / 1000000.0;
}
Expand Down Expand Up @@ -3505,6 +3546,9 @@ public static CharSequence generateSearchName(String name, String name2, String
} else if (name2 != null && name2.length() != 0) {
wholeString += " " + name2;
}
if (wholeString == null) {
return "";
}
wholeString = wholeString.trim();
String lower = " " + wholeString.toLowerCase();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1516,6 +1516,12 @@ public static int migrate(MessagesStorage messagesStorage, int version) throws E
version = 155;
}

if (version == 155) {
database.executeFast("CREATE TABLE popular_bots(uid INTEGER PRIMARY KEY, time INTEGER, offset TEXT);").stepThis().dispose();
database.executeFast("PRAGMA user_version = 156").stepThis().dispose();
version = 156;
}

return version;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.text.format.DateFormat;
import android.util.Log;
import android.util.Xml;

import androidx.annotation.StringRes;
Expand All @@ -32,13 +31,10 @@
import org.telegram.ui.RestrictedLanguagesSelectActivity;
import org.xmlpull.v1.XmlPullParser;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.Calendar;
Expand Down Expand Up @@ -1468,6 +1464,14 @@ public static String formatPluralStringComma(String key, int plural) {
return formatPluralStringComma(key, plural, ',');
}

public static String formatPluralStringSpaced(String key, int plural) {
return formatPluralStringComma(key, plural, ' ');
}

public static String formatPluralStringSpaced(String key, int plural, Object... args) {
return formatPluralStringComma(key, plural, ' ', args);
}

public static String formatPluralStringComma(String key, int plural, Object... args) {
return formatPluralStringComma(key, plural, ',', args);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
import android.os.Environment;
import android.os.PowerManager;
import android.os.SystemClock;
import android.provider.DocumentsContract;
import android.provider.MediaStore;
import android.provider.OpenableColumns;
import android.telephony.PhoneStateListener;
Expand All @@ -65,8 +64,6 @@
import android.webkit.MimeTypeMap;
import android.widget.FrameLayout;

import androidx.core.content.FileProvider;

import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.ui.AspectRatioFrameLayout;
Expand Down Expand Up @@ -3884,7 +3881,7 @@ public void setReplyingMessage(MessageObject replyToMsg, MessageObject replyToTo
recordReplyingStory = storyItem;
}

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

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) {
manualRecording = false;
requestAudioFocus(true);
requestRecordAudioFocus(true);
recordQueue.cancelRunnable(recordStartRunnable);
recordQueue.postRunnable(() -> {
setBluetoothScoOn(true);
Expand Down Expand Up @@ -4033,6 +4030,7 @@ public void toggleRecordingPause(boolean voiceOnce) {
audioToSend.attributes.add(attributeAudio);
NotificationCenter.getInstance(recordingCurrentAccount).postNotificationName(NotificationCenter.recordPaused);
NotificationCenter.getInstance(recordingCurrentAccount).postNotificationName(NotificationCenter.audioDidSent, recordingGuid, audioToSend, recordingAudioFileToSend.getAbsolutePath());
requestRecordAudioFocus(false);
});
});
} else {
Expand All @@ -4050,6 +4048,7 @@ public void toggleRecordingPause(boolean voiceOnce) {
}

AndroidUtilities.runOnUIThread(() -> {
requestRecordAudioFocus(true);
MediaDataController.getInstance(recordingCurrentAccount).pushDraftVoiceMessage(recordDialogId, recordTopicId, null);

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

try {
feedbackView.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
Expand Down Expand Up @@ -4280,15 +4279,15 @@ private void stopRecordingInternal(final int send, boolean notify, int scheduleD
recordingAudioFileToSend.delete();
}
}
requestAudioFocus(false);
requestRecordAudioFocus(false);
});
});
} else {
AutoDeleteMediaTask.unlockFile(recordingAudioFile);
if (recordingAudioFile != null) {
recordingAudioFile.delete();
}
requestAudioFocus(false);
requestRecordAudioFocus(false);
}
try {
if (audioRecorder != null) {
Expand Down Expand Up @@ -4423,7 +4422,11 @@ public void start() {
if (cancelled) {
break;
}
if (sourceFile.exists()) {
if (!sourceFile.exists()) {
sourceFile = FileLoader.getInstance(currentAccount.getCurrentAccount()).getPathToAttach(message.messageOwner, true);
FileLog.d("saving file: correcting path from " + path + " to " + (sourceFile == null ? null : sourceFile.getAbsolutePath()));
}
if (sourceFile != null && sourceFile.exists()) {
saveFileInternal(isMusic ? 3 : 2, sourceFile, name);
copiedFiles++;
}
Expand Down Expand Up @@ -4519,7 +4522,7 @@ private void addMessageToLoad(MessageObject messageObject) {
}
String fileName = FileLoader.getAttachFileName(document);
loadingMessageObjects.put(fileName, messageObject);
currentAccount.getFileLoader().loadFile(document, messageObject, FileLoader.PRIORITY_LOW, messageObject.shouldEncryptPhotoOrVideo() ? 2 : 0);
currentAccount.getFileLoader().loadFile(document, messageObject, FileLoader.PRIORITY_HIGH, messageObject.shouldEncryptPhotoOrVideo() ? 2 : 0);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3609,7 +3609,6 @@ public static void updateReactions(TLRPC.Message message, TLRPC.TL_messageReacti
}
message.reactions = reactions;
message.flags |= 1048576;
FileLog.d("msg#"+message.id+" updateReactions out=" + message.out);
}

public boolean hasReactions() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public class MessagesStorage extends BaseController {
}
}

public final static int LAST_DB_VERSION = 155;
public final static int LAST_DB_VERSION = 156;
private boolean databaseMigrationInProgress;
public boolean showClearDatabaseAlert;
private LongSparseIntArray dialogIsForum = new LongSparseIntArray();
Expand Down Expand Up @@ -724,6 +724,7 @@ public static void createTables(SQLiteDatabase database) throws SQLiteException

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ public void onReceive(Context context, Intent intent) {
} else if (intent.hasExtra("storyReaction") && intent.getBooleanExtra("storyReaction", false)) {
NotificationsController.getInstance(currentAccount).processIgnoreStoryReactions();
} else if (dialogId == 0) {
FileLog.d("set dismissDate of global to " + date);
MessagesController.getNotificationsSettings(currentAccount).edit().putInt("dismissDate", date).commit();
} else {
FileLog.d("set dismissDate of " + dialogId + " to " + date);
MessagesController.getNotificationsSettings(currentAccount).edit().putInt("dismissDate" + dialogId, date).commit();
}
}
Expand Down
Loading

0 comments on commit 8558775

Please sign in to comment.