diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MessageObject.java b/TMessagesProj/src/main/java/org/telegram/messenger/MessageObject.java index 514e5d94f..c32b5a14d 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/MessageObject.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/MessageObject.java @@ -909,12 +909,12 @@ public class MessageObject { } boolean useManualParse = !hasEntities && ( - messageOwner instanceof TLRPC.TL_message_old || + //messageOwner instanceof TLRPC.TL_message_old || //messageOwner instanceof TLRPC.TL_message_old2 || //messageOwner instanceof TLRPC.TL_message_old3 || //messageOwner instanceof TLRPC.TL_message_old4 || - messageOwner instanceof TLRPC.TL_messageForwarded_old || - messageOwner instanceof TLRPC.TL_messageForwarded_old2 || + //messageOwner instanceof TLRPC.TL_messageForwarded_old || + //messageOwner instanceof TLRPC.TL_messageForwarded_old2 || messageOwner instanceof TLRPC.TL_message_secret || isOut() && messageOwner.send_state != MESSAGE_SEND_STATE_SENT || messageOwner.id < 0 || messageOwner.media instanceof TLRPC.TL_messageMediaUnsupported); diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java index 1dff9bb90..3bbb9a608 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java @@ -1077,18 +1077,18 @@ public class MessagesController implements NotificationCenter.NotificationCenter //MessagesStorage.getInstance().updateDialogsWithDeletedMessages(messages, true, channelId); NotificationCenter.getInstance().postNotificationName(NotificationCenter.messagesDeleted, messages, channelId); if (channelId != 0) { - TLRPC.TL_channels_deleteMessages req = new TLRPC.TL_channels_deleteMessages(); + /*TLRPC.TL_channels_deleteMessages req = new TLRPC.TL_channels_deleteMessages(); req.id = toSend; req.channel = getInputChannel(channelId); ConnectionsManager.getInstance().sendRequest(req, new RequestDelegate() { @Override public void run(TLObject response, TLRPC.TL_error error) { if (error == null) { - //TLRPC.TL_messages_affectedMessages res = (TLRPC.TL_messages_affectedMessages) response; - //processNewChannelDifferenceParams(res.pts, res.pts_count, channelId); + TLRPC.TL_messages_affectedMessages res = (TLRPC.TL_messages_affectedMessages) response; + processNewChannelDifferenceParams(res.pts, res.pts_count, channelId); } } - }); + });*/ } else { /* if (randoms != null && encryptedChat != null && !randoms.isEmpty()) { @@ -1141,37 +1141,6 @@ public class MessagesController implements NotificationCenter.NotificationCenter return searchImage; } - public void loadChannelParticipants(final Integer chat_id) { - if (loadingFullParticipants.contains(chat_id) || loadedFullParticipants.contains(chat_id)) { - return; - } - loadingFullParticipants.add(chat_id); - - final TLRPC.TL_channels_getParticipants req = new TLRPC.TL_channels_getParticipants(); - req.channel = getInputChannel(chat_id); - req.filter = new TLRPC.TL_channelParticipantsRecent(); - req.offset = 0; - req.limit = 32; - ConnectionsManager.getInstance().sendRequest(req, new RequestDelegate() { - @Override - public void run(final TLObject response, final TLRPC.TL_error error) { - AndroidUtilities.runOnUIThread(new Runnable() { - @Override - public void run() { - if (error == null) { - TLRPC.TL_channels_channelParticipants res = (TLRPC.TL_channels_channelParticipants) response; - putUsers(res.users, false); - //MessagesStorage.getInstance().putUsersAndChats(res.users, null, true, true); - //MessagesStorage.getInstance().updateChannelUsers(chat_id, res.participants); - loadedFullParticipants.add(chat_id); - } - loadingFullParticipants.remove(chat_id); - } - }); - } - }); - } - public void loadChatInfo(final int chat_id, Semaphore semaphore, boolean force) { //MessagesStorage.getInstance().loadChatInfo(chat_id, semaphore, force, false); } @@ -1872,7 +1841,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter }); } }, ConnectionsManager.RequestFlagFailOnServerErrors); - } else if (type == ChatObject.CHAT_TYPE_CHANNEL || type == ChatObject.CHAT_TYPE_MEGAGROUP) { + } /*else if (type == ChatObject.CHAT_TYPE_CHANNEL || type == ChatObject.CHAT_TYPE_MEGAGROUP) { TLRPC.TL_channels_createChannel req = new TLRPC.TL_channels_createChannel(); req.title = title; req.about = about; @@ -1888,11 +1857,9 @@ public class MessagesController implements NotificationCenter.NotificationCenter AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { - /* EDUT BY MR if (error.text.startsWith("FLOOD_WAIT")) { AlertsCreator.showFloodWaitAlert(error.text, fragment); } - */ NotificationCenter.getInstance().postNotificationName(NotificationCenter.chatDidFailCreate); } }); @@ -1914,7 +1881,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter }); } }, ConnectionsManager.RequestFlagFailOnServerErrors); - } + }*/ return 0; } @@ -1929,7 +1896,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter public void changeChatAvatar(int chat_id, TLRPC.InputFile uploadedAvatar) { TLObject request; - if (ChatObject.isChannel(chat_id)) { + /*if (ChatObject.isChannel(chat_id)) { TLRPC.TL_channels_editPhoto req = new TLRPC.TL_channels_editPhoto(); req.channel = getInputChannel(chat_id); if (uploadedAvatar != null) { @@ -1940,7 +1907,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter req.photo = new TLRPC.TL_inputChatPhotoEmpty(); } request = req; - } else { + } else*/ { TLRPC.TL_messages_editChatPhoto req = new TLRPC.TL_messages_editChatPhoto(); req.chat_id = chat_id; if (uploadedAvatar != null) { diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/SendMessagesHelper.java b/TMessagesProj/src/main/java/org/telegram/messenger/SendMessagesHelper.java index 5ec38a032..8957e9781 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/SendMessagesHelper.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/SendMessagesHelper.java @@ -546,106 +546,6 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter MessagesController.getInstance().deleteMessages(messages, null, null, object.messageOwner.to_id.channel_id); } - /* - public boolean retrySendMessage(MessageObject messageObject, boolean unsent) { - if (messageObject.getId() >= 0) { - return false; - } - if (messageObject.messageOwner.action instanceof TLRPC.TL_messageEncryptedAction) { - int enc_id = (int) (messageObject.getDialogId() >> 32); - TLRPC.EncryptedChat encryptedChat = MessagesController.getInstance().getEncryptedChat(enc_id); - if (encryptedChat == null) { - //MessagesStorage.getInstance().markMessageAsSendError(messageObject.messageOwner); - messageObject.messageOwner.send_state = MessageObject.MESSAGE_SEND_STATE_SEND_ERROR; - NotificationCenter.getInstance().postNotificationName(NotificationCenter.messageSendError, messageObject.getId()); - processSentMessage(messageObject.getId()); - return false; - } - if (messageObject.messageOwner.random_id == 0) { - messageObject.messageOwner.random_id = getNextRandomId(); - } - // - //if (messageObject.messageOwner.action.encryptedAction instanceof TLRPC.TL_decryptedMessageActionSetMessageTTL) { - // SecretChatHelper.getInstance().sendTTLMessage(encryptedChat, messageObject.messageOwner); - //} else if (messageObject.messageOwner.action.encryptedAction instanceof TLRPC.TL_decryptedMessageActionDeleteMessages) { - // SecretChatHelper.getInstance().sendMessagesDeleteMessage(encryptedChat, null, messageObject.messageOwner); - //} else if (messageObject.messageOwner.action.encryptedAction instanceof TLRPC.TL_decryptedMessageActionFlushHistory) { - // SecretChatHelper.getInstance().sendClearHistoryMessage(encryptedChat, messageObject.messageOwner); - //} else if (messageObject.messageOwner.action.encryptedAction instanceof TLRPC.TL_decryptedMessageActionNotifyLayer) { - // SecretChatHelper.getInstance().sendNotifyLayerMessage(encryptedChat, messageObject.messageOwner); - //} else if (messageObject.messageOwner.action.encryptedAction instanceof TLRPC.TL_decryptedMessageActionReadMessages) { - // SecretChatHelper.getInstance().sendMessagesReadMessage(encryptedChat, null, messageObject.messageOwner); - //} else if (messageObject.messageOwner.action.encryptedAction instanceof TLRPC.TL_decryptedMessageActionScreenshotMessages) { - // SecretChatHelper.getInstance().sendScreenshotMessage(encryptedChat, null, messageObject.messageOwner); - //} else if (messageObject.messageOwner.action.encryptedAction instanceof TLRPC.TL_decryptedMessageActionTyping) { - // - //} else if (messageObject.messageOwner.action.encryptedAction instanceof TLRPC.TL_decryptedMessageActionResend) { - // - //} else if (messageObject.messageOwner.action.encryptedAction instanceof TLRPC.TL_decryptedMessageActionCommitKey) { - // SecretChatHelper.getInstance().sendCommitKeyMessage(encryptedChat, messageObject.messageOwner); - //} else if (messageObject.messageOwner.action.encryptedAction instanceof TLRPC.TL_decryptedMessageActionAbortKey) { - // SecretChatHelper.getInstance().sendAbortKeyMessage(encryptedChat, messageObject.messageOwner, 0); - //} else if (messageObject.messageOwner.action.encryptedAction instanceof TLRPC.TL_decryptedMessageActionRequestKey) { - // SecretChatHelper.getInstance().sendRequestKeyMessage(encryptedChat, messageObject.messageOwner); - //} else if (messageObject.messageOwner.action.encryptedAction instanceof TLRPC.TL_decryptedMessageActionAcceptKey) { - // SecretChatHelper.getInstance().sendAcceptKeyMessage(encryptedChat, messageObject.messageOwner); - //} else if (messageObject.messageOwner.action.encryptedAction instanceof TLRPC.TL_decryptedMessageActionNoop) { - // SecretChatHelper.getInstance().sendNoopMessage(encryptedChat, messageObject.messageOwner); - //} - return true; - } - if (unsent) { - unsentMessages.put(messageObject.getId(), messageObject); - } - sendMessage(messageObject); - return true; - } - - protected void processSentMessage(int id) { - int prevSize = unsentMessages.size(); - unsentMessages.remove(id); - if (prevSize != 0 && unsentMessages.size() == 0) { - checkUnsentMessages(); - } - } - - public void processForwardFromMyName(MessageObject messageObject, long did) { - if (messageObject == null) { - return; - } - if (messageObject.messageOwner.media != null && !(messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaEmpty) && !(messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaWebPage)) { - if (messageObject.messageOwner.media.photo instanceof TLRPC.TL_photo) { - sendMessage((TLRPC.TL_photo) messageObject.messageOwner.media.photo, null, did, messageObject.replyMessageObject, null, null); - } else if (messageObject.messageOwner.media.document instanceof TLRPC.TL_document) { - sendMessage((TLRPC.TL_document) messageObject.messageOwner.media.document, null, messageObject.messageOwner.attachPath, did, messageObject.replyMessageObject, null, null); - } else if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaVenue || messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaGeo) { - sendMessage(messageObject.messageOwner.media, did, messageObject.replyMessageObject, null, null); - } else if (messageObject.messageOwner.media.phone_number != null) { - TLRPC.User user = new TLRPC.TL_userContact_old2(); - user.phone = messageObject.messageOwner.media.phone_number; - user.first_name = messageObject.messageOwner.media.first_name; - user.last_name = messageObject.messageOwner.media.last_name; - user.id = messageObject.messageOwner.media.user_id; - sendMessage(user, did, messageObject.replyMessageObject, null, null); - } else { - ArrayList arrayList = new ArrayList<>(); - arrayList.add(messageObject); - sendMessage(arrayList, did); - } - } else if (messageObject.messageOwner.message != null) { - TLRPC.WebPage webPage = null; - if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaWebPage) { - webPage = messageObject.messageOwner.media.webpage; - } - sendMessage(messageObject.messageOwner.message, did, messageObject.replyMessageObject, webPage, true, messageObject.messageOwner.entities, null, null); - } else { - ArrayList arrayList = new ArrayList<>(); - arrayList.add(messageObject); - sendMessage(arrayList, did); - } - } - */ - public void sendSticker(TLRPC.Document document, long peer, MessageObject replyingMessageObject) { if (document == null) { return; @@ -693,380 +593,24 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter SendMessagesHelper.getInstance().sendMessageDocument((TLRPC.TL_document) document, null, null, peer, replyingMessageObject, null); } - /* - private void sendMessage(ArrayList messages, final long peer) { - if ((int) peer == 0 || messages == null || messages.isEmpty()) { - return; - } - int lower_id = (int) peer; - final TLRPC.Peer to_id = MessagesController.getPeer((int) peer); - boolean isMegagroup = false; - boolean isSignature = false; - if (lower_id > 0) { - TLRPC.User sendToUser = MessagesController.getInstance().getUser(lower_id); - if (sendToUser == null) { - return; - } - } else { - TLRPC.Chat chat = MessagesController.getInstance().getChat(-lower_id); - if (ChatObject.isChannel(chat)) { - isMegagroup = chat.megagroup; - isSignature = chat.signatures; - } - } - - ArrayList objArr = new ArrayList<>(); - ArrayList arr = new ArrayList<>(); - ArrayList randomIds = new ArrayList<>(); - ArrayList ids = new ArrayList<>(); - HashMap messagesByRandomIds = new HashMap<>(); - TLRPC.InputPeer inputPeer = MessagesController.getInputPeer(lower_id); - long lastDialogId = 0; - for (int a = 0; a < messages.size(); a++) { - MessageObject msgObj = messages.get(a); - if (msgObj.getId() <= 0) { - continue; - } - - final TLRPC.Message newMsg = new TLRPC.TL_message(); - if (msgObj.isForwarded()) { - newMsg.fwd_from = msgObj.messageOwner.fwd_from; - } else { - newMsg.fwd_from = new TLRPC.TL_messageFwdHeader(); - if (msgObj.isFromUser()) { - newMsg.fwd_from.from_id = msgObj.messageOwner.from_id; - newMsg.fwd_from.flags |= 1; - } else { - newMsg.fwd_from.channel_id = msgObj.messageOwner.to_id.channel_id; - newMsg.fwd_from.flags |= 2; - if (msgObj.messageOwner.post) { - newMsg.fwd_from.channel_post = msgObj.getId(); - newMsg.fwd_from.flags |= 4; - if (msgObj.messageOwner.from_id > 0) { - newMsg.fwd_from.from_id = msgObj.messageOwner.from_id; - newMsg.fwd_from.flags |= 1; - } - } - } - newMsg.date = msgObj.messageOwner.date; - } - newMsg.media = msgObj.messageOwner.media; - newMsg.flags = TLRPC.MESSAGE_FLAG_FWD; - if (newMsg.media != null) { - newMsg.flags |= TLRPC.MESSAGE_FLAG_HAS_MEDIA; - } - if (isMegagroup) { - newMsg.flags |= TLRPC.MESSAGE_FLAG_MEGAGROUP; - } - if (msgObj.messageOwner.via_bot_id != 0) { - newMsg.via_bot_id = msgObj.messageOwner.via_bot_id; - newMsg.flags |= TLRPC.MESSAGE_FLAG_HAS_BOT_ID; - } - newMsg.message = msgObj.messageOwner.message; - newMsg.fwd_msg_id = msgObj.getId(); - newMsg.attachPath = msgObj.messageOwner.attachPath; - newMsg.entities = msgObj.messageOwner.entities; - if (!newMsg.entities.isEmpty()) { - newMsg.flags |= TLRPC.MESSAGE_FLAG_HAS_ENTITIES; - } - if (newMsg.attachPath == null) { - newMsg.attachPath = ""; - } - newMsg.local_id = newMsg.id = UserConfig.getNewMessageId(); - newMsg.out = true; - if (to_id.channel_id != 0 && !isMegagroup) { - newMsg.from_id = isSignature ? UserConfig.getClientUserId() : -to_id.channel_id; - newMsg.post = true; - } else { - newMsg.from_id = UserConfig.getClientUserId(); - newMsg.flags |= TLRPC.MESSAGE_FLAG_HAS_FROM_ID; - } - if (newMsg.random_id == 0) { - newMsg.random_id = getNextRandomId(); - } - randomIds.add(newMsg.random_id); - messagesByRandomIds.put(newMsg.random_id, newMsg); - ids.add(newMsg.fwd_msg_id); - newMsg.date = ConnectionsManager.getInstance().getCurrentTime(); - if (inputPeer instanceof TLRPC.TL_inputPeerChannel) { - if (!isMegagroup) { - newMsg.views = 1; - newMsg.flags |= TLRPC.MESSAGE_FLAG_HAS_VIEWS; - } else { - newMsg.unread = true; - } - } else { - if ((msgObj.messageOwner.flags & TLRPC.MESSAGE_FLAG_HAS_VIEWS) != 0) { - newMsg.views = msgObj.messageOwner.views; - newMsg.flags |= TLRPC.MESSAGE_FLAG_HAS_VIEWS; - } - newMsg.unread = true; - } - newMsg.dialog_id = peer; - newMsg.to_id = to_id; - if (MessageObject.isVoiceMessage(newMsg) && newMsg.to_id.channel_id == 0) { - newMsg.media_unread = true; - } - if (msgObj.messageOwner.to_id instanceof TLRPC.TL_peerChannel) { - newMsg.ttl = -msgObj.messageOwner.to_id.channel_id; - } - MessageObject newMsgObj = new MessageObject(newMsg, null, true); - newMsgObj.messageOwner.send_state = MessageObject.MESSAGE_SEND_STATE_SENDING; - objArr.add(newMsgObj); - arr.add(newMsg); - - putToSendingMessages(newMsg); - boolean differentDialog = false; - - if (BuildVars.DEBUG_VERSION) { - FileLog.e("tmessages", "forward message user_id = " + inputPeer.user_id + " chat_id = " + inputPeer.chat_id + " channel_id = " + inputPeer.channel_id + " access_hash = " + inputPeer.access_hash); - } - - if (arr.size() == 100 || a == messages.size() - 1 || a != messages.size() - 1 && messages.get(a + 1).getDialogId() != msgObj.getDialogId()) { - MessagesStorage.getInstance().putMessages(new ArrayList<>(arr), false, true, false, 0); - MessagesController.getInstance().updateInterfaceWithMessages(peer, objArr); - NotificationCenter.getInstance().postNotificationName(NotificationCenter.dialogsNeedReload); - UserConfig.saveConfig(false); - - TLRPC.TL_messages_forwardMessages req = new TLRPC.TL_messages_forwardMessages(); - req.to_peer = inputPeer; - if (req.to_peer instanceof TLRPC.TL_inputPeerChannel) { - req.silent = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE).getBoolean("silent_" + peer, false); - } - if (msgObj.messageOwner.to_id instanceof TLRPC.TL_peerChannel) { - TLRPC.Chat chat = MessagesController.getInstance().getChat(msgObj.messageOwner.to_id.channel_id); - req.from_peer = new TLRPC.TL_inputPeerChannel(); - req.from_peer.channel_id = msgObj.messageOwner.to_id.channel_id; - if (chat != null) { - req.from_peer.access_hash = chat.access_hash; - } - } else { - req.from_peer = new TLRPC.TL_inputPeerEmpty(); - } - req.random_id = randomIds; - req.id = ids; - - final ArrayList newMsgObjArr = arr; - final ArrayList newMsgArr = objArr; - final HashMap messagesByRandomIdsFinal = messagesByRandomIds; - final boolean isMegagroupFinal = isMegagroup; - ConnectionsManager.getInstance().sendRequest(req, new RequestDelegate() { - @Override - public void run(TLObject response, final TLRPC.TL_error error) { - if (error == null) { - HashMap newMessagesByIds = new HashMap<>(); - TLRPC.Updates updates = (TLRPC.Updates) response; - for (int a = 0; a < updates.updates.size(); a++) { - TLRPC.Update update = updates.updates.get(a); - if (update instanceof TLRPC.TL_updateMessageID) { - TLRPC.TL_updateMessageID updateMessageID = (TLRPC.TL_updateMessageID) update; - newMessagesByIds.put(updateMessageID.id, updateMessageID.random_id); - updates.updates.remove(a); - a--; - } - } - Integer value = MessagesController.getInstance().dialogs_read_outbox_max.get(peer); - if (value == null) { - value = MessagesStorage.getInstance().getDialogReadMax(true, peer); - MessagesController.getInstance().dialogs_read_outbox_max.put(peer, value); - } - - for (int a = 0; a < updates.updates.size(); a++) { - TLRPC.Update update = updates.updates.get(a); - if (update instanceof TLRPC.TL_updateNewMessage || update instanceof TLRPC.TL_updateNewChannelMessage) { - TLRPC.Message message; - if (update instanceof TLRPC.TL_updateNewMessage) { - message = ((TLRPC.TL_updateNewMessage) update).message; - MessagesController.getInstance().processNewDifferenceParams(-1, update.pts, -1, update.pts_count); - } else { - message = ((TLRPC.TL_updateNewChannelMessage) update).message; - MessagesController.getInstance().processNewChannelDifferenceParams(update.pts, update.pts_count, message.to_id.channel_id); - if (isMegagroupFinal) { - message.flags |= TLRPC.MESSAGE_FLAG_MEGAGROUP; - } - } - message.unread = value < message.id; - - Long random_id = newMessagesByIds.get(message.id); - if (random_id != null) { - final TLRPC.Message newMsgObj = messagesByRandomIdsFinal.get(random_id); - if (newMsgObj == null) { - continue; - } - MessageObject msgObj = newMsgArr.get(newMsgObjArr.indexOf(newMsgObj)); - newMsgObjArr.remove(newMsgObj); - final int oldId = newMsgObj.id; - final ArrayList sentMessages = new ArrayList<>(); - sentMessages.add(message); - newMsgObj.id = message.id; - updateMediaPaths(msgObj, message, null, true); - MessagesStorage.getInstance().getStorageQueue().postRunnable(new Runnable() { - @Override - public void run() { - MessagesStorage.getInstance().updateMessageStateAndId(newMsgObj.random_id, oldId, newMsgObj.id, 0, false, to_id.channel_id); - MessagesStorage.getInstance().putMessages(sentMessages, true, false, false, 0); - AndroidUtilities.runOnUIThread(new Runnable() { - @Override - public void run() { - newMsgObj.send_state = MessageObject.MESSAGE_SEND_STATE_SENT; - SearchQuery.increasePeerRaiting(peer); - NotificationCenter.getInstance().postNotificationName(NotificationCenter.messageReceivedByServer, oldId, newMsgObj.id, newMsgObj, peer); - processSentMessage(oldId); - removeFromSendingMessages(oldId); - } - }); - if (MessageObject.isVideoMessage(newMsgObj)) { - stopVideoService(newMsgObj.attachPath); - } - } - }); - } - } - } - } else { - AndroidUtilities.runOnUIThread(new Runnable() { - @Override - public void run() { - if (error.text.equals("PEER_FLOOD")) { - NotificationCenter.getInstance().postNotificationName(NotificationCenter.needShowAlert, 0); - } - } - }); - } - for (int a = 0; a < newMsgObjArr.size(); a++) { - final TLRPC.Message newMsgObj = newMsgObjArr.get(a); - MessagesStorage.getInstance().markMessageAsSendError(newMsgObj); - AndroidUtilities.runOnUIThread(new Runnable() { - @Override - public void run() { - newMsgObj.send_state = MessageObject.MESSAGE_SEND_STATE_SEND_ERROR; - NotificationCenter.getInstance().postNotificationName(NotificationCenter.messageSendError, newMsgObj.id); - processSentMessage(newMsgObj.id); - if (MessageObject.isVideoMessage(newMsgObj)) { - stopVideoService(newMsgObj.attachPath); - } - removeFromSendingMessages(newMsgObj.id); - } - }); - } - } - }, ConnectionsManager.RequestFlagCanCompress | ConnectionsManager.RequestFlagInvokeAfter); - - if (a != messages.size() - 1) { - objArr = new ArrayList<>(); - arr = new ArrayList<>(); - randomIds = new ArrayList<>(); - ids = new ArrayList<>(); - messagesByRandomIds = new HashMap<>(); - } - } - } - } - - private void sendLocation(Location location) { - TLRPC.TL_messageMediaGeo mediaGeo = new TLRPC.TL_messageMediaGeo(); - mediaGeo.geo = new TLRPC.TL_geoPoint(); - mediaGeo.geo.lat = location.getLatitude(); - mediaGeo.geo._long = location.getLongitude(); - for (HashMap.Entry entry : waitingForLocation.entrySet()) { - MessageObject messageObject = entry.getValue(); - SendMessagesHelper.getInstance().sendMessage(mediaGeo, messageObject.getDialogId(), messageObject, null, null); - } - } - - public void sendCurrentLocation(final MessageObject messageObject, final TLRPC.KeyboardButton button) { - final String key = messageObject.getId() + "_" + Utilities.bytesToHex(button.data); - waitingForLocation.put(key, messageObject); - //locationProvider.start(); - } - - public boolean isSendingCurrentLocation(MessageObject messageObject, TLRPC.KeyboardButton button) { - return !(messageObject == null || button == null) && waitingForLocation.containsKey(messageObject.getId() + "_" + Utilities.bytesToHex(button.data)); - } - - public void sendCallback(final MessageObject messageObject, final TLRPC.KeyboardButton button, final ChatActivity parentFragment) { - if (messageObject == null || button == null || parentFragment == null) { - return; - } - final String key = messageObject.getId() + "_" + Utilities.bytesToHex(button.data); - waitingForCallback.put(key, messageObject); - TLRPC.TL_messages_getBotCallbackAnswer req = new TLRPC.TL_messages_getBotCallbackAnswer(); - req.peer = MessagesController.getInputPeer((int) messageObject.getDialogId()); - req.msg_id = messageObject.getId(); - req.data = button.data; - ConnectionsManager.getInstance().sendRequest(req, new RequestDelegate() { - @Override - public void run(final TLObject response, TLRPC.TL_error error) { - AndroidUtilities.runOnUIThread(new Runnable() { - @Override - public void run() { - if (response != null) { - TLRPC.TL_messages_botCallbackAnswer res = (TLRPC.TL_messages_botCallbackAnswer) response; - if (res.message != null) { - if (res.alert) { - if (parentFragment.getParentActivity() == null) { - return; - } - AlertDialog.Builder builder = new AlertDialog.Builder(parentFragment.getParentActivity()); - builder.setTitle(LocaleController.getString("AppName", R.string.AppName)); - builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null); - builder.setMessage(res.message); - parentFragment.showDialog(builder.create()); - } else { - int uid = messageObject.messageOwner.from_id; - if (messageObject.messageOwner.via_bot_id != 0) { - uid = messageObject.messageOwner.via_bot_id; - } - TLRPC.User user = MessagesController.getInstance().getUser(uid); - if (user == null) { - return; - } - parentFragment.showAlert(user, res.message); - } - } - } - waitingForCallback.remove(key); - } - }); - } - }, ConnectionsManager.RequestFlagFailOnServerErrors); - } - - public boolean isSendingCallback(MessageObject messageObject, TLRPC.KeyboardButton button) { - return !(messageObject == null || button == null) && waitingForCallback.containsKey(messageObject.getId() + "_" + Utilities.bytesToHex(button.data)); - } - - public void sendMessage(MessageObject retryMessageObject) { - sendMessage__(null, null, null, null, null, null, retryMessageObject.getDialogId(), retryMessageObject.messageOwner.attachPath, null, null, true, - retryMessageObject, null, retryMessageObject.messageOwner.reply_markup, retryMessageObject.messageOwner.params); - } - */ - public void sendMessageContact(TLRPC.User user, long peer, MessageObject reply_to_msg, HashMap params) { sendMessage__(null, null, null, null, user, null, peer, null, reply_to_msg, null, true, - null, null, params); + null, params); } public void sendMessageDocument(TLRPC.TL_document document, VideoEditedInfo videoEditedInfo, String path, long peer, MessageObject reply_to_msg, HashMap params) { sendMessage__(null, null, null, videoEditedInfo, null, document, peer, path, reply_to_msg, null, true, - null, null, params); + null, params); } public void sendMessageText(String message, long peer, MessageObject reply_to_msg, TLRPC.WebPage webPage, boolean searchLinks, ArrayList entities, HashMap params) { sendMessage__(message, null, null, null, null, null, peer, null, reply_to_msg, webPage, searchLinks, - entities, null, params); + entities, params); } - /* - public void sendMessageLocation(TLRPC.MessageMedia location, long peer, MessageObject reply_to_msg, HashMap params) { - sendMessage__(null, location, null, null, null, null, peer, null, reply_to_msg, null, true, null, - null, params); - } - */ - public void sendMessagePhoto(TLRPC.TL_photo photo, String path, long peer, MessageObject reply_to_msg, HashMap params) { sendMessage__(null, null, photo, null, null, null, peer, path, reply_to_msg, null, true, null, - null, params); + params); } private void sendMessage__(String message, @@ -1081,7 +625,6 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter TLRPC.WebPage webPage, boolean searchLinks, ArrayList entities, - Object replyMarkup, HashMap params) { if (peer == 0) { // peer == dialog id return; @@ -1118,60 +661,12 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter }*/ try { - /*if (retryMessageObject != null) { - newMsg = retryMessageObject.messageOwner; - if (retryMessageObject.isForwarded()) { - type = 4; - } else { - if (retryMessageObject.type == 0) { - message = newMsg.message; - type = 0; - } else if (retryMessageObject.type == 4) { - location = newMsg.media; - type = 1; - } else if (retryMessageObject.type == 1) { - photo = (TLRPC.TL_photo) newMsg.media.photo; - type = 2; - } else if (retryMessageObject.type == 3) { - type = 3; - document = (TLRPC.TL_document) newMsg.media.document; - } else if (retryMessageObject.type == 12) { - user = new TLRPC.TL_userRequest_old2(); - user.phone = newMsg.media.phone_number; - user.first_name = newMsg.media.first_name; - user.last_name = newMsg.media.last_name; - user.id = newMsg.media.user_id; - type = 6; - } else if (retryMessageObject.type == 8 || retryMessageObject.type == 9 || retryMessageObject.type == 13 || retryMessageObject.type == 14) { - document = (TLRPC.TL_document) newMsg.media.document; - type = 7; - } else if (retryMessageObject.type == 2) { - document = (TLRPC.TL_document) newMsg.media.document; - type = 8; - } - if (params != null && params.containsKey("query_id")) { - type = 9; - } - } - } else */ { + { if (message != null) { - /*if (encryptedChat != null && AndroidUtilities.getPeerLayerVersion(encryptedChat.layer) >= 17) { - newMsg = new TLRPC.TL_message_secret(); - } else*/ { - newMsg = new TLRPC.TL_message(); - } + newMsg = new TLRPC.TL_message(); if (entities != null && !entities.isEmpty()) { newMsg.entities = entities; } - /*if (encryptedChat != null && webPage instanceof TLRPC.TL_webPagePending) { - if (webPage.url != null) { - TLRPC.WebPage newWebPage = new TLRPC.TL_webPageUrlPending(); - newWebPage.url = webPage.url; - webPage = newWebPage; - } else { - webPage = null; - } - }*/ if (webPage == null) { newMsg.media = new TLRPC.TL_messageMediaEmpty(); } else { @@ -1185,11 +680,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter } newMsg.message = message; } else if (location != null) { - /*if (encryptedChat != null && AndroidUtilities.getPeerLayerVersion(encryptedChat.layer) >= 17) { - newMsg = new TLRPC.TL_message_secret(); - } else*/ { - newMsg = new TLRPC.TL_message(); - } + newMsg = new TLRPC.TL_message(); newMsg.media = location; newMsg.message = ""; if (params != null && params.containsKey("query_id")) { @@ -1198,11 +689,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter type = 1; } } else if (photo != null) { - /*if (encryptedChat != null && AndroidUtilities.getPeerLayerVersion(encryptedChat.layer) >= 17) { - newMsg = new TLRPC.TL_message_secret(); - } else*/ { - newMsg = new TLRPC.TL_message(); - } + newMsg = new TLRPC.TL_message(); newMsg.media = new TLRPC.TL_messageMediaPhoto(); newMsg.media.caption = photo.caption != null ? photo.caption : ""; newMsg.media.photo = photo; @@ -1219,11 +706,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter newMsg.attachPath = FileLoader.getPathToAttach(location1, true).toString(); } } else if (user != null) { - /*if (encryptedChat != null && AndroidUtilities.getPeerLayerVersion(encryptedChat.layer) >= 17) { - newMsg = new TLRPC.TL_message_secret(); - } else*/ { - newMsg = new TLRPC.TL_message(); - } + newMsg = new TLRPC.TL_message(); newMsg.media = new TLRPC.TL_messageMediaContact(); newMsg.media.phone_number = user.phone; newMsg.media.first_name = user.first_name; @@ -1271,6 +754,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter newMsg.flags |= TLRPC.MESSAGE_FLAG_HAS_FROM_ID; UserConfig.saveConfig(false); } + if (newMsg.random_id == 0) { newMsg.random_id = getNextRandomId(); } @@ -1283,29 +767,9 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter newMsg.flags |= TLRPC.MESSAGE_FLAG_REPLY; newMsg.reply_to_msg_id = reply_to_msg.getId(); } - /*if (replyMarkup != null && encryptedChat == null) { - newMsg.flags |= TLRPC.MESSAGE_FLAG_HAS_MARKUP; - newMsg.reply_markup = replyMarkup; - }*/ + if (lower_id != 0) { - /*if (high_id == 1) { - if (currentChatInfo == null) { - //MessagesStorage.getInstance().markMessageAsSendError(newMsg); - NotificationCenter.getInstance().postNotificationName(NotificationCenter.messageSendError, newMsg.id); - processSentMessage(newMsg.id); - return; - } - sendToPeers = new ArrayList<>(); - for (TLRPC.ChatParticipant participant : currentChatInfo.participants.participants) { - TLRPC.User sendToUser = MessagesController.getInstance().getUser(participant.user_id); - TLRPC.InputUser peerUser = MessagesController.getInputUser(sendToUser); - if (peerUser != null) { - sendToPeers.add(peerUser); - } - } - newMsg.to_id = new TLRPC.TL_peerChat(); - newMsg.to_id.chat_id = lower_id; - } else*/ { + { newMsg.to_id = MessagesController.getPeer(lower_id); if (lower_id > 0) { TLRPC.User sendToUser = MessagesController.getInstance().getUser(lower_id); @@ -1318,41 +782,9 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter }*/ } } - }/* else { - 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; - if (newMsg.ttl != 0) { - if (MessageObject.isVoiceMessage(newMsg)) { - int duration = 0; - for (int a = 0; a < newMsg.media.document.attributes.size(); a++) { - TLRPC.DocumentAttribute attribute = newMsg.media.document.attributes.get(a); - if (attribute instanceof TLRPC.TL_documentAttributeAudio) { - duration = attribute.duration; - break; - } - } - newMsg.ttl = Math.max(encryptedChat.ttl, duration + 1); - } else if (MessageObject.isVideoMessage(newMsg)) { - int duration = 0; - for (int a = 0; a < newMsg.media.document.attributes.size(); a++) { - TLRPC.DocumentAttribute attribute = newMsg.media.document.attributes.get(a); - if (attribute instanceof TLRPC.TL_documentAttributeVideo) { - duration = attribute.duration; - break; - } - } - newMsg.ttl = Math.max(encryptedChat.ttl, duration + 1); - } - } - }*/ - //if ((encryptedChat == null || AndroidUtilities.getPeerLayerVersion(encryptedChat.layer) >= 46) && high_id != 1 && MessageObject.isVoiceMessage(newMsg) && newMsg.to_id.channel_id == 0) { - newMsg.media_unread = true; - //} + } + + newMsg.media_unread = true; newMsg.send_state = MessageObject.MESSAGE_SEND_STATE_SENDING; newMsgObj = new MessageObject(newMsg, null, true); @@ -1634,15 +1066,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter */ } - /* - private void putToSendingMessages(TLRPC.Message message) { - sendingMessages.put(message.id, message); - } - private void removeFromSendingMessages(int mid) { - sendingMessages.remove(mid); - } - */ public boolean isSendingMessage(int mid) { //return sendingMessages.containsKey(mid); @@ -1656,305 +1080,6 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter return isSending; } - /* - private void performSendMessageRequest(final TLObject req, final MessageObject msgObj, final String originalPath) { - final TLRPC.Message newMsgObj = msgObj.messageOwner; - putToSendingMessages(newMsgObj); - ConnectionsManager.getInstance().sendRequest(req, new RequestDelegate() { - @Override - public void run(final TLObject response, final TLRPC.TL_error error) { - AndroidUtilities.runOnUIThread(new Runnable() { - @Override - public void run() { - boolean isSentError = false; - if (error == null) { - final int oldId = newMsgObj.id; - final boolean isBroadcast = req instanceof TLRPC.TL_messages_sendBroadcast; - final ArrayList sentMessages = new ArrayList<>(); - final String attachPath = newMsgObj.attachPath; - if (response instanceof TLRPC.TL_updateShortSentMessage) { - final TLRPC.TL_updateShortSentMessage res = (TLRPC.TL_updateShortSentMessage) response; - newMsgObj.local_id = newMsgObj.id = res.id; - newMsgObj.date = res.date; - newMsgObj.entities = res.entities; - newMsgObj.out = res.out; - if (res.media != null) { - newMsgObj.media = res.media; - newMsgObj.flags |= TLRPC.MESSAGE_FLAG_HAS_MEDIA; - } - if (!newMsgObj.entities.isEmpty()) { - newMsgObj.flags |= TLRPC.MESSAGE_FLAG_HAS_ENTITIES; - } - Utilities.stageQueue.postRunnable(new Runnable() { - @Override - public void run() { - MessagesController.getInstance().processNewDifferenceParams(-1, res.pts, res.date, res.pts_count); - } - }); - sentMessages.add(newMsgObj); - } else if (response instanceof TLRPC.Updates) { - ArrayList updates = ((TLRPC.Updates) response).updates; - TLRPC.Message message = null; - for (int a = 0; a < updates.size(); a++) { - TLRPC.Update update = updates.get(a); - if (update instanceof TLRPC.TL_updateNewMessage) { - final TLRPC.TL_updateNewMessage newMessage = (TLRPC.TL_updateNewMessage) update; - sentMessages.add(message = newMessage.message); - newMsgObj.id = newMessage.message.id; - Utilities.stageQueue.postRunnable(new Runnable() { - @Override - public void run() { - MessagesController.getInstance().processNewDifferenceParams(-1, newMessage.pts, -1, newMessage.pts_count); - } - }); - break; - } else if (update instanceof TLRPC.TL_updateNewChannelMessage) { - final TLRPC.TL_updateNewChannelMessage newMessage = (TLRPC.TL_updateNewChannelMessage) update; - sentMessages.add(message = newMessage.message); - if ((newMsgObj.flags & TLRPC.MESSAGE_FLAG_MEGAGROUP) != 0) { - newMessage.message.flags |= TLRPC.MESSAGE_FLAG_MEGAGROUP; - } - Utilities.stageQueue.postRunnable(new Runnable() { - @Override - public void run() { - MessagesController.getInstance().processNewChannelDifferenceParams(newMessage.pts, newMessage.pts_count, newMessage.message.to_id.channel_id); - } - }); - break; - } - } - if (message != null) { - Integer value = MessagesController.getInstance().dialogs_read_outbox_max.get(message.dialog_id); - if (value == null) { - value = 0;//MessagesStorage.getInstance().getDialogReadMax(message.out, message.dialog_id); - MessagesController.getInstance().dialogs_read_outbox_max.put(message.dialog_id, value); - } - message.unread = value < message.id; - - newMsgObj.id = message.id; - updateMediaPaths(msgObj, message, originalPath, false); - } else { - isSentError = true; - } - } - - if (!isSentError) { - newMsgObj.send_state = MessageObject.MESSAGE_SEND_STATE_SENT; - NotificationCenter.getInstance().postNotificationName(NotificationCenter.messageReceivedByServer, oldId, (isBroadcast ? oldId : newMsgObj.id), newMsgObj, newMsgObj.dialog_id); //TODO remove later? - MessagesStorage.getInstance().getStorageQueue().postRunnable(new Runnable() { - @Override - public void run() { - MessagesStorage.getInstance().updateMessageStateAndId(newMsgObj.random_id, oldId, (isBroadcast ? oldId : newMsgObj.id), 0, false, newMsgObj.to_id.channel_id); - MessagesStorage.getInstance().putMessages(sentMessages, true, false, isBroadcast, 0); - if (isBroadcast) { - ArrayList currentMessage = new ArrayList<>(); - currentMessage.add(newMsgObj); - MessagesStorage.getInstance().putMessages(currentMessage, true, false, false, 0); - } - AndroidUtilities.runOnUIThread(new Runnable() { - @Override - public void run() { - if (isBroadcast) { - for (int a = 0; a < sentMessages.size(); a++) { - TLRPC.Message message = sentMessages.get(a); - ArrayList arr = new ArrayList<>(); - MessageObject messageObject = new MessageObject(message, null, false); - arr.add(messageObject); - MessagesController.getInstance().updateInterfaceWithMessages(messageObject.getDialogId(), arr, true); - } - NotificationCenter.getInstance().postNotificationName(NotificationCenter.dialogsNeedReload); - } - SearchQuery.increasePeerRaiting(newMsgObj.dialog_id); - NotificationCenter.getInstance().postNotificationName(NotificationCenter.messageReceivedByServer, oldId, (isBroadcast ? oldId : newMsgObj.id), newMsgObj, newMsgObj.dialog_id); - processSentMessage(oldId); - removeFromSendingMessages(oldId); - } - }); - if (MessageObject.isVideoMessage(newMsgObj)) { - stopVideoService(attachPath); - } - } - }); - } - } else { - if (error.text.equals("PEER_FLOOD")) { - NotificationCenter.getInstance().postNotificationName(NotificationCenter.needShowAlert, 0); - } - isSentError = true; - } - if (isSentError) { - //MessagesStorage.getInstance().markMessageAsSendError(newMsgObj); - newMsgObj.send_state = MessageObject.MESSAGE_SEND_STATE_SEND_ERROR; - NotificationCenter.getInstance().postNotificationName(NotificationCenter.messageSendError, newMsgObj.id); - processSentMessage(newMsgObj.id); - if (MessageObject.isVideoMessage(newMsgObj)) { - stopVideoService(newMsgObj.attachPath); - } - removeFromSendingMessages(newMsgObj.id); - } - } - }); - } - }, new QuickAckDelegate() { - @Override - public void run() { - final int msg_id = newMsgObj.id; - AndroidUtilities.runOnUIThread(new Runnable() { - @Override - public void run() { - newMsgObj.send_state = MessageObject.MESSAGE_SEND_STATE_SENT; - NotificationCenter.getInstance().postNotificationName(NotificationCenter.messageReceivedByAck, msg_id); - } - }); - } - }, ConnectionsManager.RequestFlagCanCompress | ConnectionsManager.RequestFlagInvokeAfter | (req instanceof TLRPC.TL_messages_sendMessage ? ConnectionsManager.RequestFlagNeedQuickAck : 0)); - } - - private void updateMediaPaths(MessageObject newMsgObj, TLRPC.Message sentMessage, String originalPath, boolean post) { - TLRPC.Message newMsg = newMsgObj.messageOwner; - if (sentMessage == null) { - return; - } - if (sentMessage.media instanceof TLRPC.TL_messageMediaPhoto && sentMessage.media.photo != null && newMsg.media instanceof TLRPC.TL_messageMediaPhoto && newMsg.media.photo != null) { - //MessagesStorage.getInstance().putSentFile(originalPath, sentMessage.media.photo, 0); - - if (newMsg.media.photo.sizes.size() == 1 && newMsg.media.photo.sizes.get(0).location instanceof TLRPC.TL_fileLocationUnavailable) { - newMsg.media.photo.sizes = sentMessage.media.photo.sizes; - } else { - for (int a = 0; a < sentMessage.media.photo.sizes.size(); a++) { - TLRPC.PhotoSize size = sentMessage.media.photo.sizes.get(a); - if (size == null || size.location == null || size instanceof TLRPC.TL_photoSizeEmpty || size.type == null) { - continue; - } - for (int b = 0; b < newMsg.media.photo.sizes.size(); b++) { - TLRPC.PhotoSize size2 = newMsg.media.photo.sizes.get(b); - if (size2 == null || size2.location == null || size2.type == null) { - continue; - } - if (size2.location.volume_id == Integer.MIN_VALUE && size.type.equals(size2.type) || size.w == size2.w && size.h == size2.h) { - String fileName = size2.location.volume_id + "_" + size2.location.local_id; - String fileName2 = size.location.volume_id + "_" + size.location.local_id; - if (fileName.equals(fileName2)) { - break; - } - File cacheFile = new File(FileLoader.getInstance().getDirectory(FileLoader.MEDIA_DIR_CACHE), fileName + ".jpg"); - File cacheFile2; - if (sentMessage.media.photo.sizes.size() == 1 || size.w > 90 || size.h > 90) { - cacheFile2 = FileLoader.getPathToAttach(size); - } else { - cacheFile2 = new File(FileLoader.getInstance().getDirectory(FileLoader.MEDIA_DIR_CACHE), fileName2 + ".jpg"); - } - cacheFile.renameTo(cacheFile2); - ImageLoader.getInstance().replaceImageInCache(fileName, fileName2, size.location, post); - size2.location = size.location; - size2.size = size.size; - break; - } - } - } - } - sentMessage.message = newMsg.message; - sentMessage.attachPath = newMsg.attachPath; - newMsg.media.photo.id = sentMessage.media.photo.id; - newMsg.media.photo.access_hash = sentMessage.media.photo.access_hash; - } else if (sentMessage.media instanceof TLRPC.TL_messageMediaDocument && sentMessage.media.document != null && newMsg.media instanceof TLRPC.TL_messageMediaDocument && newMsg.media.document != null) { - if (MessageObject.isVideoMessage(sentMessage)) { - //MessagesStorage.getInstance().putSentFile(originalPath, sentMessage.media.document, 2); - sentMessage.attachPath = newMsg.attachPath; - } else if (!MessageObject.isVoiceMessage(sentMessage)) { - //MessagesStorage.getInstance().putSentFile(originalPath, sentMessage.media.document, 1); - } - - TLRPC.PhotoSize size2 = newMsg.media.document.thumb; - TLRPC.PhotoSize size = sentMessage.media.document.thumb; - if (size2 != null && size2.location != null && size2.location.volume_id == Integer.MIN_VALUE && size != null && size.location != null && !(size instanceof TLRPC.TL_photoSizeEmpty) && !(size2 instanceof TLRPC.TL_photoSizeEmpty)) { - String fileName = size2.location.volume_id + "_" + size2.location.local_id; - String fileName2 = size.location.volume_id + "_" + size.location.local_id; - if (!fileName.equals(fileName2)) { - File cacheFile = new File(FileLoader.getInstance().getDirectory(FileLoader.MEDIA_DIR_CACHE), fileName + ".jpg"); - File cacheFile2 = new File(FileLoader.getInstance().getDirectory(FileLoader.MEDIA_DIR_CACHE), fileName2 + ".jpg"); - cacheFile.renameTo(cacheFile2); - ImageLoader.getInstance().replaceImageInCache(fileName, fileName2, size.location, post); - size2.location = size.location; - size2.size = size.size; - } - } else if (size2 != null && MessageObject.isStickerMessage(sentMessage) && size2.location != null) { - size.location = size2.location; - } else if (size2 != null && size2.location instanceof TLRPC.TL_fileLocationUnavailable || size2 instanceof TLRPC.TL_photoSizeEmpty) { - newMsg.media.document.thumb = sentMessage.media.document.thumb; - } - - newMsg.media.document.dc_id = sentMessage.media.document.dc_id; - newMsg.media.document.id = sentMessage.media.document.id; - newMsg.media.document.access_hash = sentMessage.media.document.access_hash; - byte[] oldWaveform = null; - for (int a = 0; a < newMsg.media.document.attributes.size(); a++) { - TLRPC.DocumentAttribute attribute = newMsg.media.document.attributes.get(a); - if (attribute instanceof TLRPC.TL_documentAttributeAudio) { - oldWaveform = attribute.waveform; - break; - } - } - newMsg.media.document.attributes = sentMessage.media.document.attributes; - if (oldWaveform != null) { - for (int a = 0; a < newMsg.media.document.attributes.size(); a++) { - TLRPC.DocumentAttribute attribute = newMsg.media.document.attributes.get(a); - if (attribute instanceof TLRPC.TL_documentAttributeAudio) { - attribute.waveform = oldWaveform; - attribute.flags |= 4; - } - } - } - newMsg.media.document.size = sentMessage.media.document.size; - newMsg.media.document.mime_type = sentMessage.media.document.mime_type; - - if ((sentMessage.flags & TLRPC.MESSAGE_FLAG_FWD) == 0 && MessageObject.isOut(sentMessage) && MessageObject.isNewGifDocument(sentMessage.media.document)) { - MessagesController.addNewGifToRecent(sentMessage.media.document, sentMessage.date); - } - - if (newMsg.attachPath != null && newMsg.attachPath.startsWith(FileLoader.getInstance().getDirectory(FileLoader.MEDIA_DIR_CACHE).getAbsolutePath())) { - File cacheFile = new File(newMsg.attachPath); - File cacheFile2 = FileLoader.getPathToAttach(sentMessage.media.document); - if (!cacheFile.renameTo(cacheFile2)) { - sentMessage.attachPath = newMsg.attachPath; - sentMessage.message = newMsg.message; - } else { - if (MessageObject.isVideoMessage(sentMessage)) { - newMsgObj.attachPathExists = true; - } else { - newMsgObj.mediaExists = newMsgObj.attachPathExists; - newMsgObj.attachPathExists = false; - newMsg.attachPath = ""; - if (originalPath != null && originalPath.startsWith("http")) { - //MessagesStorage.getInstance().addRecentLocalFile(originalPath, cacheFile2.toString(), newMsg.media.document); - } - } - } - } else { - sentMessage.attachPath = newMsg.attachPath; - sentMessage.message = newMsg.message; - } - } else if (sentMessage.media instanceof TLRPC.TL_messageMediaContact && newMsg.media instanceof TLRPC.TL_messageMediaContact) { - newMsg.media = sentMessage.media; - } else if (sentMessage.media instanceof TLRPC.TL_messageMediaWebPage) { - newMsg.media = sentMessage.media; - } - } - - private void putToDelayedMessages(String location, DelayedMessage message) { - ArrayList arrayList = delayedMessages.get(location); - if (arrayList == null) { - arrayList = new ArrayList<>(); - delayedMessages.put(location, arrayList); - } - arrayList.add(message); - } - - protected ArrayList getDelayedMessages(String location) { - return delayedMessages.get(location); - } - */ - protected long getNextRandomId() { long val = 0; while (val == 0) { @@ -1967,24 +1092,6 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter //MessagesStorage.getInstance().getUnsentMessages(1000); } - /* - protected void processUnsentMessages(final ArrayList messages, final ArrayList users, final ArrayList chats, final ArrayList encryptedChats) { - AndroidUtilities.runOnUIThread(new Runnable() { - @Override - public void run() { - MessagesController.getInstance().putUsers(users, true); - MessagesController.getInstance().putChats(chats, true); - MessagesController.getInstance().putEncryptedChats(encryptedChats, true); - for (int a = 0; a < messages.size(); a++) { - TLRPC.Message message = messages.get(a); - MessageObject messageObject = new MessageObject(message, null, false); - retrySendMessage(messageObject, true); - } - } - }); - } - */ - public TLRPC.TL_photo generatePhotoSizes(String path, Uri imageUri) { Bitmap bitmap = ImageLoader.loadBitmap(path, imageUri, AndroidUtilities.getPhotoSize(), AndroidUtilities.getPhotoSize(), true); if (bitmap == null && AndroidUtilities.getPhotoSize() != 800) { diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/query/SharedMediaQuery.java b/TMessagesProj/src/main/java/org/telegram/messenger/query/SharedMediaQuery.java index bfbcd45cf..218c26d90 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/query/SharedMediaQuery.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/query/SharedMediaQuery.java @@ -166,23 +166,6 @@ public class SharedMediaQuery { return -1; } - public static boolean canAddMessageToMedia(TLRPC.Message message) { - if (message instanceof TLRPC.TL_message_secret && message.media instanceof TLRPC.TL_messageMediaPhoto && message.ttl != 0 && message.ttl <= 60) { - return false; - } else if (message.media instanceof TLRPC.TL_messageMediaPhoto || - message.media instanceof TLRPC.TL_messageMediaDocument && !MessageObject.isGifDocument(message.media.document)) { - return true; - } else if (!message.entities.isEmpty()) { - for (int a = 0; a < message.entities.size(); a++) { - TLRPC.MessageEntity entity = message.entities.get(a); - if (entity instanceof TLRPC.TL_messageEntityUrl || entity instanceof TLRPC.TL_messageEntityTextUrl || entity instanceof TLRPC.TL_messageEntityEmail) { - return true; - } - } - } - return false; - } - private static void processLoadedMedia(final TLRPC.messages_Messages res, final long uid, int offset, int count, int max_id, final int type, final boolean fromCache, final int classGuid, final boolean isChannel, final boolean topReached) { int lower_part = (int)uid; if (fromCache && res.messages.isEmpty() && lower_part != 0) { diff --git a/TMessagesProj/src/main/java/org/telegram/tgnet/TLRPC.java b/TMessagesProj/src/main/java/org/telegram/tgnet/TLRPC.java index 206af23a4..f5208b85e 100644 --- a/TMessagesProj/src/main/java/org/telegram/tgnet/TLRPC.java +++ b/TMessagesProj/src/main/java/org/telegram/tgnet/TLRPC.java @@ -498,37 +498,6 @@ public class TLRPC { } } - public static class TL_messages_affectedMessages extends TLObject { - public static int constructor = 0x84d19185; - - public int pts; - public int pts_count; - - public static TL_messages_affectedMessages TLdeserialize(AbstractSerializedData stream, int constructor, boolean exception) { - if (TL_messages_affectedMessages.constructor != constructor) { - if (exception) { - throw new RuntimeException(String.format("can't parse magic %x in TL_messages_affectedMessages", constructor)); - } else { - return null; - } - } - TL_messages_affectedMessages result = new TL_messages_affectedMessages(); - result.readParams(stream, exception); - return result; - } - - public void readParams(AbstractSerializedData stream, boolean exception) { - pts = stream.readInt32(exception); - pts_count = stream.readInt32(exception); - } - - public void serializeToStream(AbstractSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(pts); - stream.writeInt32(pts_count); - } - } - public static class PrivacyKey extends TLObject { public static PrivacyKey TLdeserialize(AbstractSerializedData stream, int constructor, boolean exception) { @@ -1027,7 +996,6 @@ public class TLRPC { public int w; public int h; public int duration; - public BotInlineMessage send_message; public Photo photo; public Document document; public long query_id; @@ -1044,7 +1012,6 @@ public class TLRPC { public boolean silent; public int mute_until; public String sound; - public int events_mask; public static PeerNotifySettings TLdeserialize(AbstractSerializedData stream, int constructor, boolean exception) { PeerNotifySettings result = null; @@ -1196,7 +1163,6 @@ public class TLRPC { public static class Audio extends TLObject { public long id; - public long access_hash; public int date; public int duration; public String mime_type; @@ -1224,19 +1190,6 @@ public class TLRPC { } } - public static class ReplyMarkup extends TLObject { - public ArrayList rows = new ArrayList<>(); - public int flags; - public boolean selective; - public boolean single_use; - public boolean resize; - - public static ReplyMarkup TLdeserialize(AbstractSerializedData stream, int constructor, boolean exception) { - ReplyMarkup result = null; - return result; - } - } - public static class contacts_Contacts extends TLObject { public ArrayList contacts = new ArrayList<>(); public ArrayList users = new ArrayList<>(); @@ -1627,155 +1580,6 @@ public class TLRPC { } } - public static class KeyboardButton extends TLObject { - public String text; - public String query; - public byte[] data; - public String url; - - public static KeyboardButton TLdeserialize(AbstractSerializedData stream, int constructor, boolean exception) { - KeyboardButton result = null; - return result; - } - } - - public static class TL_keyboardButtonSwitchInline extends KeyboardButton { - public static int constructor = 0xea1b7a14; - - - public void readParams(AbstractSerializedData stream, boolean exception) { - text = stream.readString(exception); - query = stream.readString(exception); - } - - public void serializeToStream(AbstractSerializedData stream) { - stream.writeInt32(constructor); - stream.writeString(text); - stream.writeString(query); - } - } - - public static class BotInlineMessage extends TLObject { - public int flags; - public GeoPoint geo; - public ReplyMarkup reply_markup; - public String caption; - public boolean no_webpage; - public String message; - public ArrayList entities = new ArrayList<>(); - public String phone_number; - public String first_name; - public String last_name; - public String title; - public String address; - public String provider; - public String venue_id; - - public static BotInlineMessage TLdeserialize(AbstractSerializedData stream, int constructor, boolean exception) { - BotInlineMessage result = null; - return result; - } - } - - public static class TL_botInlineMessageMediaGeo extends BotInlineMessage { - public static int constructor = 0x3a8fd8b8; - - - public void readParams(AbstractSerializedData stream, boolean exception) { - flags = stream.readInt32(exception); - geo = GeoPoint.TLdeserialize(stream, stream.readInt32(exception), exception); - if ((flags & 4) != 0) { - reply_markup = ReplyMarkup.TLdeserialize(stream, stream.readInt32(exception), exception); - } - } - - public void serializeToStream(AbstractSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(flags); - geo.serializeToStream(stream); - if ((flags & 4) != 0) { - reply_markup.serializeToStream(stream); - } - } - } - - public static class TL_botInlineMessageMediaVenue extends BotInlineMessage { - public static int constructor = 0x4366232e; - - - public void readParams(AbstractSerializedData stream, boolean exception) { - flags = stream.readInt32(exception); - geo = GeoPoint.TLdeserialize(stream, stream.readInt32(exception), exception); - title = stream.readString(exception); - address = stream.readString(exception); - provider = stream.readString(exception); - venue_id = stream.readString(exception); - if ((flags & 4) != 0) { - reply_markup = ReplyMarkup.TLdeserialize(stream, stream.readInt32(exception), exception); - } - } - - public void serializeToStream(AbstractSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(flags); - geo.serializeToStream(stream); - stream.writeString(title); - stream.writeString(address); - stream.writeString(provider); - stream.writeString(venue_id); - if ((flags & 4) != 0) { - reply_markup.serializeToStream(stream); - } - } - } - - public static class TL_keyboardButtonRow extends TLObject { - public static int constructor = 0x77608b83; - - public ArrayList buttons = new ArrayList<>(); - - public static TL_keyboardButtonRow TLdeserialize(AbstractSerializedData stream, int constructor, boolean exception) { - if (TL_keyboardButtonRow.constructor != constructor) { - if (exception) { - throw new RuntimeException(String.format("can't parse magic %x in TL_keyboardButtonRow", constructor)); - } else { - return null; - } - } - TL_keyboardButtonRow result = new TL_keyboardButtonRow(); - result.readParams(stream, exception); - return result; - } - - public void readParams(AbstractSerializedData stream, boolean exception) { - int magic = stream.readInt32(exception); - if (magic != 0x1cb5c415) { - if (exception) { - throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); - } - return; - } - int count = stream.readInt32(exception); - for (int a = 0; a < count; a++) { - KeyboardButton object = KeyboardButton.TLdeserialize(stream, stream.readInt32(exception), exception); - if (object == null) { - return; - } - buttons.add(object); - } - } - - public void serializeToStream(AbstractSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(0x1cb5c415); - int count = buttons.size(); - stream.writeInt32(count); - for (int a = 0; a < count; a++) { - buttons.get(a).serializeToStream(stream); - } - } - } - public static class Bool extends TLObject { public static Bool TLdeserialize(AbstractSerializedData stream, int constructor, boolean exception) { @@ -2273,23 +2077,6 @@ public class TLRPC { } } - public static class ChannelParticipantsFilter extends TLObject { - - public static ChannelParticipantsFilter TLdeserialize(AbstractSerializedData stream, int constructor, boolean exception) { - ChannelParticipantsFilter result = null; - return result; - } - } - - public static class TL_channelParticipantsRecent extends ChannelParticipantsFilter { - public static int constructor = 0xde3f3c79; - - - public void serializeToStream(AbstractSerializedData stream) { - stream.writeInt32(constructor); - } - } - public static class MessageAction extends TLObject { public String title; public String address; @@ -4567,156 +4354,6 @@ public class TLRPC { } } - public static class ChannelParticipant extends TLObject { - public int user_id; - public int date; - public int inviter_id; - public int kicked_by; - - public static ChannelParticipant TLdeserialize(AbstractSerializedData stream, int constructor, boolean exception) { - ChannelParticipant result = null; - return result; - } - } - - public static class TL_channelParticipant extends ChannelParticipant { - public static int constructor = 0x15ebac1d; - - - public void readParams(AbstractSerializedData stream, boolean exception) { - user_id = stream.readInt32(exception); - date = stream.readInt32(exception); - } - - public void serializeToStream(AbstractSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(user_id); - stream.writeInt32(date); - } - } - - public static class TL_channelParticipantEditor extends ChannelParticipant { - public static int constructor = 0x98192d61; - - - public void readParams(AbstractSerializedData stream, boolean exception) { - user_id = stream.readInt32(exception); - inviter_id = stream.readInt32(exception); - date = stream.readInt32(exception); - } - - public void serializeToStream(AbstractSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(user_id); - stream.writeInt32(inviter_id); - stream.writeInt32(date); - } - } - - public static class TL_channelParticipantModerator extends ChannelParticipant { - public static int constructor = 0x91057fef; - - - public void readParams(AbstractSerializedData stream, boolean exception) { - user_id = stream.readInt32(exception); - inviter_id = stream.readInt32(exception); - date = stream.readInt32(exception); - } - - public void serializeToStream(AbstractSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(user_id); - stream.writeInt32(inviter_id); - stream.writeInt32(date); - } - } - - public static class TL_channelParticipantCreator extends ChannelParticipant { - public static int constructor = 0xe3e2e1f9; - - - public void readParams(AbstractSerializedData stream, boolean exception) { - user_id = stream.readInt32(exception); - } - - public void serializeToStream(AbstractSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(user_id); - } - } - - public static class TL_channels_channelParticipants extends TLObject { - public static int constructor = 0xf56ee2a8; - - public int count; - public ArrayList participants = new ArrayList<>(); - public ArrayList users = new ArrayList<>(); - - public static TL_channels_channelParticipants TLdeserialize(AbstractSerializedData stream, int constructor, boolean exception) { - if (TL_channels_channelParticipants.constructor != constructor) { - if (exception) { - throw new RuntimeException(String.format("can't parse magic %x in TL_channels_channelParticipants", constructor)); - } else { - return null; - } - } - TL_channels_channelParticipants result = new TL_channels_channelParticipants(); - result.readParams(stream, exception); - return result; - } - - public void readParams(AbstractSerializedData stream, boolean exception) { - count = stream.readInt32(exception); - int magic = stream.readInt32(exception); - if (magic != 0x1cb5c415) { - if (exception) { - throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); - } - return; - } - int count = stream.readInt32(exception); - for (int a = 0; a < count; a++) { - ChannelParticipant object = ChannelParticipant.TLdeserialize(stream, stream.readInt32(exception), exception); - if (object == null) { - return; - } - participants.add(object); - } - magic = stream.readInt32(exception); - if (magic != 0x1cb5c415) { - if (exception) { - throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); - } - return; - } - count = stream.readInt32(exception); - for (int a = 0; a < count; a++) { - User object = User.TLdeserialize(stream, stream.readInt32(exception), exception); - if (object == null) { - return; - } - users.add(object); - } - } - - public void serializeToStream(AbstractSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(count); - stream.writeInt32(0x1cb5c415); - int count = participants.size(); - stream.writeInt32(count); - for (int a = 0; a < count; a++) { - participants.get(a).serializeToStream(stream); - } - stream.writeInt32(0x1cb5c415); - count = users.size(); - stream.writeInt32(count); - for (int a = 0; a < count; a++) { - users.get(a).serializeToStream(stream); - } - } - } - public static class TL_contacts_found extends TLObject { public static int constructor = 0x1aa1f784; @@ -7354,91 +6991,6 @@ public class TLRPC { } } - public static class TL_channels_deleteMessages extends TLObject { - public static int constructor = 0x84c1fd4e; - - public InputChannel channel; - public ArrayList id = new ArrayList<>(); - - public TLObject deserializeResponse(AbstractSerializedData stream, int constructor, boolean exception) { - return TL_messages_affectedMessages.TLdeserialize(stream, constructor, exception); - } - - public void serializeToStream(AbstractSerializedData stream) { - stream.writeInt32(constructor); - channel.serializeToStream(stream); - stream.writeInt32(0x1cb5c415); - int count = id.size(); - stream.writeInt32(count); - for (int a = 0; a < count; a++) { - stream.writeInt32(id.get(a)); - } - } - } - - public static class TL_channels_getParticipants extends TLObject { - public static int constructor = 0x24d98f92; - - public InputChannel channel; - public ChannelParticipantsFilter filter; - public int offset; - public int limit; - - public TLObject deserializeResponse(AbstractSerializedData stream, int constructor, boolean exception) { - return TL_channels_channelParticipants.TLdeserialize(stream, constructor, exception); - } - - public void serializeToStream(AbstractSerializedData stream) { - stream.writeInt32(constructor); - channel.serializeToStream(stream); - filter.serializeToStream(stream); - stream.writeInt32(offset); - stream.writeInt32(limit); - } - } - - public static class TL_channels_createChannel extends TLObject { - public static int constructor = 0xf4893d7f; - - public int flags; - public boolean broadcast; - public boolean megagroup; - public String title; - public String about; - - public TLObject deserializeResponse(AbstractSerializedData stream, int constructor, boolean exception) { - return Updates.TLdeserialize(stream, constructor, exception); - } - - public void serializeToStream(AbstractSerializedData stream) { - stream.writeInt32(constructor); - flags = broadcast ? (flags | 1) : (flags &~ 1); - flags = megagroup ? (flags | 2) : (flags &~ 2); - stream.writeInt32(flags); - stream.writeString(title); - stream.writeString(about); - } - } - - - - public static class TL_channels_editPhoto extends TLObject { - public static int constructor = 0xf12e57c9; - - public InputChannel channel; - public InputChatPhoto photo; - - public TLObject deserializeResponse(AbstractSerializedData stream, int constructor, boolean exception) { - return Updates.TLdeserialize(stream, constructor, exception); - } - - public void serializeToStream(AbstractSerializedData stream) { - stream.writeInt32(constructor); - channel.serializeToStream(stream); - photo.serializeToStream(stream); - } - } - //manually created //MessageMedia start @@ -7509,7 +7061,6 @@ public class TLRPC { public boolean unread; public ArrayList entities = new ArrayList<>(); public String via_bot_name; - public ReplyMarkup reply_markup; public int views; public int edit_date; public boolean silent; @@ -7590,9 +7141,6 @@ public class TLRPC { } else { media = new TL_messageMediaEmpty(); } - if ((flags & 64) != 0) { - reply_markup = ReplyMarkup.TLdeserialize(stream, stream.readInt32(exception), exception); - } if ((flags & 128) != 0) { int magic = stream.readInt32(exception); if (magic != 0x1cb5c415) { @@ -7665,9 +7213,6 @@ public class TLRPC { if ((flags & 512) != 0) { media.serializeToStream(stream); } - if ((flags & 64) != 0) { - reply_markup.serializeToStream(stream); - } if ((flags & 128) != 0) { stream.writeInt32(0x1cb5c415); int count = entities.size(); @@ -7696,134 +7241,6 @@ public class TLRPC { } } - public static class TL_messageForwarded_old2 extends Message { - public static int constructor = 0xa367e716; - - - public void readParams(AbstractSerializedData stream, boolean exception) { - flags = stream.readInt32(exception); - unread = (flags & 1) != 0; - out = (flags & 2) != 0; - mentioned = (flags & 16) != 0; - media_unread = (flags & 32) != 0; - id = stream.readInt32(exception); - fwd_from = new TL_messageFwdHeader(); - fwd_from.from_id = stream.readInt32(exception); - fwd_from.flags |= 1; - fwd_from.date = stream.readInt32(exception); - from_id = stream.readInt32(exception); - to_id = Peer.TLdeserialize(stream, stream.readInt32(exception), exception); - date = stream.readInt32(exception); - message = stream.readString(exception); - flags |= MESSAGE_FLAG_FWD | MESSAGE_FLAG_HAS_FROM_ID | MESSAGE_FLAG_HAS_MEDIA; - media = MessageMedia.TLdeserialize(stream, stream.readInt32(exception), exception); - if (id < 0) { - fwd_msg_id = stream.readInt32(exception); - } - if (id < 0 || (media != null && !(media instanceof TL_messageMediaEmpty) && message != null && message.length() != 0 && message.startsWith("-1"))) { - attachPath = stream.readString(exception); - } - } - - public void serializeToStream(AbstractSerializedData stream) { - stream.writeInt32(constructor); - flags = unread ? (flags | 1) : (flags &~ 1); - flags = out ? (flags | 2) : (flags &~ 2); - flags = mentioned ? (flags | 16) : (flags &~ 16); - flags = media_unread ? (flags | 32) : (flags &~ 32); - stream.writeInt32(flags); - stream.writeInt32(id); - stream.writeInt32(fwd_from.from_id); - stream.writeInt32(fwd_from.date); - stream.writeInt32(from_id); - to_id.serializeToStream(stream); - stream.writeInt32(date); - stream.writeString(message); - media.serializeToStream(stream); - if (id < 0) { - stream.writeInt32(fwd_msg_id); - } - stream.writeString(attachPath); - } - } - - public static class TL_messageForwarded_old extends TL_messageForwarded_old2 { - public static int constructor = 0x5f46804; - - - public void readParams(AbstractSerializedData stream, boolean exception) { - id = stream.readInt32(exception); - fwd_from = new TL_messageFwdHeader(); - fwd_from.from_id = stream.readInt32(exception); - fwd_from.flags |= 1; - fwd_from.date = stream.readInt32(exception); - from_id = stream.readInt32(exception); - to_id = Peer.TLdeserialize(stream, stream.readInt32(exception), exception); - out = stream.readBool(exception); - unread = stream.readBool(exception); - flags |= MESSAGE_FLAG_FWD | MESSAGE_FLAG_HAS_FROM_ID | MESSAGE_FLAG_HAS_MEDIA; - date = stream.readInt32(exception); - message = stream.readString(exception); - media = MessageMedia.TLdeserialize(stream, stream.readInt32(exception), exception); - if (id < 0) { - fwd_msg_id = stream.readInt32(exception); - } - if (id < 0 || (media != null && !(media instanceof TL_messageMediaEmpty) && !(media instanceof TL_messageMediaWebPage) && message != null && message.length() != 0 && message.startsWith("-1"))) { - attachPath = stream.readString(exception); - } - } - - public void serializeToStream(AbstractSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(id); - stream.writeInt32(fwd_from.from_id); - stream.writeInt32(fwd_from.date); - stream.writeInt32(from_id); - to_id.serializeToStream(stream); - stream.writeBool(out); - stream.writeBool(unread); - stream.writeInt32(date); - stream.writeString(message); - media.serializeToStream(stream); - if (id < 0) { - stream.writeInt32(fwd_msg_id); - } - stream.writeString(attachPath); - } - } - - public static class TL_message_old extends TL_message { - public static int constructor = 0x22eb6aba; - - public void readParams(AbstractSerializedData stream, boolean exception) { - id = stream.readInt32(exception); - from_id = stream.readInt32(exception); - to_id = Peer.TLdeserialize(stream, stream.readInt32(exception), exception); - out = stream.readBool(exception); - unread = stream.readBool(exception); - flags |= MESSAGE_FLAG_HAS_FROM_ID | MESSAGE_FLAG_HAS_MEDIA; - date = stream.readInt32(exception); - message = stream.readString(exception); - media = MessageMedia.TLdeserialize(stream, stream.readInt32(exception), exception); - if (id < 0 || (media != null && !(media instanceof TL_messageMediaEmpty) && !(media instanceof TL_messageMediaWebPage) && message != null && message.length() != 0 && message.startsWith("-1"))) { - attachPath = stream.readString(exception); - } - } - - public void serializeToStream(AbstractSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(id); - stream.writeInt32(from_id); - to_id.serializeToStream(stream); - stream.writeBool(out); - stream.writeBool(unread); - stream.writeInt32(date); - stream.writeString(message); - media.serializeToStream(stream); - stream.writeString(attachPath); - } - } - public static class TL_message_secret extends TL_message { public static int constructor = 0x555555f9; @@ -8045,14 +7462,6 @@ public class TLRPC { } //TL_dialog end - //ChatParticipant start - public static class TL_chatChannelParticipant extends ChatParticipant { - public static int constructor = 0xc8d7493e; - - public TLRPC.ChannelParticipant channelParticipant; - } - //ChatParticipant end - //Chat start public static class TL_chatEmpty extends Chat { public static int constructor = 0x9ba2d800; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ContextLinkCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ContextLinkCell.java index 48755d591..a59500d78 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ContextLinkCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ContextLinkCell.java @@ -226,11 +226,11 @@ public class ContextLinkCell extends View implements MediaController.FileDownloa } } if (url == null && currentPhotoObject == null && currentPhotoObjectThumb == null) { - if (inlineResult.send_message instanceof TLRPC.TL_botInlineMessageMediaVenue || inlineResult.send_message instanceof TLRPC.TL_botInlineMessageMediaGeo) { + /*if (inlineResult.send_message instanceof TLRPC.TL_botInlineMessageMediaVenue || inlineResult.send_message instanceof TLRPC.TL_botInlineMessageMediaGeo) { double lat = inlineResult.send_message.geo.lat; double lon = inlineResult.send_message.geo._long; url = String.format(Locale.US, "https://maps.googleapis.com/maps/api/staticmap?center=%f,%f&zoom=15&size=72x72&maptype=roadmap&scale=%d&markers=color:red|size:small|%f,%f&sensor=false", lat, lon, Math.min(2, (int) Math.ceil(AndroidUtilities.density)), lat, lon); - } + }*/ } int width; @@ -500,7 +500,7 @@ public class ContextLinkCell extends View implements MediaController.FileDownloa letterDrawable.draw(canvas); } } else { - if (inlineResult != null && (inlineResult.send_message instanceof TLRPC.TL_botInlineMessageMediaGeo || inlineResult.send_message instanceof TLRPC.TL_botInlineMessageMediaVenue)) { + /*if (inlineResult != null && (inlineResult.send_message instanceof TLRPC.TL_botInlineMessageMediaGeo || inlineResult.send_message instanceof TLRPC.TL_botInlineMessageMediaVenue)) { int w = Theme.inlineLocationDrawable.getIntrinsicWidth(); int h = Theme.inlineLocationDrawable.getIntrinsicHeight(); int x = linkImageView.getImageX() + (linkImageView.getImageWidth() - w) / 2; @@ -508,7 +508,7 @@ public class ContextLinkCell extends View implements MediaController.FileDownloa canvas.drawRect(linkImageView.getImageX(), linkImageView.getImageY(), linkImageView.getImageX() + linkImageView.getImageWidth(), linkImageView.getImageY() + linkImageView.getImageHeight(), LetterDrawable.paint); Theme.inlineLocationDrawable.setBounds(x, y, x + w, y + h); Theme.inlineLocationDrawable.draw(canvas); - } + }*/ } if (drawLinkImageView) { canvas.save(); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java index 41410b7d6..3fd9c566b 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java @@ -5735,7 +5735,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not TLRPC.ChatFull chatFull = (TLRPC.ChatFull) args[0]; if (currentChat != null && chatFull.id == currentChat.id) { if (chatFull instanceof TLRPC.TL_channelFull) { - if (currentChat.megagroup) { + /*if (currentChat.megagroup) { int lastDate = 0; if (chatFull.participants != null) { for (int a = 0; a < chatFull.participants.participants.size(); a++) { @@ -5745,7 +5745,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not if (lastDate == 0 || Math.abs(System.currentTimeMillis() / 1000 - lastDate) > 60 * 60) { MessagesController.getInstance().loadChannelParticipants(currentChat.id); } - } + }*/ if (chatFull.participants == null && info != null) { chatFull.participants = info.participants; } @@ -6246,45 +6246,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } } - public boolean processSwitchButton(TLRPC.TL_keyboardButtonSwitchInline button) { - if (inlineReturn == 0) { - return false; - } - String query = "@" + currentUser.username + " " + button.query; - if (inlineReturn == dialog_id) { - inlineReturn = 0; - chatActivityEnterView.setFieldText(query); - } else { - DraftQuery.saveDraft(inlineReturn, query, null, null, false); - if (parentLayout.fragmentsStack.size() > 1) { - BaseFragment prevFragment = parentLayout.fragmentsStack.get(parentLayout.fragmentsStack.size() - 2); - if (prevFragment instanceof ChatActivity && ((ChatActivity) prevFragment).dialog_id == inlineReturn) { - finishFragment(); - } else { - Bundle bundle = new Bundle(); - int lower_part = (int) inlineReturn; - int high_part = (int) (inlineReturn >> 32); - if (lower_part != 0) { - if (lower_part > 0) { - bundle.putInt("user_id", lower_part); - } else if (lower_part < 0) { - bundle.putInt("chat_id", -lower_part); - } - } else { - bundle.putInt("enc_id", high_part); - } - /*ActionBarLayout parentLayout = ChatActivity.this.parentLayout; - if (lastFragment != null) { - NotificationCenter.getInstance().removeObserver(lastFragment, NotificationCenter.closeChats); - } - NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeChats);*/ - presentFragment(new ChatActivity(bundle), true); - } - } - } - return true; - } - private void updateSearchButtons(int mask, int num, int count) { if (searchUpButton != null) { searchUpButton.setEnabled((mask & 1) != 0); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java index 6cdedd7af..dfb71d14c 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java @@ -370,8 +370,8 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe private boolean allowShowTopView; private AnimatorSet currentTopViewAnimation; - private MessageObject pendingMessageObject; - private TLRPC.KeyboardButton pendingLocationButton; + //private MessageObject pendingMessageObject; + //private TLRPC.KeyboardButton pendingLocationButton; private boolean waitingForKeyboardOpen; private Runnable openKeyboardRunnable = new Runnable() { @@ -2605,16 +2605,14 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe } public void onRequestPermissionsResultFragment(int requestCode, String[] permissions, int[] grantResults) { - if (requestCode == 2) { + /*if (requestCode == 2) { if (pendingLocationButton != null) { - /* if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { SendMessagesHelper.getInstance().sendCurrentLocation(pendingMessageObject, pendingLocationButton); } - */ pendingLocationButton = null; pendingMessageObject = null; } - } + }*/ } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java index 957326e46..5355027d8 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java @@ -706,7 +706,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. } selectedUser = user.user_id; - if (ChatObject.isChannel(currentChat)) { + /*if (ChatObject.isChannel(currentChat)) { TLRPC.ChannelParticipant channelParticipant = ((TLRPC.TL_chatChannelParticipant) user).channelParticipant; if (user.user_id != UserConfig.getClientUserId()) { if (currentChat.creator) { @@ -719,7 +719,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. } TLRPC.User u = MessagesController.getInstance().getUser(user.user_id); allowSetAdmin = channelParticipant instanceof TLRPC.TL_channelParticipant && !u.bot; - } else { + } else */ { if (user.user_id != UserConfig.getClientUserId()) { if (currentChat.creator) { allowKick = true; @@ -1093,6 +1093,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. } private void getChannelParticipants(boolean reload) { + /* if (loadingUsers || participantsMap == null || info == null) { return; } @@ -1145,6 +1146,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. } }); ConnectionsManager.getInstance().bindRequestToGuid(reqId, classGuid); + */ } private void openAddMember() { @@ -1845,7 +1847,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. if (uid != 0) { MessagesController.getInstance().deleteUserFromChat(chat_id, MessagesController.getInstance().getUser(uid), info); if (currentChat.megagroup && info != null && info.participants != null) { - boolean changed = false; + /*boolean changed = false; for (int a = 0; a < info.participants.participants.size(); a++) { TLRPC.ChannelParticipant p = ((TLRPC.TL_chatChannelParticipant) info.participants.participants.get(a)).channelParticipant; if (p.user_id == uid) { @@ -1871,7 +1873,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. updateOnlineCount(); updateRowsIds(); listAdapter.notifyDataSetChanged(); - } + }*/ } } else { NotificationCenter.getInstance().removeObserver(this, NotificationCenter.closeChats); @@ -2502,7 +2504,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. part = info.participants.participants.get(i - emptyRowChat2 - 1); } if (part != null) { - if (part instanceof TLRPC.TL_chatChannelParticipant) { + /*if (part instanceof TLRPC.TL_chatChannelParticipant) { TLRPC.ChannelParticipant channelParticipant = ((TLRPC.TL_chatChannelParticipant) part).channelParticipant; if (channelParticipant instanceof TLRPC.TL_channelParticipantCreator) { userCell.setIsAdmin(1); @@ -2511,7 +2513,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. } else { userCell.setIsAdmin(0); } - } else { + } else*/ { if (part instanceof TLRPC.TL_chatParticipantCreator) { userCell.setIsAdmin(1); } else if (currentChat.admins_enabled && part instanceof TLRPC.TL_chatParticipantAdmin) {