Java Code Examples for org.telegram.tgnet.TLRPC#TL_peerUser

The following examples show how to use org.telegram.tgnet.TLRPC#TL_peerUser . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SecretChatHelper.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
private TLRPC.Message createDeleteMessage(int mid, int seq_out, int seq_in, long random_id, TLRPC.EncryptedChat encryptedChat) {
    TLRPC.TL_messageService newMsg = new TLRPC.TL_messageService();
    newMsg.action = new TLRPC.TL_messageEncryptedAction();
    newMsg.action.encryptedAction = new TLRPC.TL_decryptedMessageActionDeleteMessages();
    newMsg.action.encryptedAction.random_ids.add(random_id);
    newMsg.local_id = newMsg.id = mid;
    newMsg.from_id = UserConfig.getInstance(currentAccount).getClientUserId();
    newMsg.unread = true;
    newMsg.out = true;
    newMsg.flags = TLRPC.MESSAGE_FLAG_HAS_FROM_ID;
    newMsg.dialog_id = ((long) encryptedChat.id) << 32;
    newMsg.to_id = new TLRPC.TL_peerUser();
    newMsg.send_state = MessageObject.MESSAGE_SEND_STATE_SENDING;
    newMsg.seq_in = seq_in;
    newMsg.seq_out = seq_out;
    if (encryptedChat.participant_id == UserConfig.getInstance(currentAccount).getClientUserId()) {
        newMsg.to_id.user_id = encryptedChat.admin_id;
    } else {
        newMsg.to_id.user_id = encryptedChat.participant_id;
    }
    newMsg.date = 0;
    newMsg.random_id = random_id;
    return newMsg;
}
 
Example 2
Source File: SecretChatHelper.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
private TLRPC.Message createDeleteMessage(int mid, int seq_out, int seq_in, long random_id, TLRPC.EncryptedChat encryptedChat) {
    TLRPC.TL_messageService newMsg = new TLRPC.TL_messageService();
    newMsg.action = new TLRPC.TL_messageEncryptedAction();
    newMsg.action.encryptedAction = new TLRPC.TL_decryptedMessageActionDeleteMessages();
    newMsg.action.encryptedAction.random_ids.add(random_id);
    newMsg.local_id = newMsg.id = mid;
    newMsg.from_id = UserConfig.getInstance(currentAccount).getClientUserId();
    newMsg.unread = true;
    newMsg.out = true;
    newMsg.flags = TLRPC.MESSAGE_FLAG_HAS_FROM_ID;
    newMsg.dialog_id = ((long) encryptedChat.id) << 32;
    newMsg.to_id = new TLRPC.TL_peerUser();
    newMsg.send_state = MessageObject.MESSAGE_SEND_STATE_SENDING;
    newMsg.seq_in = seq_in;
    newMsg.seq_out = seq_out;
    if (encryptedChat.participant_id == UserConfig.getInstance(currentAccount).getClientUserId()) {
        newMsg.to_id.user_id = encryptedChat.admin_id;
    } else {
        newMsg.to_id.user_id = encryptedChat.participant_id;
    }
    newMsg.date = 0;
    newMsg.random_id = random_id;
    return newMsg;
}
 
Example 3
Source File: SecretChatHelper.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
private TLRPC.Message createDeleteMessage(int mid, int seq_out, int seq_in, long random_id, TLRPC.EncryptedChat encryptedChat) {
    TLRPC.TL_messageService newMsg = new TLRPC.TL_messageService();
    newMsg.action = new TLRPC.TL_messageEncryptedAction();
    newMsg.action.encryptedAction = new TLRPC.TL_decryptedMessageActionDeleteMessages();
    newMsg.action.encryptedAction.random_ids.add(random_id);
    newMsg.local_id = newMsg.id = mid;
    newMsg.from_id = getUserConfig().getClientUserId();
    newMsg.unread = true;
    newMsg.out = true;
    newMsg.flags = TLRPC.MESSAGE_FLAG_HAS_FROM_ID;
    newMsg.dialog_id = ((long) encryptedChat.id) << 32;
    newMsg.to_id = new TLRPC.TL_peerUser();
    newMsg.send_state = MessageObject.MESSAGE_SEND_STATE_SENDING;
    newMsg.seq_in = seq_in;
    newMsg.seq_out = seq_out;
    if (encryptedChat.participant_id == getUserConfig().getClientUserId()) {
        newMsg.to_id.user_id = encryptedChat.admin_id;
    } else {
        newMsg.to_id.user_id = encryptedChat.participant_id;
    }
    newMsg.date = 0;
    newMsg.random_id = random_id;
    return newMsg;
}
 
Example 4
Source File: SecretChatHelper.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
private TLRPC.Message createDeleteMessage(int mid, int seq_out, int seq_in, long random_id, TLRPC.EncryptedChat encryptedChat) {
    TLRPC.TL_messageService newMsg = new TLRPC.TL_messageService();
    newMsg.action = new TLRPC.TL_messageEncryptedAction();
    newMsg.action.encryptedAction = new TLRPC.TL_decryptedMessageActionDeleteMessages();
    newMsg.action.encryptedAction.random_ids.add(random_id);
    newMsg.local_id = newMsg.id = mid;
    newMsg.from_id = getUserConfig().getClientUserId();
    newMsg.unread = true;
    newMsg.out = true;
    newMsg.flags = TLRPC.MESSAGE_FLAG_HAS_FROM_ID;
    newMsg.dialog_id = ((long) encryptedChat.id) << 32;
    newMsg.to_id = new TLRPC.TL_peerUser();
    newMsg.send_state = MessageObject.MESSAGE_SEND_STATE_SENDING;
    newMsg.seq_in = seq_in;
    newMsg.seq_out = seq_out;
    if (encryptedChat.participant_id == getUserConfig().getClientUserId()) {
        newMsg.to_id.user_id = encryptedChat.admin_id;
    } else {
        newMsg.to_id.user_id = encryptedChat.participant_id;
    }
    newMsg.date = 0;
    newMsg.random_id = random_id;
    return newMsg;
}
 
Example 5
Source File: SecretChatHelper.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private TLRPC.TL_messageService createServiceSecretMessage(final TLRPC.EncryptedChat encryptedChat, TLRPC.DecryptedMessageAction decryptedMessage) {
    TLRPC.TL_messageService newMsg = new TLRPC.TL_messageService();

    newMsg.action = new TLRPC.TL_messageEncryptedAction();
    newMsg.action.encryptedAction = decryptedMessage;
    newMsg.local_id = newMsg.id = UserConfig.getInstance(currentAccount).getNewMessageId();
    newMsg.from_id = UserConfig.getInstance(currentAccount).getClientUserId();
    newMsg.unread = true;
    newMsg.out = true;
    newMsg.flags = TLRPC.MESSAGE_FLAG_HAS_FROM_ID;
    newMsg.dialog_id = ((long) encryptedChat.id) << 32;
    newMsg.to_id = new TLRPC.TL_peerUser();
    newMsg.send_state = MessageObject.MESSAGE_SEND_STATE_SENDING;
    if (encryptedChat.participant_id == UserConfig.getInstance(currentAccount).getClientUserId()) {
        newMsg.to_id.user_id = encryptedChat.admin_id;
    } else {
        newMsg.to_id.user_id = encryptedChat.participant_id;
    }
    if (decryptedMessage instanceof TLRPC.TL_decryptedMessageActionScreenshotMessages || decryptedMessage instanceof TLRPC.TL_decryptedMessageActionSetMessageTTL) {
        newMsg.date = ConnectionsManager.getInstance(currentAccount).getCurrentTime();
    } else {
        newMsg.date = 0;
    }
    newMsg.random_id = SendMessagesHelper.getInstance(currentAccount).getNextRandomId();
    UserConfig.getInstance(currentAccount).saveConfig(false);

    ArrayList<TLRPC.Message> arr = new ArrayList<>();
    arr.add(newMsg);
    MessagesStorage.getInstance(currentAccount).putMessages(arr, false, true, true, 0);

    return newMsg;
}
 
Example 6
Source File: SecretChatHelper.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private TLRPC.TL_messageService createServiceSecretMessage(final TLRPC.EncryptedChat encryptedChat, TLRPC.DecryptedMessageAction decryptedMessage) {
    TLRPC.TL_messageService newMsg = new TLRPC.TL_messageService();

    newMsg.action = new TLRPC.TL_messageEncryptedAction();
    newMsg.action.encryptedAction = decryptedMessage;
    newMsg.local_id = newMsg.id = UserConfig.getInstance(currentAccount).getNewMessageId();
    newMsg.from_id = UserConfig.getInstance(currentAccount).getClientUserId();
    newMsg.unread = true;
    newMsg.out = true;
    newMsg.flags = TLRPC.MESSAGE_FLAG_HAS_FROM_ID;
    newMsg.dialog_id = ((long) encryptedChat.id) << 32;
    newMsg.to_id = new TLRPC.TL_peerUser();
    newMsg.send_state = MessageObject.MESSAGE_SEND_STATE_SENDING;
    if (encryptedChat.participant_id == UserConfig.getInstance(currentAccount).getClientUserId()) {
        newMsg.to_id.user_id = encryptedChat.admin_id;
    } else {
        newMsg.to_id.user_id = encryptedChat.participant_id;
    }
    if (decryptedMessage instanceof TLRPC.TL_decryptedMessageActionScreenshotMessages || decryptedMessage instanceof TLRPC.TL_decryptedMessageActionSetMessageTTL) {
        newMsg.date = ConnectionsManager.getInstance(currentAccount).getCurrentTime();
    } else {
        newMsg.date = 0;
    }
    newMsg.random_id = SendMessagesHelper.getInstance(currentAccount).getNextRandomId();
    UserConfig.getInstance(currentAccount).saveConfig(false);

    ArrayList<TLRPC.Message> arr = new ArrayList<>();
    arr.add(newMsg);
    MessagesStorage.getInstance(currentAccount).putMessages(arr, false, true, true, 0);

    return newMsg;
}
 
Example 7
Source File: SecretChatHelper.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
private TLRPC.TL_messageService createServiceSecretMessage(final TLRPC.EncryptedChat encryptedChat, TLRPC.DecryptedMessageAction decryptedMessage) {
    TLRPC.TL_messageService newMsg = new TLRPC.TL_messageService();

    newMsg.action = new TLRPC.TL_messageEncryptedAction();
    newMsg.action.encryptedAction = decryptedMessage;
    newMsg.local_id = newMsg.id = getUserConfig().getNewMessageId();
    newMsg.from_id = getUserConfig().getClientUserId();
    newMsg.unread = true;
    newMsg.out = true;
    newMsg.flags = TLRPC.MESSAGE_FLAG_HAS_FROM_ID;
    newMsg.dialog_id = ((long) encryptedChat.id) << 32;
    newMsg.to_id = new TLRPC.TL_peerUser();
    newMsg.send_state = MessageObject.MESSAGE_SEND_STATE_SENDING;
    if (encryptedChat.participant_id == getUserConfig().getClientUserId()) {
        newMsg.to_id.user_id = encryptedChat.admin_id;
    } else {
        newMsg.to_id.user_id = encryptedChat.participant_id;
    }
    if (decryptedMessage instanceof TLRPC.TL_decryptedMessageActionScreenshotMessages || decryptedMessage instanceof TLRPC.TL_decryptedMessageActionSetMessageTTL) {
        newMsg.date = getConnectionsManager().getCurrentTime();
    } else {
        newMsg.date = 0;
    }
    newMsg.random_id = getSendMessagesHelper().getNextRandomId();
    getUserConfig().saveConfig(false);

    ArrayList<TLRPC.Message> arr = new ArrayList<>();
    arr.add(newMsg);
    getMessagesStorage().putMessages(arr, false, true, true, 0, false);

    return newMsg;
}
 
Example 8
Source File: SecretChatHelper.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
private TLRPC.TL_messageService createServiceSecretMessage(final TLRPC.EncryptedChat encryptedChat, TLRPC.DecryptedMessageAction decryptedMessage) {
    TLRPC.TL_messageService newMsg = new TLRPC.TL_messageService();

    newMsg.action = new TLRPC.TL_messageEncryptedAction();
    newMsg.action.encryptedAction = decryptedMessage;
    newMsg.local_id = newMsg.id = getUserConfig().getNewMessageId();
    newMsg.from_id = getUserConfig().getClientUserId();
    newMsg.unread = true;
    newMsg.out = true;
    newMsg.flags = TLRPC.MESSAGE_FLAG_HAS_FROM_ID;
    newMsg.dialog_id = ((long) encryptedChat.id) << 32;
    newMsg.to_id = new TLRPC.TL_peerUser();
    newMsg.send_state = MessageObject.MESSAGE_SEND_STATE_SENDING;
    if (encryptedChat.participant_id == getUserConfig().getClientUserId()) {
        newMsg.to_id.user_id = encryptedChat.admin_id;
    } else {
        newMsg.to_id.user_id = encryptedChat.participant_id;
    }
    if (decryptedMessage instanceof TLRPC.TL_decryptedMessageActionScreenshotMessages || decryptedMessage instanceof TLRPC.TL_decryptedMessageActionSetMessageTTL) {
        newMsg.date = getConnectionsManager().getCurrentTime();
    } else {
        newMsg.date = 0;
    }
    newMsg.random_id = getSendMessagesHelper().getNextRandomId();
    getUserConfig().saveConfig(false);

    ArrayList<TLRPC.Message> arr = new ArrayList<>();
    arr.add(newMsg);
    getMessagesStorage().putMessages(arr, false, true, true, 0, false);

    return newMsg;
}
 
Example 9
Source File: PeopleNearbyActivity.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void didReceivedNotification(int id, int account, Object... args) {
    if (id == NotificationCenter.newLocationAvailable) {
        sendRequest(false, 0);
    } else if (id == NotificationCenter.newPeopleNearbyAvailable) {
        TLRPC.TL_updatePeerLocated update = (TLRPC.TL_updatePeerLocated) args[0];
        for (int b = 0, N2 = update.peers.size(); b < N2; b++) {
            TLRPC.PeerLocated object = update.peers.get(b);
            if (object instanceof TLRPC.TL_peerLocated) {
                TLRPC.TL_peerLocated peerLocated = (TLRPC.TL_peerLocated) object;
                boolean found = false;
                ArrayList<TLRPC.TL_peerLocated> arrayList;
                if (peerLocated.peer instanceof TLRPC.TL_peerUser) {
                    arrayList = users;
                } else {
                    arrayList = chats;
                }
                for (int a = 0, N = arrayList.size(); a < N; a++) {
                    TLRPC.TL_peerLocated old = arrayList.get(a);
                    if (old.peer.user_id != 0 && old.peer.user_id == peerLocated.peer.user_id || old.peer.chat_id != 0 && old.peer.chat_id == peerLocated.peer.chat_id || old.peer.channel_id != 0 && old.peer.channel_id == peerLocated.peer.channel_id) {
                        arrayList.set(a, peerLocated);
                        found = true;
                    }
                }
                if (!found) {
                    arrayList.add(peerLocated);
                }
            }
        }
        checkForExpiredLocations(true);
        updateRows();
    } else if (id == NotificationCenter.needDeleteDialog) {
        if (fragmentView == null || isPaused) {
            return;
        }
        long dialogId = (Long) args[0];
        TLRPC.User user = (TLRPC.User) args[1];
        TLRPC.Chat chat = (TLRPC.Chat) args[2];
        boolean revoke = (Boolean) args[3];
        Runnable deleteRunnable = () -> {
            if (chat != null) {
                if (ChatObject.isNotInChat(chat)) {
                    getMessagesController().deleteDialog(dialogId, 0, revoke);
                } else {
                    getMessagesController().deleteUserFromChat((int) -dialogId, getMessagesController().getUser(getUserConfig().getClientUserId()), null, false, revoke);
                }
            } else {
                getMessagesController().deleteDialog(dialogId, 0, revoke);
            }
        };
        if (undoView != null) {
            undoView.showWithAction(dialogId, UndoView.ACTION_DELETE, deleteRunnable);
        } else {
            deleteRunnable.run();
        }
    }
}
 
Example 10
Source File: PrivacyControlActivity.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
public MessageCell(Context context) {
    super(context);

    setWillNotDraw(false);
    setClipToPadding(false);

    shadowDrawable = Theme.getThemedDrawable(context, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow);
    setPadding(0, AndroidUtilities.dp(11), 0, AndroidUtilities.dp(11));

    int date = (int) (System.currentTimeMillis() / 1000) - 60 * 60;

    TLRPC.User currentUser = MessagesController.getInstance(currentAccount).getUser(UserConfig.getInstance(currentAccount).getClientUserId());

    TLRPC.Message message = new TLRPC.TL_message();
    message.message = LocaleController.getString("PrivacyForwardsMessageLine", R.string.PrivacyForwardsMessageLine);
    message.date = date + 60;
    message.dialog_id = 1;
    message.flags = 257 + TLRPC.MESSAGE_FLAG_FWD;
    message.from_id = 0;
    message.id = 1;
    message.fwd_from = new TLRPC.TL_messageFwdHeader();
    message.fwd_from.from_name = ContactsController.formatName(currentUser.first_name, currentUser.last_name);
    message.media = new TLRPC.TL_messageMediaEmpty();
    message.out = false;
    message.to_id = new TLRPC.TL_peerUser();
    message.to_id.user_id = UserConfig.getInstance(currentAccount).getClientUserId();
    messageObject = new MessageObject(currentAccount, message, true);
    messageObject.eventId = 1;
    messageObject.resetLayout();

    cell = new ChatMessageCell(context);
    cell.setDelegate(new ChatMessageCell.ChatMessageCellDelegate() {

    });
    cell.isChat = false;
    cell.setFullyDraw(true);
    cell.setMessageObject(messageObject, null, false, false);
    addView(cell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));

    hintView = new HintView(context, 1, true);
    addView(hintView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP, 19, 0, 19, 0));
}
 
Example 11
Source File: ThemePreviewMessagesCell.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
public ThemePreviewMessagesCell(Context context, ActionBarLayout layout, int type) {
    super(context);

    parentLayout = layout;

    setWillNotDraw(false);
    setOrientation(LinearLayout.VERTICAL);
    setPadding(0, AndroidUtilities.dp(11), 0, AndroidUtilities.dp(11));

    shadowDrawable = Theme.getThemedDrawable(context, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow);

    int date = (int) (System.currentTimeMillis() / 1000) - 60 * 60;
    TLRPC.Message message = new TLRPC.TL_message();
    if (type == 0) {
        message.message = LocaleController.getString("FontSizePreviewReply", R.string.FontSizePreviewReply);
    } else {
        message.message = LocaleController.getString("NewThemePreviewReply", R.string.NewThemePreviewReply);
    }
    message.date = date + 60;
    message.dialog_id = 1;
    message.flags = 259;
    message.from_id = UserConfig.getInstance(UserConfig.selectedAccount).getClientUserId();
    message.id = 1;
    message.media = new TLRPC.TL_messageMediaEmpty();
    message.out = true;
    message.to_id = new TLRPC.TL_peerUser();
    message.to_id.user_id = 0;
    MessageObject replyMessageObject = new MessageObject(UserConfig.selectedAccount, message, true);

    message = new TLRPC.TL_message();
    if (type == 0) {
        message.message = LocaleController.getString("FontSizePreviewLine2", R.string.FontSizePreviewLine2);
    } else {
        String text = LocaleController.getString("NewThemePreviewLine3", R.string.NewThemePreviewLine3);
        StringBuilder builder = new StringBuilder(text);
        int index1 = text.indexOf('*');
        int index2 = text.lastIndexOf('*');
        if (index1 != -1 && index2 != -1) {
            builder.replace(index2, index2 + 1, "");
            builder.replace(index1, index1 + 1, "");
            TLRPC.TL_messageEntityTextUrl entityUrl = new TLRPC.TL_messageEntityTextUrl();
            entityUrl.offset = index1;
            entityUrl.length = index2 - index1 - 1;
            entityUrl.url = "https://telegram.org";
            message.entities.add(entityUrl);
        }
        message.message = builder.toString();
    }
    message.date = date + 960;
    message.dialog_id = 1;
    message.flags = 259;
    message.from_id = UserConfig.getInstance(UserConfig.selectedAccount).getClientUserId();
    message.id = 1;
    message.media = new TLRPC.TL_messageMediaEmpty();
    message.out = true;
    message.to_id = new TLRPC.TL_peerUser();
    message.to_id.user_id = 0;
    MessageObject message1 = new MessageObject(UserConfig.selectedAccount, message, true);
    message1.resetLayout();
    message1.eventId = 1;

    message = new TLRPC.TL_message();
    if (type == 0) {
        message.message = LocaleController.getString("FontSizePreviewLine1", R.string.FontSizePreviewLine1);
    } else {
        message.message = LocaleController.getString("NewThemePreviewLine1", R.string.NewThemePreviewLine1);
    }
    message.date = date + 60;
    message.dialog_id = 1;
    message.flags = 257 + 8;
    message.from_id = 0;
    message.id = 1;
    message.reply_to_msg_id = 5;
    message.media = new TLRPC.TL_messageMediaEmpty();
    message.out = false;
    message.to_id = new TLRPC.TL_peerUser();
    message.to_id.user_id = UserConfig.getInstance(UserConfig.selectedAccount).getClientUserId();
    MessageObject message2 = new MessageObject(UserConfig.selectedAccount, message, true);
    if (type == 0) {
        message2.customReplyName = LocaleController.getString("FontSizePreviewName", R.string.FontSizePreviewName);
    } else {
        message2.customReplyName = LocaleController.getString("NewThemePreviewName", R.string.NewThemePreviewName);
    }
    message2.eventId = 1;
    message2.resetLayout();
    message2.replyMessageObject = replyMessageObject;

    for (int a = 0; a < cells.length; a++) {
        cells[a] = new ChatMessageCell(context);
        cells[a].setDelegate(new ChatMessageCell.ChatMessageCellDelegate() {

        });
        cells[a].isChat = false;
        cells[a].setFullyDraw(true);
        cells[a].setMessageObject(a == 0 ? message2 : message1, null, false, false);
        addView(cells[a], LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
    }
}
 
Example 12
Source File: PeopleNearbyActivity.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void didReceivedNotification(int id, int account, Object... args) {
    if (id == NotificationCenter.newLocationAvailable) {
        sendRequest(false, 0);
    } else if (id == NotificationCenter.newPeopleNearbyAvailable) {
        TLRPC.TL_updatePeerLocated update = (TLRPC.TL_updatePeerLocated) args[0];
        for (int b = 0, N2 = update.peers.size(); b < N2; b++) {
            TLRPC.PeerLocated object = update.peers.get(b);
            if (object instanceof TLRPC.TL_peerLocated) {
                TLRPC.TL_peerLocated peerLocated = (TLRPC.TL_peerLocated) object;
                boolean found = false;
                ArrayList<TLRPC.TL_peerLocated> arrayList;
                if (peerLocated.peer instanceof TLRPC.TL_peerUser) {
                    arrayList = users;
                } else {
                    arrayList = chats;
                }
                for (int a = 0, N = arrayList.size(); a < N; a++) {
                    TLRPC.TL_peerLocated old = arrayList.get(a);
                    if (old.peer.user_id != 0 && old.peer.user_id == peerLocated.peer.user_id || old.peer.chat_id != 0 && old.peer.chat_id == peerLocated.peer.chat_id || old.peer.channel_id != 0 && old.peer.channel_id == peerLocated.peer.channel_id) {
                        arrayList.set(a, peerLocated);
                        found = true;
                    }
                }
                if (!found) {
                    arrayList.add(peerLocated);
                }
            }
        }
        checkForExpiredLocations(true);
        updateRows();
    } else if (id == NotificationCenter.needDeleteDialog) {
        if (fragmentView == null || isPaused) {
            return;
        }
        long dialogId = (Long) args[0];
        TLRPC.User user = (TLRPC.User) args[1];
        TLRPC.Chat chat = (TLRPC.Chat) args[2];
        boolean revoke = (Boolean) args[3];
        Runnable deleteRunnable = () -> {
            if (chat != null) {
                if (ChatObject.isNotInChat(chat)) {
                    getMessagesController().deleteDialog(dialogId, 0, revoke);
                } else {
                    getMessagesController().deleteUserFromChat((int) -dialogId, getMessagesController().getUser(getUserConfig().getClientUserId()), null, false, revoke);
                }
            } else {
                getMessagesController().deleteDialog(dialogId, 0, revoke);
            }
        };
        if (undoView != null) {
            undoView.showWithAction(dialogId, UndoView.ACTION_DELETE, deleteRunnable);
        } else {
            deleteRunnable.run();
        }
    }
}
 
Example 13
Source File: PrivacyControlActivity.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
public MessageCell(Context context) {
    super(context);

    setWillNotDraw(false);
    setClipToPadding(false);

    shadowDrawable = Theme.getThemedDrawable(context, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow);
    setPadding(0, AndroidUtilities.dp(11), 0, AndroidUtilities.dp(11));

    int date = (int) (System.currentTimeMillis() / 1000) - 60 * 60;

    TLRPC.User currentUser = MessagesController.getInstance(currentAccount).getUser(UserConfig.getInstance(currentAccount).getClientUserId());

    TLRPC.Message message = new TLRPC.TL_message();
    message.message = LocaleController.getString("PrivacyForwardsMessageLine", R.string.PrivacyForwardsMessageLine);
    message.date = date + 60;
    message.dialog_id = 1;
    message.flags = 257 + TLRPC.MESSAGE_FLAG_FWD;
    message.from_id = 0;
    message.id = 1;
    message.fwd_from = new TLRPC.TL_messageFwdHeader();
    message.fwd_from.from_name = ContactsController.formatName(currentUser.first_name, currentUser.last_name);
    message.media = new TLRPC.TL_messageMediaEmpty();
    message.out = false;
    message.to_id = new TLRPC.TL_peerUser();
    message.to_id.user_id = UserConfig.getInstance(currentAccount).getClientUserId();
    messageObject = new MessageObject(currentAccount, message, true);
    messageObject.eventId = 1;
    messageObject.resetLayout();

    cell = new ChatMessageCell(context);
    cell.setDelegate(new ChatMessageCell.ChatMessageCellDelegate() {

    });
    cell.isChat = false;
    cell.setFullyDraw(true);
    cell.setMessageObject(messageObject, null, false, false);
    addView(cell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));

    hintView = new HintView(context, 1, true);
    addView(hintView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP, 19, 0, 19, 0));
}
 
Example 14
Source File: ThemePreviewMessagesCell.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
public ThemePreviewMessagesCell(Context context, ActionBarLayout layout, int type) {
    super(context);

    parentLayout = layout;

    setWillNotDraw(false);
    setOrientation(LinearLayout.VERTICAL);
    setPadding(0, AndroidUtilities.dp(11), 0, AndroidUtilities.dp(11));

    shadowDrawable = Theme.getThemedDrawable(context, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow);

    int date = (int) (System.currentTimeMillis() / 1000) - 60 * 60;
    TLRPC.Message message = new TLRPC.TL_message();
    if (type == 0) {
        message.message = LocaleController.getString("FontSizePreviewReply", R.string.FontSizePreviewReply);
    } else {
        message.message = LocaleController.getString("NewThemePreviewReply", R.string.NewThemePreviewReply);
    }
    message.date = date + 60;
    message.dialog_id = 1;
    message.flags = 259;
    message.from_id = UserConfig.getInstance(UserConfig.selectedAccount).getClientUserId();
    message.id = 1;
    message.media = new TLRPC.TL_messageMediaEmpty();
    message.out = true;
    message.to_id = new TLRPC.TL_peerUser();
    message.to_id.user_id = 0;
    MessageObject replyMessageObject = new MessageObject(UserConfig.selectedAccount, message, true);

    message = new TLRPC.TL_message();
    if (type == 0) {
        message.message = LocaleController.getString("FontSizePreviewLine2", R.string.FontSizePreviewLine2);
    } else {
        String text = LocaleController.getString("NewThemePreviewLine3", R.string.NewThemePreviewLine3);
        StringBuilder builder = new StringBuilder(text);
        int index1 = text.indexOf('*');
        int index2 = text.lastIndexOf('*');
        if (index1 != -1 && index2 != -1) {
            builder.replace(index2, index2 + 1, "");
            builder.replace(index1, index1 + 1, "");
            TLRPC.TL_messageEntityTextUrl entityUrl = new TLRPC.TL_messageEntityTextUrl();
            entityUrl.offset = index1;
            entityUrl.length = index2 - index1 - 1;
            entityUrl.url = "https://telegram.org";
            message.entities.add(entityUrl);
        }
        message.message = builder.toString();
    }
    message.date = date + 960;
    message.dialog_id = 1;
    message.flags = 259;
    message.from_id = UserConfig.getInstance(UserConfig.selectedAccount).getClientUserId();
    message.id = 1;
    message.media = new TLRPC.TL_messageMediaEmpty();
    message.out = true;
    message.to_id = new TLRPC.TL_peerUser();
    message.to_id.user_id = 0;
    MessageObject message1 = new MessageObject(UserConfig.selectedAccount, message, true);
    message1.resetLayout();
    message1.eventId = 1;

    message = new TLRPC.TL_message();
    if (type == 0) {
        message.message = LocaleController.getString("FontSizePreviewLine1", R.string.FontSizePreviewLine1);
    } else {
        message.message = LocaleController.getString("NewThemePreviewLine1", R.string.NewThemePreviewLine1);
    }
    message.date = date + 60;
    message.dialog_id = 1;
    message.flags = 257 + 8;
    message.from_id = 0;
    message.id = 1;
    message.reply_to_msg_id = 5;
    message.media = new TLRPC.TL_messageMediaEmpty();
    message.out = false;
    message.to_id = new TLRPC.TL_peerUser();
    message.to_id.user_id = UserConfig.getInstance(UserConfig.selectedAccount).getClientUserId();
    MessageObject message2 = new MessageObject(UserConfig.selectedAccount, message, true);
    if (type == 0) {
        message2.customReplyName = LocaleController.getString("FontSizePreviewName", R.string.FontSizePreviewName);
    } else {
        message2.customReplyName = LocaleController.getString("NewThemePreviewName", R.string.NewThemePreviewName);
    }
    message2.eventId = 1;
    message2.resetLayout();
    message2.replyMessageObject = replyMessageObject;

    for (int a = 0; a < cells.length; a++) {
        cells[a] = new ChatMessageCell(context);
        cells[a].setDelegate(new ChatMessageCell.ChatMessageCellDelegate() {

        });
        cells[a].isChat = false;
        cells[a].setFullyDraw(true);
        cells[a].setMessageObject(a == 0 ? message2 : message1, null, false, false);
        addView(cells[a], LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
    }
}