Update to 7.1.0 (2090)

This commit is contained in:
DrKLO 2020-09-30 16:48:47 +03:00
parent e33a2fbedc
commit 1139e12ef1
6026 changed files with 184267 additions and 29250 deletions

View file

@ -323,7 +323,7 @@ public class NotificationsController extends BaseController {
MessageObject messageObject = pushMessages.get(a);
long dialog_id = messageObject.getDialogId();
if (messageObject.messageOwner.mentioned && messageObject.messageOwner.action instanceof TLRPC.TL_messageActionPinMessage ||
(int) dialog_id == 0 || messageObject.messageOwner.to_id.channel_id != 0 && !messageObject.isMegagroup()) {
(int) dialog_id == 0 || messageObject.messageOwner.peer_id.channel_id != 0 && !messageObject.isMegagroup()) {
continue;
}
return true;
@ -338,7 +338,7 @@ public class NotificationsController extends BaseController {
MessageObject messageObject = pushMessages.get(a);
long dialog_id = messageObject.getDialogId();
if (messageObject.messageOwner.mentioned && messageObject.messageOwner.action instanceof TLRPC.TL_messageActionPinMessage ||
(int) dialog_id == 0 || messageObject.messageOwner.to_id.channel_id != 0 && !messageObject.isMegagroup()) {
(int) dialog_id == 0 || messageObject.messageOwner.peer_id.channel_id != 0 && !messageObject.isMegagroup()) {
continue;
}
popupArray.add(0, messageObject);
@ -519,8 +519,8 @@ public class NotificationsController extends BaseController {
}
popupArrayRemove.add(messageObject);
long mid = messageObject.getId();
if (messageObject.messageOwner.to_id.channel_id != 0) {
mid |= ((long) messageObject.messageOwner.to_id.channel_id) << 32;
if (messageObject.messageOwner.peer_id.channel_id != 0) {
mid |= ((long) messageObject.messageOwner.peer_id.channel_id) << 32;
}
pushMessagesDict.remove(mid);
delayedPushMessages.remove(messageObject);
@ -558,8 +558,8 @@ public class NotificationsController extends BaseController {
delayedPushMessages.remove(messageObject);
popupArrayRemove.add(messageObject);
long mid = messageObject.getId();
if (messageObject.messageOwner.to_id.channel_id != 0) {
mid |= ((long) messageObject.messageOwner.to_id.channel_id) << 32;
if (messageObject.messageOwner.peer_id.channel_id != 0) {
mid |= ((long) messageObject.messageOwner.peer_id.channel_id) << 32;
}
pushMessagesDict.remove(mid);
a--;
@ -598,7 +598,7 @@ public class NotificationsController extends BaseController {
popup = 0;
}
}
if (popup != 0 && messageObject.messageOwner.to_id.channel_id != 0 && !messageObject.isMegagroup()) {
if (popup != 0 && messageObject.messageOwner.peer_id.channel_id != 0 && !messageObject.isMegagroup()) {
popup = 0;
}
if (popup != 0) {
@ -607,11 +607,8 @@ public class NotificationsController extends BaseController {
return popup;
}
public void processNewMessages(final ArrayList<MessageObject> messageObjects, final boolean isLast, final boolean isFcm, CountDownLatch countDownLatch) {
if (messageObjects.isEmpty()) {
if (countDownLatch != null) {
countDownLatch.countDown();
}
public void processEditedMessages(final LongSparseArray<ArrayList<MessageObject>> editedMessages) {
/*if (editedMessages.size() == 0) {
return;
}
final ArrayList<MessageObject> popupArrayAdd = new ArrayList<>(0);
@ -693,6 +690,212 @@ public class NotificationsController extends BaseController {
}
added = true;
boolean isChat = lower_id < 0;
int index = settingsCache.indexOfKey(dialog_id);
boolean value;
if (index >= 0) {
value = settingsCache.valueAt(index);
} else {
int notifyOverride = getNotifyOverride(preferences, dialog_id);
if (notifyOverride == -1) {
value = isGlobalNotificationsEnabled(dialog_id, isChannel);
} else {
value = notifyOverride != 2;
}
settingsCache.put(dialog_id, value);
}
if (value) {
if (!isFcm) {
popup = addToPopupMessages(popupArrayAdd, messageObject, lower_id, dialog_id, isChannel, preferences);
}
if (!hasScheduled) {
hasScheduled = messageObject.messageOwner.from_scheduled;
}
delayedPushMessages.add(messageObject);
pushMessages.add(0, messageObject);
if (mid != 0) {
pushMessagesDict.put(mid, messageObject);
} else if (random_id != 0) {
fcmRandomMessagesDict.put(random_id, messageObject);
}
if (original_dialog_id != dialog_id) {
Integer current = pushDialogsOverrideMention.get(original_dialog_id);
pushDialogsOverrideMention.put(original_dialog_id, current == null ? 1 : current + 1);
}
}
}
if (added) {
notifyCheck = isLast;
}
if (!popupArrayAdd.isEmpty() && !AndroidUtilities.needShowPasscode() && !SharedConfig.isWaitingForPasscodeEnter) {
final int popupFinal = popup;
AndroidUtilities.runOnUIThread(() -> {
popupMessages.addAll(0, popupArrayAdd);
if (ApplicationLoader.mainInterfacePaused || !ApplicationLoader.isScreenOn) {
if (popupFinal == 3 || popupFinal == 1 && ApplicationLoader.isScreenOn || popupFinal == 2 && !ApplicationLoader.isScreenOn) {
Intent popupIntent = new Intent(ApplicationLoader.applicationContext, PopupNotificationActivity.class);
popupIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_ANIMATION | Intent.FLAG_ACTIVITY_NO_USER_ACTION | Intent.FLAG_FROM_BACKGROUND);
try {
ApplicationLoader.applicationContext.startActivity(popupIntent);
} catch (Throwable ignore) {
}
}
}
});
}
if (isFcm || hasScheduled) {
if (edited) {
delayedPushMessages.clear();
showOrUpdateNotification(notifyCheck);
} else if (added) {
MessageObject messageObject = messageObjects.get(0);
long dialog_id = messageObject.getDialogId();
Boolean isChannel;
if (messageObject.isFcmMessage()) {
isChannel = messageObject.localChannel;
} else {
isChannel = null;
}
int old_unread_count = total_unread_count;
int notifyOverride = getNotifyOverride(preferences, dialog_id);
boolean canAddValue;
if (notifyOverride == -1) {
canAddValue = isGlobalNotificationsEnabled(dialog_id, isChannel);
} else {
canAddValue = notifyOverride != 2;
}
Integer currentCount = pushDialogs.get(dialog_id);
int newCount = currentCount != null ? currentCount + 1 : 1;
if (notifyCheck && !canAddValue) {
Integer override = pushDialogsOverrideMention.get(dialog_id);
if (override != null && override != 0) {
canAddValue = true;
newCount = override;
}
}
if (canAddValue) {
if (currentCount != null) {
total_unread_count -= currentCount;
}
total_unread_count += newCount;
pushDialogs.put(dialog_id, newCount);
}
if (old_unread_count != total_unread_count) {
delayedPushMessages.clear();
showOrUpdateNotification(notifyCheck);
final int pushDialogsCount = pushDialogs.size();
AndroidUtilities.runOnUIThread(() -> {
NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.notificationsCountUpdated, currentAccount);
getNotificationCenter().postNotificationName(NotificationCenter.dialogsUnreadCounterChanged, pushDialogsCount);
});
}
notifyCheck = false;
if (showBadgeNumber) {
setBadge(getTotalAllUnreadCount());
}
}
}
if (countDownLatch != null) {
countDownLatch.countDown();
}
});*/
}
public void processNewMessages(final ArrayList<MessageObject> messageObjects, final boolean isLast, final boolean isFcm, CountDownLatch countDownLatch) {
if (messageObjects.isEmpty()) {
if (countDownLatch != null) {
countDownLatch.countDown();
}
return;
}
final ArrayList<MessageObject> popupArrayAdd = new ArrayList<>(0);
notificationsQueue.postRunnable(() -> {
boolean added = false;
boolean edited = false;
LongSparseArray<Boolean> settingsCache = new LongSparseArray<>();
SharedPreferences preferences = getAccountInstance().getNotificationsSettings();
boolean allowPinned = preferences.getBoolean("PinnedMessages", true);
int popup = 0;
boolean hasScheduled = false;
for (int a = 0; a < messageObjects.size(); a++) {
MessageObject messageObject = messageObjects.get(a);
if (messageObject.messageOwner != null && messageObject.messageOwner.silent && (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionContactSignUp || messageObject.messageOwner.action instanceof TLRPC.TL_messageActionUserJoined)) {
continue;
}
long mid = messageObject.getId();
long random_id = messageObject.isFcmMessage() ? messageObject.messageOwner.random_id : 0;
long dialog_id = messageObject.getDialogId();
int lower_id = (int) dialog_id;
boolean isChannel;
if (messageObject.isFcmMessage()) {
isChannel = messageObject.localChannel;
} else if (lower_id < 0) {
TLRPC.Chat chat = getMessagesController().getChat(-lower_id);
isChannel = ChatObject.isChannel(chat) && !chat.megagroup;
} else {
isChannel = false;
}
if (messageObject.messageOwner.peer_id.channel_id != 0) {
mid |= ((long) messageObject.messageOwner.peer_id.channel_id) << 32;
}
MessageObject oldMessageObject = pushMessagesDict.get(mid);
if (oldMessageObject == null && messageObject.messageOwner.random_id != 0) {
oldMessageObject = fcmRandomMessagesDict.get(messageObject.messageOwner.random_id);
if (oldMessageObject != null) {
fcmRandomMessagesDict.remove(messageObject.messageOwner.random_id);
}
}
if (oldMessageObject != null) {
if (oldMessageObject.isFcmMessage()) {
pushMessagesDict.put(mid, messageObject);
int idxOld = pushMessages.indexOf(oldMessageObject);
if (idxOld >= 0) {
pushMessages.set(idxOld, messageObject);
popup = addToPopupMessages(popupArrayAdd, messageObject, lower_id, dialog_id, isChannel, preferences);
}
if (isFcm && (edited = messageObject.localEdit)) {
getMessagesStorage().putPushMessage(messageObject);
}
}
continue;
}
if (edited) {
continue;
}
if (isFcm) {
getMessagesStorage().putPushMessage(messageObject);
}
long original_dialog_id = dialog_id;
if (dialog_id == opened_dialog_id && ApplicationLoader.isScreenOn) {
if (!isFcm) {
playInChatSound();
}
continue;
}
if (messageObject.messageOwner.mentioned) {
if (!allowPinned && messageObject.messageOwner.action instanceof TLRPC.TL_messageActionPinMessage) {
continue;
}
dialog_id = messageObject.getFromChatId();
}
if (isPersonalMessage(messageObject)) {
personal_count++;
}
added = true;
boolean isChat = lower_id < 0;
int index = settingsCache.indexOfKey(dialog_id);
boolean value;
@ -877,8 +1080,8 @@ public class NotificationsController extends BaseController {
a--;
delayedPushMessages.remove(messageObject);
long mid = messageObject.getId();
if (messageObject.messageOwner.to_id.channel_id != 0) {
mid |= ((long) messageObject.messageOwner.to_id.channel_id) << 32;
if (messageObject.messageOwner.peer_id.channel_id != 0) {
mid |= ((long) messageObject.messageOwner.peer_id.channel_id) << 32;
}
pushMessagesDict.remove(mid);
popupArrayToRemove.add(messageObject);
@ -938,8 +1141,8 @@ public class NotificationsController extends BaseController {
continue;
}
long mid = message.id;
if (message.to_id.channel_id != 0) {
mid |= ((long) message.to_id.channel_id) << 32;
if (message.peer_id.channel_id != 0) {
mid |= ((long) message.peer_id.channel_id) << 32;
}
if (pushMessagesDict.indexOfKey(mid) >= 0) {
continue;
@ -951,7 +1154,7 @@ public class NotificationsController extends BaseController {
long dialog_id = messageObject.getDialogId();
long original_dialog_id = dialog_id;
if (messageObject.messageOwner.mentioned) {
dialog_id = messageObject.messageOwner.from_id;
dialog_id = messageObject.getFromChatId();
}
int index = settingsCache.indexOfKey(dialog_id);
boolean value;
@ -1013,8 +1216,8 @@ public class NotificationsController extends BaseController {
for (int a = 0; a < push.size(); a++) {
MessageObject messageObject = push.get(a);
long mid = messageObject.getId();
if (messageObject.messageOwner.to_id.channel_id != 0) {
mid |= ((long) messageObject.messageOwner.to_id.channel_id) << 32;
if (messageObject.messageOwner.peer_id.channel_id != 0) {
mid |= ((long) messageObject.messageOwner.peer_id.channel_id) << 32;
}
if (pushMessagesDict.indexOfKey(mid) >= 0) {
continue;
@ -1026,7 +1229,7 @@ public class NotificationsController extends BaseController {
long original_dialog_id = dialog_id;
long random_id = messageObject.messageOwner.random_id;
if (messageObject.messageOwner.mentioned) {
dialog_id = messageObject.messageOwner.from_id;
dialog_id = messageObject.getFromChatId();
}
int index = settingsCache.indexOfKey(dialog_id);
boolean value;
@ -1142,16 +1345,16 @@ public class NotificationsController extends BaseController {
if (AndroidUtilities.needShowPasscode() || SharedConfig.isWaitingForPasscodeEnter) {
return LocaleController.getString("NotificationHiddenMessage", R.string.NotificationHiddenMessage);
}
long dialog_id = messageObject.messageOwner.dialog_id;
int chat_id = messageObject.messageOwner.to_id.chat_id != 0 ? messageObject.messageOwner.to_id.chat_id : messageObject.messageOwner.to_id.channel_id;
int from_id = messageObject.messageOwner.to_id.user_id;
long dialogId = messageObject.messageOwner.dialog_id;
int chat_id = messageObject.messageOwner.peer_id.chat_id != 0 ? messageObject.messageOwner.peer_id.chat_id : messageObject.messageOwner.peer_id.channel_id;
int fromId = messageObject.messageOwner.peer_id.user_id;
if (preview != null) {
preview[0] = true;
}
SharedPreferences preferences = getAccountInstance().getNotificationsSettings();
boolean dialogPreviewEnabled = preferences.getBoolean("content_preview_" + dialog_id, true);
boolean dialogPreviewEnabled = preferences.getBoolean("content_preview_" + dialogId, true);
if (messageObject.isFcmMessage()) {
if (chat_id == 0 && from_id != 0) {
if (chat_id == 0 && fromId != 0) {
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.O_MR1) {
userName[0] = messageObject.localName;
}
@ -1162,7 +1365,7 @@ public class NotificationsController extends BaseController {
return LocaleController.getString("Message", R.string.Message);
}
} else if (chat_id != 0) {
if (messageObject.messageOwner.to_id.channel_id == 0 || messageObject.isMegagroup()) {
if (messageObject.messageOwner.peer_id.channel_id == 0 || messageObject.isMegagroup()) {
userName[0] = messageObject.localUserName;
} else if (Build.VERSION.SDK_INT > Build.VERSION_CODES.O_MR1) {
userName[0] = messageObject.localName;
@ -1171,7 +1374,7 @@ public class NotificationsController extends BaseController {
if (preview != null) {
preview[0] = false;
}
if (!messageObject.isMegagroup() && messageObject.messageOwner.to_id.channel_id != 0) {
if (!messageObject.isMegagroup() && messageObject.messageOwner.peer_id.channel_id != 0) {
return LocaleController.formatString("ChannelMessageNoText", R.string.ChannelMessageNoText, messageObject.localName);
} else {
return LocaleController.formatString("NotificationMessageGroupNoText", R.string.NotificationMessageGroupNoText, messageObject.localUserName, messageObject.localName);
@ -1180,27 +1383,30 @@ public class NotificationsController extends BaseController {
}
return messageObject.messageOwner.message;
}
if (from_id == 0) {
if (fromId == 0) {
if (messageObject.isFromUser() || messageObject.getId() < 0) {
from_id = messageObject.messageOwner.from_id;
fromId = messageObject.getFromChatId();
} else {
from_id = -chat_id;
fromId = -chat_id;
}
} else if (from_id == getUserConfig().getClientUserId()) {
from_id = messageObject.messageOwner.from_id;
} else if (fromId == getUserConfig().getClientUserId()) {
fromId = messageObject.getFromChatId();
}
if (dialog_id == 0) {
if (dialogId == 0) {
if (chat_id != 0) {
dialog_id = -chat_id;
} else if (from_id != 0) {
dialog_id = from_id;
dialogId = -chat_id;
} else if (fromId != 0) {
dialogId = fromId;
}
}
String name = null;
if (from_id > 0) {
TLRPC.User user = getMessagesController().getUser(from_id);
if (UserObject.isReplyUser(dialogId) && messageObject.messageOwner.fwd_from != null && messageObject.messageOwner.fwd_from.from_id != null) {
fromId = MessageObject.getPeerId(messageObject.messageOwner.fwd_from.from_id);
}
if (fromId > 0) {
TLRPC.User user = getMessagesController().getUser(fromId);
if (user != null) {
name = UserObject.getUserName(user);
if (chat_id != 0) {
@ -1214,12 +1420,24 @@ public class NotificationsController extends BaseController {
}
}
} else {
TLRPC.Chat chat = getMessagesController().getChat(-from_id);
TLRPC.Chat chat = getMessagesController().getChat(-fromId);
if (chat != null) {
name = chat.title;
userName[0] = name;
}
}
if (name != null && fromId > 0 && UserObject.isReplyUser(dialogId) && messageObject.messageOwner.fwd_from != null && messageObject.messageOwner.fwd_from.saved_from_peer != null) {
int id = MessageObject.getPeerId(messageObject.messageOwner.fwd_from.saved_from_peer);
if (id < 0) {
TLRPC.Chat chat = getMessagesController().getChat(-id);
if (chat != null) {
name += " @ " + chat.title;
if (userName[0] != null) {
userName[0] = name;
}
}
}
}
if (name == null) {
return null;
@ -1237,12 +1455,12 @@ public class NotificationsController extends BaseController {
}
String msg = null;
if ((int) dialog_id == 0) {
if ((int) dialogId == 0) {
userName[0] = null;
return LocaleController.getString("NotificationHiddenMessage", R.string.NotificationHiddenMessage);
} else {
boolean isChannel = ChatObject.isChannel(chat) && !chat.megagroup;
if (dialogPreviewEnabled && (chat_id == 0 && from_id != 0 && preferences.getBoolean("EnablePreviewAll", true) || chat_id != 0 && (!isChannel && preferences.getBoolean("EnablePreviewGroup", true) || isChannel && preferences.getBoolean("EnablePreviewChannel", true)))) {
if (dialogPreviewEnabled && (chat_id == 0 && fromId != 0 && preferences.getBoolean("EnablePreviewAll", true) || chat_id != 0 && (!isChannel && preferences.getBoolean("EnablePreviewGroup", true) || isChannel && preferences.getBoolean("EnablePreviewChannel", true)))) {
if (messageObject.messageOwner instanceof TLRPC.TL_messageService) {
userName[0] = null;
if (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionUserJoined || messageObject.messageOwner.action instanceof TLRPC.TL_messageActionContactSignUp) {
@ -1266,7 +1484,7 @@ public class NotificationsController extends BaseController {
singleUserId = messageObject.messageOwner.action.users.get(0);
}
if (singleUserId != 0) {
if (messageObject.messageOwner.to_id.channel_id != 0 && !chat.megagroup) {
if (messageObject.messageOwner.peer_id.channel_id != 0 && !chat.megagroup) {
return LocaleController.formatString("ChannelAddedByNotification", R.string.ChannelAddedByNotification, name, chat.title);
} else {
if (singleUserId == getUserConfig().getClientUserId()) {
@ -1276,7 +1494,7 @@ public class NotificationsController extends BaseController {
if (u2 == null) {
return null;
}
if (from_id == u2.id) {
if (fromId == u2.id) {
if (chat.megagroup) {
return LocaleController.formatString("NotificationGroupAddSelfMega", R.string.NotificationGroupAddSelfMega, name, chat.title);
} else {
@ -1306,7 +1524,7 @@ public class NotificationsController extends BaseController {
} else if (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionChatEditTitle) {
return LocaleController.formatString("NotificationEditedGroupName", R.string.NotificationEditedGroupName, name, messageObject.messageOwner.action.title);
} else if (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionChatEditPhoto || messageObject.messageOwner.action instanceof TLRPC.TL_messageActionChatDeletePhoto) {
if (messageObject.messageOwner.to_id.channel_id != 0 && !chat.megagroup) {
if (messageObject.messageOwner.peer_id.channel_id != 0 && !chat.megagroup) {
if (messageObject.isVideoAvatar()) {
return LocaleController.formatString("ChannelVideoEditNotification", R.string.ChannelVideoEditNotification, chat.title);
} else {
@ -1322,7 +1540,7 @@ public class NotificationsController extends BaseController {
} else if (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionChatDeleteUser) {
if (messageObject.messageOwner.action.user_id == getUserConfig().getClientUserId()) {
return LocaleController.formatString("NotificationGroupKickYou", R.string.NotificationGroupKickYou, name, chat.title);
} else if (messageObject.messageOwner.action.user_id == from_id) {
} else if (messageObject.messageOwner.action.user_id == fromId) {
return LocaleController.formatString("NotificationGroupLeftMember", R.string.NotificationGroupLeftMember, name, chat.title);
} else {
TLRPC.User u2 = getMessagesController().getUser(messageObject.messageOwner.action.user_id);
@ -1573,8 +1791,8 @@ public class NotificationsController extends BaseController {
return LocaleController.getString("YouHaveNewMessage", R.string.YouHaveNewMessage);
}
long dialog_id = messageObject.messageOwner.dialog_id;
int chat_id = messageObject.messageOwner.to_id.chat_id != 0 ? messageObject.messageOwner.to_id.chat_id : messageObject.messageOwner.to_id.channel_id;
int from_id = messageObject.messageOwner.to_id.user_id;
int chat_id = messageObject.messageOwner.peer_id.chat_id != 0 ? messageObject.messageOwner.peer_id.chat_id : messageObject.messageOwner.peer_id.channel_id;
int from_id = messageObject.messageOwner.peer_id.user_id;
if (preview != null) {
preview[0] = true;
}
@ -1593,7 +1811,7 @@ public class NotificationsController extends BaseController {
if (preview != null) {
preview[0] = false;
}
if (!messageObject.isMegagroup() && messageObject.messageOwner.to_id.channel_id != 0) {
if (!messageObject.isMegagroup() && messageObject.messageOwner.peer_id.channel_id != 0) {
return LocaleController.formatString("ChannelMessageNoText", R.string.ChannelMessageNoText, messageObject.localName);
} else {
return LocaleController.formatString("NotificationMessageGroupNoText", R.string.NotificationMessageGroupNoText, messageObject.localUserName, messageObject.localName);
@ -1606,12 +1824,12 @@ public class NotificationsController extends BaseController {
int selfUsedId = getUserConfig().getClientUserId();
if (from_id == 0) {
if (messageObject.isFromUser() || messageObject.getId() < 0) {
from_id = messageObject.messageOwner.from_id;
from_id = messageObject.getFromChatId();
} else {
from_id = -chat_id;
}
} else if (from_id == selfUsedId) {
from_id = messageObject.messageOwner.from_id;
from_id = messageObject.getFromChatId();
}
if (dialog_id == 0) {
@ -1781,7 +1999,7 @@ public class NotificationsController extends BaseController {
singleUserId = messageObject.messageOwner.action.users.get(0);
}
if (singleUserId != 0) {
if (messageObject.messageOwner.to_id.channel_id != 0 && !chat.megagroup) {
if (messageObject.messageOwner.peer_id.channel_id != 0 && !chat.megagroup) {
msg = LocaleController.formatString("ChannelAddedByNotification", R.string.ChannelAddedByNotification, name, chat.title);
} else {
if (singleUserId == selfUsedId) {
@ -1821,7 +2039,7 @@ public class NotificationsController extends BaseController {
} else if (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionChatEditTitle) {
msg = LocaleController.formatString("NotificationEditedGroupName", R.string.NotificationEditedGroupName, name, messageObject.messageOwner.action.title);
} else if (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionChatEditPhoto || messageObject.messageOwner.action instanceof TLRPC.TL_messageActionChatDeletePhoto) {
if (messageObject.messageOwner.to_id.channel_id != 0 && !chat.megagroup) {
if (messageObject.messageOwner.peer_id.channel_id != 0 && !chat.megagroup) {
if (messageObject.isVideoAvatar()) {
msg = LocaleController.formatString("ChannelVideoEditNotification", R.string.ChannelVideoEditNotification, chat.title);
} else {
@ -2181,7 +2399,7 @@ public class NotificationsController extends BaseController {
}
private boolean isPersonalMessage(MessageObject messageObject) {
return messageObject.messageOwner.to_id != null && messageObject.messageOwner.to_id.chat_id == 0 && messageObject.messageOwner.to_id.channel_id == 0
return messageObject.messageOwner.peer_id != null && messageObject.messageOwner.peer_id.chat_id == 0 && messageObject.messageOwner.peer_id.channel_id == 0
&& (messageObject.messageOwner.action == null || messageObject.messageOwner.action instanceof TLRPC.TL_messageActionEmpty);
}
@ -2604,15 +2822,13 @@ public class NotificationsController extends BaseController {
boolean isChannel = false;
long override_dialog_id = dialog_id;
if (lastMessageObject.messageOwner.mentioned) {
override_dialog_id = lastMessageObject.messageOwner.from_id;
override_dialog_id = lastMessageObject.getFromChatId();
}
int mid = lastMessageObject.getId();
int chat_id = lastMessageObject.messageOwner.to_id.chat_id != 0 ? lastMessageObject.messageOwner.to_id.chat_id : lastMessageObject.messageOwner.to_id.channel_id;
int user_id = lastMessageObject.messageOwner.to_id.user_id;
if (user_id == 0) {
user_id = lastMessageObject.messageOwner.from_id;
} else if (user_id == getUserConfig().getClientUserId()) {
user_id = lastMessageObject.messageOwner.from_id;
int chat_id = lastMessageObject.messageOwner.peer_id.chat_id != 0 ? lastMessageObject.messageOwner.peer_id.chat_id : lastMessageObject.messageOwner.peer_id.channel_id;
int user_id = lastMessageObject.messageOwner.peer_id.user_id;
if (lastMessageObject.isFromUser() && (user_id == 0 || user_id == getUserConfig().getClientUserId())) {
user_id = lastMessageObject.messageOwner.from_id.user_id;
}
TLRPC.User user = getMessagesController().getUser(user_id);
@ -3255,7 +3471,9 @@ public class NotificationsController extends BaseController {
photoPath = user.photo.photo_small;
}
}
if (lowerId == selfUserId) {
if (UserObject.isReplyUser(lowerId)) {
name = LocaleController.getString("RepliesTitle", R.string.RepliesTitle);
} else if (lowerId == selfUserId) {
name = LocaleController.getString("MessageScheduledReminderNotification", R.string.MessageScheduledReminderNotification);
}
} else {
@ -3336,7 +3554,7 @@ public class NotificationsController extends BaseController {
NotificationCompat.Action wearReplyAction = null;
if ((!isChannel || isSupergroup) && canReply && !SharedConfig.isWaitingForPasscodeEnter && selfUserId != lowerId) {
if ((!isChannel || isSupergroup) && canReply && !SharedConfig.isWaitingForPasscodeEnter && selfUserId != lowerId && !UserObject.isReplyUser(lowerId)) {
Intent replyIntent = new Intent(ApplicationLoader.applicationContext, WearReplyReceiver.class);
replyIntent.putExtra("dialog_id", dialog_id);
replyIntent.putExtra("max_id", max_id);
@ -3394,10 +3612,10 @@ public class NotificationsController extends BaseController {
} else {
messagingStyle = new NotificationCompat.MessagingStyle("");
}
if (Build.VERSION.SDK_INT < 28 || lowerId < 0 && !isChannel) {
if (Build.VERSION.SDK_INT < 28 || lowerId < 0 && !isChannel || UserObject.isReplyUser(lowerId)) {
messagingStyle.setConversationTitle(conversationName);
}
messagingStyle.setGroupConversation(Build.VERSION.SDK_INT < 28 || !isChannel && lowerId < 0);
messagingStyle.setGroupConversation(Build.VERSION.SDK_INT < 28 || !isChannel && lowerId < 0 || UserObject.isReplyUser(lowerId));
StringBuilder text = new StringBuilder();
String[] senderName = new String[1];
@ -3442,7 +3660,7 @@ public class NotificationsController extends BaseController {
} else if (isChannel) {
uid = -lowerId;
} else if (lowerId < 0) {
uid = messageObject.getFromId();
uid = messageObject.getSenderId();
} else {
uid = dialog_id;
}
@ -3472,7 +3690,7 @@ public class NotificationsController extends BaseController {
if (lowerId > 0 || isChannel) {
avatar = avatalFile;
} else if (lowerId < 0) {
int fromId = messageObject.getFromId();
int fromId = messageObject.getSenderId();
TLRPC.User sender = getMessagesController().getUser(fromId);
if (sender == null) {
sender = getMessagesStorage().getUserSync(fromId);
@ -3492,7 +3710,7 @@ public class NotificationsController extends BaseController {
if (lowerId != 0) {
boolean setPhoto = false;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P && !((ActivityManager) ApplicationLoader.applicationContext.getSystemService(Context.ACTIVITY_SERVICE)).isLowRamDevice()) {
if (preview[0] && Build.VERSION.SDK_INT >= Build.VERSION_CODES.P && !((ActivityManager) ApplicationLoader.applicationContext.getSystemService(Context.ACTIVITY_SERVICE)).isLowRamDevice()) {
if (!waitingForPasscode && !messageObject.isSecretMedia() && (messageObject.type == 1 || messageObject.isSticker())) {
File attach = FileLoader.getPathToMessage(messageObject.messageOwner);
NotificationCompat.MessagingStyle.Message msg = new NotificationCompat.MessagingStyle.Message(message, ((long) messageObject.messageOwner.date) * 1000L, person);
@ -3534,7 +3752,7 @@ public class NotificationsController extends BaseController {
if (!setPhoto) {
messagingStyle.addMessage(message, ((long) messageObject.messageOwner.date) * 1000, person);
}
if (!waitingForPasscode && messageObject.isVoice()) {
if (preview[0] && !waitingForPasscode && messageObject.isVoice()) {
List<NotificationCompat.MessagingStyle.Message> messages = messagingStyle.getMessages();
if (!messages.isEmpty()) {
File f = FileLoader.getPathToMessage(messageObject.messageOwner);
@ -3564,7 +3782,7 @@ public class NotificationsController extends BaseController {
jmsg.put("text", message);
jmsg.put("date", messageObject.messageOwner.date);
if (messageObject.isFromUser() && lowerId < 0) {
TLRPC.User sender = getMessagesController().getUser(messageObject.getFromId());
TLRPC.User sender = getMessagesController().getUser(messageObject.getSenderId());
if (sender != null) {
jmsg.put("fname", sender.first_name);
jmsg.put("lname", sender.last_name);