From 09f95ec06948f5a9067b0361f1c7619b723ca22a Mon Sep 17 00:00:00 2001 From: xaxtix Date: Mon, 27 Sep 2021 19:38:27 +0300 Subject: [PATCH] Update to 8.1.2 (2432) --- TMessagesProj/build.gradle | 4 +- .../org/telegram/messenger/BuildVars.java | 4 +- .../messenger/MediaDataController.java | 37 +++++++++++++++---- .../org/telegram/messenger/MessageObject.java | 4 +- .../telegram/messenger/MessagesStorage.java | 24 ++++++++++-- .../messenger/NotificationsController.java | 13 +++---- .../telegram/ui/Adapters/DialogsAdapter.java | 3 -- .../telegram/ui/Cells/GroupCallUserCell.java | 4 +- .../java/org/telegram/ui/ChatActivity.java | 7 +++- .../ui/Components/ChatThemeBottomSheet.java | 2 +- .../telegram/ui/Components/ShareAlert.java | 4 +- .../telegram/ui/EmojiAnimationsOverlay.java | 1 - .../telegram/ui/ExternalActionActivity.java | 2 +- .../java/org/telegram/ui/LoginActivity.java | 34 +++++++++-------- .../java/org/telegram/ui/ProfileActivity.java | 2 +- 15 files changed, 94 insertions(+), 51 deletions(-) diff --git a/TMessagesProj/build.gradle b/TMessagesProj/build.gradle index f8ccffdd0..47f594092 100644 --- a/TMessagesProj/build.gradle +++ b/TMessagesProj/build.gradle @@ -299,7 +299,7 @@ android { } } - defaultConfig.versionCode = 2428 + defaultConfig.versionCode = 2432 applicationVariants.all { variant -> variant.outputs.all { output -> @@ -318,7 +318,7 @@ android { defaultConfig { minSdkVersion 16 targetSdkVersion 29 - versionName "8.0.1" + versionName "8.1.2" vectorDrawables.generatedDensities = ['mdpi', 'hdpi', 'xhdpi', 'xxhdpi'] diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java b/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java index cd643bb6a..a775a86dd 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java @@ -19,8 +19,8 @@ public class BuildVars { public static boolean USE_CLOUD_STRINGS = true; public static boolean CHECK_UPDATES = true; public static boolean NO_SCOPED_STORAGE = true/* || Build.VERSION.SDK_INT <= 28*/; - public static int BUILD_VERSION = 2431; - public static String BUILD_VERSION_STRING = "8.1.1"; + public static int BUILD_VERSION = 2432; + public static String BUILD_VERSION_STRING = "8.1.2"; public static int APP_ID = 4; public static String APP_HASH = "014b35b6184100b085b0d0572f9b5103"; public static String SMS_HASH = isStandaloneApp() ? "w0lkcmTZkKh" : (DEBUG_VERSION ? "O2P2z+/jBpJ" : "oLeq9AcOZkT"); diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MediaDataController.java b/TMessagesProj/src/main/java/org/telegram/messenger/MediaDataController.java index f9efa76c1..41719c348 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/MediaDataController.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/MediaDataController.java @@ -3999,10 +3999,27 @@ public class MediaDataController extends BaseController { if (messageObject == null) { continue; } - if (messageObject.getId() > 0 && messageObject.isReply() && messageObject.replyMessageObject == null) { + if (messageObject.getId() > 0 && messageObject.isReply()) { int messageId = messageObject.messageOwner.reply_to.reply_to_msg_id; - long did = MessageObject.getReplyToDialogId(messageObject.messageOwner); - long channelId = messageObject.messageOwner.peer_id != null ? messageObject.messageOwner.peer_id.channel_id : 0; + long channelId = 0; + if (messageObject.messageOwner.reply_to.reply_to_peer_id != null) { + if (messageObject.messageOwner.reply_to.reply_to_peer_id.channel_id != 0) { + channelId = messageObject.messageOwner.reply_to.reply_to_peer_id.channel_id; + } + } else + if (messageObject.messageOwner.peer_id.channel_id != 0) { + channelId = messageObject.messageOwner.peer_id.channel_id; + } + + if (messageObject.replyMessageObject != null) { + if (messageObject.replyMessageObject.messageOwner == null || messageObject.replyMessageObject.messageOwner.peer_id == null || messageObject.messageOwner instanceof TLRPC.TL_messageEmpty) { + continue; + } + if (messageObject.replyMessageObject.messageOwner.peer_id.channel_id == channelId) { + continue; + } + } + SparseArray> sparseArray = replyMessageOwners.get(dialogId); ArrayList ids = dialogReplyMessagesIds.get(channelId); if (sparseArray == null) { @@ -4013,12 +4030,12 @@ public class MediaDataController extends BaseController { ids = new ArrayList<>(); dialogReplyMessagesIds.put(channelId, ids); } - ArrayList arrayList = sparseArray.get(messageObject.messageOwner.reply_to.reply_to_msg_id); + ArrayList arrayList = sparseArray.get(messageId); if (arrayList == null) { arrayList = new ArrayList<>(); - sparseArray.put(messageObject.messageOwner.reply_to.reply_to_msg_id, arrayList); - if (!ids.contains(messageObject.messageOwner.reply_to.reply_to_msg_id)) { - ids.add(messageObject.messageOwner.reply_to.reply_to_msg_id); + sparseArray.put(messageId, arrayList); + if (!ids.contains(messageId)) { + ids.add(messageId); } } arrayList.add(messageObject); @@ -4090,6 +4107,12 @@ public class MediaDataController extends BaseController { getConnectionsManager().sendRequest(req, (response, error) -> { if (error == null) { TLRPC.messages_Messages messagesRes = (TLRPC.messages_Messages) response; + for (int i = 0; i < messagesRes.messages.size(); i++) { + TLRPC.Message message = messagesRes.messages.get(i); + if (message.dialog_id == 0) { + message.dialog_id = dialogId; + } + } MessageObject.fixMessagePeer(messagesRes.messages, channelId); ImageLoader.saveMessagesThumbs(messagesRes.messages); broadcastReplyMessages(messagesRes.messages, replyMessageOwners, messagesRes.users, messagesRes.chats, dialogId, false); diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MessageObject.java b/TMessagesProj/src/main/java/org/telegram/messenger/MessageObject.java index e21fe0b39..25e5e2ad6 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/MessageObject.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/MessageObject.java @@ -2958,8 +2958,8 @@ public class MessageObject { : LocaleController.formatString("ChatThemeDisabled", R.string.ChatThemeDisabled, userName, emoticon); } else { messageText = isUserSelf - ? LocaleController.formatString("ChangedChatThemeYou", R.string.ChatThemeChangedYou, emoticon) - : LocaleController.formatString("ChangedChatThemeTo", R.string.ChatThemeChangedTo, userName, emoticon); + ? LocaleController.formatString("ChatThemeChangedYou", R.string.ChatThemeChangedYou, emoticon) + : LocaleController.formatString("ChatThemeChangedTo", R.string.ChatThemeChangedTo, userName, emoticon); } } } diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesStorage.java b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesStorage.java index 23e1ebbc2..c341af62c 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesStorage.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesStorage.java @@ -48,6 +48,8 @@ import java.util.concurrent.atomic.AtomicLong; import androidx.annotation.UiThread; import androidx.collection.LongSparseArray; +import com.google.android.exoplayer2.util.Log; + public class MessagesStorage extends BaseController { public interface IntCallback { @@ -440,7 +442,12 @@ public class MessagesStorage extends BaseController { } } if (version < LAST_DB_VERSION) { - updateDbToLastVersion(version); + try { + updateDbToLastVersion(version); + } catch (Exception e) { + FileLog.e(e); + throw new RuntimeException("malformed"); + } } } } catch (Exception e) { @@ -460,6 +467,13 @@ public class MessagesStorage extends BaseController { openDatabase(openTries == 1 ? 2 : 3); } } + + AndroidUtilities.runOnUIThread(() -> { + if (databaseMigrationInProgress) { + databaseMigrationInProgress = false; + NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.onDatabaseMigration, false); + } + }); loadDialogFilters(); loadUnreadMessages(); loadPendingTasks(); @@ -1264,8 +1278,12 @@ public class MessagesStorage extends BaseController { SQLiteCursor cursor; - cursor = database.queryFinalized("SELECT mid, uid, read_state, send_state, date, data, out, ttl, media, replydata, imp, mention, forwards, replies_data, thread_reply_id FROM messages WHERE 1"); - + try { + cursor = database.queryFinalized("SELECT mid, uid, read_state, send_state, date, data, out, ttl, media, replydata, imp, mention, forwards, replies_data, thread_reply_id FROM messages WHERE 1"); + } catch (Exception e) { + cursor = null; + FileLog.e(e); + } if (cursor != null) { SQLitePreparedStatement statement = database.executeFast("REPLACE INTO messages_v2 VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); int num = 0; diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/NotificationsController.java b/TMessagesProj/src/main/java/org/telegram/messenger/NotificationsController.java index c0073b707..9bec22ab3 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/NotificationsController.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/NotificationsController.java @@ -130,8 +130,6 @@ public class NotificationsController extends BaseController { private int notificationId; private String notificationGroup; - private int lastInternalNotificationId; - static { if (Build.VERSION.SDK_INT >= 26 && ApplicationLoader.applicationContext != null) { notificationManager = NotificationManagerCompat.from(ApplicationLoader.applicationContext); @@ -158,8 +156,6 @@ public class NotificationsController extends BaseController { public NotificationsController(int instance) { super(instance); - - lastInternalNotificationId = instance * 1000000 + 5000; notificationId = currentAccount + 1; notificationGroup = "messages" + (currentAccount == 0 ? "" : currentAccount); SharedPreferences preferences = getAccountInstance().getNotificationsSettings(); @@ -3892,7 +3888,10 @@ public class NotificationsController extends BaseController { arrayList.add(messageObject); } - LongSparseArray oldIdsWear = wearNotificationsIds.clone(); + LongSparseArray oldIdsWear = new LongSparseArray<>(); + for (int i = 0; i < wearNotificationsIds.size(); i++) { + oldIdsWear.put(wearNotificationsIds.keyAt(i), wearNotificationsIds.valueAt(i)); + } wearNotificationsIds.clear(); class NotificationHolder { @@ -3914,7 +3913,7 @@ public class NotificationsController extends BaseController { void call() { if (BuildVars.LOGS_ENABLED) { - FileLog.w("show dialog notification with id " + id); + FileLog.w("show dialog notification with id " + id + " " + dialogId + " user=" + user + " chat=" + chat); } try { notificationManager.notify(id, notification.build()); @@ -3947,7 +3946,7 @@ public class NotificationsController extends BaseController { Integer internalId = oldIdsWear.get(dialogId); if (internalId == null) { - internalId = lastInternalNotificationId++; + internalId = (int) dialogId + (int) (dialogId >> 32); } else { oldIdsWear.remove(dialogId); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/DialogsAdapter.java b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/DialogsAdapter.java index 051fd0ce7..a92ae3535 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/DialogsAdapter.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/DialogsAdapter.java @@ -232,9 +232,6 @@ public class DialogsAdapter extends RecyclerListView.SelectionAdapter { } currentCount = count; - if (BuildVars.LOGS_ENABLED) { - FileLog.d("DialogsAdapter dialogsCount=" + dialogsCount + " dialogsType=" + dialogsType); - } return count; } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/GroupCallUserCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/GroupCallUserCell.java index 2794c69a1..31270b561 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/GroupCallUserCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/GroupCallUserCell.java @@ -574,7 +574,9 @@ public class GroupCallUserCell extends FrameLayout { } private void applyParticipantChanges(boolean animated, boolean internal) { - TLRPC.Chat chat = accountInstance.getMessagesController().getChat(currentCall.chatId); + if (currentCall == null) { + return; + } muteButton.setEnabled(!isSelfUser() || participant.raise_hand_rating != 0); boolean hasVoice; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java index f53da384e..5312ad5cc 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java @@ -15814,13 +15814,16 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not private void clearHistory(boolean overwrite, TLRPC.TL_updates_channelDifferenceTooLong differenceTooLong) { if (overwrite) { + if (BuildVars.LOGS_ENABLED) { + FileLog.d("clear history by overwrite firstLoading=" + firstLoading + " minMessage=" + minMessageId[0] + " topMessage=" + differenceTooLong.dialog.top_message); + } if (firstLoading) { + waitingForLoad.clear(); chatWasReset = true; last_message_id = differenceTooLong.dialog.top_message; createUnreadMessageAfterId = 0; } else { if (differenceTooLong.dialog.top_message > minMessageId[0]) { - last_message_id = Math.max(last_message_id, differenceTooLong.dialog.top_message); createUnreadMessageAfterId = Math.max(minMessageId[0] + 1, differenceTooLong.dialog.read_inbox_max_id); } } @@ -23827,7 +23830,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not if (BuildVars.LOGS_ENABLED) { FileLog.d("notify data set changed"); } - if (animated && fragmentOpened && BuildVars.DEBUG_VERSION) { + if (animated && fragmentOpened) { if (chatListView.getItemAnimator() != chatListItemAnimator) { chatListView.setItemAnimator(chatListItemAnimator); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatThemeBottomSheet.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatThemeBottomSheet.java index 10230fdf2..e5955b0ce 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatThemeBottomSheet.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatThemeBottomSheet.java @@ -565,7 +565,7 @@ public class ChatThemeBottomSheet extends BottomSheet implements NotificationCen } private void onAnimationStart() { - if (adapter != null) { + if (adapter != null && adapter.items != null) { for (ChatThemeItem item : adapter.items) { item.isDark = forceDark; } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/ShareAlert.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/ShareAlert.java index 915dad5a6..4ec672f70 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/ShareAlert.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/ShareAlert.java @@ -2145,14 +2145,14 @@ public class ShareAlert extends BottomSheet implements NotificationCenter.Notifi itemsCount += recentSearchObjects.size(); } lastFilledItem = itemsCount++; - return itemsCount; + return lastItemCont = itemsCount; } else { firstEmptyViewCell = itemsCount++; searchResultsStartRow = itemsCount; itemsCount += (searchResult.size() + searchAdapterHelper.getLocalServerSearch().size()); if (itemsCount == 1) { firstEmptyViewCell = -1; - return 0; + return lastItemCont = itemsCount = 0; } lastFilledItem = itemsCount++; } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/EmojiAnimationsOverlay.java b/TMessagesProj/src/main/java/org/telegram/ui/EmojiAnimationsOverlay.java index 5790887f9..071c675f4 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/EmojiAnimationsOverlay.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/EmojiAnimationsOverlay.java @@ -381,7 +381,6 @@ public class EmojiAnimationsOverlay implements NotificationCenter.NotificationCe lastTappedTime = System.currentTimeMillis(); timeIntervals.clear(); animationIndexes.clear(); - ; timeIntervals.add(0L); animationIndexes.add(animation); } else { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ExternalActionActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ExternalActionActivity.java index 6a1b478a9..4ee36fdb6 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ExternalActionActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ExternalActionActivity.java @@ -306,7 +306,7 @@ public class ExternalActionActivity extends Activity implements ActionBarLayout. } } - final long bot_id = intent.getLongExtra("bot_id", 0); + final long bot_id = intent.getLongExtra("bot_id", intent.getIntExtra("bot_id", 0)); final String nonce = intent.getStringExtra("nonce"); final String payload = intent.getStringExtra("payload"); final TLRPC.TL_account_getAuthorizationForm req = new TLRPC.TL_account_getAuthorizationForm(); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/LoginActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/LoginActivity.java index a227ce0ac..3035a0162 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/LoginActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/LoginActivity.java @@ -1506,26 +1506,28 @@ public class LoginActivity extends BaseFragment { TLRPC.TL_help_getCountriesList req = new TLRPC.TL_help_getCountriesList(); req.lang_code = ""; getConnectionsManager().sendRequest(req, (response, error) -> { - if (error == null) { - countriesArray.clear(); - codesMap.clear(); - phoneFormatMap.clear(); - TLRPC.TL_help_countriesList help_countriesList = (TLRPC.TL_help_countriesList) response; - for (int i = 0; i < help_countriesList.countries.size(); i++) { - TLRPC.TL_help_country c = help_countriesList.countries.get(i); - for (int k = 0; k < c.country_codes.size(); k++) { - CountrySelectActivity.Country countryWithCode = new CountrySelectActivity.Country(); - countryWithCode.name = c.default_name; - countryWithCode.code = c.country_codes.get(k).country_code; + AndroidUtilities.runOnUIThread(() -> { + if (error == null) { + countriesArray.clear(); + codesMap.clear(); + phoneFormatMap.clear(); + TLRPC.TL_help_countriesList help_countriesList = (TLRPC.TL_help_countriesList) response; + for (int i = 0; i < help_countriesList.countries.size(); i++) { + TLRPC.TL_help_country c = help_countriesList.countries.get(i); + for (int k = 0; k < c.country_codes.size(); k++) { + CountrySelectActivity.Country countryWithCode = new CountrySelectActivity.Country(); + countryWithCode.name = c.default_name; + countryWithCode.code = c.country_codes.get(k).country_code; - countriesArray.add(countryWithCode); - codesMap.put(c.country_codes.get(k).country_code, countryWithCode); - if (c.country_codes.get(k).patterns.size() > 0) { - phoneFormatMap.put(c.country_codes.get(k).country_code, c.country_codes.get(k).patterns.get(0)); + countriesArray.add(countryWithCode); + codesMap.put(c.country_codes.get(k).country_code, countryWithCode); + if (c.country_codes.get(k).patterns.size() > 0) { + phoneFormatMap.put(c.country_codes.get(k).country_code, c.country_codes.get(k).patterns.get(0)); + } } } } - } + }); }, ConnectionsManager.RequestFlagWithoutLogin | ConnectionsManager.RequestFlagFailOnServerErrors); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java index f35b1c2b5..d4b54cca9 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java @@ -2497,7 +2497,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. } if (position == settingsKeyRow) { Bundle args = new Bundle(); - args.putLong("chat_id", DialogObject.getEncryptedChatId(dialogId)); + args.putInt("chat_id", DialogObject.getEncryptedChatId(dialogId)); presentFragment(new IdenticonActivity(args)); } else if (position == settingsTimerRow) { showDialog(AlertsCreator.createTTLAlert(getParentActivity(), currentEncryptedChat, null).create());