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.ColorDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.media.MediaScannerConnection;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Environment;
|
||||
|
@ -95,6 +96,7 @@ import android.widget.ScrollView;
|
|||
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;
|
||||
|
@ -2267,11 +2269,11 @@ public class AndroidUtilities {
|
|||
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;
|
||||
}
|
||||
|
@ -2285,8 +2287,8 @@ public class AndroidUtilities {
|
|||
}
|
||||
|
||||
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())) {
|
||||
|
@ -2399,17 +2401,25 @@ public class AndroidUtilities {
|
|||
|
||||
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 "";
|
||||
|
@ -2701,7 +2711,10 @@ public class AndroidUtilities {
|
|||
}
|
||||
|
||||
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) {
|
||||
|
|
|
@ -15,15 +15,16 @@ import android.os.Build;
|
|||
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";
|
||||
|
||||
|
|
|
@ -1931,7 +1931,7 @@ public class ImageLoader {
|
|||
|
||||
@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())) {
|
||||
|
@ -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"); //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 = 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");
|
||||
}
|
||||
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++) {
|
||||
|
|
|
@ -16,6 +16,7 @@ import android.annotation.SuppressLint;
|
|||
import android.app.Activity;
|
||||
import android.app.DownloadManager;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
|
@ -81,8 +82,10 @@ import org.telegram.ui.PhotoViewer;
|
|||
import java.io.File;
|
||||
import java.io.FileDescriptor;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.ByteBuffer;
|
||||
|
@ -99,10 +102,15 @@ import java.util.concurrent.CountDownLatch;
|
|||
public class MediaController implements AudioManager.OnAudioFocusChangeListener, NotificationCenter.NotificationCenterDelegate, SensorEventListener {
|
||||
|
||||
private native int startRecord(String path, int sampleRate);
|
||||
|
||||
private native int writeFrame(ByteBuffer frame, int len);
|
||||
|
||||
private native void stopRecord();
|
||||
|
||||
public static native int isOpusFile(String path);
|
||||
|
||||
public native byte[] getWaveform(String path);
|
||||
|
||||
public native byte[] getWaveform2(short[] array, int length);
|
||||
|
||||
public boolean isBuffering() {
|
||||
|
@ -745,7 +753,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
|
|||
Cursor cursor = null;
|
||||
try {
|
||||
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.moveToNext()) {
|
||||
count += cursor.getInt(0);
|
||||
|
@ -761,7 +769,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
|
|||
}
|
||||
try {
|
||||
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.moveToNext()) {
|
||||
count += cursor.getInt(0);
|
||||
|
@ -1971,6 +1979,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
|
|||
}
|
||||
return audioPlayer.getDuration();
|
||||
}
|
||||
|
||||
public MessageObject getPlayingMessageObject() {
|
||||
return playingMessageObject;
|
||||
}
|
||||
|
@ -2496,7 +2505,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
|
|||
final MessageObject currentMessage = playingMessageObject;
|
||||
AndroidUtilities.runOnUIThread(() -> {
|
||||
if (audioPlayer != null && playingMessageObject != null && !isPaused) {
|
||||
if (isSamePlayingMessage(currentMessage )) {
|
||||
if (isSamePlayingMessage(currentMessage)) {
|
||||
seekToProgress(playingMessageObject, p);
|
||||
}
|
||||
audioPlayer.play();
|
||||
|
@ -3793,7 +3802,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
|
|||
}
|
||||
if (!cancelled) {
|
||||
if (isMusic) {
|
||||
AndroidUtilities.addMediaToGallery(Uri.fromFile(destFile));
|
||||
AndroidUtilities.addMediaToGallery(destFile);
|
||||
} else {
|
||||
DownloadManager downloadManager = (DownloadManager) ApplicationLoader.applicationContext.getSystemService(Context.DOWNLOAD_SERVICE);
|
||||
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) {
|
||||
if (fullPath == null) {
|
||||
if (fullPath == null || context == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -3887,8 +3896,9 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
|
|||
}
|
||||
|
||||
final File sourceFile = file;
|
||||
final boolean[] cancelled = new boolean[] {false};
|
||||
final boolean[] cancelled = new boolean[]{false};
|
||||
if (sourceFile.exists()) {
|
||||
|
||||
AlertDialog progressDialog = null;
|
||||
final boolean[] finished = new boolean[1];
|
||||
if (context != null && type != 0) {
|
||||
|
@ -3913,11 +3923,64 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
|
|||
|
||||
new Thread(() -> {
|
||||
try {
|
||||
boolean result = true;
|
||||
if (Build.VERSION.SDK_INT >= 29) {
|
||||
try {
|
||||
ContentValues contentValues = new ContentValues();
|
||||
String extension = MimeTypeMap.getFileExtensionFromUrl(sourceFile.getAbsolutePath());
|
||||
String mimeType = null;
|
||||
if (extension != null) {
|
||||
mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension);
|
||||
}
|
||||
Uri uriToInsert = null;
|
||||
if (type == 0) {
|
||||
uriToInsert = MediaStore.Images.Media.getContentUri(MediaStore.VOLUME_EXTERNAL_PRIMARY);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
File dirDest = new File(Environment.DIRECTORY_PICTURES, "Telegram");
|
||||
contentValues.put(MediaStore.MediaColumns.RELATIVE_PATH, dirDest + File.separator);
|
||||
}
|
||||
contentValues.put(MediaStore.Images.Media.DISPLAY_NAME, AndroidUtilities.generateFileName(0, extension));
|
||||
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 = AndroidUtilities.generatePicturePath(false, FileLoader.getFileExtension(sourceFile));
|
||||
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 = AndroidUtilities.generateVideoPath();
|
||||
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) {
|
||||
|
@ -3925,7 +3988,8 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
|
|||
} else {
|
||||
dir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MUSIC);
|
||||
}
|
||||
dir.mkdir();
|
||||
dir = new File(dir, "Telegram");
|
||||
dir.mkdirs();
|
||||
destFile = new File(dir, name);
|
||||
if (destFile.exists()) {
|
||||
int idx = name.lastIndexOf('.');
|
||||
|
@ -3946,7 +4010,6 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
|
|||
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();
|
||||
|
@ -3995,18 +4058,18 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
|
|||
destFile.delete();
|
||||
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));
|
||||
AndroidUtilities.addMediaToGallery(destFile.getAbsoluteFile());
|
||||
}
|
||||
if (onSaved != null) {
|
||||
}
|
||||
}
|
||||
if (result && onSaved != null) {
|
||||
AndroidUtilities.runOnUIThread(onSaved);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FileLog.e(e);
|
||||
}
|
||||
|
@ -4833,6 +4896,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
|
|||
|
||||
public interface VideoConvertorListener {
|
||||
boolean checkConversionCanceled();
|
||||
|
||||
void didWriteData(long availableSize, float progress);
|
||||
}
|
||||
|
||||
|
|
|
@ -5967,6 +5967,7 @@ public class MessageObject {
|
|||
attachPathExists = f.exists();
|
||||
}
|
||||
if (!attachPathExists) {
|
||||
|
||||
File file = FileLoader.getPathToMessage(messageOwner);
|
||||
if (type == 3 && needDrawBluredPreview()) {
|
||||
mediaExists = new File(file.getAbsolutePath() + ".enc").exists();
|
||||
|
|
|
@ -14606,6 +14606,13 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
.apply();
|
||||
}
|
||||
|
||||
public void markSponsoredAsRead(long dialog_id, MessageObject object) {
|
||||
ArrayList<MessageObject> messages = getSponsoredMessages(dialog_id);
|
||||
if (messages != null) {
|
||||
messages.remove(object);
|
||||
}
|
||||
}
|
||||
|
||||
public interface MessagesLoadedCallback {
|
||||
void onMessagesLoaded(boolean fromCache);
|
||||
void onError();
|
||||
|
|
|
@ -5834,7 +5834,11 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
|||
|
||||
if (messageObject.isSponsored()) {
|
||||
drawInstantView = true;
|
||||
if (messageObject.sponsoredChannelPost != 0) {
|
||||
drawInstantViewType = 12;
|
||||
} else {
|
||||
drawInstantViewType = 1;
|
||||
}
|
||||
long id = MessageObject.getPeerId(messageObject.messageOwner.from_id);
|
||||
if (id > 0) {
|
||||
TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(id);
|
||||
|
@ -6848,7 +6852,9 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
|||
if (drawInstantView && instantViewLayout == null) {
|
||||
String str;
|
||||
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);
|
||||
} else if (drawInstantViewType == 10) {
|
||||
str = LocaleController.getString("OpenBot", R.string.OpenBot);
|
||||
|
@ -6889,7 +6895,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
|||
if (currentMessageObject.type == 12) {
|
||||
totalHeight += AndroidUtilities.dp(14);
|
||||
}
|
||||
if (hasNewLineForTime) {
|
||||
if (currentMessageObject.isSponsored() && hasNewLineForTime) {
|
||||
totalHeight += AndroidUtilities.dp(16);
|
||||
}
|
||||
if (instantViewLayout != null && instantViewLayout.getLineCount() > 0) {
|
||||
|
|
|
@ -5754,7 +5754,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
} else if (returnToMessageId > 0) {
|
||||
scrollToMessageId(returnToMessageId, 0, true, returnToLoadIndex, true, 0);
|
||||
} else {
|
||||
scrollToLastMessage();
|
||||
scrollToLastMessage(false);
|
||||
if (!pinnedMessageIds.isEmpty()) {
|
||||
forceScrollToFirst = true;
|
||||
forceNextPinnedMessageId = pinnedMessageIds.get(0);
|
||||
|
@ -9332,7 +9332,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
} else {
|
||||
SendMessagesHelper.getInstance(currentAccount).sendMessage(getUserConfig().getCurrentUser(), dialog_id, messageObject, getThreadMessage(), null, null, true, 0);
|
||||
if (chatMode == 0) {
|
||||
moveScrollToLastMessage();
|
||||
moveScrollToLastMessage(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()) {
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
@ -10967,7 +10976,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
}
|
||||
}
|
||||
|
||||
private void scrollToLastMessage() {
|
||||
private void scrollToLastMessage(boolean skipSponsored) {
|
||||
if (chatListView.isFastScrollAnimationRunning()) {
|
||||
return;
|
||||
}
|
||||
|
@ -10984,7 +10993,16 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
} else {
|
||||
chatAdapter.updateRowsSafe();
|
||||
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 {
|
||||
if (progressDialog != null) {
|
||||
|
@ -13802,7 +13820,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
scrollToMessagePosition = -10000;
|
||||
scrollToMessage = null;
|
||||
} else {
|
||||
moveScrollToLastMessage();
|
||||
addSponsoredMessages(!isFirstLoading);
|
||||
moveScrollToLastMessage(true);
|
||||
}
|
||||
if (loaded_mentions_count != 0) {
|
||||
showMentionDownButton(true, true);
|
||||
|
@ -14473,7 +14492,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
}
|
||||
if (chatLayoutManager != null) {
|
||||
if (mediaUpdated && chatLayoutManager.findFirstVisibleItemPosition() == 0) {
|
||||
moveScrollToLastMessage();
|
||||
moveScrollToLastMessage(false);
|
||||
}
|
||||
}
|
||||
getNotificationsController().playOutChatSound();
|
||||
|
@ -16248,7 +16267,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
needAnimateToMessage = obj;
|
||||
}
|
||||
if (obj.isOut() && obj.wasJustSent) {
|
||||
scrollToLastMessage();
|
||||
scrollToLastMessage(true);
|
||||
return;
|
||||
}
|
||||
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);
|
||||
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()) {
|
||||
placeToPaste = messages.size();
|
||||
}
|
||||
|
@ -16632,7 +16656,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
scrollToTopOnResume = true;
|
||||
} else {
|
||||
forceScrollToTop = true;
|
||||
moveScrollToLastMessage();
|
||||
moveScrollToLastMessage(false);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -16663,7 +16687,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
chatListItemAnimator.setShouldAnimateEnterFromBottom(needMoveScrollToLastMessage);
|
||||
}
|
||||
if (needMoveScrollToLastMessage) {
|
||||
moveScrollToLastMessage();
|
||||
moveScrollToLastMessage(false);
|
||||
} else {
|
||||
int index = messages.indexOf(messageObject);
|
||||
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);
|
||||
}
|
||||
} else {
|
||||
moveScrollToLastMessage();
|
||||
moveScrollToLastMessage(false);
|
||||
}
|
||||
scrollToTopUnReadOnResume = false;
|
||||
scrollToTopOnResume = false;
|
||||
|
@ -18945,8 +18969,15 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
int messageId = 0;
|
||||
int offset = 0;
|
||||
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();
|
||||
if (position != 0) {
|
||||
if (position != 0 && !sponsoredMessageFound) {
|
||||
RecyclerListView.Holder holder = (RecyclerListView.Holder) chatListView.findViewHolderForAdapterPosition(position);
|
||||
if (holder != null) {
|
||||
int mid = 0;
|
||||
|
@ -20582,13 +20613,13 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
}
|
||||
}
|
||||
if (success && chatMode == 0) {
|
||||
moveScrollToLastMessage();
|
||||
moveScrollToLastMessage(false);
|
||||
}
|
||||
} else {
|
||||
if (getSendMessagesHelper().retrySendMessage(selectedObject, false)) {
|
||||
updateVisibleRows();
|
||||
if (chatMode == 0) {
|
||||
moveScrollToLastMessage();
|
||||
moveScrollToLastMessage(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21255,7 +21286,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
}
|
||||
} else {
|
||||
fragment.finishFragment();
|
||||
moveScrollToLastMessage();
|
||||
moveScrollToLastMessage(false);
|
||||
showFieldPanelForForward(true, fmessages);
|
||||
if (AndroidUtilities.isTablet()) {
|
||||
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) {
|
||||
getSendMessagesHelper().sendMessage(location, dialog_id, replyingMessageObject, getThreadMessage(), null, null, notify, scheduleDate);
|
||||
if (chatMode == 0) {
|
||||
moveScrollToLastMessage();
|
||||
moveScrollToLastMessage(false);
|
||||
}
|
||||
if (locationType == LocationActivity.LOCATION_TYPE_SEND || locationType == LocationActivity.LOCATION_TYPE_SEND_WITH_LIVE) {
|
||||
afterMessageSend();
|
||||
|
@ -22433,6 +22464,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
getConnectionsManager().sendRequest(req, (response, error) -> {
|
||||
|
||||
});
|
||||
getMessagesController().markSponsoredAsRead(dialog_id, object);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -326,6 +326,10 @@ public class ChatAttachAlertDocumentLayout extends ChatAttachAlert.AttachAlertLa
|
|||
if (object instanceof ListItem) {
|
||||
ListItem item = (ListItem) object;
|
||||
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 (item.icon == R.drawable.files_gallery) {
|
||||
HashMap<Object, Object> selectedPhotos = new HashMap<>();
|
||||
|
@ -369,7 +373,7 @@ public class ChatAttachAlertDocumentLayout extends ChatAttachAlert.AttachAlertLa
|
|||
if (delegate != null) {
|
||||
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();
|
||||
} else {
|
||||
int top = getTopForScroll();
|
||||
|
@ -942,7 +946,11 @@ public class ChatAttachAlertDocumentLayout extends ChatAttachAlert.AttachAlertLa
|
|||
items.clear();
|
||||
|
||||
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();
|
||||
ext.title = LocaleController.getString("InternalStorage", R.string.InternalStorage);
|
||||
ext.icon = R.drawable.files_storage;
|
||||
|
@ -1027,7 +1035,7 @@ public class ChatAttachAlertDocumentLayout extends ChatAttachAlert.AttachAlertLa
|
|||
|
||||
ListItem fs;
|
||||
try {
|
||||
File telegramPath = new File(Environment.getExternalStorageDirectory(), "Telegram");
|
||||
File telegramPath = new File(ApplicationLoader.applicationContext.getExternalFilesDir(null), "Telegram");
|
||||
if (telegramPath.exists()) {
|
||||
fs = new ListItem();
|
||||
fs.title = "Telegram";
|
||||
|
|
|
@ -9865,7 +9865,9 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
|||
MessageObject openingObject = imagesArr.get(index);
|
||||
if (!openingObject.scheduled && (parentChatActivity == null || !parentChatActivity.isThreadChat())) {
|
||||
opennedFromMedia = true;
|
||||
if (object != null) {
|
||||
startOffset = object.starOffset;
|
||||
}
|
||||
menuItem.showSubItem(gallery_menu_showinchat);
|
||||
if (openingObject.canForwardMessage()) {
|
||||
setItemVisible(sendItem, true, false);
|
||||
|
|
Loading…
Reference in a new issue