Update to 5.13.0 (1818)

This commit is contained in:
DrKLO 2019-12-31 16:08:08 +03:00
parent 28eb8dfd0e
commit f41b228a11
2574 changed files with 1023378 additions and 62330 deletions

View file

@ -323,7 +323,7 @@ public class NotificationsController extends BaseController {
}
popupArray.add(0, messageObject);
}
if (!popupArray.isEmpty() && !AndroidUtilities.needShowPasscode(false)) {
if (!popupArray.isEmpty() && !AndroidUtilities.needShowPasscode(false) && !SharedConfig.isWaitingForPasscodeEnter) {
AndroidUtilities.runOnUIThread(() -> {
popupReplyMessages = popupArray;
Intent popupIntent = new Intent(ApplicationLoader.applicationContext, PopupNotificationActivity.class);
@ -345,18 +345,34 @@ public class NotificationsController extends BaseController {
SharedPreferences preferences = getAccountInstance().getNotificationsSettings();
for (int a = 0; a < deletedMessages.size(); a++) {
int key = deletedMessages.keyAt(a);
long dialog_id = -key;
ArrayList<Integer> mids = deletedMessages.get(key);
Integer currentCount = pushDialogs.get(dialog_id);
if (currentCount == null) {
currentCount = 0;
}
Integer newCount = currentCount;
for (int b = 0; b < mids.size(); b++) {
long mid = mids.get(b);
mid |= ((long) key) << 32;
if (key != 0) {
mid |= ((long) key) << 32;
}
MessageObject messageObject = pushMessagesDict.get(mid);
if (messageObject != null) {
long dialogId = messageObject.getDialogId();
Integer currentCount = pushDialogs.get(dialogId);
if (currentCount == null) {
currentCount = 0;
}
Integer newCount = currentCount - 1;
if (newCount <= 0) {
newCount = 0;
smartNotificationsDialogs.remove(dialogId);
}
if (!newCount.equals(currentCount)) {
total_unread_count -= currentCount;
total_unread_count += newCount;
pushDialogs.put(dialogId, newCount);
}
if (newCount == 0) {
pushDialogs.remove(dialogId);
pushDialogsOverrideMention.remove(dialogId);
}
pushMessagesDict.remove(mid);
delayedPushMessages.remove(messageObject);
pushMessages.remove(messageObject);
@ -364,22 +380,8 @@ public class NotificationsController extends BaseController {
personal_count--;
}
popupArrayRemove.add(messageObject);
newCount--;
}
}
if (newCount <= 0) {
newCount = 0;
smartNotificationsDialogs.remove(dialog_id);
}
if (!newCount.equals(currentCount)) {
total_unread_count -= currentCount;
total_unread_count += newCount;
pushDialogs.put(dialog_id, newCount);
}
if (newCount == 0) {
pushDialogs.remove(dialog_id);
pushDialogsOverrideMention.remove(dialog_id);
}
}
if (!popupArrayRemove.isEmpty()) {
AndroidUtilities.runOnUIThread(() -> {
@ -705,11 +707,11 @@ public class NotificationsController extends BaseController {
notifyCheck = isLast;
}
if (!popupArrayAdd.isEmpty() && !AndroidUtilities.needShowPasscode(false)) {
if (!popupArrayAdd.isEmpty() && !AndroidUtilities.needShowPasscode(false) && !SharedConfig.isWaitingForPasscodeEnter) {
final int popupFinal = popup;
AndroidUtilities.runOnUIThread(() -> {
popupMessages.addAll(0, popupArrayAdd);
if (ApplicationLoader.mainInterfacePaused || !ApplicationLoader.isScreenOn && !SharedConfig.isWaitingForPasscodeEnter) {
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);
@ -1097,7 +1099,7 @@ public class NotificationsController extends BaseController {
private String getShortStringForMessage(MessageObject messageObject, String[] userName, boolean[] preview) {
if (AndroidUtilities.needShowPasscode(false) || SharedConfig.isWaitingForPasscodeEnter) {
return LocaleController.getString("YouHaveNewMessage", R.string.YouHaveNewMessage);
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;
@ -1196,7 +1198,7 @@ public class NotificationsController extends BaseController {
String msg = null;
if ((int) dialog_id == 0) {
userName[0] = null;
return LocaleController.getString("YouHaveNewMessage", R.string.YouHaveNewMessage);
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)))) {
@ -2352,6 +2354,7 @@ public class NotificationsController extends BaseController {
}
}*/
boolean secretChat = (int) dialogId == 0;
for (int a = 0; a < vibrationPattern.length; a++) {
newSettings.append(vibrationPattern[a]);
}
@ -2360,6 +2363,9 @@ public class NotificationsController extends BaseController {
newSettings.append(sound.toString());
}
newSettings.append(importance);
if (secretChat) {
newSettings.append("secret");
}
newSettingsHash = Utilities.MD5(newSettings.toString());
if (channelId != null && !settings.equals(newSettingsHash)) {
@ -2372,7 +2378,7 @@ public class NotificationsController extends BaseController {
}
if (channelId == null) {
channelId = currentAccount + "channel" + dialogId + "_" + Utilities.random.nextLong();
NotificationChannel notificationChannel = new NotificationChannel(channelId, name, importance);
NotificationChannel notificationChannel = new NotificationChannel(channelId, secretChat ? LocaleController.getString("SecretChatName", R.string.SecretChatName) : name, importance);
if (ledColor != 0) {
notificationChannel.enableLights(true);
notificationChannel.setLightColor(ledColor);
@ -2659,8 +2665,17 @@ public class NotificationsController extends BaseController {
} else {
chatName = UserObject.getUserName(user);
}
if ((int) dialog_id == 0 || pushDialogs.size() > 1 || AndroidUtilities.needShowPasscode(false) || SharedConfig.isWaitingForPasscodeEnter) {
name = LocaleController.getString("AppName", R.string.AppName);
boolean passcode = AndroidUtilities.needShowPasscode(false) || SharedConfig.isWaitingForPasscodeEnter;
if ((int) dialog_id == 0 || pushDialogs.size() > 1 || passcode) {
if (passcode) {
if (chat_id != 0) {
name = LocaleController.getString("NotificationHiddenChatName", R.string.NotificationHiddenChatName);
} else {
name = LocaleController.getString("NotificationHiddenName", R.string.NotificationHiddenName);
}
} else {
name = LocaleController.getString("AppName", R.string.AppName);
}
replace = false;
} else {
name = chatName;
@ -2978,6 +2993,7 @@ public class NotificationsController extends BaseController {
}
int selfUserId = getUserConfig().getClientUserId();
boolean waitingForPasscode = AndroidUtilities.needShowPasscode(false) || SharedConfig.isWaitingForPasscodeEnter;
for (int b = 0, size = sortedDialogs.size(); b < size; b++) {
long dialog_id = sortedDialogs.get(b);
@ -3086,8 +3102,12 @@ public class NotificationsController extends BaseController {
serializedChat = null;
}
if (AndroidUtilities.needShowPasscode(false) || SharedConfig.isWaitingForPasscodeEnter) {
name = LocaleController.getString("AppName", R.string.AppName);
if (waitingForPasscode) {
if (lowerId < 0) {
name = LocaleController.getString("NotificationHiddenChatName", R.string.NotificationHiddenChatName);
} else {
name = LocaleController.getString("NotificationHiddenName", R.string.NotificationHiddenName);
}
photoPath = null;
canReply = false;
}
@ -3148,7 +3168,31 @@ public class NotificationsController extends BaseController {
conversationName = String.format("%1$s (%2$d)", name, n);
}
NotificationCompat.MessagingStyle messagingStyle = new NotificationCompat.MessagingStyle("");
Person selfPerson = personCache.get(selfUserId);
if (Build.VERSION.SDK_INT >= 28 && selfPerson == null) {
TLRPC.User sender = getMessagesController().getUser(selfUserId);
if (sender == null) {
sender = getUserConfig().getCurrentUser();
}
try {
if (sender != null && sender.photo != null && sender.photo.photo_small != null && sender.photo.photo_small.volume_id != 0 && sender.photo.photo_small.local_id != 0) {
Person.Builder personBuilder = new Person.Builder().setName(LocaleController.getString("FromYou", R.string.FromYou));
File avatar = FileLoader.getPathToAttach(sender.photo.photo_small, true);
loadRoundAvatar(avatar, personBuilder);
selfPerson = personBuilder.build();
personCache.put(selfUserId, selfPerson);
}
} catch (Throwable e) {
FileLog.e(e);
}
}
NotificationCompat.MessagingStyle messagingStyle;
if (selfPerson != null) {
messagingStyle = new NotificationCompat.MessagingStyle(selfPerson);
} else {
messagingStyle = new NotificationCompat.MessagingStyle("");
}
if (Build.VERSION.SDK_INT < 28 || lowerId < 0 && !isChannel) {
messagingStyle.setConversationTitle(conversationName);
}
@ -3191,8 +3235,6 @@ public class NotificationsController extends BaseController {
}
}
//unreadConvBuilder.addMessage(message);
long uid;
if (lowerId > 0) {
uid = lowerId;
@ -3204,8 +3246,26 @@ public class NotificationsController extends BaseController {
uid = dialog_id;
}
Person person = personCache.get(uid);
if (person == null) {
Person.Builder personBuilder = new Person.Builder().setName(senderName[0] == null ? "" : senderName[0]);
String personName = "";
if (senderName[0] == null) {
if (waitingForPasscode) {
if (lowerId < 0) {
if (isChannel) {
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.O_MR1) {
personName = LocaleController.getString("NotificationHiddenChatName", R.string.NotificationHiddenChatName);
}
} else {
personName = LocaleController.getString("NotificationHiddenChatUserName", R.string.NotificationHiddenChatUserName);
}
} else if (Build.VERSION.SDK_INT > Build.VERSION_CODES.O_MR1) {
personName = LocaleController.getString("NotificationHiddenName", R.string.NotificationHiddenName);
}
}
} else {
personName = senderName[0];
}
if (person == null || !TextUtils.equals(person.getName(), personName)) {
Person.Builder personBuilder = new Person.Builder().setName(personName);
if (preview[0] && lowerId != 0 && Build.VERSION.SDK_INT >= 28) {
File avatar = null;
if (lowerId > 0 || isChannel) {
@ -3230,8 +3290,9 @@ 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 (!messageObject.isSecretMedia() && (messageObject.type == 1 || messageObject.isSticker())) {
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);
String mimeType = messageObject.isSticker() ? "image/webp" : "image/jpeg";
@ -3259,16 +3320,14 @@ public class NotificationsController extends BaseController {
if (!TextUtils.isEmpty(messageObject.caption)) {
messagingStyle.addMessage(messageObject.caption, ((long) messageObject.messageOwner.date) * 1000, person);
}
} else {
messagingStyle.addMessage(message, ((long) messageObject.messageOwner.date) * 1000, person);
setPhoto = true;
}
} else {
messagingStyle.addMessage(message, ((long) messageObject.messageOwner.date) * 1000, person);
}
} else {
}
if (!setPhoto) {
messagingStyle.addMessage(message, ((long) messageObject.messageOwner.date) * 1000, person);
}
if (messageObject.isVoice()) {
if (!waitingForPasscode && messageObject.isVoice()) {
List<NotificationCompat.MessagingStyle.Message> messages = messagingStyle.getMessages();
if (!messages.isEmpty()) {
File f = FileLoader.getPathToMessage(messageObject.messageOwner);
@ -3391,7 +3450,7 @@ public class NotificationsController extends BaseController {
dismissIntent.putExtra("messageDate", max_date);
dismissIntent.putExtra("dialogId", dialog_id);
dismissIntent.putExtra("currentAccount", currentAccount);
builder.setDeleteIntent(PendingIntent.getBroadcast(ApplicationLoader.applicationContext, 1, dismissIntent, PendingIntent.FLAG_UPDATE_CURRENT));
builder.setDeleteIntent(PendingIntent.getBroadcast(ApplicationLoader.applicationContext, internalId, dismissIntent, PendingIntent.FLAG_UPDATE_CURRENT));
if (useSummaryNotification) {
builder.setGroup(notificationGroup);
@ -3401,8 +3460,10 @@ public class NotificationsController extends BaseController {
if (wearReplyAction != null) {
builder.addAction(wearReplyAction);
}
builder.addAction(readAction);
if (pushDialogs.size() == 1 && !TextUtils.isEmpty(summary)) {
if (!waitingForPasscode) {
builder.addAction(readAction);
}
if (sortedDialogs.size() == 1 && !TextUtils.isEmpty(summary)) {
builder.setSubText(summary);
}
if (lowerId == 0) {