Fixes and improvements

This commit is contained in:
世界 2021-03-18 15:48:00 +08:00
parent 6513842f1c
commit 81d0af640f
No known key found for this signature in database
GPG Key ID: CD109927C34A63C4
12 changed files with 43 additions and 17 deletions

View File

@ -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)")

View File

@ -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);
}
}
}

View File

@ -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 "";
}

View File

@ -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();

View File

@ -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<NotificationsController> 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;

View File

@ -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();

View File

@ -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 {

View File

@ -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();

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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++;