From 81d0af640f88029c8ed7c952fd7a4a38edc4a0e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Thu, 18 Mar 2021 15:48:00 +0800 Subject: [PATCH] Fixes and improvements --- TMessagesProj/build.gradle | 4 ++-- .../main/java/org/telegram/messenger/BuildVars.java | 2 +- .../main/java/org/telegram/messenger/FileLog.java | 2 +- .../org/telegram/messenger/MessagesController.java | 13 +++++++++++++ .../telegram/messenger/NotificationsController.java | 12 +++++++++++- .../java/org/telegram/messenger/SharedConfig.java | 1 + .../java/org/telegram/tgnet/ConnectionsManager.java | 3 +-- .../main/java/org/telegram/ui/Cells/DialogCell.java | 3 +++ .../src/main/java/org/telegram/ui/ChatActivity.java | 4 ++-- .../src/main/java/org/telegram/ui/PhotoViewer.java | 10 +++++----- .../main/java/org/telegram/ui/ProfileActivity.java | 4 ++-- .../nekogram/settings/NekoChatSettingsActivity.java | 2 +- 12 files changed, 43 insertions(+), 17 deletions(-) diff --git a/TMessagesProj/build.gradle b/TMessagesProj/build.gradle index c73140b66..e12756421 100644 --- a/TMessagesProj/build.gradle +++ b/TMessagesProj/build.gradle @@ -3,8 +3,8 @@ import cn.hutool.core.util.RuntimeUtil apply plugin: 'com.android.application' apply plugin: 'kotlin-android' -def verName = "7.5.0-rc12" -def verCode = 200 + 3 * 11 +def verName = "7.5.0-rc13" +def verCode = 200 + 3 * 12 if (System.getenv("DEBUG_BUILD") == "true") { verName += "-" + RuntimeUtil.execForStr("git log --pretty=format:'%h' -n 1)") diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java b/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java index 2f7268b81..c00cbd5c3 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java @@ -46,7 +46,7 @@ public class BuildVars { if (ApplicationLoader.applicationContext != null) { SharedPreferences sharedPreferences = ApplicationLoader.applicationContext.getSharedPreferences("systemConfig", Context.MODE_PRIVATE); - LOGS_ENABLED = sharedPreferences.getBoolean("logsEnabled", DEBUG_VERSION); + LOGS_ENABLED = DEBUG_VERSION = sharedPreferences.getBoolean("logsEnabled", DEBUG_VERSION); } } } diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/FileLog.java b/TMessagesProj/src/main/java/org/telegram/messenger/FileLog.java index 4c103de29..d2a7e75c0 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/FileLog.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/FileLog.java @@ -15,7 +15,7 @@ import cn.hutool.core.util.StrUtil; public class FileLog { public static String getNetworkLogPath() { - if (BuildVars.DEBUG_VERSION) return "/dev/null"; + if (BuildVars.DEBUG_PRIVATE_VERSION) return "/dev/null"; return ""; } diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java index 048e21ca8..efeeae3c5 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java @@ -58,6 +58,7 @@ import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CountDownLatch; +import java.util.stream.Collectors; import cn.hutool.core.thread.ThreadUtil; import tw.nekomimi.nekogram.ExternalGcm; @@ -4053,6 +4054,9 @@ public class MessagesController extends BaseController implements NotificationCe } loadingBlockedPeers = false; getNotificationCenter().postNotificationName(NotificationCenter.blockedUsersDidLoad); + if (!reset && !blockedEndReached && NekoConfig.ignoreBlocked) { + getBlockedPeers(false); + } } })); } @@ -5768,12 +5772,17 @@ public class MessagesController extends BaseController implements NotificationCe newStrings.put(key, newPrintingStrings); newTypes.put(key, newPrintingStringsTypes); + if (NekoConfig.ignoreBlocked) { + arr = arr.stream().filter(it -> getMessagesController().blockePeers.indexOfKey(it.userId) == -1).collect(Collectors.toCollection(ArrayList::new)); + } + if (lower_id > 0 || lower_id == 0 || arr.size() == 1) { PrintingUser pu = arr.get(0); TLRPC.User user = getUser(pu.userId); if (user == null) { continue; } + if (pu.action instanceof TLRPC.TL_sendMessageRecordAudioAction) { if (lower_id < 0) { newPrintingStrings.put(threadId, LocaleController.formatString("IsRecordingAudio", R.string.IsRecordingAudio, getUserNameForTyping(user))); @@ -7442,6 +7451,9 @@ public class MessagesController extends BaseController implements NotificationCe TLRPC.Message lastMessage = null; for (int a = 0; a < dialogsRes.messages.size(); a++) { TLRPC.Message message = dialogsRes.messages.get(a); + if (NekoConfig.ignoreBlocked && getMessagesController().blockePeers.indexOfKey(message.peer_id.user_id) >= 0) { + continue; + } if (lastMessage == null || message.date < lastMessage.date) { lastMessage = message; } @@ -9382,6 +9394,7 @@ public class MessagesController extends BaseController implements NotificationCe } public void performLogout(int type) { + FileLog.e("performLogout", new Exception()); if (type == 1) { unregistedPush(); TLRPC.TL_auth_logOut req = new TLRPC.TL_auth_logOut(); diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/NotificationsController.java b/TMessagesProj/src/main/java/org/telegram/messenger/NotificationsController.java index 87d4dd6b7..ad00524c8 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/NotificationsController.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/NotificationsController.java @@ -77,6 +77,8 @@ import java.util.List; import java.util.Map; import java.util.concurrent.CountDownLatch; +import tw.nekomimi.nekogram.NekoConfig; + public class NotificationsController extends BaseController { public static final String EXTRA_VOICE_REPLY = "extra_voice_reply"; @@ -145,8 +147,9 @@ public class NotificationsController extends BaseController { } private static SparseArray Instance = new SparseArray<>(); + public static NotificationsController getInstance(int num) { - NotificationsController localInstance =Instance.get(num); + NotificationsController localInstance = Instance.get(num); if (localInstance == null) { synchronized (NotificationsController.class) { localInstance = Instance.get(num); @@ -702,6 +705,10 @@ public class NotificationsController extends BaseController { if (messageObject.messageOwner != null && (messageObject.isImportedForward() || messageObject.messageOwner.silent && (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionContactSignUp || messageObject.messageOwner.action instanceof TLRPC.TL_messageActionUserJoined))) { continue; } + if (NekoConfig.ignoreBlocked && getMessagesController().blockePeers.indexOfKey(messageObject.getSenderId()) >= 0) { + continue; + } + long mid = messageObject.getId(); long random_id = messageObject.isFcmMessage() ? messageObject.messageOwner.random_id : 0; long dialog_id = messageObject.getDialogId(); @@ -4028,6 +4035,9 @@ public class NotificationsController extends BaseController { } for (int a = messageObjects.size() - 1; a >= 0; a--) { MessageObject messageObject = messageObjects.get(a); + if (NekoConfig.ignoreBlocked && getMessagesController().blockePeers.indexOfKey(messageObject.getSenderId()) >= 0) { + continue; + } String message = getShortStringForMessage(messageObject, senderName, preview); if (dialog_id == selfUserId) { senderName[0] = name; diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/SharedConfig.java b/TMessagesProj/src/main/java/org/telegram/messenger/SharedConfig.java index 539513f76..77cf4c0ad 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/SharedConfig.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/SharedConfig.java @@ -953,6 +953,7 @@ public class SharedConfig { } public static void saveAccounts() { + FileLog.e("Save accounts: " + activeAccounts, new Exception()); ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE).edit() .putString("active_accounts", StringUtils.join(activeAccounts, ",")) .apply(); diff --git a/TMessagesProj/src/main/java/org/telegram/tgnet/ConnectionsManager.java b/TMessagesProj/src/main/java/org/telegram/tgnet/ConnectionsManager.java index f54eae44b..36c31eb59 100644 --- a/TMessagesProj/src/main/java/org/telegram/tgnet/ConnectionsManager.java +++ b/TMessagesProj/src/main/java/org/telegram/tgnet/ConnectionsManager.java @@ -22,7 +22,6 @@ import org.telegram.messenger.FileLog; import org.telegram.messenger.KeepAliveJob; import org.telegram.messenger.LocaleController; import org.telegram.messenger.MessagesController; -import org.telegram.messenger.MessagesStorage; import org.telegram.messenger.NotificationCenter; import org.telegram.messenger.SharedConfig; import org.telegram.messenger.StatsController; @@ -183,7 +182,7 @@ public class ConnectionsManager extends BaseController { try { systemLangCode = LocaleController.getSystemLocaleStringIso639().toLowerCase(); langCode = MessagesController.getGlobalMainSettings().getString("lang_code", systemLangCode); - if (getUserConfig().deviceInfo) { + if (getUserConfig().deviceInfo && getUserConfig().isClientActivated()) { deviceModel = Build.MANUFACTURER + Build.MODEL; systemVersion = "SDK " + Build.VERSION.SDK_INT; } else { 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 5d61729f9..db1cb1e26 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/DialogCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/DialogCell.java @@ -1912,6 +1912,9 @@ public class DialogCell extends BaseCell { if (mask == 0) { clearingDialog = MessagesController.getInstance(currentAccount).isClearingDialog(dialog.id); message = MessagesController.getInstance(currentAccount).dialogMessage.get(dialog.id); + if (message != null && NekoConfig.ignoreBlocked && MessagesController.getInstance(currentAccount).blockePeers.indexOfKey(message.getSenderId()) >= 0) { + message = null; + } lastUnreadState = message != null && message.isUnread(); if (dialog instanceof TLRPC.TL_dialogFolder) { unreadCount = MessagesStorage.getInstance(currentAccount).getArchiveUnreadCount(); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java index e603429a0..37c0d97dc 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java @@ -2455,10 +2455,10 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not if (currentEncryptedChat != null) { timeItem2 = headerItem.addSubItem(chat_enc_timer, R.drawable.baseline_timer_24, LocaleController.getString("SetTimer", R.string.SetTimer)); - } - if (currentChat == null && !currentUser.self || ChatObject.canUserDoAdminAction(currentChat, ChatObject.ACTION_DELETE_MESSAGES)) { + } else if (currentChat == null && !currentUser.self || ChatObject.canUserDoAdminAction(currentChat, ChatObject.ACTION_DELETE_MESSAGES)) { headerItem.addSubItem(auto_delete_timer, R.drawable.baseline_timer_24, LocaleController.getString("AutoDeleteSetTimer", R.string.AutoDeleteSetTimer)); } + headerItem.addSubItem(clear_history, R.drawable.baseline_delete_sweep_24, LocaleController.getString("ClearHistory", R.string.ClearHistory)); if (currentUser == null || !currentUser.self) { muteItem = headerItem.addSubItem(mute, R.drawable.baseline_volume_off_24_white, null); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java b/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java index e77f4f11a..f7feb1359 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java @@ -4175,23 +4175,23 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat ActionBarMenu menu = actionBar.createMenu(); masksItem = menu.addItem(gallery_menu_masks, R.drawable.deproko_baseline_masks_24); masksItem.setContentDescription(LocaleController.getString("Masks", R.string.Masks)); - masksItem.setIconColor(Theme.getColor(Theme.key_actionBarDefaultIcon)); + masksItem.setIconColor(Theme.getColor(Theme.key_actionBarActionModeDefaultIcon)); pipItem = menu.addItem(gallery_menu_pip, R.drawable.ic_goinline); pipItem.setContentDescription(LocaleController.getString("AccDescrPipMode", R.string.AccDescrPipMode)); - pipItem.setIconColor(Theme.getColor(Theme.key_actionBarDefaultIcon)); + pipItem.setIconColor(Theme.getColor(Theme.key_actionBarActionModeDefaultIcon)); sendNoQuoteItem = menu.addItem(gallery_menu_send_noquote, R.drawable.baseline_fast_forward_24); sendNoQuoteItem.setContentDescription(LocaleController.getString("NoQuoteForward", R.string.Forward)); - sendNoQuoteItem.setIconColor(Theme.getColor(Theme.key_actionBarDefaultIcon)); + sendNoQuoteItem.setIconColor(Theme.getColor(Theme.key_actionBarActionModeDefaultIcon)); sendItem = menu.addItem(gallery_menu_send, R.drawable.baseline_forward_24); sendItem.setContentDescription(LocaleController.getString("Forward", R.string.Forward)); - sendItem.setIconColor(Theme.getColor(Theme.key_actionBarDefaultIcon)); + sendItem.setIconColor(Theme.getColor(Theme.key_actionBarActionModeDefaultIcon)); shareItem = menu.addItem(gallery_menu_share2, R.drawable.share); shareItem.setContentDescription(LocaleController.getString("ShareFile", R.string.ShareFile)); - shareItem.setIconColor(Theme.getColor(Theme.key_actionBarDefaultIcon)); + shareItem.setIconColor(Theme.getColor(Theme.key_actionBarActionModeDefaultIcon)); menuItem = menu.addItem(0, R.drawable.ic_ab_other); menuItem.addSubItem(gallery_menu_openin, R.drawable.baseline_open_in_browser_24, LocaleController.getString("OpenInExternalApp", R.string.OpenInExternalApp)).setColors(0xfffafafa, 0xfffafafa); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java index da6ac6532..e04020d7b 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java @@ -2904,7 +2904,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. return Unit.INSTANCE; }); builder.addItem(BuildVars.LOGS_ENABLED ? LocaleController.getString("DebugMenuDisableLogs", R.string.DebugMenuDisableLogs) : LocaleController.getString("DebugMenuEnableLogs", R.string.DebugMenuEnableLogs), R.drawable.baseline_bug_report_24, (it) -> { - BuildVars.LOGS_ENABLED = !BuildVars.LOGS_ENABLED; + BuildVars.LOGS_ENABLED = BuildVars.DEBUG_VERSION = !BuildVars.LOGS_ENABLED; SharedPreferences sharedPreferences = ApplicationLoader.applicationContext.getSharedPreferences("systemConfig", Context.MODE_PRIVATE); sharedPreferences.edit().putBoolean("logsEnabled", BuildVars.LOGS_ENABLED).apply(); @@ -2978,7 +2978,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. } else if (which == 3) { getMessagesController().forceResetDialogs(); } else if (which == 4) { - BuildVars.LOGS_ENABLED = !BuildVars.LOGS_ENABLED; + BuildVars.LOGS_ENABLED = BuildVars.DEBUG_VERSION = !BuildVars.LOGS_ENABLED; SharedPreferences sharedPreferences = ApplicationLoader.applicationContext.getSharedPreferences("systemConfig", Context.MODE_PRIVATE); sharedPreferences.edit().putBoolean("logsEnabled", BuildVars.LOGS_ENABLED).commit(); updateListAnimated(false); diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoChatSettingsActivity.java b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoChatSettingsActivity.java index 4853fd985..c0676512b 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoChatSettingsActivity.java +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoChatSettingsActivity.java @@ -293,7 +293,7 @@ public class NekoChatSettingsActivity extends BaseFragment implements Notificati stickerSize2Row = rowCount++; chatRow = rowCount++; - ignoreBlockedRow = NekoConfig.ignoreBlocked || NekoXConfig.developerMode ? rowCount++ : -1; + ignoreBlockedRow = rowCount++; ignoreMutedCountRow = rowCount++; disableChatActionRow = rowCount++;