Update to 8.4.1

This commit is contained in:
xaxtix 2021-12-30 13:52:40 +03:00
parent 4a43f809b3
commit 9e740dfd4d
164 changed files with 33576 additions and 19058 deletions

View file

@ -20,20 +20,23 @@ import android.text.TextUtils;
import android.util.Base64;
import android.util.SparseArray;
import androidx.annotation.IntDef;
import androidx.core.content.pm.ShortcutManagerCompat;
import org.json.JSONObject;
import org.telegram.tgnet.ConnectionsManager;
import org.telegram.tgnet.SerializedData;
import org.telegram.ui.Components.SharedMediaLayout;
import org.telegram.ui.Components.SwipeGestureSettingsView;
import org.telegram.tgnet.TLRPC;
import org.telegram.ui.Components.SwipeGestureSettingsView;
import java.io.File;
import java.io.RandomAccessFile;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import androidx.core.content.pm.ShortcutManagerCompat;
import java.util.Locale;
public class SharedConfig {
@ -74,6 +77,7 @@ public class SharedConfig {
public static boolean searchMessagesAsListUsed;
public static boolean stickersReorderingHintUsed;
public static boolean disableVoiceAudioEffects;
public static boolean drawSnowInChat;
private static int lastLocalId = -210000;
public static String storageCacheDir;
@ -377,6 +381,7 @@ public class SharedConfig {
mediaColumnsCount = preferences.getInt("mediaColumnsCount", 3);
fastScrollHintCount = preferences.getInt("fastScrollHintCount", 3);
dontAskManageStorage = preferences.getBoolean("dontAskManageStorage", false);
drawSnowInChat = preferences.getBoolean("drawSnowInChat", BuildVars.DEBUG_VERSION);
preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
showNotificationsForAllAccounts = preferences.getBoolean("AllAccounts", true);
@ -710,6 +715,14 @@ public class SharedConfig {
editor.commit();
}
public static void toggleDrawSnowInChat() {
drawSnowInChat = !drawSnowInChat;
SharedPreferences preferences = MessagesController.getGlobalMainSettings();
SharedPreferences.Editor editor = preferences.edit();
editor.putBoolean("drawSnowInChat", drawSnowInChat);
editor.commit();
}
public static void toggleNoiseSupression() {
noiseSupression = !noiseSupression;
SharedPreferences preferences = MessagesController.getGlobalMainSettings();
@ -1119,25 +1132,38 @@ public class SharedConfig {
public final static int PERFORMANCE_CLASS_AVERAGE = 1;
public final static int PERFORMANCE_CLASS_HIGH = 2;
@Retention(RetentionPolicy.SOURCE)
@IntDef({
PERFORMANCE_CLASS_LOW,
PERFORMANCE_CLASS_AVERAGE,
PERFORMANCE_CLASS_HIGH
})
public @interface PerformanceClass {}
@PerformanceClass
public static int getDevicePerformanceClass() {
if (devicePerformanceClass == -1) {
int maxCpuFreq = -1;
try {
RandomAccessFile reader = new RandomAccessFile("/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq", "r");
String line = reader.readLine();
if (line != null) {
maxCpuFreq = Utilities.parseInt(line) / 1000;
}
reader.close();
} catch (Throwable ignore) {
}
int androidVersion = Build.VERSION.SDK_INT;
int cpuCount = ConnectionsManager.CPU_COUNT;
int memoryClass = ((ActivityManager) ApplicationLoader.applicationContext.getSystemService(Context.ACTIVITY_SERVICE)).getMemoryClass();
int totalCpuFreq = 0;
int freqResolved = 0;
for (int i = 0; i < cpuCount; i++) {
try {
RandomAccessFile reader = new RandomAccessFile(String.format(Locale.ENGLISH, "/sys/devices/system/cpu/cpu%d/cpufreq/cpuinfo_max_freq", i), "r");
String line = reader.readLine();
if (line != null) {
totalCpuFreq += Utilities.parseInt(line) / 1000;
freqResolved++;
}
reader.close();
} catch (Throwable ignore) {}
}
int maxCpuFreq = freqResolved == 0 ? -1 : (int) Math.ceil(totalCpuFreq / (float) freqResolved);
if (androidVersion < 21 || cpuCount <= 2 || memoryClass <= 100 || cpuCount <= 4 && maxCpuFreq != -1 && maxCpuFreq <= 1250 || cpuCount <= 4 && maxCpuFreq <= 1600 && memoryClass <= 128 && androidVersion <= 21 || cpuCount <= 4 && maxCpuFreq <= 1300 && memoryClass <= 128 && androidVersion <= 24) {
devicePerformanceClass = PERFORMANCE_CLASS_LOW;
} else if (cpuCount < 8 || memoryClass <= 160 || maxCpuFreq != -1 && maxCpuFreq <= 1650 || maxCpuFreq == -1 && cpuCount == 8 && androidVersion <= 23) {
} else if (cpuCount < 8 || memoryClass <= 160 || maxCpuFreq != -1 && maxCpuFreq <= 2050 || maxCpuFreq == -1 && cpuCount == 8 && androidVersion <= 23) {
devicePerformanceClass = PERFORMANCE_CLASS_AVERAGE;
} else {
devicePerformanceClass = PERFORMANCE_CLASS_HIGH;