Update to 5.10.0

This commit is contained in:
DrKLO 2019-08-22 01:53:26 +02:00
parent 9f48ec7ea2
commit 53e04b55fb
252 changed files with 11412 additions and 5153 deletions

View file

@ -17,6 +17,7 @@ import android.os.Environment;
import android.os.SystemClock;
import android.text.TextUtils;
import android.util.Base64;
import android.util.SparseArray;
import org.json.JSONObject;
import org.telegram.tgnet.ConnectionsManager;
@ -53,6 +54,9 @@ public class SharedConfig {
public static boolean useFingerprint = true;
public static String lastUpdateVersion;
public static int suggestStickers;
public static boolean loopStickers;
public static int keepMedia = 2;
public static int lastKeepMediaCheckTime;
private static int lastLocalId = -210000;
private static String passportConfigJson = "";
@ -72,7 +76,6 @@ public class SharedConfig {
public static boolean directShare = true;
public static boolean inappCamera = true;
public static boolean roundCamera16to9 = true;
public static boolean groupPhotosEnabled = true;
public static boolean noSoundHintShowed = false;
public static boolean streamMedia = true;
public static boolean streamAllVideo = false;
@ -231,7 +234,6 @@ public class SharedConfig {
inappCamera = preferences.getBoolean("inappCamera", true);
hasCameraCache = preferences.contains("cameraCache");
roundCamera16to9 = true;//preferences.getBoolean("roundCamera16to9", false);
groupPhotosEnabled = preferences.getBoolean("groupPhotosEnabled", true);
repeatMode = preferences.getInt("repeatMode", 0);
fontSize = preferences.getInt("fons_size", AndroidUtilities.isTablet() ? 18 : 16);
allowBigEmoji = preferences.getBoolean("allowBigEmoji", true);
@ -248,6 +250,9 @@ public class SharedConfig {
archiveHidden = preferences.getBoolean("archiveHidden", false);
distanceSystemType = preferences.getInt("distanceSystemType", 0);
devicePerformanceClass = preferences.getInt("devicePerformanceClass", -1);
loopStickers = preferences.getBoolean("loopStickers", true);
keepMedia = preferences.getInt("keep_media", 2);
lastKeepMediaCheckTime = preferences.getInt("lastKeepMediaCheckTime", 0);
preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
showNotificationsForAllAccounts = preferences.getBoolean("AllAccounts", true);
@ -374,6 +379,64 @@ public class SharedConfig {
editor.commit();
}
public static void setKeepMedia(int value) {
keepMedia = value;
SharedPreferences preferences = MessagesController.getGlobalMainSettings();
SharedPreferences.Editor editor = preferences.edit();
editor.putInt("keep_media", keepMedia);
editor.commit();
}
public static void checkKeepMedia() {
int time = (int) (System.currentTimeMillis() / 1000);
if (keepMedia == 2 || Math.abs(time - lastKeepMediaCheckTime) < 24 * 60 * 60) {
return;
}
lastKeepMediaCheckTime = time;
Utilities.globalQueue.postRunnable(() -> {
int days;
if (keepMedia == 0) {
days = 7;
} else if (keepMedia == 1) {
days = 30;
} else {
days = 3;
}
long currentTime = time - 60 * 60 * 24 * days;
final SparseArray<File> paths = ImageLoader.getInstance().createMediaPaths();
for (int a = 0; a < paths.size(); a++) {
if (paths.keyAt(a) == FileLoader.MEDIA_DIR_CACHE) {
continue;
}
try {
Utilities.clearDir(paths.valueAt(a).getAbsolutePath(), 0, currentTime);
} catch (Throwable e) {
FileLog.e(e);
}
}
SharedPreferences preferences = MessagesController.getGlobalMainSettings();
SharedPreferences.Editor editor = preferences.edit();
editor.putInt("lastKeepMediaCheckTime", lastKeepMediaCheckTime);
editor.commit();
});
}
public static void toggleLoopStickers() {
loopStickers = !loopStickers;
SharedPreferences preferences = MessagesController.getGlobalMainSettings();
SharedPreferences.Editor editor = preferences.edit();
editor.putBoolean("loopStickers", loopStickers);
editor.commit();
}
public static void toggleBigEmoji() {
allowBigEmoji = !allowBigEmoji;
SharedPreferences preferences = MessagesController.getGlobalMainSettings();
SharedPreferences.Editor editor = preferences.edit();
editor.putBoolean("allowBigEmoji", allowBigEmoji);
editor.commit();
}
public static void toggleShuffleMusic(int type) {
if (type == 2) {
shuffleMusic = !shuffleMusic;
@ -545,14 +608,6 @@ public class SharedConfig {
editor.commit();
}
public static void toggleGroupPhotosEnabled() {
groupPhotosEnabled = !groupPhotosEnabled;
SharedPreferences preferences = MessagesController.getGlobalMainSettings();
SharedPreferences.Editor editor = preferences.edit();
editor.putBoolean("groupPhotosEnabled", groupPhotosEnabled);
editor.commit();
}
public static void setDistanceSystemType(int type) {
distanceSystemType = type;
SharedPreferences preferences = MessagesController.getGlobalMainSettings();