diff --git a/TMessagesProj/src/main/java/org/telegram/SQLite/SQLiteDatabase.java b/TMessagesProj/src/main/java/org/telegram/SQLite/SQLiteDatabase.java index d46da3a4b..c8ea8b36e 100755 --- a/TMessagesProj/src/main/java/org/telegram/SQLite/SQLiteDatabase.java +++ b/TMessagesProj/src/main/java/org/telegram/SQLite/SQLiteDatabase.java @@ -97,7 +97,11 @@ public class SQLiteDatabase { public void beginTransaction() throws SQLiteException { if (inTransaction) { - throw new SQLiteException("database already in transaction"); + if (BuildVars.DEBUG_PRIVATE_VERSION) { + throw new SQLiteException("database already in transaction"); + } else { + commitTransaction(); + } } inTransaction = true; beginTransaction(sqliteHandle); diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/AndroidUtilities.java b/TMessagesProj/src/main/java/org/telegram/messenger/AndroidUtilities.java index c2d5c0f13..7b9077513 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/AndroidUtilities.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/AndroidUtilities.java @@ -2157,43 +2157,6 @@ public class AndroidUtilities { } } - public static void slowRunOnUIThread(Runnable runnable) { - slowRunOnUIThread(runnable, 12); - } - - public static void slowRunOnUIThread(Runnable runnable, int triesCount) { - if (SharedConfig.getDevicePerformanceClass() >= SharedConfig.PERFORMANCE_CLASS_HIGH) { - runOnUIThread(runnable); - } else { - runOnUIThread(new TryPost(runnable, triesCount)); - } - } - - private static class TryPost implements Runnable { - - private final Runnable runnable; - private int triesCount; - - private long lastTime = System.currentTimeMillis(); - private final long threshold = (long) (1000L / AndroidUtilities.screenRefreshRate * 1.25f); - - public TryPost(Runnable runnable, int triesCount) { - this.runnable = runnable; - this.triesCount = triesCount; - } - - public void run() { - final long now = System.currentTimeMillis(); - if (triesCount <= 0 || now - lastTime <= threshold) { - runnable.run(); - } else { - triesCount--; - lastTime = now; - AndroidUtilities.runOnUIThread(this); - } - } - } - public static void cancelRunOnUIThread(Runnable runnable) { if (ApplicationLoader.applicationHandler == null) { return; diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java b/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java index 31601358e..967c84bb6 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java @@ -24,8 +24,8 @@ public class BuildVars { 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 = 3195; - public static String BUILD_VERSION_STRING = "9.5.0"; + public static int BUILD_VERSION = 3199; + public static String BUILD_VERSION_STRING = "9.5.1"; public static int APP_ID = 4; public static String APP_HASH = "014b35b6184100b085b0d0572f9b5103"; diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/FileLoader.java b/TMessagesProj/src/main/java/org/telegram/messenger/FileLoader.java index 0bb64731b..55cdf44fd 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/FileLoader.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/FileLoader.java @@ -1679,7 +1679,7 @@ public class FileLoader extends BaseController { Runnable dumpFilesQueueRunnable = () -> { for (int i = 0; i < smallFilesQueue.length; i++) { - FileLog.d("download queue: dc" + (i + 1) + " small_operations=" + smallFilesQueue[i].allOperations.size() + " large_operations=" + largeFilesQueue[i].allOperations.size()); + FileLog.d("download queue: dc" + (i + 1) + " account=" + currentAccount + " small_operations=" + smallFilesQueue[i].allOperations.size() + " large_operations=" + largeFilesQueue[i].allOperations.size()); } dumpFilesQueue(); }; diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/FilePathDatabase.java b/TMessagesProj/src/main/java/org/telegram/messenger/FilePathDatabase.java index ae104ca77..d4f1b621a 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/FilePathDatabase.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/FilePathDatabase.java @@ -210,7 +210,7 @@ public class FilePathDatabase { } } - private void ensureDatabaseCreated() { + public void ensureDatabaseCreated() { if (!databaseCreated) { if (!NativeLoader.loaded()) { int tryCount = 0; diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MessageObject.java b/TMessagesProj/src/main/java/org/telegram/messenger/MessageObject.java index 6da7e0025..5d9b112a3 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/MessageObject.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/MessageObject.java @@ -6656,7 +6656,7 @@ public class MessageObject { } public boolean isMusic() { - return isMusicMessage(messageOwner) && !isVideo(); + return isMusicMessage(messageOwner) && !isVideo() && !isRoundVideo(); } public boolean isDocument() { diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java index fb28272cd..cec0644aa 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java @@ -7954,6 +7954,9 @@ public class MessagesController extends BaseController implements NotificationCe LongSparseArray chatsDict = new LongSparseArray<>(); for (int a = 0; a < messagesRes.users.size(); a++) { TLRPC.User u = messagesRes.users.get(a); + if (BuildVars.DEBUG_VERSION) { + FileLog.d("processLoadedMessages(): +usersDict put " + u.id + " " + u); + } usersDict.put(u.id, u); } for (int a = 0; a < messagesRes.chats.size(); a++) { diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesStorage.java b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesStorage.java index 282c524f4..896022f77 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesStorage.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesStorage.java @@ -261,6 +261,20 @@ public class MessagesStorage extends BaseController { } public void openDatabase(int openTries) { + if (!NativeLoader.loaded()) { + int tryCount = 0; + while (!NativeLoader.loaded()) { + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + tryCount++; + if (tryCount > 5) { + break; + } + } + } File filesDir = ApplicationLoader.getFilesDirFixed(); if (currentAccount != 0) { filesDir = new File(filesDir, "account" + currentAccount + "/"); diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/SendMessagesHelper.java b/TMessagesProj/src/main/java/org/telegram/messenger/SendMessagesHelper.java index 65dedf55e..e415f2938 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/SendMessagesHelper.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/SendMessagesHelper.java @@ -4884,9 +4884,17 @@ public class SendMessagesHelper extends BaseController implements NotificationCe } else { String location = message.obj.messageOwner.attachPath; TLRPC.Document document = message.obj.getDocument(); + if (message.sendEncryptedRequest != null && document.dc_id != 0) { File file = new File(location); if (!file.exists()) { + file = getFileLoader().getPathToMessage(message.obj.messageOwner); + if (file != null) { + message.obj.messageOwner.attachPath = location = file.getAbsolutePath(); + } + } + + if (file == null || !file.exists()) { putToDelayedMessages(FileLoader.getAttachFileName(document), message); getFileLoader().loadFile(document, message.parentObject, FileLoader.PRIORITY_HIGH, 0); return; diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/secretmedia/EncryptedFileDataSource.java b/TMessagesProj/src/main/java/org/telegram/messenger/secretmedia/EncryptedFileDataSource.java index 752650f4c..dcba10acf 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/secretmedia/EncryptedFileDataSource.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/secretmedia/EncryptedFileDataSource.java @@ -15,12 +15,15 @@ import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.upstream.BaseDataSource; import com.google.android.exoplayer2.upstream.DataSpec; import com.google.android.exoplayer2.upstream.TransferListener; +import com.google.android.exoplayer2.util.Log; import org.telegram.messenger.FileLoader; +import org.telegram.messenger.FileLog; import org.telegram.messenger.Utilities; import java.io.EOFException; import java.io.File; +import java.io.FileInputStream; import java.io.IOException; import java.io.RandomAccessFile; @@ -28,18 +31,15 @@ public final class EncryptedFileDataSource extends BaseDataSource { public static class EncryptedFileDataSourceException extends IOException { - public EncryptedFileDataSourceException(IOException cause) { + public EncryptedFileDataSourceException(Throwable cause) { super(cause); } } - private RandomAccessFile file; private Uri uri; private long bytesRemaining; private boolean opened; - private byte[] key = new byte[32]; - private byte[] iv = new byte[16]; private int fileOffset; public EncryptedFileDataSource() { @@ -54,6 +54,8 @@ public final class EncryptedFileDataSource extends BaseDataSource { } } + EncryptedFileInputStream fileInputStream; + @Override public long open(DataSpec dataSpec) throws EncryptedFileDataSourceException { try { @@ -61,22 +63,21 @@ public final class EncryptedFileDataSource extends BaseDataSource { File path = new File(dataSpec.uri.getPath()); String name = path.getName(); File keyPath = new File(FileLoader.getInternalCacheDir(), name + ".key"); - RandomAccessFile keyFile = new RandomAccessFile(keyPath, "r"); - keyFile.read(key); - keyFile.read(iv); - keyFile.close(); - file = new RandomAccessFile(path, "r"); - file.seek(dataSpec.position); - fileOffset = (int) dataSpec.position; - bytesRemaining = dataSpec.length == C.LENGTH_UNSET ? file.length() - dataSpec.position : dataSpec.length; + FileLog.d("EncryptedFileDataSource " + path + " " + keyPath); + fileInputStream = new EncryptedFileInputStream(path, keyPath); + fileInputStream.skip(dataSpec.position); + bytesRemaining = dataSpec.length == C.LENGTH_UNSET ? fileInputStream.available() : dataSpec.length; + FileLog.d("EncryptedFileDataSource bytesRemaining" + bytesRemaining); if (bytesRemaining < 0) { throw new EOFException(); } - } catch (IOException e) { + } catch (Exception e) { + FileLog.e(e); throw new EncryptedFileDataSourceException(e); } + FileLog.d("EncryptedFileDataSource opened"); opened = true; transferStarted(dataSpec); @@ -92,10 +93,10 @@ public final class EncryptedFileDataSource extends BaseDataSource { } else { int bytesRead; try { - bytesRead = file.read(buffer, offset, (int) Math.min(bytesRemaining, readLength)); - Utilities.aesCtrDecryptionByteArray(buffer, key, iv, offset, bytesRead, fileOffset); + bytesRead = fileInputStream.read(buffer, offset, (int) Math.min(bytesRemaining, readLength)); fileOffset += bytesRead; } catch (IOException e) { + FileLog.e(e); throw new EncryptedFileDataSourceException(e); } @@ -118,13 +119,13 @@ public final class EncryptedFileDataSource extends BaseDataSource { uri = null; fileOffset = 0; try { - if (file != null) { - file.close(); + if (fileInputStream != null) { + fileInputStream.close(); } } catch (IOException e) { + FileLog.e(e); throw new EncryptedFileDataSourceException(e); } finally { - file = null; if (opened) { opened = false; transferEnded(); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/CacheControlActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/CacheControlActivity.java index be1ae3445..a464ac936 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/CacheControlActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/CacheControlActivity.java @@ -452,6 +452,7 @@ public class CacheControlActivity extends BaseFragment implements NotificationCe private void loadDialogEntities() { getFileLoader().getFileDatabase().getQueue().postRunnable(() -> { + getFileLoader().getFileDatabase().ensureDatabaseCreated(); CacheModel cacheModel = new CacheModel(false); LongSparseArray dilogsFilesEntities = new LongSparseArray<>(); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java index ec7ca5b62..08bba1386 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java @@ -53,6 +53,7 @@ import android.text.TextUtils; import android.text.style.CharacterStyle; import android.text.style.ClickableSpan; import android.text.style.URLSpan; +import android.util.Log; import android.util.Property; import android.util.SparseArray; import android.util.StateSet; @@ -82,6 +83,7 @@ import org.telegram.PhoneFormat.PhoneFormat; import org.telegram.messenger.AccountInstance; import org.telegram.messenger.AndroidUtilities; import org.telegram.messenger.ApplicationLoader; +import org.telegram.messenger.BuildVars; import org.telegram.messenger.ChatObject; import org.telegram.messenger.ContactsController; import org.telegram.messenger.DialogObject; @@ -12931,9 +12933,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate } return ""; } - { - return "DELETED"; - } + return "DELETED"; } private Object getAuthorStatus() { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/DialogCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/DialogCell.java index 740d52f2b..b206cd138 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/DialogCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/DialogCell.java @@ -328,6 +328,7 @@ public class DialogCell extends BaseCell { private int thumbsCount; private boolean hasVideoThumb; private Paint thumbBackgroundPaint; + private boolean[] thumbImageSeen = new boolean[3]; private ImageReceiver[] thumbImage = new ImageReceiver[3]; private boolean[] drawPlay = new boolean[3]; private boolean[] drawSpoiler = new boolean[3]; @@ -2270,6 +2271,11 @@ public class DialogCell extends BaseCell { } for (int i = 0; i < thumbsCount; ++i) { thumbImage[i].setImageX(left + offset + AndroidUtilities.dp((thumbSize + 2) * i)); + thumbImageSeen[i] = true; + } + } else { + for (int i = 0; i < 3; ++i) { + thumbImageSeen[i] = false; } } } @@ -3646,6 +3652,9 @@ public class DialogCell extends BaseCell { canvas.translate(0, top); } for (int i = 0; i < thumbsCount; ++i) { + if (!thumbImageSeen[i]) { + continue; + } if (thumbBackgroundPaint == null) { thumbBackgroundPaint = new Paint(Paint.ANTI_ALIAS_FLAG); thumbBackgroundPaint.setShadowLayer(AndroidUtilities.dp(1.34f), 0, AndroidUtilities.dp(0.34f), 0x18000000); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java index dddbbde8d..521f4273f 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java @@ -344,7 +344,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not private long chatInviterId; - private static ArrayList chatMessageCellsCache = new ArrayList<>(); + private ArrayList chatMessageCellsCache = new ArrayList<>(); private HashMap alreadyPlayedStickers = new HashMap<>(); @@ -2713,6 +2713,11 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } actionBarBackgroundPaint.setColor(getThemedColor(Theme.key_actionBarDefault)); + if (chatMessageCellsCache.isEmpty()) { + for (int a = 0; a < 15; a++) { + chatMessageCellsCache.add(new ChatMessageCell(context, true, themeDelegate)); + } + } for (int a = 1; a >= 0; a--) { selectedMessagesIds[a].clear(); selectedMessagesCanCopyIds[a].clear(); @@ -27541,14 +27546,15 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not View view = null; if (viewType == 0) { if (!chatMessageCellsCache.isEmpty()) { - view = chatMessageCellsCache.remove(0); + view = chatMessageCellsCache.get(0); + chatMessageCellsCache.remove(0); } else { view = new ChatMessageCell(mContext, true, themeDelegate); } ChatMessageCell chatMessageCell = (ChatMessageCell) view; chatMessageCell.setResourcesProvider(themeDelegate); chatMessageCell.shouldCheckVisibleOnScreen = true; - chatMessageCell.setDelegate(getChatMessageCellDelegate()); + chatMessageCell.setDelegate(new ChatMessageCellDelegate()); if (currentEncryptedChat == null) { chatMessageCell.setAllowAssistant(true); } @@ -31661,14 +31667,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not return skeleton; } - public static void preload(Context context) { - if (context != null && chatMessageCellsCache.isEmpty()) { - for (int i = 0; i < 8; ++i) { - chatMessageCellsCache.add(new ChatMessageCell(context, true, null)); - } - } - } - @Override public SizeNotifierFrameLayout getContentView() { return contentView; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java index 2fe7d1992..ddd170f62 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java @@ -2453,7 +2453,7 @@ public class ChatActivityEnterView extends BlurredFrameLayout implements Notific if (Build.VERSION.SDK_INT >= 21) { giftButton.setBackground(Theme.createSelectorDrawable(getThemedColor(Theme.key_listSelector))); } - attachLayout.addView(giftButton, 0, LayoutHelper.createFrame(48, 48, Gravity.BOTTOM | Gravity.RIGHT)); + attachLayout.addView(giftButton, 0, LayoutHelper.createFrame(48, 48, Gravity.CENTER_VERTICAL | Gravity.RIGHT)); giftButton.setOnClickListener(v -> new GiftPremiumBottomSheet(getParentFragment(), getParentFragment().getCurrentUser()).show()); } @@ -5453,11 +5453,11 @@ public class ChatActivityEnterView extends BlurredFrameLayout implements Notific scheduledButton.setVisibility(VISIBLE); scheduledButton.setTag(1); scheduledButton.setPivotX(AndroidUtilities.dp(48)); - animators.add(ObjectAnimator.ofFloat(scheduledButton, View.TRANSLATION_X, AndroidUtilities.dp(botButton != null && botButton.getVisibility() == VISIBLE ? 96 : 48))); + animators.add(ObjectAnimator.ofFloat(scheduledButton, View.TRANSLATION_X, AndroidUtilities.dp(botButton != null && botButton.getVisibility() == VISIBLE ? 96 : 48) - AndroidUtilities.dp(giftButton != null && giftButton.getVisibility() == VISIBLE ? 48 : 0))); animators.add(ObjectAnimator.ofFloat(scheduledButton, View.ALPHA, 1.0f)); animators.add(ObjectAnimator.ofFloat(scheduledButton, View.SCALE_X, 1.0f)); } else { - scheduledButton.setTranslationX(AndroidUtilities.dp(botButton != null && botButton.getVisibility() == VISIBLE ? 96 : 48)); + scheduledButton.setTranslationX(AndroidUtilities.dp(botButton != null && botButton.getVisibility() == VISIBLE ? 96 : 48) - AndroidUtilities.dp(giftButton != null && giftButton.getVisibility() == VISIBLE ? 48 : 0)); scheduledButton.setAlpha(1.0f); scheduledButton.setScaleX(1.0f); } @@ -5584,7 +5584,7 @@ public class ChatActivityEnterView extends BlurredFrameLayout implements Notific scheduledButton.setVisibility(VISIBLE); scheduledButton.setTag(1); } - scheduledButton.setTranslationX(AndroidUtilities.dp(botButton != null && botButton.getVisibility() == VISIBLE ? 96 : 48)); + scheduledButton.setTranslationX(AndroidUtilities.dp(botButton != null && botButton.getVisibility() == VISIBLE ? 96 : 48) - AndroidUtilities.dp(giftButton != null && giftButton.getVisibility() == VISIBLE ? 48 : 0)); scheduledButton.setAlpha(1.0f); scheduledButton.setScaleX(1.0f); scheduledButton.setScaleY(1.0f); @@ -5629,11 +5629,11 @@ public class ChatActivityEnterView extends BlurredFrameLayout implements Notific scheduledButton.setTag(null); animators.add(ObjectAnimator.ofFloat(scheduledButton, View.ALPHA, 0.0f)); animators.add(ObjectAnimator.ofFloat(scheduledButton, View.SCALE_X, 0.0f)); - animators.add(ObjectAnimator.ofFloat(scheduledButton, View.TRANSLATION_X, AndroidUtilities.dp(botButton == null || botButton.getVisibility() == GONE ? 48 : 96))); + animators.add(ObjectAnimator.ofFloat(scheduledButton, View.TRANSLATION_X, AndroidUtilities.dp(botButton != null && botButton.getVisibility() == VISIBLE ? 96 : 48) - AndroidUtilities.dp(giftButton != null && giftButton.getVisibility() == VISIBLE ? 48 : 0))); } else { scheduledButton.setAlpha(0.0f); scheduledButton.setScaleX(0.0f); - scheduledButton.setTranslationX(AndroidUtilities.dp(botButton == null || botButton.getVisibility() == GONE ? 48 : 96)); + scheduledButton.setTranslationX(AndroidUtilities.dp(botButton != null && botButton.getVisibility() == VISIBLE ? 96 : 48) - AndroidUtilities.dp(giftButton != null && giftButton.getVisibility() == VISIBLE ? 48 : 0)); } } runningAnimation2.playTogether(animators); @@ -5788,7 +5788,7 @@ public class ChatActivityEnterView extends BlurredFrameLayout implements Notific scheduledButton.setAlpha(0.0f); scheduledButton.setScaleX(0.0f); scheduledButton.setScaleY(1.0f); - scheduledButton.setTranslationX(AndroidUtilities.dp(botButton == null || botButton.getVisibility() == GONE ? 48 : 96)); + scheduledButton.setTranslationX(AndroidUtilities.dp(botButton != null && botButton.getVisibility() == VISIBLE ? 96 : 48) - AndroidUtilities.dp(giftButton != null && giftButton.getVisibility() == VISIBLE ? 48 : 0)); } } } @@ -5990,7 +5990,7 @@ public class ChatActivityEnterView extends BlurredFrameLayout implements Notific scheduledButton.setPivotX(AndroidUtilities.dp(48)); animators.add(ObjectAnimator.ofFloat(scheduledButton, View.ALPHA, 1.0f)); animators.add(ObjectAnimator.ofFloat(scheduledButton, View.SCALE_X, 1.0f)); - animators.add(ObjectAnimator.ofFloat(scheduledButton, View.TRANSLATION_X, 0)); + animators.add(ObjectAnimator.ofFloat(scheduledButton, View.TRANSLATION_X, giftButton != null && giftButton.getVisibility() == VISIBLE ? -AndroidUtilities.dp(48) : 0)); } else { scheduledButton.setAlpha(1.0f); scheduledButton.setScaleX(1.0f); @@ -7410,8 +7410,9 @@ public class ChatActivityEnterView extends BlurredFrameLayout implements Notific public void updateGiftButton(boolean animated) { boolean visible = !MessagesController.getInstance(currentAccount).premiumLocked && MessagesController.getInstance(currentAccount).giftAttachMenuIcon && - MessagesController.getInstance(currentAccount).giftTextFieldIcon && getParentFragment() != null && getParentFragment().getCurrentUser() != null && !BuildVars.IS_BILLING_UNAVAILABLE && - !getParentFragment().getCurrentUser().self && !getParentFragment().getCurrentUser().premium && getParentFragment().getCurrentUserInfo() != null && !getParentFragment().getCurrentUserInfo().premium_gifts.isEmpty(); + MessagesController.getInstance(currentAccount).giftTextFieldIcon && getParentFragment() != null && getParentFragment().getCurrentUser() != null && + !BuildVars.IS_BILLING_UNAVAILABLE && !getParentFragment().getCurrentUser().self && !getParentFragment().getCurrentUser().premium && + getParentFragment().getCurrentUserInfo() != null && !getParentFragment().getCurrentUserInfo().premium_gifts.isEmpty() && !isInScheduleMode(); if (!visible && giftButton == null) { return; @@ -7419,6 +7420,14 @@ public class ChatActivityEnterView extends BlurredFrameLayout implements Notific createGiftButton(); AndroidUtilities.updateViewVisibilityAnimated(giftButton, visible, 1f, animated); + if (scheduledButton != null && scheduledButton.getVisibility() == View.VISIBLE) { + float tX = (visible ? -AndroidUtilities.dp(48) : 0) + AndroidUtilities.dp(botButton != null && botButton.getVisibility() == VISIBLE ? 48 : 0); + if (animated) { + scheduledButton.animate().translationX(tX).setDuration(150).start(); + } else { + scheduledButton.setTranslationX(tX); + } + } } public void updateScheduleButton(boolean animated) { @@ -7470,6 +7479,9 @@ public class ChatActivityEnterView extends BlurredFrameLayout implements Notific if (notifyButton != null) { notifyButton.setVisibility(notifyVisible && scheduledButton.getVisibility() != VISIBLE ? VISIBLE : GONE); } + if (giftButton != null && giftButton.getVisibility() == VISIBLE) { + scheduledButton.setTranslationX(-AndroidUtilities.dp(48)); + } } } else if (scheduledButton != null) { if (visible) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/Premium/LimitReachedBottomSheet.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/Premium/LimitReachedBottomSheet.java index e4df0e463..327e65d10 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/Premium/LimitReachedBottomSheet.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/Premium/LimitReachedBottomSheet.java @@ -231,16 +231,22 @@ public class LimitReachedBottomSheet extends BottomSheetWithRecyclerListView { } private void sendInviteMessages() { + String link = null; + TLRPC.ChatFull chatFull = MessagesController.getInstance(currentAccount).getChatFull(fromChat.id); + if (chatFull == null) { + dismiss(); + return; + } + if (fromChat.username != null) { + link = "@" + fromChat.username; + } else if (chatFull.exported_invite != null) { + link = chatFull.exported_invite.link; + } else { + dismiss(); + return; + } for (Object obj : selectedChats) { TLRPC.User user = (TLRPC.User) obj; - TLRPC.ChatFull chatFull = MessagesController.getInstance(currentAccount).getChatFull(fromChat.id); - String link; - if (fromChat.username != null) { - link = "@" + fromChat.username; - } else { - link = chatFull.exported_invite.link; - } - TLRPC.TL_webPage webPage = null; SendMessagesHelper.getInstance(currentAccount).sendMessage(link, user.id, null, null, linkPreview, false, null, null, null, false, 0, null, false); } AndroidUtilities.runOnUIThread(() -> { @@ -497,7 +503,7 @@ public class LimitReachedBottomSheet extends BottomSheetWithRecyclerListView { TLRPC.ChatFull chatFull = MessagesController.getInstance(currentAccount).getChatFull(fromChat.id); String link; - if (fromChat.username == null && chatFull != null) { + if (fromChat.username == null && chatFull != null && chatFull.exported_invite != null) { link = chatFull.exported_invite.link; TLRPC.TL_messages_getWebPage webPagePreview = new TLRPC.TL_messages_getWebPage(); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/ProfileGalleryView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/ProfileGalleryView.java index e16c91e41..7df0ad428 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/ProfileGalleryView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/ProfileGalleryView.java @@ -906,7 +906,11 @@ public class ProfileGalleryView extends CircularViewPager implements Notificatio thumbsFileNames.add(null); videoFileNames.add(null); imagesLocations.add(prevImageLocation); - thumbsLocations.add(prevThumbLocation); + ImageLocation thumbLocation = prevThumbLocation; + if (thumbLocation == null) { + thumbLocation = ImageLocation.getForPhoto(sizeThumb, photo); + } + thumbsLocations.add(thumbLocation); vectorAvatars.add(prevVectorAvatarThumbDrawable); videoLocations.add(null); photos.add(null); @@ -1115,7 +1119,7 @@ public class ProfileGalleryView extends CircularViewPager implements Notificatio item.imageView.isVideo = videoLocation != null; needProgress = vectorAvatars.get(imageLocationPosition) == null; ImageLocation location = thumbsLocations.get(imageLocationPosition); - String filter = location.photoSize instanceof TLRPC.TL_photoStrippedSize ? "b" : null; + String filter = (location != null && location.photoSize instanceof TLRPC.TL_photoStrippedSize) ? "b" : null; String parent = "avatar_" + dialogId; item.imageView.setImageMedia(vectorAvatars.get(imageLocationPosition), videoLocation, null, imagesLocations.get(imageLocationPosition), null, thumbsLocations.get(imageLocationPosition), filter, null, imagesLocationsSizes.get(imageLocationPosition), 1, parent); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/ReactedUsersListView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/ReactedUsersListView.java index 370b6685d..87d419e93 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/ReactedUsersListView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/ReactedUsersListView.java @@ -446,6 +446,10 @@ public class ReactedUsersListView extends FrameLayout { } void setUserReaction(TLRPC.MessagePeerReaction reaction) { + if (reaction == null) { + return; + } + TLRPC.User u = MessagesController.getInstance(currentAccount).getUser(MessageObject.getPeerId(reaction.peer_id)); if (u == null) { return; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/TranslateButton.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/TranslateButton.java index 6bd0fae77..bdda008ef 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/TranslateButton.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/TranslateButton.java @@ -24,6 +24,7 @@ import org.telegram.messenger.LocaleController; import org.telegram.messenger.MessagesController; import org.telegram.messenger.R; import org.telegram.messenger.TranslateController; +import org.telegram.messenger.UserConfig; import org.telegram.tgnet.TLRPC; import org.telegram.ui.ActionBar.ActionBarMenuSubItem; import org.telegram.ui.ActionBar.ActionBarPopupWindow; @@ -302,5 +303,7 @@ public class TranslateButton extends FrameLayout { } textView.setText(TextUtils.concat(translateIcon, " ", text)); } + + menuView.setVisibility(UserConfig.getInstance(currentAccount).isPremium() ? VISIBLE : GONE); } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/DialogsActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/DialogsActivity.java index 81696aeaa..37b967f5a 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/DialogsActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/DialogsActivity.java @@ -2343,10 +2343,6 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter. databaseMigrationHint = null; } - if (initialDialogsType == DIALOGS_TYPE_DEFAULT) { - AndroidUtilities.runOnUIThread(DialogsActivity::preload, 350); - } - return true; } @@ -2368,14 +2364,6 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter. } } - private static void preload() { - if (SharedConfig.getDevicePerformanceClass() < SharedConfig.PERFORMANCE_CLASS_HIGH) { - SecretMediaViewer.getInstance(); - ChatActivity.preload(ApplicationLoader.applicationContext); - ArticleViewer.hasInstance(); - } - } - private Drawable premiumStar; public void updateStatus(TLRPC.User user, boolean animated) { if (statusDrawable == null || actionBar == null) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/LiteModeSettingsActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/LiteModeSettingsActivity.java index d78fa847e..c235f444d 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/LiteModeSettingsActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/LiteModeSettingsActivity.java @@ -223,7 +223,9 @@ public class LiteModeSettingsActivity extends BaseFragment { items.add(Item.asCheckbox(LocaleController.getString("LiteOptionsBackground"), LiteMode.FLAG_CHAT_BACKGROUND)); items.add(Item.asCheckbox(LocaleController.getString("LiteOptionsTopics"), LiteMode.FLAG_CHAT_FORUM_TWOCOLUMN)); items.add(Item.asCheckbox(LocaleController.getString("LiteOptionsSpoiler"), LiteMode.FLAG_CHAT_SPOILER)); - items.add(Item.asCheckbox(LocaleController.getString("LiteOptionsBlur"), LiteMode.FLAG_CHAT_BLUR)); + if (SharedConfig.canBlurChat()) { + items.add(Item.asCheckbox(LocaleController.getString("LiteOptionsBlur"), LiteMode.FLAG_CHAT_BLUR)); + } items.add(Item.asCheckbox(LocaleController.getString("LiteOptionsScale"), LiteMode.FLAG_CHAT_SCALE)); } items.add(Item.asSwitch(R.drawable.msg2_call_earpiece, LocaleController.getString("LiteOptionsCalls"), LiteMode.FLAG_CALLS_ANIMATIONS)); @@ -557,6 +559,9 @@ public class LiteModeSettingsActivity extends BaseFragment { count += ((flags & LiteMode.FLAG_ANIMATED_EMOJI_CHAT_NOT_PREMIUM) > 0 ? -1 : 0) + ((flags & LiteMode.FLAG_ANIMATED_EMOJI_CHAT_PREMIUM) > 0 ? -1 : 0) + ((flags & LiteMode.FLAG_ANIMATED_EMOJI_CHAT) > 0 ? +1 : 0); count += ((flags & LiteMode.FLAG_ANIMATED_EMOJI_REACTIONS_NOT_PREMIUM) > 0 ? -1 : 0) + ((flags & LiteMode.FLAG_ANIMATED_EMOJI_REACTIONS_PREMIUM) > 0 ? -1 : 0) + ((flags & LiteMode.FLAG_ANIMATED_EMOJI_REACTIONS) > 0 ? +1 : 0); count += ((flags & LiteMode.FLAG_ANIMATED_EMOJI_KEYBOARD_NOT_PREMIUM) > 0 ? -1 : 0) + ((flags & LiteMode.FLAG_ANIMATED_EMOJI_KEYBOARD_PREMIUM) > 0 ? -1 : 0) + ((flags & LiteMode.FLAG_ANIMATED_EMOJI_KEYBOARD) > 0 ? +1 : 0); + if (!SharedConfig.canBlurChat() && (flags & LiteMode.FLAG_CHAT_BLUR) > 0) { + count--; + } return count; } diff --git a/TMessagesProj_AppHockeyApp/src/main/java/org/telegram/messenger/ApplicationLoaderImpl.java b/TMessagesProj_AppHockeyApp/src/main/java/org/telegram/messenger/ApplicationLoaderImpl.java index ddbc13bb8..1a7503e18 100644 --- a/TMessagesProj_AppHockeyApp/src/main/java/org/telegram/messenger/ApplicationLoaderImpl.java +++ b/TMessagesProj_AppHockeyApp/src/main/java/org/telegram/messenger/ApplicationLoaderImpl.java @@ -9,6 +9,7 @@ import com.microsoft.appcenter.crashes.Crashes; import com.microsoft.appcenter.distribute.Distribute; import org.telegram.messenger.regular.BuildConfig; +import org.telegram.tgnet.TLRPC; public class ApplicationLoaderImpl extends ApplicationLoader { @Override diff --git a/gradle.properties b/gradle.properties index 9f3a81206..2ce9d842a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -13,8 +13,8 @@ # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # org.gradle.parallel=true #Sat Mar 12 05:53:50 MSK 2016 -APP_VERSION_CODE=3195 -APP_VERSION_NAME=9.5.0 +APP_VERSION_CODE=3199 +APP_VERSION_NAME=9.5.1 APP_PACKAGE=org.telegram.messenger RELEASE_KEY_PASSWORD=android RELEASE_KEY_ALIAS=androidkey