mirror of
https://github.com/DrKLO/Telegram.git
synced 2024-12-22 14:35:03 +01:00
Changed broadcast lists ids
old broadcast lists will be broken
This commit is contained in:
parent
2eb84e23f6
commit
755446e9bb
8 changed files with 204 additions and 184 deletions
|
@ -83,7 +83,7 @@ android {
|
|||
defaultConfig {
|
||||
minSdkVersion 8
|
||||
targetSdkVersion 19
|
||||
versionCode 292
|
||||
versionCode 293
|
||||
versionName "1.7.0"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -221,4 +221,8 @@ public class AndroidUtilities {
|
|||
FileLog.e("tmessages", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static long makeBroadcastId(int id) {
|
||||
return 0x0000000100000000L | ((long)id & 0x00000000FFFFFFFFL);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -765,6 +765,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
TLRPC.TL_dialog dialog = dialogs_dict.get(did);
|
||||
if (dialog != null) {
|
||||
int lower_part = (int)did;
|
||||
int high_id = (int)(did >> 32);
|
||||
|
||||
if (offset == 0) {
|
||||
if (!onlyHistory) {
|
||||
|
@ -785,6 +786,10 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
NotificationCenter.getInstance().postNotificationName(dialogsNeedReload);
|
||||
}
|
||||
|
||||
if (high_id == 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (lower_part != 0) {
|
||||
TLRPC.TL_messages_deleteHistory req = new TLRPC.TL_messages_deleteHistory();
|
||||
req.offset = offset;
|
||||
|
@ -831,8 +836,6 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
}
|
||||
});
|
||||
} else {
|
||||
int high_id = (int)(did >> 32);
|
||||
if (high_id > 0) {
|
||||
if (onlyHistory) {
|
||||
TLRPC.EncryptedChat encryptedChat = encryptedChats.get(high_id);
|
||||
sendClearHistoryMessage(encryptedChat);
|
||||
|
@ -842,7 +845,6 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void loadChatInfo(final int chat_id) {
|
||||
currentChatInfo = null;
|
||||
|
@ -1046,7 +1048,12 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
return;
|
||||
}
|
||||
int lower_part = (int)dialog_id;
|
||||
int high_id = (int)(dialog_id >> 32);
|
||||
if (lower_part != 0) {
|
||||
if (high_id == 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
TLRPC.TL_messages_setTyping req = new TLRPC.TL_messages_setTyping();
|
||||
if (lower_part < 0) {
|
||||
req.peer = new TLRPC.TL_inputPeerChat();
|
||||
|
@ -1075,8 +1082,6 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
}, true, RPCRequest.RPCRequestClassGeneric | RPCRequest.RPCRequestClassFailOnServerErrors);
|
||||
ConnectionsManager.getInstance().bindRequestToGuid(reqId, classGuid);
|
||||
} else {
|
||||
int high_id = (int)(dialog_id >> 32);
|
||||
if (high_id > 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_setEncryptedTyping req = new TLRPC.TL_messages_setEncryptedTyping();
|
||||
|
@ -1094,7 +1099,6 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void loadMessages(final long dialog_id, final int offset, final int count, final int max_id, boolean fromCache, int midDate, final int classGuid, boolean from_unread, boolean forward) {
|
||||
int lower_part = (int)dialog_id;
|
||||
|
@ -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) {
|
||||
int lower_part = (int)dialog_id;
|
||||
int high_id = (int)(dialog_id >> 32);
|
||||
|
||||
if (lower_part != 0) {
|
||||
if (max_id == 0 && offset == 0) {
|
||||
if (max_id == 0 && offset == 0 || high_id == 1) {
|
||||
return;
|
||||
}
|
||||
TLRPC.TL_messages_readHistory req = new TLRPC.TL_messages_readHistory();
|
||||
|
@ -1646,8 +1652,6 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
if (max_date == 0) {
|
||||
return;
|
||||
}
|
||||
int high_id = (int)(dialog_id >> 32);
|
||||
if (high_id > 0) {
|
||||
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) {
|
||||
|
@ -1691,7 +1695,6 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void cancelSendingMessage(MessageObject object) {
|
||||
String keyToRemvoe = null;
|
||||
|
@ -1975,10 +1978,26 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
newMsg.unread = true;
|
||||
newMsg.dialog_id = peer;
|
||||
int lower_id = (int)peer;
|
||||
int high_id = (int)(peer >> 32);
|
||||
TLRPC.EncryptedChat encryptedChat = null;
|
||||
TLRPC.InputPeer sendToPeer = null;
|
||||
ArrayList<TLRPC.InputUser> sendToPeers = null;
|
||||
if (lower_id != 0) {
|
||||
if (high_id == 1) {
|
||||
if (currentChatInfo == null) {
|
||||
return;
|
||||
}
|
||||
sendToPeers = new ArrayList<TLRPC.InputUser>();
|
||||
for (TLRPC.TL_chatParticipant participant : currentChatInfo.participants) {
|
||||
TLRPC.User sendToUser = users.get(participant.user_id);
|
||||
TLRPC.InputUser peerUser = getInputUser(sendToUser);
|
||||
if (peerUser != null) {
|
||||
sendToPeers.add(peerUser);
|
||||
}
|
||||
}
|
||||
newMsg.to_id = new TLRPC.TL_peerChat();
|
||||
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;
|
||||
|
@ -2001,9 +2020,8 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
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()) {
|
||||
|
@ -2012,21 +2030,6 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
newMsg.to_id.user_id = encryptedChat.participant_id;
|
||||
}
|
||||
newMsg.ttl = encryptedChat.ttl;
|
||||
} else {
|
||||
if (currentChatInfo == null) {
|
||||
return;
|
||||
}
|
||||
sendToPeers = new ArrayList<TLRPC.InputUser>();
|
||||
for (TLRPC.TL_chatParticipant participant : currentChatInfo.participants) {
|
||||
TLRPC.User sendToUser = users.get(participant.user_id);
|
||||
TLRPC.InputUser peerUser = getInputUser(sendToUser);
|
||||
if (peerUser != null) {
|
||||
sendToPeers.add(peerUser);
|
||||
}
|
||||
}
|
||||
newMsg.to_id = new TLRPC.TL_peerChat();
|
||||
newMsg.to_id.chat_id = high_id;
|
||||
}
|
||||
}
|
||||
newMsg.out = true;
|
||||
newMsg.date = ConnectionsManager.getInstance().getCurrentTime();
|
||||
|
@ -2886,7 +2889,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
newMsg.local_id = newMsg.id = UserConfig.getNewMessageId();
|
||||
newMsg.from_id = UserConfig.getClientUserId();
|
||||
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.chat_id = chat.id;
|
||||
newMsg.out = false;
|
||||
|
|
|
@ -366,6 +366,17 @@ public class MessagesStorage {
|
|||
if (!messagesOnly) {
|
||||
database.executeFast("DELETE FROM dialogs WHERE did = " + 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("DELETE FROM media_counts WHERE uid = " + did).stepThis().dispose();
|
||||
|
@ -2429,7 +2440,13 @@ public class MessagesStorage {
|
|||
buffersStorage.reuseFreeBuffer(data);
|
||||
|
||||
int lower_id = (int)dialog.id;
|
||||
int high_id = (int)(dialog.id >> 32);
|
||||
if (lower_id != 0) {
|
||||
if (high_id == 1) {
|
||||
if (!chatsToLoad.contains(lower_id)) {
|
||||
chatsToLoad.add(lower_id);
|
||||
}
|
||||
} else {
|
||||
if (lower_id > 0) {
|
||||
if (!usersToLoad.contains(lower_id)) {
|
||||
usersToLoad.add(lower_id);
|
||||
|
@ -2439,17 +2456,11 @@ public class MessagesStorage {
|
|||
chatsToLoad.add(-lower_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
int high_id = (int)(dialog.id >> 32);
|
||||
if (high_id > 0) {
|
||||
if (!encryptedToLoad.contains(high_id)) {
|
||||
encryptedToLoad.add(high_id);
|
||||
}
|
||||
} else {
|
||||
if (!chatsToLoad.contains(high_id)) {
|
||||
chatsToLoad.add(high_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
cursor.dispose();
|
||||
|
@ -2702,7 +2713,13 @@ public class MessagesStorage {
|
|||
buffersStorage.reuseFreeBuffer(data);
|
||||
|
||||
int lower_id = (int)dialog.id;
|
||||
int high_id = (int)(dialog.id >> 32);
|
||||
if (lower_id != 0) {
|
||||
if (high_id == 1) {
|
||||
if (!chatsToLoad.contains(lower_id)) {
|
||||
chatsToLoad.add(lower_id);
|
||||
}
|
||||
} else {
|
||||
if (lower_id > 0) {
|
||||
if (!usersToLoad.contains(lower_id)) {
|
||||
usersToLoad.add(lower_id);
|
||||
|
@ -2712,17 +2729,11 @@ public class MessagesStorage {
|
|||
chatsToLoad.add(-lower_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
int high_id = (int)(dialog.id >> 32);
|
||||
if (high_id > 0) {
|
||||
if (!encryptedToLoad.contains(high_id)) {
|
||||
encryptedToLoad.add(high_id);
|
||||
}
|
||||
} else {
|
||||
if (!chatsToLoad.contains(high_id)) {
|
||||
chatsToLoad.add(high_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
cursor.dispose();
|
||||
|
|
|
@ -225,22 +225,22 @@ public class DialogCell extends BaseCell {
|
|||
encryptedChat = null;
|
||||
|
||||
int lower_id = (int)currentDialog.id;
|
||||
int high_id = (int)(currentDialog.id >> 32);
|
||||
if (lower_id != 0) {
|
||||
if (high_id == 1) {
|
||||
chat = MessagesController.getInstance().chats.get(lower_id);
|
||||
} else {
|
||||
if (lower_id < 0) {
|
||||
chat = MessagesController.getInstance().chats.get(-lower_id);
|
||||
} else {
|
||||
user = MessagesController.getInstance().users.get(lower_id);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
int high_id = (int)(currentDialog.id >> 32);
|
||||
if (high_id > 0) {
|
||||
encryptedChat = MessagesController.getInstance().encryptedChats.get(high_id);
|
||||
if (encryptedChat != null) {
|
||||
user = MessagesController.getInstance().users.get(encryptedChat.user_id);
|
||||
}
|
||||
} else {
|
||||
chat = MessagesController.getInstance().chats.get(high_id);
|
||||
}
|
||||
}
|
||||
|
||||
int placeHolderId = 0;
|
||||
|
|
|
@ -129,6 +129,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
private View pagedownButton;
|
||||
private TextView topPanelText;
|
||||
private long dialog_id;
|
||||
private boolean isBraodcast = false;
|
||||
private HashMap<Integer, MessageObject> selectedMessagesIds = 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) {
|
||||
dialog_id = -chatId;
|
||||
} else {
|
||||
dialog_id = ((long)chatId) << 32;
|
||||
isBraodcast = true;
|
||||
dialog_id = AndroidUtilities.makeBroadcastId(chatId);
|
||||
}
|
||||
} else if (userId != 0) {
|
||||
currentUser = MessagesController.getInstance().users.get(userId);
|
||||
|
@ -1051,8 +1053,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
|
||||
private int getMessageType(MessageObject messageObject) {
|
||||
if (currentEncryptedChat == null) {
|
||||
boolean isBroadcastError = (int)dialog_id == 0 && 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) {
|
||||
boolean isBroadcastError = isBraodcast && messageObject.messageOwner.id <= 0 && messageObject.messageOwner.send_state == MessagesController.MESSAGE_SEND_STATE_SEND_ERROR;
|
||||
if (!isBraodcast && messageObject.messageOwner.id <= 0 && messageObject.isOut() || isBroadcastError) {
|
||||
if (messageObject.messageOwner.send_state == MessagesController.MESSAGE_SEND_STATE_SEND_ERROR) {
|
||||
if (!(messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaEmpty)) {
|
||||
return 0;
|
||||
|
@ -1778,7 +1780,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
if (messArr.size() != count) {
|
||||
if (isCache) {
|
||||
cacheEndReaced = true;
|
||||
if ((int)dialog_id == 0) {
|
||||
if (currentEncryptedChat != null || isBraodcast) {
|
||||
endReached = true;
|
||||
}
|
||||
} else {
|
||||
|
@ -2932,7 +2934,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
@Override
|
||||
public void didSelectDialog(MessagesActivity activity, long did, boolean param) {
|
||||
if (dialog_id != 0 && (forwaringMessage != null || !selectedMessagesIds.isEmpty())) {
|
||||
if ((int)dialog_id == 0 && currentEncryptedChat == null) {
|
||||
if (isBraodcast) {
|
||||
param = true;
|
||||
}
|
||||
if (did != dialog_id) {
|
||||
|
|
|
@ -447,23 +447,23 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
|
|||
public void didSelectDialog(MessagesActivity messageFragment, long dialog_id, boolean param) {
|
||||
if (dialog_id != 0) {
|
||||
int lower_part = (int)dialog_id;
|
||||
int high_id = (int)(dialog_id >> 32);
|
||||
|
||||
Bundle args = new Bundle();
|
||||
args.putBoolean("scrollToTopOnResume", true);
|
||||
NotificationCenter.getInstance().postNotificationName(MessagesController.closeChats);
|
||||
if (lower_part != 0) {
|
||||
if (high_id == 1) {
|
||||
args.putInt("chat_id", lower_part);
|
||||
} else {
|
||||
if (lower_part > 0) {
|
||||
args.putInt("user_id", lower_part);
|
||||
} else if (lower_part < 0) {
|
||||
args.putInt("chat_id", -lower_part);
|
||||
}
|
||||
} else {
|
||||
int high_id = (int)(dialog_id >> 32);
|
||||
if (high_id > 0) {
|
||||
args.putInt("enc_id", high_id);
|
||||
} else {
|
||||
args.putInt("chat_id", high_id);
|
||||
}
|
||||
} else {
|
||||
args.putInt("enc_id", high_id);
|
||||
}
|
||||
ChatActivity fragment = new ChatActivity(args);
|
||||
presentFragment(fragment, true);
|
||||
|
|
|
@ -288,19 +288,19 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
|||
} else {
|
||||
Bundle args = new Bundle();
|
||||
int lower_part = (int)dialog_id;
|
||||
int high_id = (int)(dialog_id >> 32);
|
||||
if (lower_part != 0) {
|
||||
if (high_id == 1) {
|
||||
args.putInt("chat_id", lower_part);
|
||||
} else {
|
||||
if (lower_part > 0) {
|
||||
args.putInt("user_id", lower_part);
|
||||
} else if (lower_part < 0) {
|
||||
args.putInt("chat_id", -lower_part);
|
||||
}
|
||||
} else {
|
||||
int high_id = (int)(dialog_id >> 32);
|
||||
if (high_id > 0) {
|
||||
args.putInt("enc_id", high_id);
|
||||
} else {
|
||||
args.putInt("chat_id", high_id);
|
||||
}
|
||||
} else {
|
||||
args.putInt("enc_id", high_id);
|
||||
}
|
||||
presentFragment(new ChatActivity(args));
|
||||
}
|
||||
|
@ -493,7 +493,15 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
|||
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
||||
int lower_part = (int)dialog_id;
|
||||
int high_id = (int)(dialog_id >> 32);
|
||||
if (lower_part != 0) {
|
||||
if (high_id == 1) {
|
||||
TLRPC.Chat chat = MessagesController.getInstance().chats.get(lower_part);
|
||||
if (chat == null) {
|
||||
return;
|
||||
}
|
||||
builder.setMessage(LocaleController.formatStringSimple(selectAlertString, chat.title));
|
||||
} else {
|
||||
if (lower_part > 0) {
|
||||
TLRPC.User user = MessagesController.getInstance().users.get(lower_part);
|
||||
if (user == null) {
|
||||
|
@ -507,22 +515,14 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
|||
}
|
||||
builder.setMessage(LocaleController.formatStringSimple(selectAlertString, chat.title));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
int high_id = (int)(dialog_id >> 32);
|
||||
if (high_id > 0) {
|
||||
TLRPC.EncryptedChat chat = MessagesController.getInstance().encryptedChats.get(high_id);
|
||||
TLRPC.User user = MessagesController.getInstance().users.get(chat.user_id);
|
||||
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));
|
||||
}
|
||||
}
|
||||
CheckBox checkBox = null;
|
||||
/*if (delegate instanceof ChatActivity) {
|
||||
|
|
Loading…
Reference in a new issue