From f424ea165af4e868391b24640d2e715d1a45ce3c Mon Sep 17 00:00:00 2001 From: DrKLO Date: Fri, 5 Jun 2020 17:08:29 +0300 Subject: [PATCH] Update to 6.2.0 (1986) --- TMessagesProj/build.gradle | 2 +- .../org/telegram/messenger/BuildVars.java | 2 +- .../telegram/messenger/MessagesStorage.java | 100 ++++-------------- .../ui/ActionBar/DrawerLayoutContainer.java | 3 + .../ui/Cells/TextSelectionHelper.java | 1 + .../java/org/telegram/ui/ChatActivity.java | 1 + .../ui/Components/FiltersListBottomSheet.java | 8 +- .../telegram/ui/Components/VideoPlayer.java | 1 + .../java/org/telegram/ui/LaunchActivity.java | 2 +- .../java/org/telegram/ui/PhotoViewer.java | 72 +++++++++---- 10 files changed, 89 insertions(+), 103 deletions(-) diff --git a/TMessagesProj/build.gradle b/TMessagesProj/build.gradle index 32f624b81..41f45bf36 100644 --- a/TMessagesProj/build.gradle +++ b/TMessagesProj/build.gradle @@ -276,7 +276,7 @@ android { } } - defaultConfig.versionCode = 1985 + defaultConfig.versionCode = 1986 def tgVoipDexFileName = "libtgvoip.dex" def tgVoipDexClasses = ["AudioRecordJNI", "AudioTrackJNI", "NativeTgVoipDelegate", "NativeTgVoipInstance", "TgVoipNativeLoader", "Resampler", "VLog"] diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java b/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java index 205c0dce0..ad0bf36cb 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java @@ -19,7 +19,7 @@ public class BuildVars { public static boolean USE_CLOUD_STRINGS = true; public static boolean CHECK_UPDATES = true; public static boolean TON_WALLET_STANDALONE = false; - public static int BUILD_VERSION = 1985; + public static int BUILD_VERSION = 1986; public static String BUILD_VERSION_STRING = "6.2.0"; public static int APP_ID = 4; public static String APP_HASH = "014b35b6184100b085b0d0572f9b5103"; diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesStorage.java b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesStorage.java index c369717f5..36b015d32 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesStorage.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesStorage.java @@ -2046,8 +2046,8 @@ public class MessagesStorage extends BaseController { flag = MessagesController.DIALOG_FILTER_FLAG_GROUPS; } if ((flags & flag) != 0) { - if (((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_ARCHIVED) == 0 || archivedDialogs.indexOfKey(-chat.id) < 0 || dialogsWithMentions.indexOfKey(-chat.id) >= 0) && - ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) == 0 || mutedDialogs.indexOfKey(-chat.id) < 0)) { + if (((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_ARCHIVED) == 0 || archivedDialogs.indexOfKey(-chat.id) < 0) && + ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) == 0 || mutedDialogs.indexOfKey(-chat.id) < 0 || dialogsWithMentions.indexOfKey(-chat.id) >= 0)) { unreadCount--; } } @@ -3537,15 +3537,23 @@ public class MessagesStorage extends BaseController { public void resetMentionsCount(final long did, final int count) { storageQueue.postRunnable(() -> { try { - if (count == 0) { - database.executeFast(String.format(Locale.US, "UPDATE messages SET read_state = read_state | 2 WHERE uid = %d AND mention = 1 AND read_state IN(0, 1)", did)).stepThis().dispose(); + int prevUnreadCount = 0; + SQLiteCursor cursor = database.queryFinalized("SELECT unread_count_i FROM dialogs WHERE did = " + did); + if (cursor.next()) { + prevUnreadCount = cursor.intValue(0); } - database.executeFast(String.format(Locale.US, "UPDATE dialogs SET unread_count_i = %d WHERE did = %d", count, did)).stepThis().dispose(); - LongSparseArray sparseArray = new LongSparseArray<>(1); - sparseArray.put(did, count); - getMessagesController().processDialogsUpdateRead(null, sparseArray); - if (count == 0) { - updateFiltersReadCounter(null, sparseArray, true); + cursor.dispose(); + if (prevUnreadCount != 0 || count != 0) { + if (count == 0) { + database.executeFast(String.format(Locale.US, "UPDATE messages SET read_state = read_state | 2 WHERE uid = %d AND mention = 1 AND read_state IN(0, 1)", did)).stepThis().dispose(); + } + database.executeFast(String.format(Locale.US, "UPDATE dialogs SET unread_count_i = %d WHERE did = %d", count, did)).stepThis().dispose(); + LongSparseArray sparseArray = new LongSparseArray<>(1); + sparseArray.put(did, count); + getMessagesController().processDialogsUpdateRead(null, sparseArray); + if (count == 0) { + updateFiltersReadCounter(null, sparseArray, true); + } } } catch (Exception e) { FileLog.e(e); @@ -3967,74 +3975,6 @@ public class MessagesStorage extends BaseController { } } if (filter != null) { - for (int b = 0, N2 = filter.alwaysShow.size(); b < N2; b++) { - int did = filter.alwaysShow.get(b); - if (did > 0) { - TLRPC.User user = usersDict.get(did); - if (user != null) { - if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) != 0 && mutedDialogs.indexOfKey(user.id) >= 0) { - unreadCount--; - } else { - if (user.bot) { - if ((flags & MessagesController.DIALOG_FILTER_FLAG_BOTS) == 0) { - unreadCount--; - } - } else if (user.self || user.contact) { - if ((flags & MessagesController.DIALOG_FILTER_FLAG_CONTACTS) == 0) { - unreadCount--; - } - } else { - if ((flags & MessagesController.DIALOG_FILTER_FLAG_NON_CONTACTS) == 0) { - unreadCount--; - } - } - } - } - user = encUsersDict.get(did); - if (user != null) { - int count = encryptedChatsByUsersCount.get(did, 0); - if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) != 0 && mutedDialogs.indexOfKey(user.id) >= 0) { - unreadCount -= count; - } else { - if (user.bot) { - if ((flags & MessagesController.DIALOG_FILTER_FLAG_BOTS) == 0) { - unreadCount -= count; - } - } else if (user.self || user.contact) { - if ((flags & MessagesController.DIALOG_FILTER_FLAG_CONTACTS) == 0) { - unreadCount -= count; - } - } else { - if ((flags & MessagesController.DIALOG_FILTER_FLAG_NON_CONTACTS) == 0) { - unreadCount -= count; - } - } - } - } - } else { - TLRPC.Chat chat = chatsDict.get(-did); - if (chat != null) { - if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) != 0 && mutedDialogs.indexOfKey(-chat.id) >= 0 && dialogsWithMentions.indexOfKey(-chat.id) < 0 && dialogsWithUnread.indexOfKey(-chat.id) < 0) { - unreadCount--; - } else { - if (ChatObject.isChannel(chat) && !chat.megagroup) { - if ((flags & MessagesController.DIALOG_FILTER_FLAG_CHANNELS) == 0) { - unreadCount--; - } - } else { - if ((flags & MessagesController.DIALOG_FILTER_FLAG_GROUPS) == 0) { - boolean hasUnread = dialogsWithUnread.indexOfKey(did) >= 0; - boolean hasMention = dialogsWithMentions.indexOfKey(did) >= 0; - if (!hasUnread && !hasMention) { - unreadCount--; - } - } - } - } - } - } - } - for (int b = 0, N2 = filter.alwaysShow.size(); b < N2; b++) { int did = filter.alwaysShow.get(b); if (did > 0) { @@ -4132,8 +4072,8 @@ public class MessagesStorage extends BaseController { flag = MessagesController.DIALOG_FILTER_FLAG_GROUPS; } if ((flags & flag) != 0) { - if (((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_ARCHIVED) == 0 || archivedDialogs.indexOfKey(-chat.id) < 0 || dialogsWithMentions.indexOfKey(-chat.id) >= 0) && - ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) == 0 || mutedDialogs.indexOfKey(-chat.id) < 0)) { + if (((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_ARCHIVED) == 0 || archivedDialogs.indexOfKey(-chat.id) < 0) && + ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) == 0 || mutedDialogs.indexOfKey(-chat.id) < 0 || dialogsWithMentions.indexOfKey(-chat.id) >= 0)) { unreadCount++; } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/DrawerLayoutContainer.java b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/DrawerLayoutContainer.java index 952399fac..b91a12831 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/DrawerLayoutContainer.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/DrawerLayoutContainer.java @@ -21,6 +21,7 @@ import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.os.Build; import androidx.annotation.Keep; + import android.view.DisplayCutout; import android.view.Gravity; import android.view.MotionEvent; @@ -468,6 +469,8 @@ public class DrawerLayoutContainer extends FrameLayout { } } inLayout = false; + } else { + AndroidUtilities.displaySize.y = heightSize - AndroidUtilities.statusBarHeight; } final boolean applyInsets = lastInsets != null && Build.VERSION.SDK_INT >= 21; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextSelectionHelper.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextSelectionHelper.java index a2b62a1d4..bab718860 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextSelectionHelper.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextSelectionHelper.java @@ -967,6 +967,7 @@ public abstract class TextSelectionHelper= 21) { @@ -360,7 +360,11 @@ public class FiltersListBottomSheet extends BottomSheet implements NotificationC @Override public int getItemCount() { - return dialogFilters.size() + 1; + int count = dialogFilters.size(); + if (count < 10) { + count++; + } + return count; } @Override diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/VideoPlayer.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/VideoPlayer.java index f20fb1a41..0eae0a112 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/VideoPlayer.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/VideoPlayer.java @@ -156,6 +156,7 @@ public class VideoPlayer implements ExoPlayer.EventListener, SimpleExoPlayer.Vid } else { factory = new DefaultRenderersFactory(ApplicationLoader.applicationContext); } + factory.setExtensionRendererMode(DefaultRenderersFactory.EXTENSION_RENDERER_MODE_PREFER); player = ExoPlayerFactory.newSimpleInstance(ApplicationLoader.applicationContext, factory, trackSelector, loadControl, null); player.addListener(this); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java index 681777251..4a2180729 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java @@ -2045,7 +2045,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa boolean hideProgressDialog = true; if (error == null && actionBarLayout != null) { TLRPC.ChatInvite invite = (TLRPC.ChatInvite) response; - if (invite.chat != null && (!ChatObject.isLeftFromChat(invite.chat) || !invite.chat.kicked && !TextUtils.isEmpty(invite.chat.username))) { + if (invite.chat != null && (!ChatObject.isLeftFromChat(invite.chat) || !invite.chat.kicked && (!TextUtils.isEmpty(invite.chat.username) || BuildVars.DEBUG_PRIVATE_VERSION))) { MessagesController.getInstance(intentAccount).putChat(invite.chat, false); ArrayList chats = new ArrayList<>(); chats.add(invite.chat); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java b/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java index a929a0177..d9b60d649 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java @@ -1112,6 +1112,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat private float[] animAlphas = new float[3]; private float[] alphas = new float[3]; private float scale = 1.0f; + private boolean visible; public PhotoProgressView(View parentView) { if (decelerateInterpolator == null) { @@ -1201,12 +1202,16 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat } else { previousBackgroundState = -2; } - backgroundState = state; + onBackgroundStateUpdated(backgroundState = state); parent.invalidate(); } + protected void onBackgroundStateUpdated(int state) { + } + public void setAlpha(float value) { alphas[0] = animAlphas[0] = value; + checkVisibility(); } public void setScale(float value) { @@ -1219,6 +1224,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat if (!animated) { animAlphas[index] = alpha; } + checkVisibility(); parent.invalidate(); } } @@ -1227,6 +1233,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat for (int i = 0; i < alphas.length; i++) { alphas[i] = animAlphas[i] = 1.0f; } + checkVisibility(); } private float calculateAlpha() { @@ -1241,13 +1248,25 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat return alpha; } - public boolean isVisible() { + private void checkVisibility() { + boolean newVisible = true; for (int i = 0; i < alphas.length; i++) { if (alphas[i] != 1.0f) { - return false; + newVisible = false; + break; } } - return true; + if (newVisible != visible) { + visible = newVisible; + onVisibilityChanged(visible); + } + } + + protected void onVisibilityChanged(boolean visible) { + } + + public boolean isVisible() { + return visible; } public int getX() { @@ -2808,6 +2827,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat } heightSize += AndroidUtilities.statusBarHeight; } + AndroidUtilities.displaySize.y = heightSize - AndroidUtilities.statusBarHeight - insets.getStableInsetBottom(); heightSize -= insets.getSystemWindowInsetBottom(); } else { if (heightSize > AndroidUtilities.displaySize.y) { @@ -3438,7 +3458,21 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat setCaptionHwLayerEnabled(true); for (int a = 0; a < 3; a++) { - photoProgressViews[a] = new PhotoProgressView(containerView); + photoProgressViews[a] = new PhotoProgressView(containerView) { + @Override + protected void onBackgroundStateUpdated(int state) { + if (this == photoProgressViews[0]) { + updateAccessibilityOverlayVisibility(); + } + } + + @Override + protected void onVisibilityChanged(boolean visible) { + if (this == photoProgressViews[0]) { + updateAccessibilityOverlayVisibility(); + } + } + }; photoProgressViews[a].setBackgroundState(PROGRESS_EMPTY, false); } @@ -5212,7 +5246,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat if (!isPlaying) { isPlaying = true; photoProgressViews[0].setBackgroundState(isCurrentVideo ? PROGRESS_NONE : PROGRESS_PAUSE, false); - photoProgressViews[0].setIndexedAlpha(1, !isCurrentVideo && ((playerAutoStarted && !playerWasPlaying) || !isActionBarVisible) ? 0f : 1f, false); + photoProgressViews[0].setIndexedAlpha(1, !isCurrentVideo && !isAccessibilityEnabled() && ((playerAutoStarted && !playerWasPlaying) || !isActionBarVisible) ? 0f : 1f, false); playerWasPlaying = true; AndroidUtilities.runOnUIThread(updateProgressRunnable); } @@ -5528,8 +5562,6 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat } inPreview = preview; - - updateAccessibilityOverlayVisibility(); } private void createVideoTextureView(MediaController.SavedFilterState savedFilterState) { @@ -5580,7 +5612,6 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat } videoPlayer.releasePlayer(true); videoPlayer = null; - updateAccessibilityOverlayVisibility(); } else { playerWasPlaying = false; } @@ -7767,7 +7798,6 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat animateCaption = false; } isCurrentVideo = true; - updateAccessibilityOverlayVisibility(); boolean isMuted = false; float start = 0.0f; float end = 1.0f; @@ -7812,7 +7842,6 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat animateCaption = false; } isCurrentVideo = false; - updateAccessibilityOverlayVisibility(); compressItem.setVisibility(View.GONE); if (isAnimation || sendPhotoType == SELECT_TYPE_QR || isDocumentsPicker) { paintItem.setVisibility(View.GONE); @@ -8133,6 +8162,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat photoProgressViews[0] = photoProgressViews[2]; photoProgressViews[2] = tempProgress; setIndexToImage(leftImage, currentIndex - 1); + updateAccessibilityOverlayVisibility(); checkProgress(1, true, false); checkProgress(2, true, false); @@ -8146,6 +8176,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat photoProgressViews[0] = photoProgressViews[1]; photoProgressViews[1] = tempProgress; setIndexToImage(rightImage, currentIndex + 1); + updateAccessibilityOverlayVisibility(); checkProgress(1, true, false); checkProgress(2, true, false); @@ -9353,7 +9384,6 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat } MediaController.getInstance().injectVideoPlayer(videoPlayer, currentMessageObject); videoPlayer = null; - updateAccessibilityOverlayVisibility(); } } @@ -11624,12 +11654,18 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat } private void updateAccessibilityOverlayVisibility() { - if (playButtonAccessibilityOverlay == null) - return; - if (isCurrentVideo && (videoPlayer == null || !videoPlayer.isPlaying())) { - playButtonAccessibilityOverlay.setVisibility(View.VISIBLE); - } else { - playButtonAccessibilityOverlay.setVisibility(View.INVISIBLE); + if (playButtonAccessibilityOverlay != null) { + final int state = photoProgressViews[0].backgroundState; + if (photoProgressViews[0].isVisible() && (state == PROGRESS_PLAY || state == PROGRESS_PAUSE)) { + if (state == PROGRESS_PLAY) { + playButtonAccessibilityOverlay.setContentDescription(LocaleController.getString("AccActionPlay", R.string.AccActionPlay)); + } else { + playButtonAccessibilityOverlay.setContentDescription(LocaleController.getString("AccActionPause", R.string.AccActionPause)); + } + playButtonAccessibilityOverlay.setVisibility(View.VISIBLE); + } else { + playButtonAccessibilityOverlay.setVisibility(View.INVISIBLE); + } } }