mirror of
https://github.com/DrKLO/Telegram.git
synced 2024-12-22 14:35:03 +01:00
Update to 8.2.3
This commit is contained in:
parent
1d379b9a7b
commit
44be21dd0f
10 changed files with 278 additions and 151 deletions
|
@ -38,6 +38,7 @@ import android.graphics.Typeface;
|
||||||
import android.graphics.drawable.BitmapDrawable;
|
import android.graphics.drawable.BitmapDrawable;
|
||||||
import android.graphics.drawable.ColorDrawable;
|
import android.graphics.drawable.ColorDrawable;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.media.MediaScannerConnection;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
|
@ -95,6 +96,7 @@ import android.widget.ScrollView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.android.internal.telephony.ITelephony;
|
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.SmsRetriever;
|
||||||
import com.google.android.gms.auth.api.phone.SmsRetrieverClient;
|
import com.google.android.gms.auth.api.phone.SmsRetrieverClient;
|
||||||
import com.google.android.gms.tasks.Task;
|
import com.google.android.gms.tasks.Task;
|
||||||
|
@ -2267,11 +2269,11 @@ public class AndroidUtilities {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
File f = new File(fromPath);
|
File f = new File(fromPath);
|
||||||
Uri contentUri = Uri.fromFile(f);
|
addMediaToGallery(f);
|
||||||
addMediaToGallery(contentUri);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void addMediaToGallery(Uri uri) {
|
public static void addMediaToGallery(File file) {
|
||||||
|
Uri uri = Uri.fromFile(file);
|
||||||
if (uri == null) {
|
if (uri == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -2285,8 +2287,8 @@ public class AndroidUtilities {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static File getAlbumDir(boolean secretChat) {
|
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)) {
|
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);
|
return FileLoader.getDirectory(FileLoader.MEDIA_DIR_IMAGE);
|
||||||
}
|
}
|
||||||
File storageDir = null;
|
File storageDir = null;
|
||||||
if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
|
if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
|
||||||
|
@ -2399,17 +2401,25 @@ public class AndroidUtilities {
|
||||||
|
|
||||||
public static File generatePicturePath(boolean secretChat, String ext) {
|
public static File generatePicturePath(boolean secretChat, String ext) {
|
||||||
try {
|
try {
|
||||||
File storageDir = getAlbumDir(secretChat);
|
File storageDir = ApplicationLoader.applicationContext.getExternalFilesDir(Environment.DIRECTORY_PICTURES);
|
||||||
Date date = new Date();
|
return new File(storageDir, generateFileName(0, ext));
|
||||||
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));
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
FileLog.e(e);
|
FileLog.e(e);
|
||||||
}
|
}
|
||||||
return null;
|
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) {
|
public static CharSequence generateSearchName(String name, String name2, String q) {
|
||||||
if (name == null && name2 == null || TextUtils.isEmpty(q)) {
|
if (name == null && name2 == null || TextUtils.isEmpty(q)) {
|
||||||
return "";
|
return "";
|
||||||
|
@ -2701,7 +2711,10 @@ public class AndroidUtilities {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean copyFile(InputStream sourceFile, File destFile) throws IOException {
|
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];
|
byte[] buf = new byte[4096];
|
||||||
int len;
|
int len;
|
||||||
while ((len = sourceFile.read(buf)) > 0) {
|
while ((len = sourceFile.read(buf)) > 0) {
|
||||||
|
|
|
@ -15,15 +15,16 @@ import android.os.Build;
|
||||||
public class BuildVars {
|
public class BuildVars {
|
||||||
|
|
||||||
public static boolean DEBUG_VERSION = false;
|
public static boolean DEBUG_VERSION = false;
|
||||||
public static boolean LOGS_ENABLED = false;
|
|
||||||
public static boolean DEBUG_PRIVATE_VERSION = false;
|
public static boolean DEBUG_PRIVATE_VERSION = false;
|
||||||
|
public static boolean LOGS_ENABLED = false;
|
||||||
public static boolean USE_CLOUD_STRINGS = true;
|
public static boolean USE_CLOUD_STRINGS = true;
|
||||||
public static boolean CHECK_UPDATES = true;
|
public static boolean CHECK_UPDATES = true;
|
||||||
public static boolean NO_SCOPED_STORAGE = Build.VERSION.SDK_INT <= 29;
|
public static boolean NO_SCOPED_STORAGE = Build.VERSION.SDK_INT <= 29;
|
||||||
public static int BUILD_VERSION = 2462;
|
public static int BUILD_VERSION = 2466;
|
||||||
public static String BUILD_VERSION_STRING = "8.2.1";
|
public static String BUILD_VERSION_STRING = "8.2.3";
|
||||||
public static int APP_ID = 4;
|
public static int APP_ID = 4;
|
||||||
public static String APP_HASH = "014b35b6184100b085b0d0572f9b5103";
|
public static String APP_HASH = "014b35b6184100b085b0d0572f9b5103";
|
||||||
|
|
||||||
public static String SMS_HASH = isStandaloneApp() ? "w0lkcmTZkKh" : (DEBUG_VERSION ? "O2P2z+/jBpJ" : "oLeq9AcOZkT");
|
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";
|
public static String PLAYSTORE_APP_URL = "https://play.google.com/store/apps/details?id=org.telegram.messenger";
|
||||||
|
|
||||||
|
|
|
@ -1931,7 +1931,7 @@ public class ImageLoader {
|
||||||
|
|
||||||
@TargetApi(26)
|
@TargetApi(26)
|
||||||
private static void moveDirectory(File source, File target) {
|
private static void moveDirectory(File source, File target) {
|
||||||
if (!target.exists() && !target.mkdir()) {
|
if (!source.exists() || (!target.exists() && !target.mkdir())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try (Stream<Path> files = Files.list(source.toPath())) {
|
try (Stream<Path> files = Files.list(source.toPath())) {
|
||||||
|
@ -1984,27 +1984,20 @@ public class ImageLoader {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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.mkdirs();
|
||||||
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);
|
|
||||||
}*/
|
|
||||||
if (Build.VERSION.SDK_INT >= 19 && !telegramPath.isDirectory()) {
|
if (Build.VERSION.SDK_INT >= 19 && !telegramPath.isDirectory()) {
|
||||||
ArrayList<File> dirs = AndroidUtilities.getDataDirs();
|
ArrayList<File> dirs = AndroidUtilities.getDataDirs();
|
||||||
for (int a = 0, N = dirs.size(); a < N; a++) {
|
for (int a = 0, N = dirs.size(); a < N; a++) {
|
||||||
|
|
|
@ -16,6 +16,7 @@ import android.annotation.SuppressLint;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.DownloadManager;
|
import android.app.DownloadManager;
|
||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
|
import android.content.ContentValues;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
@ -81,8 +82,10 @@ import org.telegram.ui.PhotoViewer;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileDescriptor;
|
import java.io.FileDescriptor;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.io.OutputStream;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
|
@ -99,10 +102,15 @@ import java.util.concurrent.CountDownLatch;
|
||||||
public class MediaController implements AudioManager.OnAudioFocusChangeListener, NotificationCenter.NotificationCenterDelegate, SensorEventListener {
|
public class MediaController implements AudioManager.OnAudioFocusChangeListener, NotificationCenter.NotificationCenterDelegate, SensorEventListener {
|
||||||
|
|
||||||
private native int startRecord(String path, int sampleRate);
|
private native int startRecord(String path, int sampleRate);
|
||||||
|
|
||||||
private native int writeFrame(ByteBuffer frame, int len);
|
private native int writeFrame(ByteBuffer frame, int len);
|
||||||
|
|
||||||
private native void stopRecord();
|
private native void stopRecord();
|
||||||
|
|
||||||
public static native int isOpusFile(String path);
|
public static native int isOpusFile(String path);
|
||||||
|
|
||||||
public native byte[] getWaveform(String path);
|
public native byte[] getWaveform(String path);
|
||||||
|
|
||||||
public native byte[] getWaveform2(short[] array, int length);
|
public native byte[] getWaveform2(short[] array, int length);
|
||||||
|
|
||||||
public boolean isBuffering() {
|
public boolean isBuffering() {
|
||||||
|
@ -454,7 +462,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
|
||||||
private static final float VOLUME_NORMAL = 1.0f;
|
private static final float VOLUME_NORMAL = 1.0f;
|
||||||
private static final int AUDIO_NO_FOCUS_NO_DUCK = 0;
|
private static final int AUDIO_NO_FOCUS_NO_DUCK = 0;
|
||||||
private static final int AUDIO_NO_FOCUS_CAN_DUCK = 1;
|
private static final int AUDIO_NO_FOCUS_CAN_DUCK = 1;
|
||||||
private static final int AUDIO_FOCUSED = 2;
|
private static final int AUDIO_FOCUSED = 2;
|
||||||
|
|
||||||
private static class VideoConvertMessage {
|
private static class VideoConvertMessage {
|
||||||
public MessageObject messageObject;
|
public MessageObject messageObject;
|
||||||
|
@ -745,7 +753,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
|
||||||
Cursor cursor = null;
|
Cursor cursor = null;
|
||||||
try {
|
try {
|
||||||
if (ApplicationLoader.applicationContext.checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
|
if (ApplicationLoader.applicationContext.checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
|
||||||
cursor = MediaStore.Images.Media.query(ApplicationLoader.applicationContext.getContentResolver(), MediaStore.Images.Media.EXTERNAL_CONTENT_URI, new String[] {"COUNT(_id)"}, null, null, null);
|
cursor = MediaStore.Images.Media.query(ApplicationLoader.applicationContext.getContentResolver(), MediaStore.Images.Media.EXTERNAL_CONTENT_URI, new String[]{"COUNT(_id)"}, null, null, null);
|
||||||
if (cursor != null) {
|
if (cursor != null) {
|
||||||
if (cursor.moveToNext()) {
|
if (cursor.moveToNext()) {
|
||||||
count += cursor.getInt(0);
|
count += cursor.getInt(0);
|
||||||
|
@ -761,7 +769,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if (ApplicationLoader.applicationContext.checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
|
if (ApplicationLoader.applicationContext.checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
|
||||||
cursor = MediaStore.Images.Media.query(ApplicationLoader.applicationContext.getContentResolver(), MediaStore.Video.Media.EXTERNAL_CONTENT_URI, new String[] {"COUNT(_id)"}, null, null, null);
|
cursor = MediaStore.Images.Media.query(ApplicationLoader.applicationContext.getContentResolver(), MediaStore.Video.Media.EXTERNAL_CONTENT_URI, new String[]{"COUNT(_id)"}, null, null, null);
|
||||||
if (cursor != null) {
|
if (cursor != null) {
|
||||||
if (cursor.moveToNext()) {
|
if (cursor.moveToNext()) {
|
||||||
count += cursor.getInt(0);
|
count += cursor.getInt(0);
|
||||||
|
@ -1971,6 +1979,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
|
||||||
}
|
}
|
||||||
return audioPlayer.getDuration();
|
return audioPlayer.getDuration();
|
||||||
}
|
}
|
||||||
|
|
||||||
public MessageObject getPlayingMessageObject() {
|
public MessageObject getPlayingMessageObject() {
|
||||||
return playingMessageObject;
|
return playingMessageObject;
|
||||||
}
|
}
|
||||||
|
@ -2496,7 +2505,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
|
||||||
final MessageObject currentMessage = playingMessageObject;
|
final MessageObject currentMessage = playingMessageObject;
|
||||||
AndroidUtilities.runOnUIThread(() -> {
|
AndroidUtilities.runOnUIThread(() -> {
|
||||||
if (audioPlayer != null && playingMessageObject != null && !isPaused) {
|
if (audioPlayer != null && playingMessageObject != null && !isPaused) {
|
||||||
if (isSamePlayingMessage(currentMessage )) {
|
if (isSamePlayingMessage(currentMessage)) {
|
||||||
seekToProgress(playingMessageObject, p);
|
seekToProgress(playingMessageObject, p);
|
||||||
}
|
}
|
||||||
audioPlayer.play();
|
audioPlayer.play();
|
||||||
|
@ -2853,7 +2862,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
|
||||||
/*if (Build.VERSION.SDK_INT >= 26) {
|
/*if (Build.VERSION.SDK_INT >= 26) {
|
||||||
ApplicationLoader.applicationContext.startForegroundService(intent);
|
ApplicationLoader.applicationContext.startForegroundService(intent);
|
||||||
} else {*/
|
} else {*/
|
||||||
ApplicationLoader.applicationContext.startService(intent);
|
ApplicationLoader.applicationContext.startService(intent);
|
||||||
//}
|
//}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
FileLog.e(e);
|
FileLog.e(e);
|
||||||
|
@ -3245,7 +3254,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
|
||||||
/*if (Build.VERSION.SDK_INT >= 26) {
|
/*if (Build.VERSION.SDK_INT >= 26) {
|
||||||
ApplicationLoader.applicationContext.startForegroundService(intent);
|
ApplicationLoader.applicationContext.startForegroundService(intent);
|
||||||
} else {*/
|
} else {*/
|
||||||
ApplicationLoader.applicationContext.startService(intent);
|
ApplicationLoader.applicationContext.startService(intent);
|
||||||
//}
|
//}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
FileLog.e(e);
|
FileLog.e(e);
|
||||||
|
@ -3793,7 +3802,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
|
||||||
}
|
}
|
||||||
if (!cancelled) {
|
if (!cancelled) {
|
||||||
if (isMusic) {
|
if (isMusic) {
|
||||||
AndroidUtilities.addMediaToGallery(Uri.fromFile(destFile));
|
AndroidUtilities.addMediaToGallery(destFile);
|
||||||
} else {
|
} else {
|
||||||
DownloadManager downloadManager = (DownloadManager) ApplicationLoader.applicationContext.getSystemService(Context.DOWNLOAD_SERVICE);
|
DownloadManager downloadManager = (DownloadManager) ApplicationLoader.applicationContext.getSystemService(Context.DOWNLOAD_SERVICE);
|
||||||
String mimeType = mime;
|
String mimeType = mime;
|
||||||
|
@ -3870,7 +3879,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void saveFile(String fullPath, Context context, final int type, final String name, final String mime, final Runnable onSaved) {
|
public static void saveFile(String fullPath, Context context, final int type, final String name, final String mime, final Runnable onSaved) {
|
||||||
if (fullPath == null) {
|
if (fullPath == null || context == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3887,8 +3896,9 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
|
||||||
}
|
}
|
||||||
|
|
||||||
final File sourceFile = file;
|
final File sourceFile = file;
|
||||||
final boolean[] cancelled = new boolean[] {false};
|
final boolean[] cancelled = new boolean[]{false};
|
||||||
if (sourceFile.exists()) {
|
if (sourceFile.exists()) {
|
||||||
|
|
||||||
AlertDialog progressDialog = null;
|
AlertDialog progressDialog = null;
|
||||||
final boolean[] finished = new boolean[1];
|
final boolean[] finished = new boolean[1];
|
||||||
if (context != null && type != 0) {
|
if (context != null && type != 0) {
|
||||||
|
@ -3913,99 +3923,152 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
|
||||||
|
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
File destFile;
|
boolean result = true;
|
||||||
if (type == 0) {
|
if (Build.VERSION.SDK_INT >= 29) {
|
||||||
destFile = AndroidUtilities.generatePicturePath(false, FileLoader.getFileExtension(sourceFile));
|
try {
|
||||||
} else if (type == 1) {
|
ContentValues contentValues = new ContentValues();
|
||||||
destFile = AndroidUtilities.generateVideoPath();
|
String extension = MimeTypeMap.getFileExtensionFromUrl(sourceFile.getAbsolutePath());
|
||||||
} else {
|
String mimeType = null;
|
||||||
File dir;
|
if (extension != null) {
|
||||||
if (type == 2) {
|
mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension);
|
||||||
dir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
|
}
|
||||||
} else {
|
Uri uriToInsert = null;
|
||||||
dir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MUSIC);
|
if (type == 0) {
|
||||||
}
|
uriToInsert = MediaStore.Images.Media.getContentUri(MediaStore.VOLUME_EXTERNAL_PRIMARY);
|
||||||
dir.mkdir();
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||||
destFile = new File(dir, name);
|
File dirDest = new File(Environment.DIRECTORY_PICTURES, "Telegram");
|
||||||
if (destFile.exists()) {
|
contentValues.put(MediaStore.MediaColumns.RELATIVE_PATH, dirDest + File.separator);
|
||||||
int idx = name.lastIndexOf('.');
|
|
||||||
for (int a = 0; a < 10; a++) {
|
|
||||||
String newName;
|
|
||||||
if (idx != -1) {
|
|
||||||
newName = name.substring(0, idx) + "(" + (a + 1) + ")" + name.substring(idx);
|
|
||||||
} else {
|
|
||||||
newName = name + "(" + (a + 1) + ")";
|
|
||||||
}
|
}
|
||||||
destFile = new File(dir, newName);
|
contentValues.put(MediaStore.Images.Media.DISPLAY_NAME, AndroidUtilities.generateFileName(0, extension));
|
||||||
if (!destFile.exists()) {
|
contentValues.put(MediaStore.Images.Media.MIME_TYPE, mimeType);
|
||||||
|
} else if (type == 1) {
|
||||||
|
File dirDest = new File(Environment.DIRECTORY_MOVIES, "Telegram");
|
||||||
|
contentValues.put(MediaStore.MediaColumns.RELATIVE_PATH, dirDest + File.separator);
|
||||||
|
uriToInsert = MediaStore.Video.Media.getContentUri(MediaStore.VOLUME_EXTERNAL_PRIMARY);
|
||||||
|
contentValues.put(MediaStore.Video.Media.DISPLAY_NAME, AndroidUtilities.generateFileName(1, extension));
|
||||||
|
} else if (type == 2) {
|
||||||
|
File dirDest = new File(Environment.DIRECTORY_DOWNLOADS, "Telegram");
|
||||||
|
contentValues.put(MediaStore.MediaColumns.RELATIVE_PATH, dirDest + File.separator);
|
||||||
|
uriToInsert = MediaStore.Downloads.getContentUri(MediaStore.VOLUME_EXTERNAL_PRIMARY);
|
||||||
|
contentValues.put(MediaStore.Downloads.DISPLAY_NAME, sourceFile.getName());
|
||||||
|
} else {
|
||||||
|
File dirDest = new File(Environment.DIRECTORY_MUSIC, "Telegram");
|
||||||
|
contentValues.put(MediaStore.MediaColumns.RELATIVE_PATH, dirDest + File.separator);
|
||||||
|
uriToInsert = MediaStore.Audio.Media.getContentUri(MediaStore.VOLUME_EXTERNAL_PRIMARY);
|
||||||
|
contentValues.put(MediaStore.Audio.Media.DISPLAY_NAME, sourceFile.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
contentValues.put(MediaStore.MediaColumns.MIME_TYPE, mimeType);
|
||||||
|
|
||||||
|
Uri dstUri = context.getContentResolver().insert(uriToInsert, contentValues);
|
||||||
|
if (dstUri != null) {
|
||||||
|
FileInputStream fileInputStream = new FileInputStream(sourceFile);
|
||||||
|
OutputStream outputStream = context.getContentResolver().openOutputStream(dstUri);
|
||||||
|
AndroidUtilities.copyFile(fileInputStream, outputStream);
|
||||||
|
fileInputStream.close();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
FileLog.e(e);
|
||||||
|
result = false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
File destFile;
|
||||||
|
if (type == 0) {
|
||||||
|
destFile = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "Telegram");
|
||||||
|
destFile.mkdirs();
|
||||||
|
destFile = new File(destFile, AndroidUtilities.generateFileName(0, FileLoader.getFileExtension(sourceFile)));
|
||||||
|
} else if (type == 1) {
|
||||||
|
destFile = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES), "Telegram");
|
||||||
|
destFile.mkdirs();
|
||||||
|
destFile = new File(destFile, AndroidUtilities.generateFileName(1, FileLoader.getFileExtension(sourceFile)));
|
||||||
|
} else {
|
||||||
|
File dir;
|
||||||
|
if (type == 2) {
|
||||||
|
dir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
|
||||||
|
} else {
|
||||||
|
dir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MUSIC);
|
||||||
|
}
|
||||||
|
dir = new File(dir, "Telegram");
|
||||||
|
dir.mkdirs();
|
||||||
|
destFile = new File(dir, name);
|
||||||
|
if (destFile.exists()) {
|
||||||
|
int idx = name.lastIndexOf('.');
|
||||||
|
for (int a = 0; a < 10; a++) {
|
||||||
|
String newName;
|
||||||
|
if (idx != -1) {
|
||||||
|
newName = name.substring(0, idx) + "(" + (a + 1) + ")" + name.substring(idx);
|
||||||
|
} else {
|
||||||
|
newName = name + "(" + (a + 1) + ")";
|
||||||
|
}
|
||||||
|
destFile = new File(dir, newName);
|
||||||
|
if (!destFile.exists()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!destFile.exists()) {
|
||||||
|
destFile.createNewFile();
|
||||||
|
}
|
||||||
|
long lastProgress = System.currentTimeMillis() - 500;
|
||||||
|
try (FileInputStream inputStream = new FileInputStream(sourceFile); FileChannel source = inputStream.getChannel(); FileChannel destination = new FileOutputStream(destFile).getChannel()) {
|
||||||
|
long size = source.size();
|
||||||
|
try {
|
||||||
|
@SuppressLint("DiscouragedPrivateApi") Method getInt = FileDescriptor.class.getDeclaredMethod("getInt$");
|
||||||
|
int fdint = (Integer) getInt.invoke(inputStream.getFD());
|
||||||
|
if (AndroidUtilities.isInternalUri(fdint)) {
|
||||||
|
if (finalProgress != null) {
|
||||||
|
AndroidUtilities.runOnUIThread(() -> {
|
||||||
|
try {
|
||||||
|
finalProgress.dismiss();
|
||||||
|
} catch (Exception e) {
|
||||||
|
FileLog.e(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} catch (Throwable e) {
|
||||||
|
FileLog.e(e);
|
||||||
|
}
|
||||||
|
for (long a = 0; a < size; a += 4096) {
|
||||||
|
if (cancelled[0]) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
destination.transferFrom(source, a, Math.min(4096, size - a));
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!destFile.exists()) {
|
|
||||||
destFile.createNewFile();
|
|
||||||
}
|
|
||||||
boolean result = true;
|
|
||||||
long lastProgress = System.currentTimeMillis() - 500;
|
|
||||||
try (FileInputStream inputStream = new FileInputStream(sourceFile); FileChannel source = inputStream.getChannel(); FileChannel destination = new FileOutputStream(destFile).getChannel()) {
|
|
||||||
long size = source.size();
|
|
||||||
try {
|
|
||||||
@SuppressLint("DiscouragedPrivateApi") Method getInt = FileDescriptor.class.getDeclaredMethod("getInt$");
|
|
||||||
int fdint = (Integer) getInt.invoke(inputStream.getFD());
|
|
||||||
if (AndroidUtilities.isInternalUri(fdint)) {
|
|
||||||
if (finalProgress != null) {
|
if (finalProgress != null) {
|
||||||
AndroidUtilities.runOnUIThread(() -> {
|
if (lastProgress <= System.currentTimeMillis() - 500) {
|
||||||
try {
|
lastProgress = System.currentTimeMillis();
|
||||||
finalProgress.dismiss();
|
final int progress = (int) ((float) a / (float) size * 100);
|
||||||
} catch (Exception e) {
|
AndroidUtilities.runOnUIThread(() -> {
|
||||||
FileLog.e(e);
|
try {
|
||||||
}
|
finalProgress.setProgress(progress);
|
||||||
});
|
} catch (Exception e) {
|
||||||
|
FileLog.e(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Exception e) {
|
||||||
FileLog.e(e);
|
FileLog.e(e);
|
||||||
|
result = false;
|
||||||
}
|
}
|
||||||
for (long a = 0; a < size; a += 4096) {
|
if (cancelled[0]) {
|
||||||
if (cancelled[0]) {
|
destFile.delete();
|
||||||
break;
|
result = false;
|
||||||
}
|
}
|
||||||
destination.transferFrom(source, a, Math.min(4096, size - a));
|
if (result) {
|
||||||
if (finalProgress != null) {
|
if (type == 2) {
|
||||||
if (lastProgress <= System.currentTimeMillis() - 500) {
|
DownloadManager downloadManager = (DownloadManager) ApplicationLoader.applicationContext.getSystemService(Context.DOWNLOAD_SERVICE);
|
||||||
lastProgress = System.currentTimeMillis();
|
downloadManager.addCompletedDownload(destFile.getName(), destFile.getName(), false, mime, destFile.getAbsolutePath(), destFile.length(), true);
|
||||||
final int progress = (int) ((float) a / (float) size * 100);
|
} else {
|
||||||
AndroidUtilities.runOnUIThread(() -> {
|
AndroidUtilities.addMediaToGallery(destFile.getAbsoluteFile());
|
||||||
try {
|
|
||||||
finalProgress.setProgress(progress);
|
|
||||||
} catch (Exception e) {
|
|
||||||
FileLog.e(e);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
|
||||||
FileLog.e(e);
|
|
||||||
result = false;
|
|
||||||
}
|
}
|
||||||
if (cancelled[0]) {
|
if (result && onSaved != null) {
|
||||||
destFile.delete();
|
AndroidUtilities.runOnUIThread(onSaved);
|
||||||
result = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result) {
|
|
||||||
if (type == 2) {
|
|
||||||
DownloadManager downloadManager = (DownloadManager) ApplicationLoader.applicationContext.getSystemService(Context.DOWNLOAD_SERVICE);
|
|
||||||
downloadManager.addCompletedDownload(destFile.getName(), destFile.getName(), false, mime, destFile.getAbsolutePath(), destFile.length(), true);
|
|
||||||
} else {
|
|
||||||
AndroidUtilities.addMediaToGallery(Uri.fromFile(destFile));
|
|
||||||
}
|
|
||||||
if (onSaved != null) {
|
|
||||||
AndroidUtilities.runOnUIThread(onSaved);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
FileLog.e(e);
|
FileLog.e(e);
|
||||||
|
@ -4833,6 +4896,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
|
||||||
|
|
||||||
public interface VideoConvertorListener {
|
public interface VideoConvertorListener {
|
||||||
boolean checkConversionCanceled();
|
boolean checkConversionCanceled();
|
||||||
|
|
||||||
void didWriteData(long availableSize, float progress);
|
void didWriteData(long availableSize, float progress);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5967,6 +5967,7 @@ public class MessageObject {
|
||||||
attachPathExists = f.exists();
|
attachPathExists = f.exists();
|
||||||
}
|
}
|
||||||
if (!attachPathExists) {
|
if (!attachPathExists) {
|
||||||
|
|
||||||
File file = FileLoader.getPathToMessage(messageOwner);
|
File file = FileLoader.getPathToMessage(messageOwner);
|
||||||
if (type == 3 && needDrawBluredPreview()) {
|
if (type == 3 && needDrawBluredPreview()) {
|
||||||
mediaExists = new File(file.getAbsolutePath() + ".enc").exists();
|
mediaExists = new File(file.getAbsolutePath() + ".enc").exists();
|
||||||
|
|
|
@ -14606,6 +14606,13 @@ public class MessagesController extends BaseController implements NotificationCe
|
||||||
.apply();
|
.apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void markSponsoredAsRead(long dialog_id, MessageObject object) {
|
||||||
|
ArrayList<MessageObject> messages = getSponsoredMessages(dialog_id);
|
||||||
|
if (messages != null) {
|
||||||
|
messages.remove(object);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public interface MessagesLoadedCallback {
|
public interface MessagesLoadedCallback {
|
||||||
void onMessagesLoaded(boolean fromCache);
|
void onMessagesLoaded(boolean fromCache);
|
||||||
void onError();
|
void onError();
|
||||||
|
|
|
@ -5834,7 +5834,11 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
||||||
|
|
||||||
if (messageObject.isSponsored()) {
|
if (messageObject.isSponsored()) {
|
||||||
drawInstantView = true;
|
drawInstantView = true;
|
||||||
drawInstantViewType = 1;
|
if (messageObject.sponsoredChannelPost != 0) {
|
||||||
|
drawInstantViewType = 12;
|
||||||
|
} else {
|
||||||
|
drawInstantViewType = 1;
|
||||||
|
}
|
||||||
long id = MessageObject.getPeerId(messageObject.messageOwner.from_id);
|
long id = MessageObject.getPeerId(messageObject.messageOwner.from_id);
|
||||||
if (id > 0) {
|
if (id > 0) {
|
||||||
TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(id);
|
TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(id);
|
||||||
|
@ -6848,7 +6852,9 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
||||||
if (drawInstantView && instantViewLayout == null) {
|
if (drawInstantView && instantViewLayout == null) {
|
||||||
String str;
|
String str;
|
||||||
instantWidth = AndroidUtilities.dp(12 + 9 + 12);
|
instantWidth = AndroidUtilities.dp(12 + 9 + 12);
|
||||||
if (drawInstantViewType == 1) {
|
if (drawInstantViewType == 12) {
|
||||||
|
str = LocaleController.getString("OpenChannelPost", R.string.OpenChannelPost);
|
||||||
|
} else if (drawInstantViewType == 1) {
|
||||||
str = LocaleController.getString("OpenChannel", R.string.OpenChannel);
|
str = LocaleController.getString("OpenChannel", R.string.OpenChannel);
|
||||||
} else if (drawInstantViewType == 10) {
|
} else if (drawInstantViewType == 10) {
|
||||||
str = LocaleController.getString("OpenBot", R.string.OpenBot);
|
str = LocaleController.getString("OpenBot", R.string.OpenBot);
|
||||||
|
@ -6889,7 +6895,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
||||||
if (currentMessageObject.type == 12) {
|
if (currentMessageObject.type == 12) {
|
||||||
totalHeight += AndroidUtilities.dp(14);
|
totalHeight += AndroidUtilities.dp(14);
|
||||||
}
|
}
|
||||||
if (hasNewLineForTime) {
|
if (currentMessageObject.isSponsored() && hasNewLineForTime) {
|
||||||
totalHeight += AndroidUtilities.dp(16);
|
totalHeight += AndroidUtilities.dp(16);
|
||||||
}
|
}
|
||||||
if (instantViewLayout != null && instantViewLayout.getLineCount() > 0) {
|
if (instantViewLayout != null && instantViewLayout.getLineCount() > 0) {
|
||||||
|
|
|
@ -5754,7 +5754,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||||
} else if (returnToMessageId > 0) {
|
} else if (returnToMessageId > 0) {
|
||||||
scrollToMessageId(returnToMessageId, 0, true, returnToLoadIndex, true, 0);
|
scrollToMessageId(returnToMessageId, 0, true, returnToLoadIndex, true, 0);
|
||||||
} else {
|
} else {
|
||||||
scrollToLastMessage();
|
scrollToLastMessage(false);
|
||||||
if (!pinnedMessageIds.isEmpty()) {
|
if (!pinnedMessageIds.isEmpty()) {
|
||||||
forceScrollToFirst = true;
|
forceScrollToFirst = true;
|
||||||
forceNextPinnedMessageId = pinnedMessageIds.get(0);
|
forceNextPinnedMessageId = pinnedMessageIds.get(0);
|
||||||
|
@ -9332,7 +9332,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||||
} else {
|
} else {
|
||||||
SendMessagesHelper.getInstance(currentAccount).sendMessage(getUserConfig().getCurrentUser(), dialog_id, messageObject, getThreadMessage(), null, null, true, 0);
|
SendMessagesHelper.getInstance(currentAccount).sendMessage(getUserConfig().getCurrentUser(), dialog_id, messageObject, getThreadMessage(), null, null, true, 0);
|
||||||
if (chatMode == 0) {
|
if (chatMode == 0) {
|
||||||
moveScrollToLastMessage();
|
moveScrollToLastMessage(false);
|
||||||
}
|
}
|
||||||
hideFieldPanel(false);
|
hideFieldPanel(false);
|
||||||
}
|
}
|
||||||
|
@ -10892,9 +10892,18 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void moveScrollToLastMessage() {
|
private void moveScrollToLastMessage(boolean skipSponsored) {
|
||||||
if (chatListView != null && !messages.isEmpty() && !pinchToZoomHelper.isInOverlayMode()) {
|
if (chatListView != null && !messages.isEmpty() && !pinchToZoomHelper.isInOverlayMode()) {
|
||||||
chatLayoutManager.scrollToPositionWithOffset(0, 0);
|
int position = 0;
|
||||||
|
if (skipSponsored) {
|
||||||
|
while (position < messages.size()) {
|
||||||
|
if (!messages.get(position).isSponsored()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
position++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
chatLayoutManager.scrollToPositionWithOffset(position, 0);
|
||||||
chatListView.stopScroll();
|
chatListView.stopScroll();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10967,7 +10976,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void scrollToLastMessage() {
|
private void scrollToLastMessage(boolean skipSponsored) {
|
||||||
if (chatListView.isFastScrollAnimationRunning()) {
|
if (chatListView.isFastScrollAnimationRunning()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -10984,7 +10993,16 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||||
} else {
|
} else {
|
||||||
chatAdapter.updateRowsSafe();
|
chatAdapter.updateRowsSafe();
|
||||||
chatScrollHelperCallback.scrollTo = null;
|
chatScrollHelperCallback.scrollTo = null;
|
||||||
chatScrollHelper.scrollToPosition(0, 0, true, true);
|
int position = 0;
|
||||||
|
if (skipSponsored) {
|
||||||
|
while (position < messages.size()) {
|
||||||
|
if (!messages.get(position).isSponsored()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
position++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
chatScrollHelper.scrollToPosition(position, 0, true, true);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (progressDialog != null) {
|
if (progressDialog != null) {
|
||||||
|
@ -13802,7 +13820,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||||
scrollToMessagePosition = -10000;
|
scrollToMessagePosition = -10000;
|
||||||
scrollToMessage = null;
|
scrollToMessage = null;
|
||||||
} else {
|
} else {
|
||||||
moveScrollToLastMessage();
|
addSponsoredMessages(!isFirstLoading);
|
||||||
|
moveScrollToLastMessage(true);
|
||||||
}
|
}
|
||||||
if (loaded_mentions_count != 0) {
|
if (loaded_mentions_count != 0) {
|
||||||
showMentionDownButton(true, true);
|
showMentionDownButton(true, true);
|
||||||
|
@ -14473,7 +14492,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||||
}
|
}
|
||||||
if (chatLayoutManager != null) {
|
if (chatLayoutManager != null) {
|
||||||
if (mediaUpdated && chatLayoutManager.findFirstVisibleItemPosition() == 0) {
|
if (mediaUpdated && chatLayoutManager.findFirstVisibleItemPosition() == 0) {
|
||||||
moveScrollToLastMessage();
|
moveScrollToLastMessage(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
getNotificationsController().playOutChatSound();
|
getNotificationsController().playOutChatSound();
|
||||||
|
@ -16248,7 +16267,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||||
needAnimateToMessage = obj;
|
needAnimateToMessage = obj;
|
||||||
}
|
}
|
||||||
if (obj.isOut() && obj.wasJustSent) {
|
if (obj.isOut() && obj.wasJustSent) {
|
||||||
scrollToLastMessage();
|
scrollToLastMessage(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (obj.type < 0 || messagesDict[0].indexOfKey(messageId) >= 0) {
|
if (obj.type < 0 || messagesDict[0].indexOfKey(messageId) >= 0) {
|
||||||
|
@ -16481,7 +16500,12 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||||
}
|
}
|
||||||
maxDate[0] = Math.max(maxDate[0], obj.messageOwner.date);
|
maxDate[0] = Math.max(maxDate[0], obj.messageOwner.date);
|
||||||
messagesDict[0].put(messageId, obj);
|
messagesDict[0].put(messageId, obj);
|
||||||
ArrayList<MessageObject> dayArray = messagesByDays.get(obj.dateKey);
|
ArrayList<MessageObject> dayArray;
|
||||||
|
if (isAd && !messages.isEmpty()) {
|
||||||
|
dayArray = messagesByDays.get(messages.get(0).dateKey);
|
||||||
|
} else {
|
||||||
|
dayArray = messagesByDays.get(obj.dateKey);
|
||||||
|
}
|
||||||
if (placeToPaste > messages.size()) {
|
if (placeToPaste > messages.size()) {
|
||||||
placeToPaste = messages.size();
|
placeToPaste = messages.size();
|
||||||
}
|
}
|
||||||
|
@ -16632,7 +16656,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||||
scrollToTopOnResume = true;
|
scrollToTopOnResume = true;
|
||||||
} else {
|
} else {
|
||||||
forceScrollToTop = true;
|
forceScrollToTop = true;
|
||||||
moveScrollToLastMessage();
|
moveScrollToLastMessage(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -16663,7 +16687,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||||
chatListItemAnimator.setShouldAnimateEnterFromBottom(needMoveScrollToLastMessage);
|
chatListItemAnimator.setShouldAnimateEnterFromBottom(needMoveScrollToLastMessage);
|
||||||
}
|
}
|
||||||
if (needMoveScrollToLastMessage) {
|
if (needMoveScrollToLastMessage) {
|
||||||
moveScrollToLastMessage();
|
moveScrollToLastMessage(false);
|
||||||
} else {
|
} else {
|
||||||
int index = messages.indexOf(messageObject);
|
int index = messages.indexOf(messageObject);
|
||||||
if (chatLayoutManager != null && index > 0 && (chatLayoutManager.findViewByPosition(chatAdapter.messagesStartRow + index) != null || chatLayoutManager.findViewByPosition(chatAdapter.messagesStartRow + index - 1) != null)) {
|
if (chatLayoutManager != null && index > 0 && (chatLayoutManager.findViewByPosition(chatAdapter.messagesStartRow + index) != null || chatLayoutManager.findViewByPosition(chatAdapter.messagesStartRow + index - 1) != null)) {
|
||||||
|
@ -18828,7 +18852,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||||
chatLayoutManager.scrollToPositionWithOffset(chatAdapter.messagesStartRow + messages.indexOf(scrollToMessage), yOffset, bottom);
|
chatLayoutManager.scrollToPositionWithOffset(chatAdapter.messagesStartRow + messages.indexOf(scrollToMessage), yOffset, bottom);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
moveScrollToLastMessage();
|
moveScrollToLastMessage(false);
|
||||||
}
|
}
|
||||||
scrollToTopUnReadOnResume = false;
|
scrollToTopUnReadOnResume = false;
|
||||||
scrollToTopOnResume = false;
|
scrollToTopOnResume = false;
|
||||||
|
@ -18945,8 +18969,15 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||||
int messageId = 0;
|
int messageId = 0;
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
if (chatLayoutManager != null) {
|
if (chatLayoutManager != null) {
|
||||||
|
boolean sponsoredMessageFound = false;
|
||||||
|
for (int i = 0; i < chatListView.getChildCount(); i++) {
|
||||||
|
if (chatListView.getChildAt(i) instanceof ChatMessageCell && ((ChatMessageCell) chatListView.getChildAt(i)).getMessageObject().isSponsored()) {
|
||||||
|
sponsoredMessageFound = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
int position = chatLayoutManager.findFirstVisibleItemPosition();
|
int position = chatLayoutManager.findFirstVisibleItemPosition();
|
||||||
if (position != 0) {
|
if (position != 0 && !sponsoredMessageFound) {
|
||||||
RecyclerListView.Holder holder = (RecyclerListView.Holder) chatListView.findViewHolderForAdapterPosition(position);
|
RecyclerListView.Holder holder = (RecyclerListView.Holder) chatListView.findViewHolderForAdapterPosition(position);
|
||||||
if (holder != null) {
|
if (holder != null) {
|
||||||
int mid = 0;
|
int mid = 0;
|
||||||
|
@ -20582,13 +20613,13 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (success && chatMode == 0) {
|
if (success && chatMode == 0) {
|
||||||
moveScrollToLastMessage();
|
moveScrollToLastMessage(false);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (getSendMessagesHelper().retrySendMessage(selectedObject, false)) {
|
if (getSendMessagesHelper().retrySendMessage(selectedObject, false)) {
|
||||||
updateVisibleRows();
|
updateVisibleRows();
|
||||||
if (chatMode == 0) {
|
if (chatMode == 0) {
|
||||||
moveScrollToLastMessage();
|
moveScrollToLastMessage(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21255,7 +21286,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fragment.finishFragment();
|
fragment.finishFragment();
|
||||||
moveScrollToLastMessage();
|
moveScrollToLastMessage(false);
|
||||||
showFieldPanelForForward(true, fmessages);
|
showFieldPanelForForward(true, fmessages);
|
||||||
if (AndroidUtilities.isTablet()) {
|
if (AndroidUtilities.isTablet()) {
|
||||||
hideActionMode();
|
hideActionMode();
|
||||||
|
@ -21545,7 +21576,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||||
public void didSelectLocation(TLRPC.MessageMedia location, int locationType, boolean notify, int scheduleDate) {
|
public void didSelectLocation(TLRPC.MessageMedia location, int locationType, boolean notify, int scheduleDate) {
|
||||||
getSendMessagesHelper().sendMessage(location, dialog_id, replyingMessageObject, getThreadMessage(), null, null, notify, scheduleDate);
|
getSendMessagesHelper().sendMessage(location, dialog_id, replyingMessageObject, getThreadMessage(), null, null, notify, scheduleDate);
|
||||||
if (chatMode == 0) {
|
if (chatMode == 0) {
|
||||||
moveScrollToLastMessage();
|
moveScrollToLastMessage(false);
|
||||||
}
|
}
|
||||||
if (locationType == LocationActivity.LOCATION_TYPE_SEND || locationType == LocationActivity.LOCATION_TYPE_SEND_WITH_LIVE) {
|
if (locationType == LocationActivity.LOCATION_TYPE_SEND || locationType == LocationActivity.LOCATION_TYPE_SEND_WITH_LIVE) {
|
||||||
afterMessageSend();
|
afterMessageSend();
|
||||||
|
@ -22433,6 +22464,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||||
getConnectionsManager().sendRequest(req, (response, error) -> {
|
getConnectionsManager().sendRequest(req, (response, error) -> {
|
||||||
|
|
||||||
});
|
});
|
||||||
|
getMessagesController().markSponsoredAsRead(dialog_id, object);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -326,6 +326,10 @@ public class ChatAttachAlertDocumentLayout extends ChatAttachAlert.AttachAlertLa
|
||||||
if (object instanceof ListItem) {
|
if (object instanceof ListItem) {
|
||||||
ListItem item = (ListItem) object;
|
ListItem item = (ListItem) object;
|
||||||
File file = item.file;
|
File file = item.file;
|
||||||
|
boolean isExternalStorageManager = false;
|
||||||
|
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.R) {
|
||||||
|
isExternalStorageManager = Environment.isExternalStorageManager();
|
||||||
|
}
|
||||||
if (file == null) {
|
if (file == null) {
|
||||||
if (item.icon == R.drawable.files_gallery) {
|
if (item.icon == R.drawable.files_gallery) {
|
||||||
HashMap<Object, Object> selectedPhotos = new HashMap<>();
|
HashMap<Object, Object> selectedPhotos = new HashMap<>();
|
||||||
|
@ -369,7 +373,7 @@ public class ChatAttachAlertDocumentLayout extends ChatAttachAlert.AttachAlertLa
|
||||||
if (delegate != null) {
|
if (delegate != null) {
|
||||||
delegate.startMusicSelectActivity();
|
delegate.startMusicSelectActivity();
|
||||||
}
|
}
|
||||||
} else if (!BuildVars.NO_SCOPED_STORAGE && item.icon == R.drawable.files_storage) {
|
} else if (!BuildVars.NO_SCOPED_STORAGE && item.icon == R.drawable.files_storage && !isExternalStorageManager) {
|
||||||
delegate.startDocumentSelectActivity();
|
delegate.startDocumentSelectActivity();
|
||||||
} else {
|
} else {
|
||||||
int top = getTopForScroll();
|
int top = getTopForScroll();
|
||||||
|
@ -942,7 +946,11 @@ public class ChatAttachAlertDocumentLayout extends ChatAttachAlert.AttachAlertLa
|
||||||
items.clear();
|
items.clear();
|
||||||
|
|
||||||
HashSet<String> paths = new HashSet<>();
|
HashSet<String> paths = new HashSet<>();
|
||||||
if (!BuildVars.NO_SCOPED_STORAGE) {
|
boolean isExternalStorageManager = false;
|
||||||
|
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.R) {
|
||||||
|
isExternalStorageManager = Environment.isExternalStorageManager();
|
||||||
|
}
|
||||||
|
if (!BuildVars.NO_SCOPED_STORAGE && !isExternalStorageManager) {
|
||||||
ListItem ext = new ListItem();
|
ListItem ext = new ListItem();
|
||||||
ext.title = LocaleController.getString("InternalStorage", R.string.InternalStorage);
|
ext.title = LocaleController.getString("InternalStorage", R.string.InternalStorage);
|
||||||
ext.icon = R.drawable.files_storage;
|
ext.icon = R.drawable.files_storage;
|
||||||
|
@ -1027,7 +1035,7 @@ public class ChatAttachAlertDocumentLayout extends ChatAttachAlert.AttachAlertLa
|
||||||
|
|
||||||
ListItem fs;
|
ListItem fs;
|
||||||
try {
|
try {
|
||||||
File telegramPath = new File(Environment.getExternalStorageDirectory(), "Telegram");
|
File telegramPath = new File(ApplicationLoader.applicationContext.getExternalFilesDir(null), "Telegram");
|
||||||
if (telegramPath.exists()) {
|
if (telegramPath.exists()) {
|
||||||
fs = new ListItem();
|
fs = new ListItem();
|
||||||
fs.title = "Telegram";
|
fs.title = "Telegram";
|
||||||
|
|
|
@ -9865,7 +9865,9 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||||
MessageObject openingObject = imagesArr.get(index);
|
MessageObject openingObject = imagesArr.get(index);
|
||||||
if (!openingObject.scheduled && (parentChatActivity == null || !parentChatActivity.isThreadChat())) {
|
if (!openingObject.scheduled && (parentChatActivity == null || !parentChatActivity.isThreadChat())) {
|
||||||
opennedFromMedia = true;
|
opennedFromMedia = true;
|
||||||
startOffset = object.starOffset;
|
if (object != null) {
|
||||||
|
startOffset = object.starOffset;
|
||||||
|
}
|
||||||
menuItem.showSubItem(gallery_menu_showinchat);
|
menuItem.showSubItem(gallery_menu_showinchat);
|
||||||
if (openingObject.canForwardMessage()) {
|
if (openingObject.canForwardMessage()) {
|
||||||
setItemVisible(sendItem, true, false);
|
setItemVisible(sendItem, true, false);
|
||||||
|
|
Loading…
Reference in a new issue