Changed broadcast lists ids

old broadcast lists will be broken
This commit is contained in:
DrKLO 2014-07-27 14:53:00 +04:00
parent 2eb84e23f6
commit 755446e9bb
8 changed files with 204 additions and 184 deletions

View file

@ -83,7 +83,7 @@ android {
defaultConfig { defaultConfig {
minSdkVersion 8 minSdkVersion 8
targetSdkVersion 19 targetSdkVersion 19
versionCode 292 versionCode 293
versionName "1.7.0" versionName "1.7.0"
} }
} }

View file

@ -221,4 +221,8 @@ public class AndroidUtilities {
FileLog.e("tmessages", e); FileLog.e("tmessages", e);
} }
} }
public static long makeBroadcastId(int id) {
return 0x0000000100000000L | ((long)id & 0x00000000FFFFFFFFL);
}
} }

View file

@ -765,6 +765,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
TLRPC.TL_dialog dialog = dialogs_dict.get(did); TLRPC.TL_dialog dialog = dialogs_dict.get(did);
if (dialog != null) { if (dialog != null) {
int lower_part = (int)did; int lower_part = (int)did;
int high_id = (int)(did >> 32);
if (offset == 0) { if (offset == 0) {
if (!onlyHistory) { if (!onlyHistory) {
@ -785,6 +786,10 @@ public class MessagesController implements NotificationCenter.NotificationCenter
NotificationCenter.getInstance().postNotificationName(dialogsNeedReload); NotificationCenter.getInstance().postNotificationName(dialogsNeedReload);
} }
if (high_id == 1) {
return;
}
if (lower_part != 0) { if (lower_part != 0) {
TLRPC.TL_messages_deleteHistory req = new TLRPC.TL_messages_deleteHistory(); TLRPC.TL_messages_deleteHistory req = new TLRPC.TL_messages_deleteHistory();
req.offset = offset; req.offset = offset;
@ -831,14 +836,11 @@ public class MessagesController implements NotificationCenter.NotificationCenter
} }
}); });
} else { } else {
int high_id = (int)(did >> 32); if (onlyHistory) {
if (high_id > 0) { TLRPC.EncryptedChat encryptedChat = encryptedChats.get(high_id);
if (onlyHistory) { sendClearHistoryMessage(encryptedChat);
TLRPC.EncryptedChat encryptedChat = encryptedChats.get(high_id); } else {
sendClearHistoryMessage(encryptedChat); declineSecretChat(high_id);
} else {
declineSecretChat(high_id);
}
} }
} }
} }
@ -1046,7 +1048,12 @@ public class MessagesController implements NotificationCenter.NotificationCenter
return; return;
} }
int lower_part = (int)dialog_id; int lower_part = (int)dialog_id;
int high_id = (int)(dialog_id >> 32);
if (lower_part != 0) { if (lower_part != 0) {
if (high_id == 1) {
return;
}
TLRPC.TL_messages_setTyping req = new TLRPC.TL_messages_setTyping(); TLRPC.TL_messages_setTyping req = new TLRPC.TL_messages_setTyping();
if (lower_part < 0) { if (lower_part < 0) {
req.peer = new TLRPC.TL_inputPeerChat(); req.peer = new TLRPC.TL_inputPeerChat();
@ -1075,23 +1082,20 @@ public class MessagesController implements NotificationCenter.NotificationCenter
}, true, RPCRequest.RPCRequestClassGeneric | RPCRequest.RPCRequestClassFailOnServerErrors); }, true, RPCRequest.RPCRequestClassGeneric | RPCRequest.RPCRequestClassFailOnServerErrors);
ConnectionsManager.getInstance().bindRequestToGuid(reqId, classGuid); ConnectionsManager.getInstance().bindRequestToGuid(reqId, classGuid);
} else { } else {
int high_id = (int)(dialog_id >> 32); TLRPC.EncryptedChat chat = encryptedChats.get(high_id);
if (high_id > 0) { if (chat.auth_key != null && chat.auth_key.length > 1 && chat instanceof TLRPC.TL_encryptedChat) {
TLRPC.EncryptedChat chat = encryptedChats.get(high_id); TLRPC.TL_messages_setEncryptedTyping req = new TLRPC.TL_messages_setEncryptedTyping();
if (chat.auth_key != null && chat.auth_key.length > 1 && chat instanceof TLRPC.TL_encryptedChat) { req.peer = new TLRPC.TL_inputEncryptedChat();
TLRPC.TL_messages_setEncryptedTyping req = new TLRPC.TL_messages_setEncryptedTyping(); req.peer.chat_id = chat.id;
req.peer = new TLRPC.TL_inputEncryptedChat(); req.peer.access_hash = chat.access_hash;
req.peer.chat_id = chat.id; req.typing = true;
req.peer.access_hash = chat.access_hash; long reqId = ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() {
req.typing = true; @Override
long reqId = ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() { public void run(TLObject response, TLRPC.TL_error error) {
@Override
public void run(TLObject response, TLRPC.TL_error error) {
} }
}, true, RPCRequest.RPCRequestClassGeneric | RPCRequest.RPCRequestClassFailOnServerErrors); }, true, RPCRequest.RPCRequestClassGeneric | RPCRequest.RPCRequestClassFailOnServerErrors);
ConnectionsManager.getInstance().bindRequestToGuid(reqId, classGuid); ConnectionsManager.getInstance().bindRequestToGuid(reqId, classGuid);
}
} }
} }
} }
@ -1555,8 +1559,10 @@ public class MessagesController implements NotificationCenter.NotificationCenter
public void markDialogAsRead(final long dialog_id, final int max_id, final int max_positive_id, final int offset, final int max_date, final boolean was) { public void markDialogAsRead(final long dialog_id, final int max_id, final int max_positive_id, final int offset, final int max_date, final boolean was) {
int lower_part = (int)dialog_id; int lower_part = (int)dialog_id;
int high_id = (int)(dialog_id >> 32);
if (lower_part != 0) { if (lower_part != 0) {
if (max_id == 0 && offset == 0) { if (max_id == 0 && offset == 0 || high_id == 1) {
return; return;
} }
TLRPC.TL_messages_readHistory req = new TLRPC.TL_messages_readHistory(); TLRPC.TL_messages_readHistory req = new TLRPC.TL_messages_readHistory();
@ -1646,49 +1652,46 @@ public class MessagesController implements NotificationCenter.NotificationCenter
if (max_date == 0) { if (max_date == 0) {
return; return;
} }
int high_id = (int)(dialog_id >> 32); NotificationsController.getInstance().processReadMessages(null, dialog_id, max_date, 0);
if (high_id > 0) { TLRPC.EncryptedChat chat = encryptedChats.get(high_id);
NotificationsController.getInstance().processReadMessages(null, dialog_id, max_date, 0); if (chat.auth_key != null && chat.auth_key.length > 1 && chat instanceof TLRPC.TL_encryptedChat) {
TLRPC.EncryptedChat chat = encryptedChats.get(high_id); TLRPC.TL_messages_readEncryptedHistory req = new TLRPC.TL_messages_readEncryptedHistory();
if (chat.auth_key != null && chat.auth_key.length > 1 && chat instanceof TLRPC.TL_encryptedChat) { req.peer = new TLRPC.TL_inputEncryptedChat();
TLRPC.TL_messages_readEncryptedHistory req = new TLRPC.TL_messages_readEncryptedHistory(); req.peer.chat_id = chat.id;
req.peer = new TLRPC.TL_inputEncryptedChat(); req.peer.access_hash = chat.access_hash;
req.peer.chat_id = chat.id; req.max_date = max_date;
req.peer.access_hash = chat.access_hash;
req.max_date = max_date;
ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() { ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() {
@Override
public void run(TLObject response, TLRPC.TL_error error) {
//MessagesStorage.getInstance().processPendingRead(dialog_id, max_id, max_date, true);
}
});
}
MessagesStorage.getInstance().processPendingRead(dialog_id, max_id, max_date, false);
MessagesStorage.getInstance().storageQueue.postRunnable(new Runnable() {
@Override
public void run() {
Utilities.RunOnUIThread(new Runnable() {
@Override @Override
public void run(TLObject response, TLRPC.TL_error error) { public void run() {
//MessagesStorage.getInstance().processPendingRead(dialog_id, max_id, max_date, true); TLRPC.TL_dialog dialog = dialogs_dict.get(dialog_id);
if (dialog != null) {
dialog.unread_count = 0;
NotificationCenter.getInstance().postNotificationName(dialogsNeedReload);
}
HashMap<Long, Integer> dialogsToUpdate = new HashMap<Long, Integer>();
dialogsToUpdate.put(dialog_id, 0);
NotificationsController.getInstance().processDialogsUpdateRead(dialogsToUpdate, true);
} }
}); });
} }
MessagesStorage.getInstance().processPendingRead(dialog_id, max_id, max_date, false); });
MessagesStorage.getInstance().storageQueue.postRunnable(new Runnable() { if (chat.ttl > 0 && was) {
@Override int serverTime = Math.max(ConnectionsManager.getInstance().getCurrentTime(), max_date);
public void run() { MessagesStorage.getInstance().createTaskForDate(chat.id, serverTime, serverTime, 0);
Utilities.RunOnUIThread(new Runnable() {
@Override
public void run() {
TLRPC.TL_dialog dialog = dialogs_dict.get(dialog_id);
if (dialog != null) {
dialog.unread_count = 0;
NotificationCenter.getInstance().postNotificationName(dialogsNeedReload);
}
HashMap<Long, Integer> dialogsToUpdate = new HashMap<Long, Integer>();
dialogsToUpdate.put(dialog_id, 0);
NotificationsController.getInstance().processDialogsUpdateRead(dialogsToUpdate, true);
}
});
}
});
if (chat.ttl > 0 && was) {
int serverTime = Math.max(ConnectionsManager.getInstance().getCurrentTime(), max_date);
MessagesStorage.getInstance().createTaskForDate(chat.id, serverTime, serverTime, 0);
}
} }
} }
} }
@ -1975,44 +1978,12 @@ public class MessagesController implements NotificationCenter.NotificationCenter
newMsg.unread = true; newMsg.unread = true;
newMsg.dialog_id = peer; newMsg.dialog_id = peer;
int lower_id = (int)peer; int lower_id = (int)peer;
int high_id = (int)(peer >> 32);
TLRPC.EncryptedChat encryptedChat = null; TLRPC.EncryptedChat encryptedChat = null;
TLRPC.InputPeer sendToPeer = null; TLRPC.InputPeer sendToPeer = null;
ArrayList<TLRPC.InputUser> sendToPeers = null; ArrayList<TLRPC.InputUser> sendToPeers = null;
if (lower_id != 0) { if (lower_id != 0) {
if (lower_id < 0) { if (high_id == 1) {
newMsg.to_id = new TLRPC.TL_peerChat();
newMsg.to_id.chat_id = -lower_id;
sendToPeer = new TLRPC.TL_inputPeerChat();
sendToPeer.chat_id = -lower_id;
} else {
newMsg.to_id = new TLRPC.TL_peerUser();
newMsg.to_id.user_id = lower_id;
TLRPC.User sendToUser = users.get(lower_id);
if (sendToUser == null) {
return;
}
if (sendToUser instanceof TLRPC.TL_userForeign || sendToUser instanceof TLRPC.TL_userRequest) {
sendToPeer = new TLRPC.TL_inputPeerForeign();
sendToPeer.user_id = sendToUser.id;
sendToPeer.access_hash = sendToUser.access_hash;
} else {
sendToPeer = new TLRPC.TL_inputPeerContact();
sendToPeer.user_id = sendToUser.id;
}
}
} else {
int high_id = (int)(peer >> 32);
if (high_id > 0) {
encryptedChat = encryptedChats.get(high_id);
newMsg.to_id = new TLRPC.TL_peerUser();
if (encryptedChat.participant_id == UserConfig.getClientUserId()) {
newMsg.to_id.user_id = encryptedChat.admin_id;
} else {
newMsg.to_id.user_id = encryptedChat.participant_id;
}
newMsg.ttl = encryptedChat.ttl;
} else {
if (currentChatInfo == null) { if (currentChatInfo == null) {
return; return;
} }
@ -2026,7 +1997,39 @@ public class MessagesController implements NotificationCenter.NotificationCenter
} }
newMsg.to_id = new TLRPC.TL_peerChat(); newMsg.to_id = new TLRPC.TL_peerChat();
newMsg.to_id.chat_id = high_id; newMsg.to_id.chat_id = high_id;
} else {
if (lower_id < 0) {
newMsg.to_id = new TLRPC.TL_peerChat();
newMsg.to_id.chat_id = -lower_id;
sendToPeer = new TLRPC.TL_inputPeerChat();
sendToPeer.chat_id = -lower_id;
} else {
newMsg.to_id = new TLRPC.TL_peerUser();
newMsg.to_id.user_id = lower_id;
TLRPC.User sendToUser = users.get(lower_id);
if (sendToUser == null) {
return;
}
if (sendToUser instanceof TLRPC.TL_userForeign || sendToUser instanceof TLRPC.TL_userRequest) {
sendToPeer = new TLRPC.TL_inputPeerForeign();
sendToPeer.user_id = sendToUser.id;
sendToPeer.access_hash = sendToUser.access_hash;
} else {
sendToPeer = new TLRPC.TL_inputPeerContact();
sendToPeer.user_id = sendToUser.id;
}
}
} }
} else {
encryptedChat = encryptedChats.get(high_id);
newMsg.to_id = new TLRPC.TL_peerUser();
if (encryptedChat.participant_id == UserConfig.getClientUserId()) {
newMsg.to_id.user_id = encryptedChat.admin_id;
} else {
newMsg.to_id.user_id = encryptedChat.participant_id;
}
newMsg.ttl = encryptedChat.ttl;
} }
newMsg.out = true; newMsg.out = true;
newMsg.date = ConnectionsManager.getInstance().getCurrentTime(); newMsg.date = ConnectionsManager.getInstance().getCurrentTime();
@ -2886,7 +2889,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
newMsg.local_id = newMsg.id = UserConfig.getNewMessageId(); newMsg.local_id = newMsg.id = UserConfig.getNewMessageId();
newMsg.from_id = UserConfig.getClientUserId(); newMsg.from_id = UserConfig.getClientUserId();
newMsg.unread = false; newMsg.unread = false;
newMsg.dialog_id = ((long)chat.id) << 32; newMsg.dialog_id = AndroidUtilities.makeBroadcastId(chat.id);
newMsg.to_id = new TLRPC.TL_peerChat(); newMsg.to_id = new TLRPC.TL_peerChat();
newMsg.to_id.chat_id = chat.id; newMsg.to_id.chat_id = chat.id;
newMsg.out = false; newMsg.out = false;

View file

@ -366,6 +366,17 @@ public class MessagesStorage {
if (!messagesOnly) { if (!messagesOnly) {
database.executeFast("DELETE FROM dialogs WHERE did = " + did).stepThis().dispose(); database.executeFast("DELETE FROM dialogs WHERE did = " + did).stepThis().dispose();
database.executeFast("DELETE FROM chat_settings WHERE uid = " + did).stepThis().dispose(); database.executeFast("DELETE FROM chat_settings WHERE uid = " + did).stepThis().dispose();
int lower_id = (int)did;
int high_id = (int)(did >> 32);
if (lower_id != 0) {
if (high_id == 1) {
database.executeFast("DELETE FROM chats WHERE uid = " + lower_id).stepThis().dispose();
} else if (lower_id < 0) {
database.executeFast("DELETE FROM chats WHERE uid = " + (-lower_id)).stepThis().dispose();
}
} else {
database.executeFast("DELETE FROM enc_chats WHERE uid = " + high_id).stepThis().dispose();
}
} }
database.executeFast("UPDATE dialogs SET unread_count = 0 WHERE did = " + did).stepThis().dispose(); database.executeFast("UPDATE dialogs SET unread_count = 0 WHERE did = " + did).stepThis().dispose();
database.executeFast("DELETE FROM media_counts WHERE uid = " + did).stepThis().dispose(); database.executeFast("DELETE FROM media_counts WHERE uid = " + did).stepThis().dispose();
@ -2429,26 +2440,26 @@ public class MessagesStorage {
buffersStorage.reuseFreeBuffer(data); buffersStorage.reuseFreeBuffer(data);
int lower_id = (int)dialog.id; int lower_id = (int)dialog.id;
int high_id = (int)(dialog.id >> 32);
if (lower_id != 0) { if (lower_id != 0) {
if (lower_id > 0) { if (high_id == 1) {
if (!usersToLoad.contains(lower_id)) { if (!chatsToLoad.contains(lower_id)) {
usersToLoad.add(lower_id); chatsToLoad.add(lower_id);
} }
} else { } else {
if (!chatsToLoad.contains(-lower_id)) { if (lower_id > 0) {
chatsToLoad.add(-lower_id); if (!usersToLoad.contains(lower_id)) {
usersToLoad.add(lower_id);
}
} else {
if (!chatsToLoad.contains(-lower_id)) {
chatsToLoad.add(-lower_id);
}
} }
} }
} else { } else {
int high_id = (int)(dialog.id >> 32); if (!encryptedToLoad.contains(high_id)) {
if (high_id > 0) { encryptedToLoad.add(high_id);
if (!encryptedToLoad.contains(high_id)) {
encryptedToLoad.add(high_id);
}
} else {
if (!chatsToLoad.contains(high_id)) {
chatsToLoad.add(high_id);
}
} }
} }
} }
@ -2702,26 +2713,26 @@ public class MessagesStorage {
buffersStorage.reuseFreeBuffer(data); buffersStorage.reuseFreeBuffer(data);
int lower_id = (int)dialog.id; int lower_id = (int)dialog.id;
int high_id = (int)(dialog.id >> 32);
if (lower_id != 0) { if (lower_id != 0) {
if (lower_id > 0) { if (high_id == 1) {
if (!usersToLoad.contains(lower_id)) { if (!chatsToLoad.contains(lower_id)) {
usersToLoad.add(lower_id); chatsToLoad.add(lower_id);
} }
} else { } else {
if (!chatsToLoad.contains(-lower_id)) { if (lower_id > 0) {
chatsToLoad.add(-lower_id); if (!usersToLoad.contains(lower_id)) {
usersToLoad.add(lower_id);
}
} else {
if (!chatsToLoad.contains(-lower_id)) {
chatsToLoad.add(-lower_id);
}
} }
} }
} else { } else {
int high_id = (int)(dialog.id >> 32); if (!encryptedToLoad.contains(high_id)) {
if (high_id > 0) { encryptedToLoad.add(high_id);
if (!encryptedToLoad.contains(high_id)) {
encryptedToLoad.add(high_id);
}
} else {
if (!chatsToLoad.contains(high_id)) {
chatsToLoad.add(high_id);
}
} }
} }
} }

View file

@ -225,21 +225,21 @@ public class DialogCell extends BaseCell {
encryptedChat = null; encryptedChat = null;
int lower_id = (int)currentDialog.id; int lower_id = (int)currentDialog.id;
int high_id = (int)(currentDialog.id >> 32);
if (lower_id != 0) { if (lower_id != 0) {
if (lower_id < 0) { if (high_id == 1) {
chat = MessagesController.getInstance().chats.get(-lower_id); chat = MessagesController.getInstance().chats.get(lower_id);
} else { } else {
user = MessagesController.getInstance().users.get(lower_id); if (lower_id < 0) {
chat = MessagesController.getInstance().chats.get(-lower_id);
} else {
user = MessagesController.getInstance().users.get(lower_id);
}
} }
} else { } else {
int high_id = (int)(currentDialog.id >> 32); encryptedChat = MessagesController.getInstance().encryptedChats.get(high_id);
if (high_id > 0) { if (encryptedChat != null) {
encryptedChat = MessagesController.getInstance().encryptedChats.get(high_id); user = MessagesController.getInstance().users.get(encryptedChat.user_id);
if (encryptedChat != null) {
user = MessagesController.getInstance().users.get(encryptedChat.user_id);
}
} else {
chat = MessagesController.getInstance().chats.get(high_id);
} }
} }

View file

@ -129,6 +129,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
private View pagedownButton; private View pagedownButton;
private TextView topPanelText; private TextView topPanelText;
private long dialog_id; private long dialog_id;
private boolean isBraodcast = false;
private HashMap<Integer, MessageObject> selectedMessagesIds = new HashMap<Integer, MessageObject>(); private HashMap<Integer, MessageObject> selectedMessagesIds = new HashMap<Integer, MessageObject>();
private HashMap<Integer, MessageObject> selectedMessagesCanCopyIds = new HashMap<Integer, MessageObject>(); private HashMap<Integer, MessageObject> selectedMessagesCanCopyIds = new HashMap<Integer, MessageObject>();
@ -215,7 +216,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (chatId > 0) { if (chatId > 0) {
dialog_id = -chatId; dialog_id = -chatId;
} else { } else {
dialog_id = ((long)chatId) << 32; isBraodcast = true;
dialog_id = AndroidUtilities.makeBroadcastId(chatId);
} }
} else if (userId != 0) { } else if (userId != 0) {
currentUser = MessagesController.getInstance().users.get(userId); currentUser = MessagesController.getInstance().users.get(userId);
@ -1051,8 +1053,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
private int getMessageType(MessageObject messageObject) { private int getMessageType(MessageObject messageObject) {
if (currentEncryptedChat == null) { if (currentEncryptedChat == null) {
boolean isBroadcastError = (int)dialog_id == 0 && messageObject.messageOwner.id <= 0 && messageObject.messageOwner.send_state == MessagesController.MESSAGE_SEND_STATE_SEND_ERROR; boolean isBroadcastError = isBraodcast && messageObject.messageOwner.id <= 0 && messageObject.messageOwner.send_state == MessagesController.MESSAGE_SEND_STATE_SEND_ERROR;
if ((int)dialog_id != 0 && messageObject.messageOwner.id <= 0 && messageObject.isOut() || isBroadcastError) { if (!isBraodcast && messageObject.messageOwner.id <= 0 && messageObject.isOut() || isBroadcastError) {
if (messageObject.messageOwner.send_state == MessagesController.MESSAGE_SEND_STATE_SEND_ERROR) { if (messageObject.messageOwner.send_state == MessagesController.MESSAGE_SEND_STATE_SEND_ERROR) {
if (!(messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaEmpty)) { if (!(messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaEmpty)) {
return 0; return 0;
@ -1778,7 +1780,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (messArr.size() != count) { if (messArr.size() != count) {
if (isCache) { if (isCache) {
cacheEndReaced = true; cacheEndReaced = true;
if ((int)dialog_id == 0) { if (currentEncryptedChat != null || isBraodcast) {
endReached = true; endReached = true;
} }
} else { } else {
@ -2932,7 +2934,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
@Override @Override
public void didSelectDialog(MessagesActivity activity, long did, boolean param) { public void didSelectDialog(MessagesActivity activity, long did, boolean param) {
if (dialog_id != 0 && (forwaringMessage != null || !selectedMessagesIds.isEmpty())) { if (dialog_id != 0 && (forwaringMessage != null || !selectedMessagesIds.isEmpty())) {
if ((int)dialog_id == 0 && currentEncryptedChat == null) { if (isBraodcast) {
param = true; param = true;
} }
if (did != dialog_id) { if (did != dialog_id) {

View file

@ -447,23 +447,23 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
public void didSelectDialog(MessagesActivity messageFragment, long dialog_id, boolean param) { public void didSelectDialog(MessagesActivity messageFragment, long dialog_id, boolean param) {
if (dialog_id != 0) { if (dialog_id != 0) {
int lower_part = (int)dialog_id; int lower_part = (int)dialog_id;
int high_id = (int)(dialog_id >> 32);
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putBoolean("scrollToTopOnResume", true); args.putBoolean("scrollToTopOnResume", true);
NotificationCenter.getInstance().postNotificationName(MessagesController.closeChats); NotificationCenter.getInstance().postNotificationName(MessagesController.closeChats);
if (lower_part != 0) { if (lower_part != 0) {
if (lower_part > 0) { if (high_id == 1) {
args.putInt("user_id", lower_part); args.putInt("chat_id", lower_part);
} else if (lower_part < 0) { } else {
args.putInt("chat_id", -lower_part); if (lower_part > 0) {
args.putInt("user_id", lower_part);
} else if (lower_part < 0) {
args.putInt("chat_id", -lower_part);
}
} }
} else { } else {
int high_id = (int)(dialog_id >> 32); args.putInt("enc_id", high_id);
if (high_id > 0) {
args.putInt("enc_id", high_id);
} else {
args.putInt("chat_id", high_id);
}
} }
ChatActivity fragment = new ChatActivity(args); ChatActivity fragment = new ChatActivity(args);
presentFragment(fragment, true); presentFragment(fragment, true);

View file

@ -288,19 +288,19 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
} else { } else {
Bundle args = new Bundle(); Bundle args = new Bundle();
int lower_part = (int)dialog_id; int lower_part = (int)dialog_id;
int high_id = (int)(dialog_id >> 32);
if (lower_part != 0) { if (lower_part != 0) {
if (lower_part > 0) { if (high_id == 1) {
args.putInt("user_id", lower_part); args.putInt("chat_id", lower_part);
} else if (lower_part < 0) { } else {
args.putInt("chat_id", -lower_part); if (lower_part > 0) {
args.putInt("user_id", lower_part);
} else if (lower_part < 0) {
args.putInt("chat_id", -lower_part);
}
} }
} else { } else {
int high_id = (int)(dialog_id >> 32); args.putInt("enc_id", high_id);
if (high_id > 0) {
args.putInt("enc_id", high_id);
} else {
args.putInt("chat_id", high_id);
}
} }
presentFragment(new ChatActivity(args)); presentFragment(new ChatActivity(args));
} }
@ -493,36 +493,36 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setTitle(LocaleController.getString("AppName", R.string.AppName)); builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
int lower_part = (int)dialog_id; int lower_part = (int)dialog_id;
int high_id = (int)(dialog_id >> 32);
if (lower_part != 0) { if (lower_part != 0) {
if (lower_part > 0) { if (high_id == 1) {
TLRPC.User user = MessagesController.getInstance().users.get(lower_part); TLRPC.Chat chat = MessagesController.getInstance().chats.get(lower_part);
if (user == null) {
return;
}
builder.setMessage(LocaleController.formatStringSimple(selectAlertString, Utilities.formatName(user.first_name, user.last_name)));
} else if (lower_part < 0) {
TLRPC.Chat chat = MessagesController.getInstance().chats.get(-lower_part);
if (chat == null) { if (chat == null) {
return; return;
} }
builder.setMessage(LocaleController.formatStringSimple(selectAlertString, chat.title)); builder.setMessage(LocaleController.formatStringSimple(selectAlertString, chat.title));
} else {
if (lower_part > 0) {
TLRPC.User user = MessagesController.getInstance().users.get(lower_part);
if (user == null) {
return;
}
builder.setMessage(LocaleController.formatStringSimple(selectAlertString, Utilities.formatName(user.first_name, user.last_name)));
} else if (lower_part < 0) {
TLRPC.Chat chat = MessagesController.getInstance().chats.get(-lower_part);
if (chat == null) {
return;
}
builder.setMessage(LocaleController.formatStringSimple(selectAlertString, chat.title));
}
} }
} else { } else {
int high_id = (int)(dialog_id >> 32); TLRPC.EncryptedChat chat = MessagesController.getInstance().encryptedChats.get(high_id);
if (high_id > 0) { TLRPC.User user = MessagesController.getInstance().users.get(chat.user_id);
TLRPC.EncryptedChat chat = MessagesController.getInstance().encryptedChats.get(high_id); if (user == null) {
TLRPC.User user = MessagesController.getInstance().users.get(chat.user_id); return;
if (user == null) {
return;
}
builder.setMessage(LocaleController.formatStringSimple(selectAlertString, Utilities.formatName(user.first_name, user.last_name)));
} else {
TLRPC.Chat chat = MessagesController.getInstance().chats.get(high_id);
if (chat == null) {
return;
}
builder.setMessage(LocaleController.formatStringSimple(selectAlertString, chat.title));
} }
builder.setMessage(LocaleController.formatStringSimple(selectAlertString, Utilities.formatName(user.first_name, user.last_name)));
} }
CheckBox checkBox = null; CheckBox checkBox = null;
/*if (delegate instanceof ChatActivity) { /*if (delegate instanceof ChatActivity) {