Skip to content

Commit

Permalink
Update to 8.2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
xaxtix committed Nov 9, 2021
1 parent 1d379b9 commit 44be21d
Show file tree
Hide file tree
Showing 10 changed files with 275 additions and 148 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.media.MediaScannerConnection;
import android.net.Uri;
import android.os.Build;
import android.os.Environment;
Expand Down Expand Up @@ -95,6 +96,7 @@
import android.widget.TextView;

import com.android.internal.telephony.ITelephony;
import com.google.android.exoplayer2.util.Log;
import com.google.android.gms.auth.api.phone.SmsRetriever;
import com.google.android.gms.auth.api.phone.SmsRetrieverClient;
import com.google.android.gms.tasks.Task;
Expand Down Expand Up @@ -2267,11 +2269,11 @@ public static void addMediaToGallery(String fromPath) {
return;
}
File f = new File(fromPath);
Uri contentUri = Uri.fromFile(f);
addMediaToGallery(contentUri);
addMediaToGallery(f);
}

public static void addMediaToGallery(Uri uri) {
public static void addMediaToGallery(File file) {
Uri uri = Uri.fromFile(file);
if (uri == null) {
return;
}
Expand All @@ -2285,8 +2287,8 @@ public static void addMediaToGallery(Uri uri) {
}

private static File getAlbumDir(boolean secretChat) {
if (secretChat || !BuildVars.NO_SCOPED_STORAGE || (Build.VERSION.SDK_INT >= 23 && ApplicationLoader.applicationContext.checkSelfPermission(android.Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED)) {
return FileLoader.getDirectory(FileLoader.MEDIA_DIR_CACHE);
if (secretChat || !BuildVars.NO_SCOPED_STORAGE ||(Build.VERSION.SDK_INT >= 23 && ApplicationLoader.applicationContext.checkSelfPermission(android.Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED)) {
return FileLoader.getDirectory(FileLoader.MEDIA_DIR_IMAGE);
}
File storageDir = null;
if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
Expand Down Expand Up @@ -2399,17 +2401,25 @@ public static File generatePicturePath() {

public static File generatePicturePath(boolean secretChat, String ext) {
try {
File storageDir = getAlbumDir(secretChat);
Date date = new Date();
date.setTime(System.currentTimeMillis() + Utilities.random.nextInt(1000) + 1);
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss_SSS", Locale.US).format(date);
return new File(storageDir, "IMG_" + timeStamp + "." + (TextUtils.isEmpty(ext) ? "jpg" : ext));
File storageDir = ApplicationLoader.applicationContext.getExternalFilesDir(Environment.DIRECTORY_PICTURES);
return new File(storageDir, generateFileName(0, ext));
} catch (Exception e) {
FileLog.e(e);
}
return null;
}

public static String generateFileName(int type, String ext) {
Date date = new Date();
date.setTime(System.currentTimeMillis() + Utilities.random.nextInt(1000) + 1);
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss_SSS", Locale.US).format(date);
if (type == 0) {
return "IMG_" + timeStamp + "." + (TextUtils.isEmpty(ext) ? "jpg" : ext);
} else {
return "VID_" + timeStamp + ".mp4";
}
}

public static CharSequence generateSearchName(String name, String name2, String q) {
if (name == null && name2 == null || TextUtils.isEmpty(q)) {
return "";
Expand Down Expand Up @@ -2701,7 +2711,10 @@ public static byte[] decodeQuotedPrintable(final byte[] bytes) {
}

public static boolean copyFile(InputStream sourceFile, File destFile) throws IOException {
OutputStream out = new FileOutputStream(destFile);
return copyFile(sourceFile, new FileOutputStream(destFile));
}

public static boolean copyFile(InputStream sourceFile, OutputStream out) throws IOException {
byte[] buf = new byte[4096];
int len;
while ((len = sourceFile.read(buf)) > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@
public class BuildVars {

public static boolean DEBUG_VERSION = false;
public static boolean LOGS_ENABLED = false;
public static boolean DEBUG_PRIVATE_VERSION = false;
public static boolean LOGS_ENABLED = false;
public static boolean USE_CLOUD_STRINGS = true;
public static boolean CHECK_UPDATES = true;
public static boolean NO_SCOPED_STORAGE = Build.VERSION.SDK_INT <= 29;
public static int BUILD_VERSION = 2462;
public static String BUILD_VERSION_STRING = "8.2.1";
public static int BUILD_VERSION = 2466;
public static String BUILD_VERSION_STRING = "8.2.3";
public static int APP_ID = 4;
public static String APP_HASH = "014b35b6184100b085b0d0572f9b5103";

public static String SMS_HASH = isStandaloneApp() ? "w0lkcmTZkKh" : (DEBUG_VERSION ? "O2P2z+/jBpJ" : "oLeq9AcOZkT");
public static String PLAYSTORE_APP_URL = "https://play.google.com/store/apps/details?id=org.telegram.messenger";

Expand Down
33 changes: 13 additions & 20 deletions TMessagesProj/src/main/java/org/telegram/messenger/ImageLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -1931,7 +1931,7 @@ public void removeTestWebFile(String url) {

@TargetApi(26)
private static void moveDirectory(File source, File target) {
if (!target.exists() && !target.mkdir()) {
if (!source.exists() || (!target.exists() && !target.mkdir())) {
return;
}
try (Stream<Path> files = Files.list(source.toPath())) {
Expand Down Expand Up @@ -1984,27 +1984,20 @@ public SparseArray<File> createMediaPaths() {
}
}
}
telegramPath = new File(path, "Telegram");
telegramPath.mkdirs();
/*int version = 0;
try {
PackageManager pm = ApplicationLoader.applicationContext.getPackageManager();
ApplicationInfo applicationInfo = pm.getApplicationInfo(ApplicationLoader.applicationContext.getPackageName(), 0);
if (applicationInfo != null) {
version = applicationInfo.targetSdkVersion;
}
} catch (Throwable ignore) {

if (Build.VERSION.SDK_INT >= 30) {
File newPath = ApplicationLoader.applicationContext.getExternalFilesDir(null);
telegramPath = new File(newPath, "Telegram");
// File oldPath = new File(path, "Telegram");
// long moveStart = System.currentTimeMillis();
// moveDirectory(oldPath, telegramPath);
// long dt = System.currentTimeMillis() - moveStart;
// FileLog.d("move time = " + dt);
} else {
telegramPath = new File(path, "Telegram");
}
File newPath = ApplicationLoader.applicationContext.getExternalFilesDir(null);
telegramPath = new File(newPath, "Telegram"); //TODO
if (Build.VERSION.SDK_INT >= 29 && version < 30) {
File oldPath = new File(path, "Telegram");
long moveStart = SystemClock.elapsedRealtime();
moveDirectory(oldPath, telegramPath);
long dt = SystemClock.elapsedRealtime() - moveStart;
FileLog.d("move time = " + dt);
}*/
telegramPath.mkdirs();

if (Build.VERSION.SDK_INT >= 19 && !telegramPath.isDirectory()) {
ArrayList<File> dirs = AndroidUtilities.getDataDirs();
for (int a = 0, N = dirs.size(); a < N; a++) {
Expand Down
Loading

0 comments on commit 44be21d

Please sign in to comment.