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

The following examples show how to use org.telegram.tgnet.TLRPC#ChannelParticipant . 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: ChatUsersActivity.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
private void updateParticipantWithRights(TLRPC.ChannelParticipant channelParticipant, TLRPC.TL_chatAdminRights rightsAdmin, TLRPC.TL_chatBannedRights rightsBanned, int user_id, boolean withDelegate) {
    boolean delegateCalled = false;
    for (int a = 0; a < 3; a++) {
        SparseArray<TLObject> map;
        if (a == 0) {
            map = contactsMap;
        } else if (a == 1) {
            map = botsMap;
        } else {
            map = participantsMap;
        }
        TLObject p = map.get(channelParticipant.user_id);
        if (p instanceof TLRPC.ChannelParticipant) {
            channelParticipant = (TLRPC.ChannelParticipant) p;
            channelParticipant.admin_rights = rightsAdmin;
            channelParticipant.banned_rights = rightsBanned;
            if (withDelegate) {
                channelParticipant.promoted_by = getUserConfig().getClientUserId();
            }
        }
        if (withDelegate && p != null && !delegateCalled && delegate != null) {
            delegateCalled = true;
            delegate.didAddParticipantToList(user_id, p);
        }
    }
}
 
Example 2
Source File: ProfileActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private boolean isParticipantAdmin(TLRPC.ChatParticipant participant)
{
    if (participant instanceof TLRPC.TL_chatChannelParticipant)
    {
        TLRPC.ChannelParticipant channelParticipant = ((TLRPC.TL_chatChannelParticipant) participant).channelParticipant;
        return channelParticipant instanceof TLRPC.TL_channelParticipantCreator || channelParticipant instanceof TLRPC.TL_channelParticipantAdmin;
    }
    else
    {
        return participant instanceof TLRPC.TL_chatParticipantCreator || (currentChat != null &&
                currentChat.admins_enabled && participant instanceof TLRPC.TL_chatParticipantAdmin);
    }
}
 
Example 3
Source File: ChatUsersActivity.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
private void removeParticipants(TLObject object) {
    if (object instanceof TLRPC.ChatParticipant) {
        TLRPC.ChatParticipant chatParticipant = (TLRPC.ChatParticipant) object;
        removeParticipants(chatParticipant.user_id);
    } else if (object instanceof TLRPC.ChannelParticipant) {
        TLRPC.ChannelParticipant channelParticipant = (TLRPC.ChannelParticipant) object;
        removeParticipants(channelParticipant.user_id);
    }
}
 
Example 4
Source File: ChannelAdminLogActivity.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
private void addCanBanUser(Bundle bundle, int uid) {
    if (!currentChat.megagroup || admins == null || !ChatObject.canBlockUsers(currentChat)) {
        return;
    }
    for (int a = 0; a < admins.size(); a++) {
        TLRPC.ChannelParticipant channelParticipant = admins.get(a);
        if (channelParticipant.user_id == uid) {
            if (!channelParticipant.can_edit) {
                return;
            }
            break;
        }
    }
    bundle.putInt("ban_chat_id", currentChat.id);
}
 
Example 5
Source File: ChannelUsersActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
public TLRPC.ChannelParticipant getItem(int position) {
    if (participantsStartRow != -1 && position >= participantsStartRow && position < participantsEndRow) {
        return participants.get(position - participantsStartRow);
    } else if (participants2StartRow != -1 && position >= participants2StartRow && position < participants2EndRow) {
        return participants2.get(position - participants2StartRow);
    }
    return null;
}
 
Example 6
Source File: ChannelAdminLogActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private void addCanBanUser(Bundle bundle, int uid) {
    if (!currentChat.megagroup || admins == null || !ChatObject.canBlockUsers(currentChat)) {
        return;
    }
    for (int a = 0; a < admins.size(); a++) {
        TLRPC.ChannelParticipant channelParticipant = admins.get(a);
        if (channelParticipant.user_id == uid) {
            if (!channelParticipant.can_edit) {
                return;
            }
            break;
        }
    }
    bundle.putInt("ban_chat_id", currentChat.id);
}
 
Example 7
Source File: ChannelUsersActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
public TLRPC.ChannelParticipant getItem(int position) {
    if (participantsStartRow != -1 && position >= participantsStartRow && position < participantsEndRow) {
        return participants.get(position - participantsStartRow);
    } else if (participants2StartRow != -1 && position >= participants2StartRow && position < participants2EndRow) {
        return participants2.get(position - participants2StartRow);
    }
    return null;
}
 
Example 8
Source File: ChannelUsersActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private int getChannelAdminParticipantType(TLRPC.ChannelParticipant participant) {
    if (participant instanceof TLRPC.TL_channelParticipantCreator || participant instanceof TLRPC.TL_channelParticipantSelf) {
        return 0;
    } else if (participant instanceof TLRPC.TL_channelParticipantAdmin) {
        return 1;
    }  else {
        return 2;
    }
}
 
Example 9
Source File: ProfileActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private boolean isParticipantAdmin(TLRPC.ChatParticipant participant)
{
    if (participant instanceof TLRPC.TL_chatChannelParticipant)
    {
        TLRPC.ChannelParticipant channelParticipant = ((TLRPC.TL_chatChannelParticipant) participant).channelParticipant;
        return channelParticipant instanceof TLRPC.TL_channelParticipantCreator || channelParticipant instanceof TLRPC.TL_channelParticipantAdmin;
    }
    else
    {
        return participant instanceof TLRPC.TL_chatParticipantCreator || (currentChat != null &&
                currentChat.admins_enabled && participant instanceof TLRPC.TL_chatParticipantAdmin);
    }
}
 
Example 10
Source File: AdminLogFilterAlert.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
public void setCurrentAdmins(ArrayList<TLRPC.ChannelParticipant> admins) {
    currentAdmins = admins;
    if (adapter != null) {
        adapter.notifyDataSetChanged();
    }
}
 
Example 11
Source File: ChannelEditActivity.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
public TLRPC.ChannelParticipant getItem(int i) {
    return searchAdapterHelper.getGroupSearch().get(i);
}
 
Example 12
Source File: ChannelEditActivity.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int i) {
    boolean checkBackground = true;
    switch (holder.getItemViewType()) {
        case 0:
            ManageChatTextCell textCell = (ManageChatTextCell) holder.itemView;
            textCell.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
            textCell.setTag(Theme.key_windowBackgroundWhiteBlackText);

            if (i == managementRow) {
                textCell.setText(LocaleController.getString("ChannelAdministrators", R.string.ChannelAdministrators), info != null ? String.format("%d", info.admins_count) : null, R.drawable.group_admin, blockedUsersRow != -1);
            } else if (i == blockedUsersRow) {
                textCell.setText(LocaleController.getString("ChannelBlacklist", R.string.ChannelBlacklist), info != null ? String.format("%d", info.kicked_count + info.banned_count) : null, R.drawable.group_banned, false);
            } else if (i == eventLogRow) {
                textCell.setText(LocaleController.getString("EventLog", R.string.EventLog), null, R.drawable.group_log, true);
            } else if (i == infoRow) {
                textCell.setText(currentChat.megagroup ? LocaleController.getString("EventLogFilterGroupInfo", R.string.EventLogFilterGroupInfo) : LocaleController.getString("EventLogFilterChannelInfo", R.string.EventLogFilterChannelInfo), null, R.drawable.group_edit, true);
            } else if (i == permissionsRow) {
                //textCell.setText(LocaleController.getString("ChatPermissions", R.string.ChatPermissions), null, R.drawable.group_log, true); //TODO icon
            }
            break;
        case 1:
            ManageChatUserCell userCell = ((ManageChatUserCell) holder.itemView);
            userCell.setTag(i);
            TLRPC.ChatParticipant part;
            if (!sortedUsers.isEmpty()) {
                part = info.participants.participants.get(sortedUsers.get(i - membersStartRow));
            } else {
                part = info.participants.participants.get(i - membersStartRow);
            }
            if (part != null) {
                if (part instanceof TLRPC.TL_chatChannelParticipant) {
                    TLRPC.ChannelParticipant channelParticipant = ((TLRPC.TL_chatChannelParticipant) part).channelParticipant;
                    userCell.setIsAdmin(channelParticipant instanceof TLRPC.TL_channelParticipantCreator || channelParticipant instanceof TLRPC.TL_channelParticipantAdmin);
                } else {
                    userCell.setIsAdmin(part instanceof TLRPC.TL_chatParticipantAdmin);
                }
                userCell.setData(MessagesController.getInstance(currentAccount).getUser(part.user_id), null, null);
            }
            break;
        case 2:
            if (i == membersSectionRow && membersStartRow != -1) {
                holder.itemView.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow));
            } else {
                holder.itemView.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
            }
            break;
    }
}
 
Example 13
Source File: SearchAdapterHelper.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
public ArrayList<TLRPC.ChannelParticipant> getGroupSearch() {
    return groupSearch;
}
 
Example 14
Source File: SearchAdapterHelper.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
public ArrayList<TLRPC.ChannelParticipant> getGroupSearch2() {
    return groupSearch2;
}
 
Example 15
Source File: AdminLogFilterAlert.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
public void setCurrentAdmins(ArrayList<TLRPC.ChannelParticipant> admins) {
    currentAdmins = admins;
    if (adapter != null) {
        adapter.notifyDataSetChanged();
    }
}
 
Example 16
Source File: SearchAdapterHelper.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
public ArrayList<TLRPC.ChannelParticipant> getGroupSearch2() {
    return groupSearch2;
}
 
Example 17
Source File: AdminLogFilterAlert.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
public void setCurrentAdmins(ArrayList<TLRPC.ChannelParticipant> admins) {
    currentAdmins = admins;
    if (adapter != null) {
        adapter.notifyDataSetChanged();
    }
}
 
Example 18
Source File: SearchAdapterHelper.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
public ArrayList<TLRPC.ChannelParticipant> getGroupSearch() {
    return groupSearch;
}
 
Example 19
Source File: ChannelEditActivity.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int i) {
    boolean checkBackground = true;
    switch (holder.getItemViewType()) {
        case 0:
            ManageChatTextCell textCell = (ManageChatTextCell) holder.itemView;
            textCell.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
            textCell.setTag(Theme.key_windowBackgroundWhiteBlackText);

            if (i == managementRow) {
                textCell.setText(LocaleController.getString("ChannelAdministrators", R.string.ChannelAdministrators), info != null ? String.format("%d", info.admins_count) : null, R.drawable.group_admin, blockedUsersRow != -1);
            } else if (i == blockedUsersRow) {
                textCell.setText(LocaleController.getString("ChannelBlacklist", R.string.ChannelBlacklist), info != null ? String.format("%d", info.kicked_count + info.banned_count) : null, R.drawable.group_banned, false);
            } else if (i == eventLogRow) {
                textCell.setText(LocaleController.getString("EventLog", R.string.EventLog), null, R.drawable.group_log, true);
            } else if (i == infoRow) {
                textCell.setText(currentChat.megagroup ? LocaleController.getString("EventLogFilterGroupInfo", R.string.EventLogFilterGroupInfo) : LocaleController.getString("EventLogFilterChannelInfo", R.string.EventLogFilterChannelInfo), null, R.drawable.group_edit, true);
            } else if (i == permissionsRow) {
                //textCell.setText(LocaleController.getString("ChatPermissions", R.string.ChatPermissions), null, R.drawable.group_log, true); //TODO icon
            }
            break;
        case 1:
            ManageChatUserCell userCell = ((ManageChatUserCell) holder.itemView);
            userCell.setTag(i);
            TLRPC.ChatParticipant part;
            if (!sortedUsers.isEmpty()) {
                part = info.participants.participants.get(sortedUsers.get(i - membersStartRow));
            } else {
                part = info.participants.participants.get(i - membersStartRow);
            }
            if (part != null) {
                if (part instanceof TLRPC.TL_chatChannelParticipant) {
                    TLRPC.ChannelParticipant channelParticipant = ((TLRPC.TL_chatChannelParticipant) part).channelParticipant;
                    userCell.setIsAdmin(channelParticipant instanceof TLRPC.TL_channelParticipantCreator || channelParticipant instanceof TLRPC.TL_channelParticipantAdmin);
                } else {
                    userCell.setIsAdmin(part instanceof TLRPC.TL_chatParticipantAdmin);
                }
                userCell.setData(MessagesController.getInstance(currentAccount).getUser(part.user_id), null, null);
            }
            break;
        case 2:
            if (i == membersSectionRow && membersStartRow != -1) {
                holder.itemView.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow));
            } else {
                holder.itemView.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
            }
            break;
    }
}
 
Example 20
Source File: AdminLogFilterAlert.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
public void setCurrentAdmins(ArrayList<TLRPC.ChannelParticipant> admins) {
    currentAdmins = admins;
    if (adapter != null) {
        adapter.notifyDataSetChanged();
    }
}