update to 8.8.5

This commit is contained in:
xaxtix 2022-07-04 15:54:30 +04:00
parent 43401a515c
commit 6cb1cdf898
19 changed files with 332 additions and 182 deletions

View file

@ -235,7 +235,7 @@ android {
} }
} }
defaultConfig.versionCode = 2711 defaultConfig.versionCode = 2721
applicationVariants.all { variant -> applicationVariants.all { variant ->
variant.outputs.all { output -> variant.outputs.all { output ->
@ -254,7 +254,7 @@ android {
defaultConfig { defaultConfig {
minSdkVersion 16 minSdkVersion 16
targetSdkVersion 30 targetSdkVersion 30
versionName "8.8.4" versionName "8.8.5"
vectorDrawables.generatedDensities = ['mdpi', 'hdpi', 'xhdpi', 'xxhdpi'] vectorDrawables.generatedDensities = ['mdpi', 'hdpi', 'xhdpi', 'xxhdpi']

View file

@ -6,7 +6,7 @@ import java.util.concurrent.CountDownLatch;
public class AnimatedFileDrawableStream implements FileLoadOperationStream { public class AnimatedFileDrawableStream implements FileLoadOperationStream {
private FileLoadOperation loadOperation; private final FileLoadOperation loadOperation;
private CountDownLatch countDownLatch; private CountDownLatch countDownLatch;
private TLRPC.Document document; private TLRPC.Document document;
private ImageLocation location; private ImageLocation location;
@ -20,8 +20,6 @@ public class AnimatedFileDrawableStream implements FileLoadOperationStream {
private boolean finishedLoadingFile; private boolean finishedLoadingFile;
private String finishedFilePath; private String finishedFilePath;
private boolean ignored;
public AnimatedFileDrawableStream(TLRPC.Document d, ImageLocation l, Object p, int a, boolean prev) { public AnimatedFileDrawableStream(TLRPC.Document d, ImageLocation l, Object p, int a, boolean prev) {
document = d; document = d;
location = l; location = l;
@ -63,6 +61,7 @@ public class AnimatedFileDrawableStream implements FileLoadOperationStream {
} }
synchronized (sync) { synchronized (sync) {
if (canceled) { if (canceled) {
FileLoader.getInstance(currentAccount).cancelLoadFile(document);
return 0; return 0;
} }
countDownLatch = new CountDownLatch(1); countDownLatch = new CountDownLatch(1);

View file

@ -198,6 +198,7 @@ public class ApplicationLoader extends Application {
if (BuildVars.LOGS_ENABLED) { if (BuildVars.LOGS_ENABLED) {
FileLog.d("app start time = " + (startTime = SystemClock.elapsedRealtime())); FileLog.d("app start time = " + (startTime = SystemClock.elapsedRealtime()));
FileLog.d("buildVersion = " + BuildVars.BUILD_VERSION);
} }
if (applicationContext == null) { if (applicationContext == null) {
applicationContext = getApplicationContext(); applicationContext = getApplicationContext();

View file

@ -20,10 +20,10 @@ public class BuildVars {
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 = 2711; public static int BUILD_VERSION = 2722;
public static String BUILD_VERSION_STRING = "8.8.4"; public static String BUILD_VERSION_STRING = "8.8.5";
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";

View file

@ -70,9 +70,13 @@ public class FileLoadOperation {
private int cdnChunkCheckSize = 1024 * 128; private int cdnChunkCheckSize = 1024 * 128;
private int maxDownloadRequests = 4; private int maxDownloadRequests = 4;
private int maxDownloadRequestsBig = 4; private int maxDownloadRequestsBig = 4;
private int bigFileSizeFrom = 1024 * 1024; private int bigFileSizeFrom = 10 * 1024 * 1024;
private int maxCdnParts = (int) (FileLoader.DEFAULT_MAX_FILE_SIZE / downloadChunkSizeBig); private int maxCdnParts = (int) (FileLoader.DEFAULT_MAX_FILE_SIZE / downloadChunkSizeBig);
//load small parts for stream
private int downloadChunkSizeAnimation = 1024 * 128;
private int maxDownloadRequestsAnimation = 4;
private final static int preloadMaxBytes = 2 * 1024 * 1024; private final static int preloadMaxBytes = 2 * 1024 * 1024;
private String fileName; private String fileName;
@ -136,7 +140,7 @@ public class FileLoadOperation {
private HashMap<Long, TLRPC.TL_fileHash> cdnHashes; private HashMap<Long, TLRPC.TL_fileHash> cdnHashes;
private boolean forceBig; private boolean isStream;
private byte[] encryptKey; private byte[] encryptKey;
private byte[] encryptIv; private byte[] encryptIv;
@ -174,17 +178,19 @@ public class FileLoadOperation {
private int currentType; private int currentType;
public FilePathDatabase.PathData pathSaveData; public FilePathDatabase.PathData pathSaveData;
private long startTime;
public interface FileLoadOperationDelegate { public interface FileLoadOperationDelegate {
void didFinishLoadingFile(FileLoadOperation operation, File finalFile); void didFinishLoadingFile(FileLoadOperation operation, File finalFile);
void didFailedLoadingFile(FileLoadOperation operation, int state); void didFailedLoadingFile(FileLoadOperation operation, int state);
void didChangedLoadProgress(FileLoadOperation operation, long uploadedSize, long totalSize); void didChangedLoadProgress(FileLoadOperation operation, long uploadedSize, long totalSize);
void saveFilePath(FilePathDatabase.PathData pathSaveData, File cacheFileFinal); void saveFilePath(FilePathDatabase.PathData pathSaveData, File cacheFileFinal);
boolean hasAnotherRefOnFile(String path);
} }
private void updateParams() { private void updateParams() {
if (MessagesController.getInstance(currentAccount).getfileExperimentalParams) { if (MessagesController.getInstance(currentAccount).getfileExperimentalParams) {
downloadChunkSizeBig = 1024 * 128; downloadChunkSizeBig = 1024 * 512;
maxDownloadRequests = 8; maxDownloadRequests = 8;
maxDownloadRequestsBig = 8; maxDownloadRequestsBig = 8;
} else { } else {
@ -198,7 +204,7 @@ public class FileLoadOperation {
public FileLoadOperation(ImageLocation imageLocation, Object parent, String extension, long size) { public FileLoadOperation(ImageLocation imageLocation, Object parent, String extension, long size) {
updateParams(); updateParams();
parentObject = parent; parentObject = parent;
forceBig = imageLocation.imageType == FileLoader.IMAGE_TYPE_ANIMATION; isStream = imageLocation.imageType == FileLoader.IMAGE_TYPE_ANIMATION;
if (imageLocation.isEncrypted()) { if (imageLocation.isEncrypted()) {
location = new TLRPC.TL_inputEncryptedFileLocation(); location = new TLRPC.TL_inputEncryptedFileLocation();
location.id = imageLocation.location.volume_id; location.id = imageLocation.location.volume_id;
@ -632,10 +638,15 @@ public class FileLoadOperation {
} }
public boolean start(final FileLoadOperationStream stream, final long streamOffset, final boolean steamPriority) { public boolean start(final FileLoadOperationStream stream, final long streamOffset, final boolean steamPriority) {
startTime = System.currentTimeMillis();
updateParams(); updateParams();
if (currentDownloadChunkSize == 0) { if (currentDownloadChunkSize == 0) {
currentDownloadChunkSize = totalBytesCount >= bigFileSizeFrom || forceBig ? downloadChunkSizeBig : downloadChunkSize; if (isStream) {
currentMaxDownloadRequests = totalBytesCount >= bigFileSizeFrom || forceBig ? maxDownloadRequestsBig : maxDownloadRequests; currentDownloadChunkSize = downloadChunkSizeAnimation;
currentMaxDownloadRequests = maxDownloadRequestsAnimation;
}
currentDownloadChunkSize = totalBytesCount >= bigFileSizeFrom || isStream ? downloadChunkSizeBig : downloadChunkSize;
currentMaxDownloadRequests = totalBytesCount >= bigFileSizeFrom || isStream ? maxDownloadRequestsBig : maxDownloadRequests;
} }
final boolean alreadyStarted = state != stateIdle; final boolean alreadyStarted = state != stateIdle;
final boolean wasPaused = paused; final boolean wasPaused = paused;
@ -780,7 +791,9 @@ public class FileLoadOperation {
} }
boolean finalFileExist = cacheFileFinal.exists(); boolean finalFileExist = cacheFileFinal.exists();
if (finalFileExist && (parentObject instanceof TLRPC.TL_theme || totalBytesCount != 0 && totalBytesCount != cacheFileFinal.length())) { if (finalFileExist && (parentObject instanceof TLRPC.TL_theme || totalBytesCount != 0 && totalBytesCount != cacheFileFinal.length())) {
cacheFileFinal.delete(); if (!delegate.hasAnotherRefOnFile(cacheFileFinal.toString())) {
cacheFileFinal.delete();
}
finalFileExist = false; finalFileExist = false;
} }
@ -1309,7 +1322,7 @@ public class FileLoadOperation {
} }
} }
if (BuildVars.LOGS_ENABLED) { if (BuildVars.LOGS_ENABLED) {
FileLog.d("finished downloading file to " + cacheFileFinal); FileLog.d("finished downloading file to " + cacheFileFinal + " time = " + (System.currentTimeMillis() - startTime));
} }
if (increment) { if (increment) {
if (currentType == ConnectionsManager.FileTypeAudio) { if (currentType == ConnectionsManager.FileTypeAudio) {
@ -1433,7 +1446,7 @@ public class FileLoadOperation {
protected boolean processRequestResult(RequestInfo requestInfo, TLRPC.TL_error error) { protected boolean processRequestResult(RequestInfo requestInfo, TLRPC.TL_error error) {
if (state != stateDownloading) { if (state != stateDownloading) {
if (BuildVars.DEBUG_VERSION) { if (BuildVars.DEBUG_VERSION) {
FileLog.d("trying to write to finished file " + cacheFileFinal + " offset " + requestInfo.offset); FileLog.e(new Exception("trying to write to finished file " + cacheFileFinal + " offset " + requestInfo.offset));
} }
return false; return false;
} }

View file

@ -88,7 +88,7 @@ public class FileLoader extends BaseController {
private ConcurrentHashMap<String, FileLoadOperation> loadOperationPaths = new ConcurrentHashMap<>(); private ConcurrentHashMap<String, FileLoadOperation> loadOperationPaths = new ConcurrentHashMap<>();
private ArrayList<FileLoadOperation> activeFileLoadOperation = new ArrayList<>(); private ArrayList<FileLoadOperation> activeFileLoadOperation = new ArrayList<>();
private ConcurrentHashMap<String, Boolean> loadOperationPathsUI = new ConcurrentHashMap<>(10, 1, 2); private ConcurrentHashMap<String, LoadOperationUIObject> loadOperationPathsUI = new ConcurrentHashMap<>(10, 1, 2);
private HashMap<String, Long> uploadSizes = new HashMap<>(); private HashMap<String, Long> uploadSizes = new HashMap<>();
private HashMap<String, Boolean> loadingVideos = new HashMap<>(); private HashMap<String, Boolean> loadingVideos = new HashMap<>();
@ -513,7 +513,12 @@ public class FileLoader extends BaseController {
} else { } else {
fileName = name; fileName = name;
} }
boolean removed = loadOperationPathsUI.remove(fileName) != null; LoadOperationUIObject uiObject = loadOperationPathsUI.remove(fileName);
Runnable runnable = uiObject != null ? uiObject.loadInternalRunnable : null;
boolean removed = uiObject != null;
if (runnable != null) {
fileLoaderQueue.cancelRunnable(runnable);
}
fileLoaderQueue.postRunnable(() -> { fileLoaderQueue.postRunnable(() -> {
FileLoadOperation operation = loadOperationPaths.remove(fileName); FileLoadOperation operation = loadOperationPaths.remove(fileName);
if (operation != null) { if (operation != null) {
@ -621,7 +626,7 @@ public class FileLoader extends BaseController {
return null; return null;
} }
if (cacheType != 10 && !TextUtils.isEmpty(fileName) && !fileName.contains("" + Integer.MIN_VALUE)) { if (cacheType != 10 && !TextUtils.isEmpty(fileName) && !fileName.contains("" + Integer.MIN_VALUE)) {
loadOperationPathsUI.put(fileName, true); loadOperationPathsUI.put(fileName, new LoadOperationUIObject());
} }
if (document != null && parentObject instanceof MessageObject && ((MessageObject) parentObject).putInDownloadsStore && !((MessageObject) parentObject).isAnyKindOfSticker()) { if (document != null && parentObject instanceof MessageObject && ((MessageObject) parentObject).putInDownloadsStore && !((MessageObject) parentObject).isAnyKindOfSticker()) {
@ -830,6 +835,11 @@ public class FileLoader extends BaseController {
public void saveFilePath(FilePathDatabase.PathData pathSaveData, File cacheFileFinal) { public void saveFilePath(FilePathDatabase.PathData pathSaveData, File cacheFileFinal) {
getFileDatabase().putPath(pathSaveData.id, pathSaveData.dc, pathSaveData.type, cacheFileFinal != null ? cacheFileFinal.toString() : null); getFileDatabase().putPath(pathSaveData.id, pathSaveData.dc, pathSaveData.type, cacheFileFinal != null ? cacheFileFinal.toString() : null);
} }
@Override
public boolean hasAnotherRefOnFile(String path) {
return getFileDatabase().hasAnotherRefOnFile(path);
}
}; };
operation.setDelegate(fileLoadOperationDelegate); operation.setDelegate(fileLoadOperationDelegate);
@ -955,10 +965,13 @@ public class FileLoader extends BaseController {
} else { } else {
fileName = null; fileName = null;
} }
Runnable runnable = () -> loadFileInternal(document, secureDocument, webDocument, location, imageLocation, parentObject, locationExt, locationSize, priority, null, 0, false, cacheType);
if (cacheType != 10 && !TextUtils.isEmpty(fileName) && !fileName.contains("" + Integer.MIN_VALUE)) { if (cacheType != 10 && !TextUtils.isEmpty(fileName) && !fileName.contains("" + Integer.MIN_VALUE)) {
loadOperationPathsUI.put(fileName, true); LoadOperationUIObject uiObject = new FileLoader.LoadOperationUIObject();
uiObject.loadInternalRunnable = runnable;
loadOperationPathsUI.put(fileName, uiObject);
} }
fileLoaderQueue.postRunnable(() -> loadFileInternal(document, secureDocument, webDocument, location, imageLocation, parentObject, locationExt, locationSize, priority, null, 0, false, cacheType)); fileLoaderQueue.postRunnable(runnable);
} }
protected FileLoadOperation loadStreamFile(final FileLoadOperationStream stream, final TLRPC.Document document, final ImageLocation location, final Object parentObject, final int offset, final boolean priority) { protected FileLoadOperation loadStreamFile(final FileLoadOperationStream stream, final TLRPC.Document document, final ImageLocation location, final Object parentObject, final int offset, final boolean priority) {
@ -1644,4 +1657,8 @@ public class FileLoader extends BaseController {
} }
return false; return false;
} }
private static class LoadOperationUIObject {
Runnable loadInternalRunnable;
}
} }

View file

@ -21,7 +21,7 @@ public class FilePathDatabase {
private File cacheFile; private File cacheFile;
private File shmCacheFile; private File shmCacheFile;
private final static int LAST_DB_VERSION = 1; private final static int LAST_DB_VERSION = 2;
private final static String DATABASE_NAME = "file_to_path"; private final static String DATABASE_NAME = "file_to_path";
private final static String DATABASE_BACKUP_NAME = "file_to_path_backup"; private final static String DATABASE_BACKUP_NAME = "file_to_path_backup";
@ -57,6 +57,7 @@ public class FilePathDatabase {
if (createTable) { if (createTable) {
database.executeFast("CREATE TABLE paths(document_id INTEGER, dc_id INTEGER, type INTEGER, path TEXT, PRIMARY KEY(document_id, dc_id, type));").stepThis().dispose(); database.executeFast("CREATE TABLE paths(document_id INTEGER, dc_id INTEGER, type INTEGER, path TEXT, PRIMARY KEY(document_id, dc_id, type));").stepThis().dispose();
database.executeFast("CREATE INDEX IF NOT EXISTS path_in_paths ON paths(path);").stepThis().dispose();
database.executeFast("PRAGMA user_version = " + LAST_DB_VERSION).stepThis().dispose(); database.executeFast("PRAGMA user_version = " + LAST_DB_VERSION).stepThis().dispose();
} else { } else {
int version = database.executeInt("PRAGMA user_version"); int version = database.executeInt("PRAGMA user_version");
@ -66,6 +67,7 @@ public class FilePathDatabase {
if (version == 0) { if (version == 0) {
throw new Exception("malformed"); throw new Exception("malformed");
} }
migrateDatabase(version);
//migration //migration
} }
if (!fromBackup) { if (!fromBackup) {
@ -89,6 +91,14 @@ public class FilePathDatabase {
} }
} }
private void migrateDatabase(int version) throws SQLiteException {
if (version == 1) {
database.executeFast("CREATE INDEX IF NOT EXISTS path_in_paths ON paths(path);").stepThis().dispose();
database.executeFast("PRAGMA user_version = " + 2).stepThis().dispose();
version = 2;
}
}
private void createBackup() { private void createBackup() {
File filesDir = ApplicationLoader.getFilesDirFixed(); File filesDir = ApplicationLoader.getFilesDirFixed();
if (currentAccount != 0) { if (currentAccount != 0) {
@ -117,7 +127,7 @@ public class FilePathDatabase {
try { try {
return AndroidUtilities.copyFile(backupCacheFile, cacheFile); return AndroidUtilities.copyFile(backupCacheFile, cacheFile);
} catch (IOException e) { } catch (IOException e) {
FileLog.e(e); FileLog.e(e);
} }
return false; return false;
} }
@ -182,6 +192,7 @@ public class FilePathDatabase {
SQLitePreparedStatement state = null; SQLitePreparedStatement state = null;
try { try {
if (path != null) { if (path != null) {
database.executeFast("DELETE FROM paths WHERE path = '" + path + "'");
state = database.executeFast("REPLACE INTO paths VALUES(?, ?, ?, ?)"); state = database.executeFast("REPLACE INTO paths VALUES(?, ?, ?, ?)");
state.requery(); state.requery();
state.bindLong(1, id); state.bindLong(1, id);
@ -243,6 +254,29 @@ public class FilePathDatabase {
}); });
} }
public boolean hasAnotherRefOnFile(String path) {
CountDownLatch syncLatch = new CountDownLatch(1);
boolean[] res = new boolean[]{false};
dispatchQueue.postRunnable(() -> {
try {
SQLiteCursor cursor = database.queryFinalized("SELECT document_id FROM paths WHERE path = '" + path + "'");
if (cursor.next()) {
res[0] = true;
}
} catch (Exception e) {
FileLog.e(e);
}
syncLatch.countDown();
});
try {
syncLatch.await();
} catch (InterruptedException e) {
FileLog.e(e);
}
return res[0];
}
public static class PathData { public static class PathData {
public final long id; public final long id;
public final int dc; public final int dc;

View file

@ -1739,12 +1739,12 @@ public class ImageLoader {
final ArrayList<ImageReceiver> finalImageReceiverArray = new ArrayList<>(imageReceiverArray); final ArrayList<ImageReceiver> finalImageReceiverArray = new ArrayList<>(imageReceiverArray);
final ArrayList<Integer> finalImageReceiverGuidsArray = new ArrayList<>(imageReceiverGuidsArray); final ArrayList<Integer> finalImageReceiverGuidsArray = new ArrayList<>(imageReceiverGuidsArray);
AndroidUtilities.runOnUIThread(() -> { AndroidUtilities.runOnUIThread(() -> {
if (image instanceof AnimatedFileDrawable) { if (image instanceof AnimatedFileDrawable && !((AnimatedFileDrawable) image).isWebmSticker) {
boolean imageSet = false; boolean imageSet = false;
AnimatedFileDrawable fileDrawable = (AnimatedFileDrawable) image; AnimatedFileDrawable fileDrawable = (AnimatedFileDrawable) image;
for (int a = 0; a < finalImageReceiverArray.size(); a++) { for (int a = 0; a < finalImageReceiverArray.size(); a++) {
ImageReceiver imgView = finalImageReceiverArray.get(a); ImageReceiver imgView = finalImageReceiverArray.get(a);
AnimatedFileDrawable toSet = fileDrawable; AnimatedFileDrawable toSet = (a == 0 ? fileDrawable : fileDrawable.makeCopy());
if (imgView.setImageBitmapByKey(toSet, key, type, false, finalImageReceiverGuidsArray.get(a))) { if (imgView.setImageBitmapByKey(toSet, key, type, false, finalImageReceiverGuidsArray.get(a))) {
if (toSet == fileDrawable) { if (toSet == fileDrawable) {
imageSet = true; imageSet = true;

View file

@ -280,6 +280,8 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg
private ArrayList<Runnable> loadingOperations = new ArrayList<>(); private ArrayList<Runnable> loadingOperations = new ArrayList<>();
private boolean attachedToWindow; private boolean attachedToWindow;
private boolean videoThumbIsSame; private boolean videoThumbIsSame;
private boolean allowLoadingOnAttachedOnly;
private boolean shouldLoadOnAttach;
public int animatedFileDrawableRepeatMaxCount; public int animatedFileDrawableRepeatMaxCount;
@ -410,6 +412,23 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg
} }
public void setImage(ImageLocation mediaLocation, String mediaFilter, ImageLocation imageLocation, String imageFilter, ImageLocation thumbLocation, String thumbFilter, Drawable thumb, long size, String ext, Object parentObject, int cacheType) { public void setImage(ImageLocation mediaLocation, String mediaFilter, ImageLocation imageLocation, String imageFilter, ImageLocation thumbLocation, String thumbFilter, Drawable thumb, long size, String ext, Object parentObject, int cacheType) {
if (allowLoadingOnAttachedOnly && !attachedToWindow) {
if (setImageBackup == null) {
setImageBackup = new SetImageBackup();
}
setImageBackup.mediaLocation = mediaLocation;
setImageBackup.mediaFilter = mediaFilter;
setImageBackup.imageLocation = imageLocation;
setImageBackup.imageFilter = imageFilter;
setImageBackup.thumbLocation = thumbLocation;
setImageBackup.thumbFilter = thumbFilter;
setImageBackup.thumb = thumb;
setImageBackup.size = size;
setImageBackup.ext = ext;
setImageBackup.cacheType = cacheType;
setImageBackup.parentObject = parentObject;
return;
}
if (ignoreImageSet) { if (ignoreImageSet) {
return; return;
} }
@ -625,7 +644,11 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg
if (delegate != null) { if (delegate != null) {
delegate.didSetImage(this, currentImageDrawable != null || currentThumbDrawable != null || staticThumbDrawable != null || currentMediaDrawable != null, currentImageDrawable == null && currentMediaDrawable == null, false); delegate.didSetImage(this, currentImageDrawable != null || currentThumbDrawable != null || staticThumbDrawable != null || currentMediaDrawable != null, currentImageDrawable == null && currentMediaDrawable == null, false);
} }
loadImage();
isRoundVideo = parentObject instanceof MessageObject && ((MessageObject) parentObject).isRoundVideo();
}
private void loadImage() {
ImageLoader.getInstance().loadImageForImageReceiver(this); ImageLoader.getInstance().loadImageForImageReceiver(this);
if (parentView != null) { if (parentView != null) {
if (invalidateAll) { if (invalidateAll) {
@ -634,8 +657,6 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg
parentView.invalidate((int) imageX, (int) imageY, (int) (imageX + imageW), (int) (imageY + imageH)); parentView.invalidate((int) imageX, (int) imageY, (int) (imageX + imageW), (int) (imageY + imageH));
} }
} }
isRoundVideo = parentObject instanceof MessageObject && ((MessageObject) parentObject).isRoundVideo();
} }
public boolean canInvertBitmap() { public boolean canInvertBitmap() {
@ -2514,4 +2535,8 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg
videoThumbIsSame = b; videoThumbIsSame = b;
} }
public void setAllowLoadingOnAttachedOnly(boolean b) {
allowLoadingOnAttachedOnly = b;
}
} }

View file

@ -28,6 +28,8 @@ import android.util.SparseArray;
import android.util.SparseBooleanArray; import android.util.SparseBooleanArray;
import android.util.SparseIntArray; import android.util.SparseIntArray;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.collection.LongSparseArray; import androidx.collection.LongSparseArray;
import androidx.core.app.NotificationManagerCompat; import androidx.core.app.NotificationManagerCompat;
import androidx.core.util.Consumer; import androidx.core.util.Consumer;
@ -8839,6 +8841,15 @@ public class MessagesController extends BaseController implements NotificationCe
for (int a = 0; a < dialogsToUpdate.size(); a++) { for (int a = 0; a < dialogsToUpdate.size(); a++) {
long dialogId = dialogsToUpdate.keyAt(a); long dialogId = dialogsToUpdate.keyAt(a);
TLRPC.Dialog currentDialog = dialogs_dict.get(dialogId); TLRPC.Dialog currentDialog = dialogs_dict.get(dialogId);
if (currentDialog == null) {
for (int i = 0; i < allDialogs.size(); i++) {
if (allDialogs.get(i).id == dialogId) {
dialogs_dict.put(dialogId, allDialogs.get(i));
currentDialog = allDialogs.get(i);
break;
}
}
}
if (currentDialog != null) { if (currentDialog != null) {
int prevCount = currentDialog.unread_count; int prevCount = currentDialog.unread_count;
currentDialog.unread_count = dialogsToUpdate.valueAt(a); currentDialog.unread_count = dialogsToUpdate.valueAt(a);
@ -9076,6 +9087,12 @@ public class MessagesController extends BaseController implements NotificationCe
if (value == null) { if (value == null) {
value = 0; value = 0;
} }
if (d.read_inbox_max_id > d.top_message) {
d.read_inbox_max_id = d.top_message;
}
if (value > d.top_message) {
value = d.top_message;
}
dialogs_read_inbox_max.put(d.id, Math.max(value, d.read_inbox_max_id)); dialogs_read_inbox_max.put(d.id, Math.max(value, d.read_inbox_max_id));
value = dialogs_read_outbox_max.get(d.id); value = dialogs_read_outbox_max.get(d.id);
@ -12072,6 +12089,7 @@ public class MessagesController extends BaseController implements NotificationCe
TLRPC.User user3 = null; TLRPC.User user3 = null;
TLRPC.Chat channel = null; TLRPC.Chat channel = null;
FileLog.d("update message short userId = " + userId);
if (user == null || user.min) { if (user == null || user.min) {
user = getMessagesStorage().getUserSync(userId); user = getMessagesStorage().getUserSync(userId);
if (user != null && user.min) { if (user != null && user.min) {

View file

@ -27,7 +27,6 @@ import org.telegram.SQLite.SQLiteCursor;
import org.telegram.SQLite.SQLiteDatabase; import org.telegram.SQLite.SQLiteDatabase;
import org.telegram.SQLite.SQLiteException; import org.telegram.SQLite.SQLiteException;
import org.telegram.SQLite.SQLitePreparedStatement; import org.telegram.SQLite.SQLitePreparedStatement;
import org.telegram.messenger.ringtone.RingtoneDataStore;
import org.telegram.messenger.support.LongSparseIntArray; import org.telegram.messenger.support.LongSparseIntArray;
import org.telegram.tgnet.NativeByteBuffer; import org.telegram.tgnet.NativeByteBuffer;
import org.telegram.tgnet.RequestDelegate; import org.telegram.tgnet.RequestDelegate;
@ -2361,6 +2360,11 @@ public class MessagesStorage extends BaseController {
data.reuse(); data.reuse();
} }
} }
if (!DialogObject.isEncryptedDialog(dialogId)) {
if (dialog.read_inbox_max_id > dialog.top_message) {
dialog.read_inbox_max_id = 0;
}
}
if (DialogObject.isEncryptedDialog(dialogId)) { if (DialogObject.isEncryptedDialog(dialogId)) {
int encryptedChatId = DialogObject.getEncryptedChatId(dialogId); int encryptedChatId = DialogObject.getEncryptedChatId(dialogId);
if (!encryptedToLoad.contains(encryptedChatId)) { if (!encryptedToLoad.contains(encryptedChatId)) {
@ -9292,15 +9296,22 @@ public class MessagesStorage extends BaseController {
if (!(message.action instanceof TLRPC.TL_messageActionHistoryClear) && (!MessageObject.isOut(message) || message.from_scheduled) && (message.id > 0 || MessageObject.isUnread(message))) { if (!(message.action instanceof TLRPC.TL_messageActionHistoryClear) && (!MessageObject.isOut(message) || message.from_scheduled) && (message.id > 0 || MessageObject.isUnread(message))) {
int currentMaxId = dialogsReadMax.get(message.dialog_id, -1); int currentMaxId = dialogsReadMax.get(message.dialog_id, -1);
if (currentMaxId == -1) { if (currentMaxId == -1) {
SQLiteCursor cursor = database.queryFinalized("SELECT inbox_max FROM dialogs WHERE did = " + message.dialog_id); SQLiteCursor cursor = database.queryFinalized("SELECT last_mid, inbox_max FROM dialogs WHERE did = " + message.dialog_id);
if (cursor.next()) { if (cursor.next()) {
currentMaxId = cursor.intValue(0); int lastMessageId = cursor.intValue(0);
int inboxMax = cursor.intValue(1);
if (inboxMax > lastMessageId) {
currentMaxId = 0;
} else {
currentMaxId = inboxMax;
}
} else { } else {
currentMaxId = 0; currentMaxId = 0;
} }
cursor.dispose(); cursor.dispose();
dialogsReadMax.put(message.dialog_id, currentMaxId); dialogsReadMax.put(message.dialog_id, currentMaxId);
} }
FileLog.d("update messageRead currentMaxId = " + currentMaxId);
if (message.id < 0 || currentMaxId < message.id) { if (message.id < 0 || currentMaxId < message.id) {
StringBuilder messageIds = messageIdsMap.get(message.dialog_id); StringBuilder messageIds = messageIdsMap.get(message.dialog_id);
if (messageIds == null) { if (messageIds == null) {
@ -9318,6 +9329,7 @@ public class MessagesStorage extends BaseController {
dialogMessagesIdsMap.put(message.dialog_id, ids); dialogMessagesIdsMap.put(message.dialog_id, ids);
} }
ids.add(messageId); ids.add(messageId);
FileLog.d("addMessage = " + messageId);
} }
} }
if (MediaDataController.canAddMessageToMedia(message)) { if (MediaDataController.canAddMessageToMedia(message)) {
@ -10666,6 +10678,11 @@ public class MessagesStorage extends BaseController {
addUsersAndChatsFromMessage(message, usersToLoad, chatsToLoad); addUsersAndChatsFromMessage(message, usersToLoad, chatsToLoad);
} }
if (!DialogObject.isEncryptedDialog(dialogId)) {
if (dialog.read_inbox_max_id > dialog.top_message) {
dialog.read_inbox_max_id = 0;
}
}
if (DialogObject.isEncryptedDialog(dialogId)) { if (DialogObject.isEncryptedDialog(dialogId)) {
int encryptedChatId = DialogObject.getEncryptedChatId(dialogId); int encryptedChatId = DialogObject.getEncryptedChatId(dialogId);
if (!encryptedToLoad.contains(encryptedChatId)) { if (!encryptedToLoad.contains(encryptedChatId)) {
@ -11801,6 +11818,12 @@ public class MessagesStorage extends BaseController {
} }
} }
if (!DialogObject.isEncryptedDialog(dialogId)) {
if (dialog.read_inbox_max_id > dialog.top_message) {
dialog.read_inbox_max_id = 0;
}
}
if (DialogObject.isEncryptedDialog(dialogId)) { if (DialogObject.isEncryptedDialog(dialogId)) {
int encryptedChatId = DialogObject.getEncryptedChatId(dialogId); int encryptedChatId = DialogObject.getEncryptedChatId(dialogId);
if (!encryptedToLoad.contains(encryptedChatId)) { if (!encryptedToLoad.contains(encryptedChatId)) {
@ -12382,11 +12405,20 @@ public class MessagesStorage extends BaseController {
try { try {
if (outbox) { if (outbox) {
cursor = database.queryFinalized("SELECT outbox_max FROM dialogs WHERE did = " + dialog_id); cursor = database.queryFinalized("SELECT outbox_max FROM dialogs WHERE did = " + dialog_id);
if (cursor.next()) {
max[0] = cursor.intValue(0);
}
} else { } else {
cursor = database.queryFinalized("SELECT inbox_max FROM dialogs WHERE did = " + dialog_id); cursor = database.queryFinalized("SELECT last_mid, inbox_max FROM dialogs WHERE did = " + dialog_id);
} if (cursor.next()) {
if (cursor.next()) { int lastMid = cursor.intValue(0);
max[0] = cursor.intValue(0); int inboxMax = cursor.intValue(1);
if (inboxMax > lastMid) {
max[0] = 0;
} else {
max[0] = inboxMax;
}
}
} }
} catch (Exception e) { } catch (Exception e) {
FileLog.e(e); FileLog.e(e);

View file

@ -86,6 +86,13 @@ public class AboutLinkCell extends FrameLayout {
private FrameLayout container; private FrameLayout container;
private Drawable rippleBackground; private Drawable rippleBackground;
private StaticLayout firstThreeLinesLayout;
private StaticLayout[] nextLinesLayouts = null;
private int lastInlineLine = -1;
private Point[] nextLinesLayoutsPositions;
private boolean needSpace = false;
private boolean moreButtonDisabled;
public AboutLinkCell(Context context, BaseFragment fragment) { public AboutLinkCell(Context context, BaseFragment fragment) {
this(context, fragment, null); this(context, fragment, null);
} }
@ -626,12 +633,10 @@ public class AboutLinkCell extends FrameLayout {
} }
} }
private StaticLayout firstThreeLinesLayout;
private StaticLayout[] nextLinesLayouts = null;
private int lastInlineLine = -1;
private Point[] nextLinesLayoutsPositions;
private boolean needSpace = false;
private void checkTextLayout(int maxWidth, boolean force) { private void checkTextLayout(int maxWidth, boolean force) {
if (moreButtonDisabled) {
shouldExpand = false;
}
if (stringBuilder != null && (maxWidth != lastMaxWidth || force)) { if (stringBuilder != null && (maxWidth != lastMaxWidth || force)) {
textLayout = makeTextLayout(stringBuilder, maxWidth); textLayout = makeTextLayout(stringBuilder, maxWidth);
shouldExpand = textLayout.getLineCount() >= 4; // && valueTextView.getVisibility() != View.VISIBLE; shouldExpand = textLayout.getLineCount() >= 4; // && valueTextView.getVisibility() != View.VISIBLE;
@ -731,4 +736,8 @@ public class AboutLinkCell extends FrameLayout {
} }
} }
} }
public void setMoreButtonDisabled(boolean moreButtonDisabled) {
this.moreButtonDisabled = moreButtonDisabled;
}
} }

View file

@ -164,6 +164,8 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
public boolean clipToGroupBounds; public boolean clipToGroupBounds;
private boolean flipImage; private boolean flipImage;
private boolean visibleOnScreen;
public boolean shouldCheckVisibleOnScreen;
public RadialProgress2 getRadialProgress() { public RadialProgress2 getRadialProgress() {
return radialProgress; return radialProgress;
@ -332,6 +334,13 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
currentMessageObject.markReactionsAsRead(); currentMessageObject.markReactionsAsRead();
} }
public void setVisibleOnScreen(boolean visibleOnScreen) {
if (this.visibleOnScreen != visibleOnScreen) {
this.visibleOnScreen = visibleOnScreen;
checkImageReceiversAttachState();
}
}
public interface ChatMessageCellDelegate { public interface ChatMessageCellDelegate {
default void didPressUserAvatar(ChatMessageCell cell, TLRPC.User user, float touchX, float touchY) { default void didPressUserAvatar(ChatMessageCell cell, TLRPC.User user, float touchX, float touchY) {
} }
@ -1067,16 +1076,20 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
backgroundDrawable = new MessageBackgroundDrawable(this); backgroundDrawable = new MessageBackgroundDrawable(this);
avatarImage = new ImageReceiver(); avatarImage = new ImageReceiver();
avatarImage.setAllowLoadingOnAttachedOnly(true);
avatarImage.setRoundRadius(AndroidUtilities.dp(21)); avatarImage.setRoundRadius(AndroidUtilities.dp(21));
avatarDrawable = new AvatarDrawable(); avatarDrawable = new AvatarDrawable();
replyImageReceiver = new ImageReceiver(this); replyImageReceiver = new ImageReceiver(this);
replyImageReceiver.setAllowLoadingOnAttachedOnly(true);
replyImageReceiver.setRoundRadius(AndroidUtilities.dp(2)); replyImageReceiver.setRoundRadius(AndroidUtilities.dp(2));
locationImageReceiver = new ImageReceiver(this); locationImageReceiver = new ImageReceiver(this);
locationImageReceiver.setAllowLoadingOnAttachedOnly(true);
locationImageReceiver.setRoundRadius(AndroidUtilities.dp(26.1f)); locationImageReceiver.setRoundRadius(AndroidUtilities.dp(26.1f));
TAG = DownloadController.getInstance(currentAccount).generateObserverTag(); TAG = DownloadController.getInstance(currentAccount).generateObserverTag();
contactAvatarDrawable = new AvatarDrawable(); contactAvatarDrawable = new AvatarDrawable();
photoImage = new ImageReceiver(this); photoImage = new ImageReceiver(this);
photoImage.setAllowLoadingOnAttachedOnly(true);
photoImage.setUseRoundForThumbDrawable(true); photoImage.setUseRoundForThumbDrawable(true);
photoImage.setDelegate(this); photoImage.setDelegate(this);
radialProgress = new RadialProgress2(this, resourcesProvider); radialProgress = new RadialProgress2(this, resourcesProvider);
@ -3425,22 +3438,8 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
} }
} }
attachedToWindow = false; attachedToWindow = false;
radialProgress.onDetachedFromWindow();
videoRadialProgress.onDetachedFromWindow();
avatarImage.onDetachedFromWindow(); avatarImage.onDetachedFromWindow();
if (pollAvatarImages != null) { checkImageReceiversAttachState();
for (int a = 0; a < pollAvatarImages.length; a++) {
pollAvatarImages[a].onDetachedFromWindow();
}
}
if (commentAvatarImages != null) {
for (int a = 0; a < commentAvatarImages.length; a++) {
commentAvatarImages[a].onDetachedFromWindow();
}
}
replyImageReceiver.onDetachedFromWindow();
locationImageReceiver.onDetachedFromWindow();
photoImage.onDetachedFromWindow();
if (addedForTest && currentUrl != null && currentWebFile != null) { if (addedForTest && currentUrl != null && currentWebFile != null) {
ImageLoader.getInstance().removeTestWebFile(currentUrl); ImageLoader.getInstance().removeTestWebFile(currentUrl);
addedForTest = false; addedForTest = false;
@ -3505,35 +3504,12 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
checkBoxTranslation = 0; checkBoxTranslation = 0;
updateTranslation(); updateTranslation();
radialProgress.onAttachedToWindow();
videoRadialProgress.onAttachedToWindow();
avatarImage.setParentView((View) getParent()); avatarImage.setParentView((View) getParent());
avatarImage.onAttachedToWindow(); avatarImage.onAttachedToWindow();
checkImageReceiversAttachState();
if (currentMessageObject != null) { if (currentMessageObject != null) {
setAvatar(currentMessageObject); setAvatar(currentMessageObject);
} }
if (pollAvatarImages != null) {
for (int a = 0; a < pollAvatarImages.length; a++) {
pollAvatarImages[a].onAttachedToWindow();
}
}
if (commentAvatarImages != null) {
for (int a = 0; a < commentAvatarImages.length; a++) {
commentAvatarImages[a].onAttachedToWindow();
}
}
replyImageReceiver.onAttachedToWindow();
locationImageReceiver.onAttachedToWindow();
if (photoImage.onAttachedToWindow()) {
if (drawPhotoImage) {
updateButtonState(false, false, false);
}
} else {
updateButtonState(false, false, false);
}
if (currentMessageObject != null && (isRoundVideo || currentMessageObject.isVideo())) {
checkVideoPlayback(true, null);
}
if (documentAttachType == DOCUMENT_ATTACH_TYPE_VIDEO && autoPlayingMedia) { if (documentAttachType == DOCUMENT_ATTACH_TYPE_VIDEO && autoPlayingMedia) {
animatingNoSoundPlaying = MediaController.getInstance().isPlayingMessage(currentMessageObject); animatingNoSoundPlaying = MediaController.getInstance().isPlayingMessage(currentMessageObject);
animatingNoSoundProgress = animatingNoSoundPlaying ? 0.0f : 1.0f; animatingNoSoundProgress = animatingNoSoundPlaying ? 0.0f : 1.0f;
@ -3557,6 +3533,92 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
updateFlagSecure(); updateFlagSecure();
} }
boolean imageReceiversAttachState;
private void checkImageReceiversAttachState() {
boolean newAttachState = attachedToWindow && (visibleOnScreen || !shouldCheckVisibleOnScreen);
if (newAttachState == imageReceiversAttachState) {
return;
}
imageReceiversAttachState = newAttachState;
if (newAttachState) {
radialProgress.onAttachedToWindow();
videoRadialProgress.onAttachedToWindow();
if (pollAvatarImages != null) {
for (int a = 0; a < pollAvatarImages.length; a++) {
pollAvatarImages[a].onAttachedToWindow();
}
}
if (commentAvatarImages != null) {
for (int a = 0; a < commentAvatarImages.length; a++) {
commentAvatarImages[a].onAttachedToWindow();
}
}
replyImageReceiver.onAttachedToWindow();
locationImageReceiver.onAttachedToWindow();
if (photoImage.onAttachedToWindow()) {
if (drawPhotoImage) {
updateButtonState(false, false, false);
}
} else {
updateButtonState(false, false, false);
}
if (currentMessageObject != null && (isRoundVideo || currentMessageObject.isVideo())) {
checkVideoPlayback(true, null);
}
if (currentMessageObject != null && !currentMessageObject.mediaExists) {
int canDownload = DownloadController.getInstance(currentAccount).canDownloadMedia(currentMessageObject.messageOwner);
TLRPC.Document document = currentMessageObject.getDocument();
boolean loadDocumentFromImageReceiver = MessageObject.isStickerDocument(document) || MessageObject.isAnimatedStickerDocument(document, true) || MessageObject.isGifDocument(document) || MessageObject.isRoundVideoDocument(document);
if (!loadDocumentFromImageReceiver) {
TLRPC.PhotoSize photo = document == null ? FileLoader.getClosestPhotoSizeWithSize(currentMessageObject.photoThumbs, AndroidUtilities.getPhotoSize()) : null;
if (canDownload == 2 || canDownload == 1 && currentMessageObject.isVideo()) {
if (document != null && !currentMessageObject.shouldEncryptPhotoOrVideo() && currentMessageObject.canStreamVideo()) {
FileLoader.getInstance(currentAccount).loadFile(document, currentMessageObject, 0, 10);
}
} else if (canDownload != 0){
if (document != null) {
FileLoader.getInstance(currentAccount).loadFile(document, currentMessageObject, 0, MessageObject.isVideoDocument(document) && currentMessageObject.shouldEncryptPhotoOrVideo() ? 2 : 0);
} else if (photo != null) {
FileLoader.getInstance(currentAccount).loadFile(ImageLocation.getForObject(photo, currentMessageObject.photoThumbsObject), currentMessageObject, null, 0, currentMessageObject.shouldEncryptPhotoOrVideo() ? 2 : 0);
}
}
updateButtonState(false, false, false);
}
}
} else {
radialProgress.onDetachedFromWindow();
videoRadialProgress.onDetachedFromWindow();
if (pollAvatarImages != null) {
for (int a = 0; a < pollAvatarImages.length; a++) {
pollAvatarImages[a].onDetachedFromWindow();
}
}
if (commentAvatarImages != null) {
for (int a = 0; a < commentAvatarImages.length; a++) {
commentAvatarImages[a].onDetachedFromWindow();
}
}
replyImageReceiver.onDetachedFromWindow();
locationImageReceiver.onDetachedFromWindow();
photoImage.onDetachedFromWindow();
if (currentMessageObject != null && !currentMessageObject.mediaExists && !currentMessageObject.putInDownloadsStore) {
TLRPC.Document document = currentMessageObject.getDocument();
boolean loadDocumentFromImageReceiver = MessageObject.isStickerDocument(document) || MessageObject.isAnimatedStickerDocument(document, true) || MessageObject.isGifDocument(document) || MessageObject.isRoundVideoDocument(document);
if (!loadDocumentFromImageReceiver) {
if (document != null) {
FileLoader.getInstance(currentAccount).cancelLoadFile(document);
} else {
TLRPC.PhotoSize photo = FileLoader.getClosestPhotoSizeWithSize(currentMessageObject.photoThumbs, AndroidUtilities.getPhotoSize());
if (photo != null) {
FileLoader.getInstance(currentAccount).cancelLoadFile(photo);
}
}
}
}
}
}
private void setMessageContent(MessageObject messageObject, MessageObject.GroupedMessages groupedMessages, boolean bottomNear, boolean topNear) { private void setMessageContent(MessageObject messageObject, MessageObject.GroupedMessages groupedMessages, boolean bottomNear, boolean topNear) {
if (messageObject.checkLayout() || currentPosition != null && lastHeight != AndroidUtilities.displaySize.y) { if (messageObject.checkLayout() || currentPosition != null && lastHeight != AndroidUtilities.displaySize.y) {
currentMessageObject = null; currentMessageObject = null;
@ -11291,10 +11353,6 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
if (currentMessageObject == null) { if (currentMessageObject == null) {
return; return;
} }
if (!wasLayout && !animationRunning) {
forceLayout();
return;
}
if (!wasLayout) { if (!wasLayout) {
onLayout(false, getLeft(), getTop(), getRight(), getBottom()); onLayout(false, getLeft(), getTop(), getRight(), getBottom());
} }

View file

@ -2063,29 +2063,31 @@ public class DialogCell extends BaseCell {
if (isDialogCell) { if (isDialogCell) {
TLRPC.Dialog dialog = MessagesController.getInstance(currentAccount).dialogs_dict.get(currentDialogId); TLRPC.Dialog dialog = MessagesController.getInstance(currentAccount).dialogs_dict.get(currentDialogId);
if (dialog != null) { if (dialog != null) {
clearingDialog = MessagesController.getInstance(currentAccount).isClearingDialog(dialog.id); if (mask == 0) {
message = MessagesController.getInstance(currentAccount).dialogMessage.get(dialog.id); clearingDialog = MessagesController.getInstance(currentAccount).isClearingDialog(dialog.id);
lastUnreadState = message != null && message.isUnread(); message = MessagesController.getInstance(currentAccount).dialogMessage.get(dialog.id);
if (dialog instanceof TLRPC.TL_dialogFolder) { lastUnreadState = message != null && message.isUnread();
unreadCount = MessagesStorage.getInstance(currentAccount).getArchiveUnreadCount(); if (dialog instanceof TLRPC.TL_dialogFolder) {
mentionCount = 0; unreadCount = MessagesStorage.getInstance(currentAccount).getArchiveUnreadCount();
reactionMentionCount = 0; mentionCount = 0;
} else { reactionMentionCount = 0;
unreadCount = dialog.unread_count; } else {
mentionCount = dialog.unread_mentions_count; unreadCount = dialog.unread_count;
reactionMentionCount = dialog.unread_reactions_count; mentionCount = dialog.unread_mentions_count;
} reactionMentionCount = dialog.unread_reactions_count;
markUnread = dialog.unread_mark; }
currentEditDate = message != null ? message.messageOwner.edit_date : 0; markUnread = dialog.unread_mark;
lastMessageDate = dialog.last_message_date; currentEditDate = message != null ? message.messageOwner.edit_date : 0;
if (dialogsType == 7 || dialogsType == 8) { lastMessageDate = dialog.last_message_date;
MessagesController.DialogFilter filter = MessagesController.getInstance(currentAccount).selectedDialogFilter[dialogsType == 8 ? 1 : 0]; if (dialogsType == 7 || dialogsType == 8) {
drawPin = filter != null && filter.pinnedDialogs.indexOfKey(dialog.id) >= 0; MessagesController.DialogFilter filter = MessagesController.getInstance(currentAccount).selectedDialogFilter[dialogsType == 8 ? 1 : 0];
} else { drawPin = filter != null && filter.pinnedDialogs.indexOfKey(dialog.id) >= 0;
drawPin = currentDialogFolderId == 0 && dialog.pinned; } else {
} drawPin = currentDialogFolderId == 0 && dialog.pinned;
if (message != null) { }
lastSendState = message.messageOwner.send_state; if (message != null) {
lastSendState = message.messageOwner.send_state;
}
} }
} else { } else {
unreadCount = 0; unreadCount = 0;
@ -2147,7 +2149,7 @@ public class DialogCell extends BaseCell {
continueUpdate = true; continueUpdate = true;
} }
} }
if (!continueUpdate && (mask & MessagesController.UPDATE_MASK_READ_DIALOG_MESSAGE) != 0) { if (!continueUpdate) {
if (message != null && lastUnreadState != message.isUnread()) { if (message != null && lastUnreadState != message.isUnread()) {
lastUnreadState = message.isUnread(); lastUnreadState = message.isUnread();
continueUpdate = true; continueUpdate = true;

View file

@ -10511,76 +10511,6 @@ ChatActivity extends BaseFragment implements NotificationCenter.NotificationCent
if (chatListView == null) { if (chatListView == null) {
return; return;
} }
int count = chatListView.getChildCount();
int firstMessagePosition = -1;
int lastMessagePosition = -1;
for (int a = 0; a < count; a++) {
View child = chatListView.getChildAt(a);
if (!(child instanceof ChatMessageCell)) {
continue;
}
RecyclerListView.ViewHolder holder = chatListView.findContainingViewHolder(child);
if (holder != null) {
int p = holder.getAdapterPosition();
if (firstMessagePosition == -1) {
firstMessagePosition = p;
}
lastMessagePosition = p;
}
ChatMessageCell cell = (ChatMessageCell) child;
MessageObject object = cell.getMessageObject();
if (object == null || object.mediaExists || !object.isSent() || object.loadingCancelled) {
continue;
}
TLRPC.Document document = object.getDocument();
if (document == null) {
continue;
}
int canDownload;
if (!MessageObject.isStickerDocument(document) && !MessageObject.isAnimatedStickerDocument(document, true) && !MessageObject.isGifDocument(document) && !MessageObject.isRoundVideoDocument(document)
&& (canDownload = getDownloadController().canDownloadMedia(object.messageOwner)) != 0) {
if (canDownload == 2) {
if (currentEncryptedChat == null && !object.shouldEncryptPhotoOrVideo() && object.canStreamVideo()) {
getFileLoader().loadFile(document, object, 0, 10);
}
} else {
int cacheType;
if (object.isWallpaper() || object.isTheme()) {
cacheType = 1;
} else if (MessageObject.isVideoDocument(document) && object.shouldEncryptPhotoOrVideo()) {
cacheType = 2;
} else {
cacheType = 0;
}
getFileLoader().loadFile(document, object, 0, cacheType);
cell.updateButtonState(false, true, false);
}
}
}
if (firstMessagePosition != -1) {
int lastPosition;
if (scrollUp) {
firstMessagePosition = lastPosition = lastMessagePosition;
firstMessagePosition = Math.min(firstMessagePosition + 10, chatAdapter.messagesEndRow);
for (int a = lastPosition, N = messages.size(); a < firstMessagePosition; a++) {
int n = a - chatAdapter.messagesStartRow;
if (n < 0 || n >= N) {
continue;
}
checkAutoDownloadMessage(messages.get(n));
}
} else {
lastPosition = Math.max(firstMessagePosition - 20, chatAdapter.messagesStartRow);
for (int a = firstMessagePosition - 1, N = messages.size(); a >= lastPosition; a--) {
int n = a - chatAdapter.messagesStartRow;
if (n < 0 || n >= N) {
continue;
}
checkAutoDownloadMessage(messages.get(n));
}
}
}
showNoSoundHint(); showNoSoundHint();
} }
@ -11943,9 +11873,15 @@ ChatActivity extends BaseFragment implements NotificationCenter.NotificationCent
messageCell.isBlurred = (view.getY() < clipTop && view.getY() + view.getMeasuredHeight() > clipTop) || (view.getY() + view.getMeasuredHeight() > chatListView.getMeasuredHeight() - blurredViewBottomOffset && view.getY() < chatListView.getMeasuredHeight() - blurredViewBottomOffset); messageCell.isBlurred = (view.getY() < clipTop && view.getY() + view.getMeasuredHeight() > clipTop) || (view.getY() + view.getMeasuredHeight() > chatListView.getMeasuredHeight() - blurredViewBottomOffset && view.getY() < chatListView.getMeasuredHeight() - blurredViewBottomOffset);
} }
if (bottom <= clipTop - chatListViewPaddingVisibleOffset || top > chatListView.getMeasuredHeight()) { if (bottom <= clipTop - chatListViewPaddingVisibleOffset || top > chatListView.getMeasuredHeight() - blurredViewBottomOffset) {
if (messageCell != null) {
messageCell.setVisibleOnScreen(false);
}
continue; continue;
} }
if (messageCell != null) {
messageCell.setVisibleOnScreen(true);
}
int viewTop = top >= 0 ? 0 : -top; int viewTop = top >= 0 ? 0 : -top;
int viewBottom = view.getMeasuredHeight(); int viewBottom = view.getMeasuredHeight();
@ -24863,6 +24799,7 @@ ChatActivity extends BaseFragment implements NotificationCenter.NotificationCent
view = new ChatMessageCell(mContext, true, themeDelegate); view = new ChatMessageCell(mContext, true, themeDelegate);
} }
ChatMessageCell chatMessageCell = (ChatMessageCell) view; ChatMessageCell chatMessageCell = (ChatMessageCell) view;
chatMessageCell.shouldCheckVisibleOnScreen = true;
chatMessageCell.setDelegate(new ChatMessageCell.ChatMessageCellDelegate() { chatMessageCell.setDelegate(new ChatMessageCell.ChatMessageCellDelegate() {
@Override @Override

View file

@ -981,7 +981,11 @@ public class InstantCameraView extends FrameLayout implements NotificationCenter
} }
} }
if (sortedSizes.isEmpty() || SharedConfig.getDevicePerformanceClass() == SharedConfig.PERFORMANCE_CLASS_LOW || SharedConfig.getDevicePerformanceClass() == SharedConfig.PERFORMANCE_CLASS_AVERAGE) { if (sortedSizes.isEmpty() || SharedConfig.getDevicePerformanceClass() == SharedConfig.PERFORMANCE_CLASS_LOW || SharedConfig.getDevicePerformanceClass() == SharedConfig.PERFORMANCE_CLASS_AVERAGE) {
return CameraController.chooseOptimalSize(previewSizes, 480, 270, aspectRatio); if (!sortedSizes.isEmpty()) {
return CameraController.chooseOptimalSize(sortedSizes, 480, 270, aspectRatio);
} else {
return CameraController.chooseOptimalSize(previewSizes, 480, 270, aspectRatio);
}
} }
Collections.sort(sortedSizes, (o1, o2) -> { Collections.sort(sortedSizes, (o1, o2) -> {
float a1 = Math.abs(1f - Math.min(o1.mHeight, o1.mWidth) / (float) Math.max(o1.mHeight, o1.mWidth)); float a1 = Math.abs(1f - Math.min(o1.mHeight, o1.mWidth) / (float) Math.max(o1.mHeight, o1.mWidth));

View file

@ -48,8 +48,8 @@ public class Star3DIcon {
int trianglesCount; int trianglesCount;
float enterAlpha = 0f; float enterAlpha = 0f;
public float spec1 = 0f; public float spec1 = 2f;
public float spec2 = 0f; public float spec2 = 0.13f;
public float diffuse = 1f; public float diffuse = 1f;
public int gradientColor1; public int gradientColor1;
public int gradientColor2; public int gradientColor2;

View file

@ -7670,6 +7670,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
aboutLinkCell.setTextAndValue(LocaleController.getString("UserBio", R.string.UserBio), LocaleController.getString("UserBioDetail", R.string.UserBioDetail), false); aboutLinkCell.setTextAndValue(LocaleController.getString("UserBio", R.string.UserBio), LocaleController.getString("UserBioDetail", R.string.UserBioDetail), false);
currentBio = null; currentBio = null;
} }
aboutLinkCell.setMoreButtonDisabled(true);
} }
if (position == bioRow) { if (position == bioRow) {
aboutLinkCell.setOnClickListener(e -> { aboutLinkCell.setOnClickListener(e -> {