Update to 3.7.0

This commit is contained in:
DrKLO 2016-03-16 15:26:32 +03:00
parent 6154c891bd
commit a7513b3ba1
145 changed files with 12568 additions and 5776 deletions

View file

@ -61,7 +61,7 @@ public class NotificationsController {
private int wearNotificationId = 10000;
private int autoNotificationId = 20000;
public ArrayList<MessageObject> popupMessages = new ArrayList<>();
private long openned_dialog_id = 0;
private long opened_dialog_id = 0;
private int total_unread_count = 0;
private int personal_count = 0;
private boolean notifyCheck = false;
@ -147,7 +147,7 @@ public class NotificationsController {
notificationsQueue.postRunnable(new Runnable() {
@Override
public void run() {
openned_dialog_id = 0;
opened_dialog_id = 0;
total_unread_count = 0;
personal_count = 0;
pushMessages.clear();
@ -178,11 +178,11 @@ public class NotificationsController {
inChatSoundEnabled = value;
}
public void setOpennedDialogId(final long dialog_id) {
public void setOpenedDialogId(final long dialog_id) {
notificationsQueue.postRunnable(new Runnable() {
@Override
public void run() {
openned_dialog_id = dialog_id;
opened_dialog_id = dialog_id;
}
});
}
@ -393,7 +393,7 @@ public class NotificationsController {
}
long dialog_id = messageObject.getDialogId();
long original_dialog_id = dialog_id;
if (dialog_id == openned_dialog_id && ApplicationLoader.isScreenOn) {
if (dialog_id == opened_dialog_id && ApplicationLoader.isScreenOn) {
playInChatSound();
continue;
}
@ -406,7 +406,7 @@ public class NotificationsController {
added = true;
Boolean value = settingsCache.get(dialog_id);
boolean isChat = (int)dialog_id < 0;
boolean isChat = (int) dialog_id < 0;
popup = (int)dialog_id == 0 ? 0 : preferences.getInt(isChat ? "popupGroup" : "popupAll", 0);
if (value == null) {
int notifyOverride = getNotifyOverride(preferences, dialog_id);
@ -582,7 +582,7 @@ public class NotificationsController {
value = !(notifyOverride == 2 || (!preferences.getBoolean("EnableAll", true) || ((int) dialog_id < 0) && !preferences.getBoolean("EnableGroup", true)) && notifyOverride == 0);
settingsCache.put(dialog_id, value);
}
if (!value || dialog_id == openned_dialog_id && ApplicationLoader.isScreenOn) {
if (!value || dialog_id == opened_dialog_id && ApplicationLoader.isScreenOn) {
continue;
}
pushMessagesDict.put(mid, messageObject);
@ -757,6 +757,8 @@ public class NotificationsController {
msg = LocaleController.formatString("NotificationMessageVideo", R.string.NotificationMessageVideo, name);
} else if (messageObject.isVoice()) {
msg = LocaleController.formatString("NotificationMessageAudio", R.string.NotificationMessageAudio, name);
} else if (messageObject.isMusic()) {
msg = LocaleController.formatString("NotificationMessageMusic", R.string.NotificationMessageMusic, name);
} else if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaContact) {
msg = LocaleController.formatString("NotificationMessageContact", R.string.NotificationMessageContact, name);
} else if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaGeo || messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaVenue) {
@ -801,7 +803,11 @@ public class NotificationsController {
return null;
}
if (from_id == u2.id) {
msg = LocaleController.formatString("NotificationGroupAddSelf", R.string.NotificationGroupAddSelf, name, chat.title);
if (messageObject.isMegagroup()) {
msg = LocaleController.formatString("NotificationGroupAddSelfMega", R.string.NotificationGroupAddSelfMega, name, chat.title);
} else {
msg = LocaleController.formatString("NotificationGroupAddSelf", R.string.NotificationGroupAddSelf, name, chat.title);
}
} else {
msg = LocaleController.formatString("NotificationGroupAddMember", R.string.NotificationGroupAddMember, name, chat.title, UserObject.getUserName(u2));
}
@ -851,10 +857,91 @@ public class NotificationsController {
msg = LocaleController.formatString("ActionMigrateFromGroupNotify", R.string.ActionMigrateFromGroupNotify, chat.title);
} else if (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionChannelMigrateFrom) {
msg = LocaleController.formatString("ActionMigrateFromGroupNotify", R.string.ActionMigrateFromGroupNotify, messageObject.messageOwner.action.title);
} else if (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionPinMessage) {
if (messageObject.replyMessageObject == null) {
if (!ChatObject.isChannel(chat) || chat.megagroup) {
msg = LocaleController.formatString("NotificationActionPinnedNoText", R.string.NotificationActionPinnedNoText, name, chat.title);
} else {
msg = LocaleController.formatString("NotificationActionPinnedNoTextChannel", R.string.NotificationActionPinnedNoTextChannel, name, chat.title);
}
} else {
MessageObject object = messageObject.replyMessageObject;
if (object.isMusic()) {
if (!ChatObject.isChannel(chat) || chat.megagroup) {
msg = LocaleController.formatString("NotificationActionPinnedMusic", R.string.NotificationActionPinnedMusic, name, chat.title);
} else {
msg = LocaleController.formatString("NotificationActionPinnedMusicChannel", R.string.NotificationActionPinnedMusicChannel, chat.title);
}
} else if (object.isVideo()) {
if (!ChatObject.isChannel(chat) || chat.megagroup) {
msg = LocaleController.formatString("NotificationActionPinnedVideo", R.string.NotificationActionPinnedVideo, name, chat.title);
} else {
msg = LocaleController.formatString("NotificationActionPinnedVideoChannel", R.string.NotificationActionPinnedVideoChannel, chat.title);
}
} else if (object.isGif()) {
if (!ChatObject.isChannel(chat) || chat.megagroup) {
msg = LocaleController.formatString("NotificationActionPinnedGif", R.string.NotificationActionPinnedGif, name, chat.title);
} else {
msg = LocaleController.formatString("NotificationActionPinnedGifChannel", R.string.NotificationActionPinnedGifChannel, chat.title);
}
} else if (object.isVoice()) {
if (!ChatObject.isChannel(chat) || chat.megagroup) {
msg = LocaleController.formatString("NotificationActionPinnedVoice", R.string.NotificationActionPinnedVoice, name, chat.title);
} else {
msg = LocaleController.formatString("NotificationActionPinnedVoiceChannel", R.string.NotificationActionPinnedVoiceChannel, chat.title);
}
} else if (object.isSticker()) {
if (!ChatObject.isChannel(chat) || chat.megagroup) {
msg = LocaleController.formatString("NotificationActionPinnedSticker", R.string.NotificationActionPinnedSticker, name, chat.title);
} else {
msg = LocaleController.formatString("NotificationActionPinnedStickerChannel", R.string.NotificationActionPinnedStickerChannel, chat.title);
}
} else if (object.messageOwner.media instanceof TLRPC.TL_messageMediaDocument) {
if (!ChatObject.isChannel(chat) || chat.megagroup) {
msg = LocaleController.formatString("NotificationActionPinnedFile", R.string.NotificationActionPinnedFile, name, chat.title);
} else {
msg = LocaleController.formatString("NotificationActionPinnedFileChannel", R.string.NotificationActionPinnedFileChannel, chat.title);
}
} else if (object.messageOwner.media instanceof TLRPC.TL_messageMediaGeo) {
if (!ChatObject.isChannel(chat) || chat.megagroup) {
msg = LocaleController.formatString("NotificationActionPinnedGeo", R.string.NotificationActionPinnedGeo, name, chat.title);
} else {
msg = LocaleController.formatString("NotificationActionPinnedGeoChannel", R.string.NotificationActionPinnedGeoChannel, chat.title);
}
} else if (object.messageOwner.media instanceof TLRPC.TL_messageMediaContact) {
if (!ChatObject.isChannel(chat) || chat.megagroup) {
msg = LocaleController.formatString("NotificationActionPinnedContact", R.string.NotificationActionPinnedContact, name, chat.title);
} else {
msg = LocaleController.formatString("NotificationActionPinnedContactChannel", R.string.NotificationActionPinnedContactChannel, chat.title);
}
} else if (object.messageOwner.media instanceof TLRPC.TL_messageMediaPhoto) {
if (!ChatObject.isChannel(chat) || chat.megagroup) {
msg = LocaleController.formatString("NotificationActionPinnedPhoto", R.string.NotificationActionPinnedPhoto, name, chat.title);
} else {
msg = LocaleController.formatString("NotificationActionPinnedPhotoChannel", R.string.NotificationActionPinnedPhotoChannel, chat.title);
}
} else if (object.messageText != null && object.messageText.length() > 0) {
CharSequence message = object.messageText;
if (message.length() > 20) {
message = message.subSequence(0, 20) + "...";
}
if (!ChatObject.isChannel(chat) || chat.megagroup) {
msg = LocaleController.formatString("NotificationActionPinnedText", R.string.NotificationActionPinnedText, name, message, chat.title);
} else {
msg = LocaleController.formatString("NotificationActionPinnedTextChannel", R.string.NotificationActionPinnedTextChannel, chat.title, message);
}
} else {
if (!ChatObject.isChannel(chat) || chat.megagroup) {
msg = LocaleController.formatString("NotificationActionPinnedNoText", R.string.NotificationActionPinnedNoText, name, chat.title);
} else {
msg = LocaleController.formatString("NotificationActionPinnedNoTextChannel", R.string.NotificationActionPinnedNoTextChannel, chat.title);
}
}
}
}
} else {
if (ChatObject.isChannel(chat) && !chat.megagroup) {
if (from_id < 0) {
if (messageObject.isImportant()) {
if (messageObject.isMediaEmpty()) {
if (!shortMessage && messageObject.messageOwner.message != null && messageObject.messageOwner.message.length() != 0) {
msg = LocaleController.formatString("NotificationMessageGroupText", R.string.NotificationMessageGroupText, name, chat.title, messageObject.messageOwner.message);
@ -867,6 +954,8 @@ public class NotificationsController {
msg = LocaleController.formatString("ChannelMessageVideo", R.string.ChannelMessageVideo, name, chat.title);
} else if (messageObject.isVoice()) {
msg = LocaleController.formatString("ChannelMessageAudio", R.string.ChannelMessageAudio, name, chat.title);
} else if (messageObject.isMusic()) {
msg = LocaleController.formatString("ChannelMessageMusic", R.string.ChannelMessageMusic, name, chat.title);
} else if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaContact) {
msg = LocaleController.formatString("ChannelMessageContact", R.string.ChannelMessageContact, name, chat.title);
} else if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaGeo || messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaVenue) {
@ -893,6 +982,8 @@ public class NotificationsController {
msg = LocaleController.formatString("ChannelMessageGroupVideo", R.string.ChannelMessageGroupVideo, name, chat.title);
} else if (messageObject.isVoice()) {
msg = LocaleController.formatString("ChannelMessageGroupAudio", R.string.ChannelMessageGroupAudio, name, chat.title);
} else if (messageObject.isMusic()) {
msg = LocaleController.formatString("ChannelMessageGroupMusic", R.string.ChannelMessageGroupMusic, name, chat.title);
} else if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaContact) {
msg = LocaleController.formatString("ChannelMessageGroupContact", R.string.ChannelMessageGroupContact, name, chat.title);
} else if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaGeo || messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaVenue) {
@ -920,6 +1011,8 @@ public class NotificationsController {
msg = LocaleController.formatString("NotificationMessageGroupVideo", R.string.NotificationMessageGroupVideo, name, chat.title);
} else if (messageObject.isVoice()) {
msg = LocaleController.formatString("NotificationMessageGroupAudio", R.string.NotificationMessageGroupAudio, name, chat.title);
} else if (messageObject.isMusic()) {
msg = LocaleController.formatString("NotificationMessageGroupMusic", R.string.NotificationMessageGroupMusic, name, chat.title);
} else if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaContact) {
msg = LocaleController.formatString("NotificationMessageGroupContact", R.string.NotificationMessageGroupContact, name, chat.title);
} else if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaGeo || messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaVenue) {
@ -1073,7 +1166,7 @@ public class NotificationsController {
try {
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Context.MODE_PRIVATE);
int notifyOverride = getNotifyOverride(preferences, openned_dialog_id);
int notifyOverride = getNotifyOverride(preferences, opened_dialog_id);
if (notifyOverride == 2) {
return;
}
@ -1405,12 +1498,6 @@ public class NotificationsController {
}
}
if (silent == 1) {
FileLog.e("tmessages", "don't notify " + lastMessage);
} else {
FileLog.e("tmessages", "notify" + lastMessage);
}
if (!notifyAboutLast || silent == 1) {
mBuilder.setPriority(NotificationCompat.PRIORITY_LOW);
} else {