mirror of
https://github.com/DrKLO/Telegram.git
synced 2024-12-22 14:35:03 +01:00
Bug fixes
This commit is contained in:
parent
755446e9bb
commit
e27094b963
4 changed files with 149 additions and 63 deletions
|
@ -83,7 +83,7 @@ android {
|
|||
defaultConfig {
|
||||
minSdkVersion 8
|
||||
targetSdkVersion 19
|
||||
versionCode 293
|
||||
versionCode 296
|
||||
versionName "1.7.0"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -777,10 +777,20 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
dialog.unread_count = 0;
|
||||
}
|
||||
dialogMessage.remove(dialog.top_message);
|
||||
NotificationsController.getInstance().processReadMessages(null, did, 0, Integer.MAX_VALUE);
|
||||
HashMap<Long, Integer> dialogsToUpdate = new HashMap<Long, Integer>();
|
||||
dialogsToUpdate.put(did, 0);
|
||||
NotificationsController.getInstance().processDialogsUpdateRead(dialogsToUpdate, true);
|
||||
MessagesStorage.getInstance().storageQueue.postRunnable(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Utilities.RunOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
NotificationsController.getInstance().processReadMessages(null, did, 0, Integer.MAX_VALUE);
|
||||
HashMap<Long, Integer> dialogsToUpdate = new HashMap<Long, Integer>();
|
||||
dialogsToUpdate.put(did, 0);
|
||||
NotificationsController.getInstance().processDialogsUpdateRead(dialogsToUpdate, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
MessagesStorage.getInstance().deleteDialog(did, onlyHistory);
|
||||
NotificationCenter.getInstance().postNotificationName(removeAllMessagesFromDialog, did);
|
||||
NotificationCenter.getInstance().postNotificationName(dialogsNeedReload);
|
||||
|
@ -1344,7 +1354,8 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
}
|
||||
});
|
||||
for (TLRPC.TL_dialog d : dialogs) {
|
||||
if ((int)d.id != 0) {
|
||||
int high_id = (int)(d.id >> 32);
|
||||
if ((int)d.id != 0 && high_id != 1) {
|
||||
dialogsServerOnly.add(d);
|
||||
}
|
||||
}
|
||||
|
@ -1508,7 +1519,8 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
}
|
||||
});
|
||||
for (TLRPC.TL_dialog d : dialogs) {
|
||||
if ((int)d.id != 0) {
|
||||
int high_id = (int)(d.id >> 32);
|
||||
if ((int)d.id != 0 && high_id != 1) {
|
||||
dialogsServerOnly.add(d);
|
||||
}
|
||||
}
|
||||
|
@ -1583,7 +1595,6 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
req.max_id = max_positive_id;
|
||||
req.offset = offset;
|
||||
if (offset == 0) {
|
||||
NotificationsController.getInstance().processReadMessages(null, dialog_id, 0, max_positive_id);
|
||||
MessagesStorage.getInstance().processPendingRead(dialog_id, max_positive_id, max_date, false);
|
||||
MessagesStorage.getInstance().storageQueue.postRunnable(new Runnable() {
|
||||
@Override
|
||||
|
@ -1596,6 +1607,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
dialog.unread_count = 0;
|
||||
NotificationCenter.getInstance().postNotificationName(dialogsNeedReload);
|
||||
}
|
||||
NotificationsController.getInstance().processReadMessages(null, dialog_id, 0, max_positive_id);
|
||||
HashMap<Long, Integer> dialogsToUpdate = new HashMap<Long, Integer>();
|
||||
dialogsToUpdate.put(dialog_id, 0);
|
||||
NotificationsController.getInstance().processDialogsUpdateRead(dialogsToUpdate, true);
|
||||
|
@ -1652,7 +1664,6 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
if (max_date == 0) {
|
||||
return;
|
||||
}
|
||||
NotificationsController.getInstance().processReadMessages(null, dialog_id, max_date, 0);
|
||||
TLRPC.EncryptedChat chat = encryptedChats.get(high_id);
|
||||
if (chat.auth_key != null && chat.auth_key.length > 1 && chat instanceof TLRPC.TL_encryptedChat) {
|
||||
TLRPC.TL_messages_readEncryptedHistory req = new TLRPC.TL_messages_readEncryptedHistory();
|
||||
|
@ -1676,6 +1687,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
Utilities.RunOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
NotificationsController.getInstance().processReadMessages(null, dialog_id, max_date, 0);
|
||||
TLRPC.TL_dialog dialog = dialogs_dict.get(dialog_id);
|
||||
if (dialog != null) {
|
||||
dialog.unread_count = 0;
|
||||
|
@ -3693,14 +3705,19 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
updateInterfaceWithMessages(key, value);
|
||||
}
|
||||
NotificationCenter.getInstance().postNotificationName(dialogsNeedReload);
|
||||
if (!pushMessages.isEmpty()) {
|
||||
NotificationsController.getInstance().processNewMessages(pushMessages, !(res instanceof TLRPC.TL_updates_differenceSlice));
|
||||
}
|
||||
}
|
||||
});
|
||||
MessagesStorage.getInstance().storageQueue.postRunnable(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!pushMessages.isEmpty()) {
|
||||
Utilities.RunOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
NotificationsController.getInstance().processNewMessages(pushMessages, !(res instanceof TLRPC.TL_updates_differenceSlice));
|
||||
}
|
||||
});
|
||||
}
|
||||
MessagesStorage.getInstance().startTransaction(false);
|
||||
MessagesStorage.getInstance().putMessages(res.new_messages, false, false, false);
|
||||
MessagesStorage.getInstance().putUsersAndChats(res.users, res.chats, false, false);
|
||||
|
@ -3795,13 +3812,24 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
if (printUpdate) {
|
||||
NotificationCenter.getInstance().postNotificationName(updateInterfaces, UPDATE_MASK_USER_PRINT);
|
||||
}
|
||||
if (!obj.isFromMe() && obj.isUnread()) {
|
||||
NotificationsController.getInstance().processNewMessages(objArr, true);
|
||||
}
|
||||
|
||||
updateInterfaceWithMessages(-updates.chat_id, objArr);
|
||||
NotificationCenter.getInstance().postNotificationName(dialogsNeedReload);
|
||||
}
|
||||
});
|
||||
MessagesStorage.getInstance().storageQueue.postRunnable(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Utilities.RunOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!obj.isFromMe() && obj.isUnread()) {
|
||||
NotificationsController.getInstance().processNewMessages(objArr, true);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
MessagesStorage.getInstance().putMessages(arr, false, true, false);
|
||||
} else if (MessagesStorage.lastSeqValue != updates.seq) {
|
||||
FileLog.e("tmessages", "need get diff TL_updateShortChatMessage, seq: " + MessagesStorage.lastSeqValue + " " + updates.seq);
|
||||
|
@ -3850,13 +3878,23 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
if (printUpdate) {
|
||||
NotificationCenter.getInstance().postNotificationName(updateInterfaces, UPDATE_MASK_USER_PRINT);
|
||||
}
|
||||
if (!obj.isFromMe() && obj.isUnread()) {
|
||||
NotificationsController.getInstance().processNewMessages(objArr, true);
|
||||
}
|
||||
updateInterfaceWithMessages(updates.from_id, objArr);
|
||||
NotificationCenter.getInstance().postNotificationName(dialogsNeedReload);
|
||||
}
|
||||
});
|
||||
MessagesStorage.getInstance().storageQueue.postRunnable(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Utilities.RunOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!obj.isFromMe() && obj.isUnread()) {
|
||||
NotificationsController.getInstance().processNewMessages(objArr, true);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
MessagesStorage.getInstance().putMessages(arr, false, true, false);
|
||||
} else if (MessagesStorage.lastSeqValue != updates.seq) {
|
||||
FileLog.e("tmessages", "need get diff TL_updateShortMessage, seq: " + MessagesStorage.lastSeqValue + " " + updates.seq);
|
||||
|
@ -4265,7 +4303,8 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
}
|
||||
});
|
||||
for (TLRPC.TL_dialog d : dialogs) {
|
||||
if ((int)d.id != 0) {
|
||||
int high_id = (int)(d.id >> 32);
|
||||
if ((int)d.id != 0 && high_id != 1) {
|
||||
dialogsServerOnly.add(d);
|
||||
}
|
||||
}
|
||||
|
@ -4327,6 +4366,20 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
ContactsController.getInstance().processContactsUpdates(contactsIds, usersDict);
|
||||
}
|
||||
|
||||
MessagesStorage.getInstance().storageQueue.postRunnable(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Utilities.RunOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!pushMessages.isEmpty()) {
|
||||
NotificationsController.getInstance().processNewMessages(pushMessages, true);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
if (!messagesArr.isEmpty()) {
|
||||
MessagesStorage.getInstance().putMessages(messagesArr, true, true, false);
|
||||
}
|
||||
|
@ -4415,9 +4468,6 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
}
|
||||
NotificationCenter.getInstance().postNotificationName(dialogsNeedReload);
|
||||
}
|
||||
if (!pushMessages.isEmpty()) {
|
||||
NotificationsController.getInstance().processNewMessages(pushMessages, true);
|
||||
}
|
||||
if (!markAsReadMessages.isEmpty()) {
|
||||
for (Integer id : markAsReadMessages) {
|
||||
MessageObject obj = dialogMessage.get(id);
|
||||
|
@ -4441,9 +4491,6 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
}
|
||||
}
|
||||
}
|
||||
if (!markAsReadMessages.isEmpty()) {
|
||||
NotificationsController.getInstance().processReadMessages(markAsReadMessages, 0, 0, 0);
|
||||
}
|
||||
if (!deletedMessages.isEmpty()) {
|
||||
NotificationCenter.getInstance().postNotificationName(messagesDeleted, deletedMessages);
|
||||
for (Integer id : deletedMessages) {
|
||||
|
@ -4472,21 +4519,20 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
}
|
||||
});
|
||||
|
||||
if (!markAsReadMessages.isEmpty() || !markAsReadEncrypted.isEmpty()) {
|
||||
MessagesStorage.getInstance().storageQueue.postRunnable(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Utilities.RunOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!markAsReadMessages.isEmpty()) {
|
||||
NotificationCenter.getInstance().postNotificationName(messagesReaded, markAsReadMessages);
|
||||
}
|
||||
MessagesStorage.getInstance().storageQueue.postRunnable(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Utilities.RunOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!markAsReadMessages.isEmpty()) {
|
||||
NotificationCenter.getInstance().postNotificationName(messagesReaded, markAsReadMessages);
|
||||
NotificationsController.getInstance().processReadMessages(markAsReadMessages, 0, 0, 0);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
if (!markAsReadMessages.isEmpty() || !markAsReadEncrypted.isEmpty()) {
|
||||
if (!markAsReadMessages.isEmpty()) {
|
||||
|
@ -4566,13 +4612,23 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
updateInterfaceWithMessages(uid, messages, false);
|
||||
}
|
||||
|
||||
private void updateInterfaceWithMessages(long uid, ArrayList<MessageObject> messages, boolean isBroadcast) {
|
||||
private void updateInterfaceWithMessages(final long uid, final ArrayList<MessageObject> messages, boolean isBroadcast) {
|
||||
MessageObject lastMessage = null;
|
||||
TLRPC.TL_dialog dialog = dialogs_dict.get(uid);
|
||||
|
||||
boolean isEncryptedChat = ((int)uid) == 0;
|
||||
|
||||
NotificationCenter.getInstance().postNotificationName(didReceivedNewMessages, uid, messages);
|
||||
MessagesStorage.getInstance().storageQueue.postRunnable(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Utilities.RunOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
NotificationCenter.getInstance().postNotificationName(didReceivedNewMessages, uid, messages);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
for (MessageObject message : messages) {
|
||||
if (lastMessage == null || (!isEncryptedChat && message.messageOwner.id > lastMessage.messageOwner.id || isEncryptedChat && message.messageOwner.id < lastMessage.messageOwner.id) || message.messageOwner.date > lastMessage.messageOwner.date) {
|
||||
|
@ -4623,7 +4679,8 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
}
|
||||
});
|
||||
for (TLRPC.TL_dialog d : dialogs) {
|
||||
if ((int)d.id != 0) {
|
||||
int high_id = (int)(d.id >> 32);
|
||||
if ((int)d.id != 0 && high_id != 1) {
|
||||
dialogsServerOnly.add(d);
|
||||
}
|
||||
}
|
||||
|
@ -4854,10 +4911,20 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
dialog.unread_count = 0;
|
||||
dialogMessage.remove(dialog.top_message);
|
||||
}
|
||||
NotificationsController.getInstance().processReadMessages(null, did, 0, Integer.MAX_VALUE);
|
||||
HashMap<Long, Integer> dialogsToUpdate = new HashMap<Long, Integer>();
|
||||
dialogsToUpdate.put(did, 0);
|
||||
NotificationsController.getInstance().processDialogsUpdateRead(dialogsToUpdate, true);
|
||||
MessagesStorage.getInstance().storageQueue.postRunnable(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Utilities.RunOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
NotificationsController.getInstance().processReadMessages(null, did, 0, Integer.MAX_VALUE);
|
||||
HashMap<Long, Integer> dialogsToUpdate = new HashMap<Long, Integer>();
|
||||
dialogsToUpdate.put(did, 0);
|
||||
NotificationsController.getInstance().processDialogsUpdateRead(dialogsToUpdate, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
MessagesStorage.getInstance().deleteDialog(did, true);
|
||||
NotificationCenter.getInstance().postNotificationName(removeAllMessagesFromDialog, did);
|
||||
NotificationCenter.getInstance().postNotificationName(dialogsNeedReload);
|
||||
|
@ -5145,7 +5212,8 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
}
|
||||
});
|
||||
for (TLRPC.TL_dialog d : dialogs) {
|
||||
if ((int) d.id != 0) {
|
||||
int high_id = (int)(d.id >> 32);
|
||||
if ((int)d.id != 0 && high_id != 1) {
|
||||
dialogsServerOnly.add(d);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -183,6 +183,8 @@ public class NotificationsController {
|
|||
}
|
||||
msg = LocaleController.formatString("NotificationGroupKickMember", R.string.NotificationGroupKickMember, Utilities.formatName(user.first_name, user.last_name), chat.title, Utilities.formatName(u2.first_name, u2.last_name));
|
||||
}
|
||||
} else if (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionChatCreate) {
|
||||
msg = messageObject.messageText.toString();
|
||||
}
|
||||
} else {
|
||||
if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaEmpty) {
|
||||
|
@ -508,9 +510,6 @@ public class NotificationsController {
|
|||
if (oldCount != popupMessages.size()) {
|
||||
NotificationCenter.getInstance().postNotificationName(pushMessagesUpdated);
|
||||
}
|
||||
// if (readMessages != null || oldCount2 != pushMessages.size() || readMessages == null && dialog_id == 0) {
|
||||
// showOrUpdateNotification(notifyCheck);
|
||||
// }
|
||||
}
|
||||
|
||||
public void processNewMessages(ArrayList<MessageObject> messageObjects, boolean isLast) {
|
||||
|
@ -585,6 +584,15 @@ public class NotificationsController {
|
|||
}
|
||||
if (newCount == 0) {
|
||||
pushDialogs.remove(dialog_id);
|
||||
for (int a = 0; a < pushMessages.size(); a++) {
|
||||
MessageObject messageObject = pushMessages.get(a);
|
||||
if (messageObject.getDialogId() == dialog_id) {
|
||||
pushMessages.remove(a);
|
||||
a--;
|
||||
pushMessagesDict.remove(messageObject.messageOwner.id);
|
||||
popupMessages.remove(messageObject);
|
||||
}
|
||||
}
|
||||
} else if (canAddValue) {
|
||||
total_unread_count += newCount;
|
||||
pushDialogs.put(dialog_id, newCount);
|
||||
|
@ -611,7 +619,6 @@ public class NotificationsController {
|
|||
pushDialogs.clear();
|
||||
total_unread_count = 0;
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Context.MODE_PRIVATE);
|
||||
String dialogsToLoad = "";
|
||||
for (HashMap.Entry<Long, Integer> entry : dialogs.entrySet()) {
|
||||
long dialog_id = entry.getKey();
|
||||
int notify_override = preferences.getInt("notify2_" + dialog_id, 0);
|
||||
|
@ -619,10 +626,6 @@ public class NotificationsController {
|
|||
if (!(notify_override == 2 || (!preferences.getBoolean("EnableAll", true) || isChat && !preferences.getBoolean("EnableGroup", true)) && notify_override == 0)) {
|
||||
pushDialogs.put(dialog_id, entry.getValue());
|
||||
total_unread_count += entry.getValue();
|
||||
if (dialogsToLoad.length() != 0) {
|
||||
dialogsToLoad += ",";
|
||||
}
|
||||
dialogsToLoad += "" + dialog_id;
|
||||
}
|
||||
}
|
||||
if (total_unread_count == 0) {
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
package org.telegram.ui;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
|
@ -149,7 +150,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
private int unread_to_load = 0;
|
||||
private int first_unread_id = 0;
|
||||
private int last_unread_id = 0;
|
||||
private boolean unread_end_reached = true;
|
||||
private boolean unread_end_reached = false;
|
||||
private boolean loadingForward = false;
|
||||
private MessageObject unreadMessageObject = null;
|
||||
|
||||
|
@ -617,6 +618,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
View bottomOverlayChat = fragmentView.findViewById(R.id.bottom_overlay_chat);
|
||||
progressView = fragmentView.findViewById(R.id.progressLayout);
|
||||
pagedownButton = fragmentView.findViewById(R.id.pagedown_button);
|
||||
pagedownButton.setVisibility(View.GONE);
|
||||
|
||||
View progressViewInner = progressView.findViewById(R.id.progressLayoutInner);
|
||||
|
||||
|
@ -743,8 +745,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
if (firstVisibleItem + visibleItemCount == totalItemCount && unread_end_reached) {
|
||||
showPagedownButton(false, true);
|
||||
}
|
||||
} else {
|
||||
showPagedownButton(false, false);
|
||||
}
|
||||
for (int a = 0; a < visibleItemCount; a++) {
|
||||
View view = absListView.getChildAt(a);
|
||||
|
@ -873,7 +873,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
}
|
||||
if (show) {
|
||||
if (pagedownButton.getVisibility() == View.GONE) {
|
||||
if (android.os.Build.VERSION.SDK_INT >= 16 && animated) {
|
||||
if (android.os.Build.VERSION.SDK_INT >= 12 && animated) {
|
||||
pagedownButton.setVisibility(View.VISIBLE);
|
||||
pagedownButton.setAlpha(0);
|
||||
pagedownButton.animate().alpha(1).setDuration(200).start();
|
||||
|
@ -883,13 +883,28 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
}
|
||||
} else {
|
||||
if (pagedownButton.getVisibility() == View.VISIBLE) {
|
||||
if (android.os.Build.VERSION.SDK_INT >= 16 && animated) {
|
||||
pagedownButton.animate().alpha(0).withEndAction(new Runnable() {
|
||||
if (android.os.Build.VERSION.SDK_INT >= 12 && animated) {
|
||||
pagedownButton.animate().alpha(0).setDuration(200).setListener(new Animator.AnimatorListener() {
|
||||
@Override
|
||||
public void run() {
|
||||
public void onAnimationStart(Animator animation) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
pagedownButton.setVisibility(View.GONE);
|
||||
}
|
||||
}).setDuration(200).start();
|
||||
|
||||
@Override
|
||||
public void onAnimationCancel(Animator animation) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationRepeat(Animator animation) {
|
||||
|
||||
}
|
||||
}).start();
|
||||
} else {
|
||||
pagedownButton.setVisibility(View.GONE);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue