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

The following examples show how to use org.telegram.tgnet.TLRPC#ChatFull . 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: MentionsAdapter.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
public void setChatInfo(TLRPC.ChatFull chatInfo) {
    currentAccount = UserConfig.selectedAccount;
    info = chatInfo;
    if (!inlineMediaEnabled && foundContextBot != null && parentFragment != null) {
        TLRPC.Chat chat = parentFragment.getCurrentChat();
        if (chat != null) {
            inlineMediaEnabled = ChatObject.canSendStickers(chat);
            if (inlineMediaEnabled) {
                searchResultUsernames = null;
                notifyDataSetChanged();
                delegate.needChangePanelVisibility(false);
                processFoundUser(foundContextBot);
            }
        }
    }
    if (lastText != null) {
        searchUsernameOrHashtag(lastText, lastPosition, messages, lastUsernameOnly);
    }
}
 
Example 2
Source File: ChatAvatarContainer.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public void updateOnlineCount() {
    if (parentFragment == null) {
        return;
    }
    onlineCount = 0;
    TLRPC.ChatFull info = parentFragment.getCurrentChatInfo();
    if (info == null) {
        return;
    }
    int currentTime = ConnectionsManager.getInstance(currentAccount).getCurrentTime();
    if (info instanceof TLRPC.TL_chatFull || info instanceof TLRPC.TL_channelFull && info.participants_count <= 200 && info.participants != null) {
        for (int a = 0; a < info.participants.participants.size(); a++) {
            TLRPC.ChatParticipant participant = info.participants.participants.get(a);
            TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(participant.user_id);
            if (user != null && user.status != null && (user.status.expires > currentTime || user.id == UserConfig.getInstance(currentAccount).getClientUserId()) && user.status.expires > 10000) {
                onlineCount++;
            }
        }
    }
}
 
Example 3
Source File: GroupStickersActivity.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void didReceivedNotification(int id, int account, Object... args) {
    if (id == NotificationCenter.stickersDidLoaded) {
        if ((Integer) args[0] == DataQuery.TYPE_IMAGE) {
            updateRows();
        }
    } else if (id == NotificationCenter.chatInfoDidLoaded) {
        TLRPC.ChatFull chatFull = (TLRPC.ChatFull) args[0];
        if (chatFull.id == chatId) {
            if (info == null && chatFull.stickerset != null) {
                selectedStickerSet = DataQuery.getInstance(currentAccount).getGroupStickerSetById(chatFull.stickerset);
            }
            info = chatFull;
            updateRows();
        }
    } else if (id == NotificationCenter.groupStickersDidLoaded) {
        long setId = (Long) args[0];
        if (info != null && info.stickerset != null && info.stickerset.id == id) {
            updateRows();
        }
    }
}
 
Example 4
Source File: ChatLinkActivity.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void didReceivedNotification(int id, int account, Object... args) {
    if (id == NotificationCenter.chatInfoDidLoad) {
        TLRPC.ChatFull chatFull = (TLRPC.ChatFull) args[0];
        if (chatFull.id == currentChatId) {
            info = chatFull;
            loadChats();
            updateRows();
        } else if (waitingForFullChat != null && waitingForFullChat.id == chatFull.id) {
            try {
                waitingForFullChatProgressAlert.dismiss();
            } catch (Throwable ignore) {

            }
            waitingForFullChatProgressAlert = null;
            showLinkAlert(waitingForFullChat, false);
            waitingForFullChat = null;
        }
    }
}
 
Example 5
Source File: MentionsAdapter.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public void setChatInfo(TLRPC.ChatFull chatInfo)
{
    currentAccount = UserConfig.selectedAccount;
    info = chatInfo;
    if (!inlineMediaEnabled && foundContextBot != null && parentFragment != null)
    {
        TLRPC.Chat chat = parentFragment.getCurrentChat();
        if (chat != null)
        {
            inlineMediaEnabled = ChatObject.canSendStickers(chat);
            if (inlineMediaEnabled)
            {
                searchResultUsernames = null;
                notifyDataSetChanged();
                delegate.needChangePanelVisibility(false);
                processFoundUser(foundContextBot);
            }
        }
    }
    if (lastText != null)
    {
        searchUsernameOrHashtag(lastText, lastPosition, messages, lastUsernameOnly);
    }
}
 
Example 6
Source File: ChannelEditInfoActivity.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void didReceivedNotification(int id, int account, Object... args) {
    if (id == NotificationCenter.chatInfoDidLoaded) {
        TLRPC.ChatFull chatFull = (TLRPC.ChatFull) args[0];
        if (chatFull.id == chatId) {
            if (info == null) {
                descriptionTextView.setText(chatFull.about);
                historyHidden = chatFull.hidden_prehistory;
                if (radioButtonCell3 != null) {
                    radioButtonCell3.setChecked(!historyHidden, false);
                    radioButtonCell4.setChecked(historyHidden, false);
                }
            }
            info = chatFull;
            invite = chatFull.exported_invite;
            updatePrivatePublic();
        }
    }
}
 
Example 7
Source File: ProfileActivity.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public void setChatInfo(TLRPC.ChatFull chatInfo)
{
    info = chatInfo;
    if (info != null && info.migrated_from_chat_id != 0)
        mergeDialogId = -info.migrated_from_chat_id;

    if (info != null && info.participants != null && info.participants.participants.size() > 0)
    {
        chatParticipantsList.clear();
        chatAdminParticipantsList.clear();
        chatOnlineParticipantsList.clear();
        for (TLRPC.ChatParticipant participant : info.participants.participants)
        {
            chatParticipantsList.add(participant);
            chatAdminParticipantsList.add(participant);
            chatOnlineParticipantsList.add(participant);
        }
        sortParticipants(chatAdminParticipantsList);
        sortParticipants(chatOnlineParticipantsList);
        updateOnlineCount();
    }

    fetchUsersFromChannelInfo();
}
 
Example 8
Source File: MentionsAdapter.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
public void setChatInfo(TLRPC.ChatFull chatInfo) {
    currentAccount = UserConfig.selectedAccount;
    info = chatInfo;
    if (!inlineMediaEnabled && foundContextBot != null && parentFragment != null) {
        TLRPC.Chat chat = parentFragment.getCurrentChat();
        if (chat != null) {
            inlineMediaEnabled = ChatObject.canSendStickers(chat);
            if (inlineMediaEnabled) {
                searchResultUsernames = null;
                notifyDataSetChanged();
                delegate.needChangePanelVisibility(false);
                processFoundUser(foundContextBot);
            }
        }
    }
    if (lastText != null) {
        searchUsernameOrHashtag(lastText, lastPosition, messages, lastUsernameOnly);
    }
}
 
Example 9
Source File: ChatActivityEnterView.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
public void setChatInfo(TLRPC.ChatFull chatInfo)
{
    info = chatInfo;
    if (emojiView != null)
    {
        emojiView.setChatInfo(info);
    }
}
 
Example 10
Source File: ChatEditActivity.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
public void setInfo(TLRPC.ChatFull chatFull) {
    info = chatFull;
    if (chatFull != null) {
        if (currentChat == null) {
            currentChat = MessagesController.getInstance(currentAccount).getChat(chatId);
        }
        historyHidden = !ChatObject.isChannel(currentChat) || info.hidden_prehistory;
    }
}
 
Example 11
Source File: ChannelEditActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public void didReceivedNotification(int id, int account, Object... args) {
    if (id == NotificationCenter.chatInfoDidLoaded) {
        TLRPC.ChatFull chatFull = (TLRPC.ChatFull) args[0];
        if (chatFull.id == chat_id) {
            boolean byChannelUsers = (Boolean) args[2];
            if (info instanceof TLRPC.TL_channelFull) {
                if (chatFull.participants == null && info != null) {
                    chatFull.participants = info.participants;
                }
            }
            boolean loadChannelParticipants = info == null && chatFull instanceof TLRPC.TL_channelFull;
            info = chatFull;
            fetchUsersFromChannelInfo();
            updateRowsIds();
            if (listViewAdapter != null) {
                listViewAdapter.notifyDataSetChanged();
            }
            TLRPC.Chat newChat = MessagesController.getInstance(currentAccount).getChat(chat_id);
            if (newChat != null) {
                currentChat = newChat;
            }
            if (loadChannelParticipants || !byChannelUsers) {
                getChannelParticipants(true);
            }
        }
    } else if (id == NotificationCenter.closeChats) {
        removeSelfFromStack();
    }
}
 
Example 12
Source File: ChatUsersActivity.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void didReceivedNotification(int id, int account, Object... args) {
    if (id == NotificationCenter.chatInfoDidLoad) {
        TLRPC.ChatFull chatFull = (TLRPC.ChatFull) args[0];
        boolean byChannelUsers = (Boolean) args[2];
        if (chatFull.id == chatId && (!byChannelUsers || !ChatObject.isChannel(currentChat))) {
            boolean hadInfo = info != null;
            info = chatFull;
            if (!hadInfo) {
                selectedSlowmode = initialSlowmode = getCurrentSlowmode();
            }
            AndroidUtilities.runOnUIThread(() -> loadChatParticipants(0, 200));
        }
    }
}
 
Example 13
Source File: ChatEditTypeActivity.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
public void setInfo(TLRPC.ChatFull chatFull) {
    info = chatFull;
    if (chatFull != null) {
        if (chatFull.exported_invite instanceof TLRPC.TL_chatInviteExported) {
            invite = chatFull.exported_invite;
        } else {
            generateLink(false);
        }
    }
}
 
Example 14
Source File: ChatEditTypeActivity.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void didReceivedNotification(int id, int account, Object... args) {
    if (id == NotificationCenter.chatInfoDidLoad) {
        TLRPC.ChatFull chatFull = (TLRPC.ChatFull) args[0];
        if (chatFull.id == chatId) {
            info = chatFull;
            invite = chatFull.exported_invite;
            updatePrivatePublic();
        }
    }
}
 
Example 15
Source File: ChatEditActivity.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
public void setInfo(TLRPC.ChatFull chatFull) {
    info = chatFull;
    if (chatFull != null) {
        if (currentChat == null) {
            currentChat = MessagesController.getInstance(currentAccount).getChat(chatId);
        }
        historyHidden = !ChatObject.isChannel(currentChat) || info.hidden_prehistory;
    }
}
 
Example 16
Source File: ChatEditActivity.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void didReceivedNotification(int id, int account, Object... args) {
    if (id == NotificationCenter.chatInfoDidLoad) {
        TLRPC.ChatFull chatFull = (TLRPC.ChatFull) args[0];
        if (chatFull.id == chatId) {
            if (info == null && descriptionTextView != null) {
                descriptionTextView.setText(chatFull.about);
            }
            info = chatFull;
            historyHidden = !ChatObject.isChannel(currentChat) || info.hidden_prehistory;
            updateFields(false);
        }
    }
}
 
Example 17
Source File: ChatLinkActivity.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
private void showLinkAlert(TLRPC.Chat chat, boolean query) {
    TLRPC.ChatFull chatFull = getMessagesController().getChatFull(chat.id);
    if (chatFull == null) {
        if (query) {
            getMessagesController().loadFullChat(chat.id, 0, true);
            waitingForFullChat = chat;
            waitingForFullChatProgressAlert = new AlertDialog(getParentActivity(), 3);
            AndroidUtilities.runOnUIThread(() -> {
                if (waitingForFullChatProgressAlert == null) {
                    return;
                }
                waitingForFullChatProgressAlert.setOnCancelListener(dialog -> waitingForFullChat = null);
                showDialog(waitingForFullChatProgressAlert);
            }, 500);
        }
        return;
    }
    AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());

    TextView messageTextView = new TextView(getParentActivity());
    messageTextView.setTextColor(Theme.getColor(Theme.key_dialogTextBlack));
    messageTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    messageTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP);
    String message;
    if (TextUtils.isEmpty(chat.username)) {
        message = LocaleController.formatString("DiscussionLinkGroupPublicPrivateAlert", R.string.DiscussionLinkGroupPublicPrivateAlert, chat.title, currentChat.title);
    } else {
        if (TextUtils.isEmpty(currentChat.username)) {
            message = LocaleController.formatString("DiscussionLinkGroupPrivateAlert", R.string.DiscussionLinkGroupPrivateAlert, chat.title, currentChat.title);
        } else {
            message = LocaleController.formatString("DiscussionLinkGroupPublicAlert", R.string.DiscussionLinkGroupPublicAlert, chat.title, currentChat.title);
        }
    }
    if (chatFull.hidden_prehistory) {
        message += "\n\n" + LocaleController.getString("DiscussionLinkGroupAlertHistory", R.string.DiscussionLinkGroupAlertHistory);
    }
    messageTextView.setText(AndroidUtilities.replaceTags(message));

    FrameLayout frameLayout2 = new FrameLayout(getParentActivity());
    builder.setView(frameLayout2);

    AvatarDrawable avatarDrawable = new AvatarDrawable();
    avatarDrawable.setTextSize(AndroidUtilities.dp(12));

    BackupImageView imageView = new BackupImageView(getParentActivity());
    imageView.setRoundRadius(AndroidUtilities.dp(20));
    frameLayout2.addView(imageView, LayoutHelper.createFrame(40, 40, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 22, 5, 22, 0));

    TextView textView = new TextView(getParentActivity());
    textView.setTextColor(Theme.getColor(Theme.key_actionBarDefaultSubmenuItem));
    textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
    textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    textView.setLines(1);
    textView.setMaxLines(1);
    textView.setSingleLine(true);
    textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL);
    textView.setEllipsize(TextUtils.TruncateAt.END);
    textView.setText(chat.title);

    frameLayout2.addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, (LocaleController.isRTL ? 21 : 76), 11, (LocaleController.isRTL ? 76 : 21), 0));
    frameLayout2.addView(messageTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 24, 57, 24, 9));
    avatarDrawable.setInfo(chat);
    imageView.setImage(ImageLocation.getForChat(chat, false), "50_50", avatarDrawable, chat);
    builder.setPositiveButton(LocaleController.getString("DiscussionLinkGroup", R.string.DiscussionLinkGroup), (dialogInterface, i) -> {
        if (chatFull.hidden_prehistory) {
            MessagesController.getInstance(currentAccount).toogleChannelInvitesHistory(chat.id, false);
        }
        linkChat(chat, null);
    });
    builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
    showDialog(builder.create());
}
 
Example 18
Source File: SetAdminsActivity.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
public void setChatInfo(TLRPC.ChatFull chatParticipants) {
    info = chatParticipants;
    updateChatParticipants();
}
 
Example 19
Source File: GroupStickersActivity.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
public void setInfo(TLRPC.ChatFull chatFull) {
    info = chatFull;
    if (info != null && info.stickerset != null) {
        selectedStickerSet = DataQuery.getInstance(currentAccount).getGroupStickerSetById(info.stickerset);
    }
}
 
Example 20
Source File: GroupStickersActivity.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
public void setInfo(TLRPC.ChatFull chatFull) {
    info = chatFull;
    if (info != null && info.stickerset != null) {
        selectedStickerSet = DataQuery.getInstance(currentAccount).getGroupStickerSetById(info.stickerset);
    }
}