Java Code Examples for org.telegram.messenger.ChatObject#getBannedRightsString()

The following examples show how to use org.telegram.messenger.ChatObject#getBannedRightsString() . 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: ChatRightsEditActivity.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
private boolean checkDiscard() {
    boolean changed;
    if (currentType == TYPE_BANNED) {
        String newBannedRights = ChatObject.getBannedRightsString(bannedRights);
        changed = !currentBannedRights.equals(newBannedRights);
    } else {
        changed = !initialRank.equals(currentRank);
    }
    if (changed) {
        AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
        builder.setTitle(LocaleController.getString("UserRestrictionsApplyChanges", R.string.UserRestrictionsApplyChanges));
        TLRPC.Chat chat = MessagesController.getInstance(currentAccount).getChat(chatId);
        builder.setMessage(AndroidUtilities.replaceTags(LocaleController.formatString("UserRestrictionsApplyChangesText", R.string.UserRestrictionsApplyChangesText, chat.title)));
        builder.setPositiveButton(LocaleController.getString("ApplyTheme", R.string.ApplyTheme), (dialogInterface, i) -> onDonePressed());
        builder.setNegativeButton(LocaleController.getString("PassportDiscard", R.string.PassportDiscard), (dialog, which) -> finishFragment());
        showDialog(builder.create());
        return false;
    }
    return true;
}
 
Example 2
Source File: ChatUsersActivity.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
public ChatUsersActivity(Bundle args) {
    super(args);
    chatId = arguments.getInt("chat_id");
    type = arguments.getInt("type");
    needOpenSearch = arguments.getBoolean("open_search");
    selectType = arguments.getInt("selectType");
    currentChat = getMessagesController().getChat(chatId);
    if (currentChat != null && currentChat.default_banned_rights != null) {
        defaultBannedRights.view_messages = currentChat.default_banned_rights.view_messages;
        defaultBannedRights.send_stickers = currentChat.default_banned_rights.send_stickers;
        defaultBannedRights.send_media = currentChat.default_banned_rights.send_media;
        defaultBannedRights.embed_links = currentChat.default_banned_rights.embed_links;
        defaultBannedRights.send_messages = currentChat.default_banned_rights.send_messages;
        defaultBannedRights.send_games = currentChat.default_banned_rights.send_games;
        defaultBannedRights.send_inline = currentChat.default_banned_rights.send_inline;
        defaultBannedRights.send_gifs = currentChat.default_banned_rights.send_gifs;
        defaultBannedRights.pin_messages = currentChat.default_banned_rights.pin_messages;
        defaultBannedRights.send_polls = currentChat.default_banned_rights.send_polls;
        defaultBannedRights.invite_users = currentChat.default_banned_rights.invite_users;
        defaultBannedRights.change_info = currentChat.default_banned_rights.change_info;
    }
    initialBannedRights = ChatObject.getBannedRightsString(defaultBannedRights);
    isChannel = ChatObject.isChannel(currentChat) && !currentChat.megagroup;
}
 
Example 3
Source File: ChatUsersActivity.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
private boolean checkDiscard() {
    String newBannedRights = ChatObject.getBannedRightsString(defaultBannedRights);
    if (!newBannedRights.equals(initialBannedRights) || initialSlowmode != selectedSlowmode) {
        AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
        builder.setTitle(LocaleController.getString("UserRestrictionsApplyChanges", R.string.UserRestrictionsApplyChanges));
        if (isChannel) {
            builder.setMessage(LocaleController.getString("ChannelSettingsChangedAlert", R.string.ChannelSettingsChangedAlert));
        } else {
            builder.setMessage(LocaleController.getString("GroupSettingsChangedAlert", R.string.GroupSettingsChangedAlert));
        }
        builder.setPositiveButton(LocaleController.getString("ApplyTheme", R.string.ApplyTheme), (dialogInterface, i) -> processDone());
        builder.setNegativeButton(LocaleController.getString("PassportDiscard", R.string.PassportDiscard), (dialog, which) -> finishFragment());
        showDialog(builder.create());
        return false;
    }
    return true;
}
 
Example 4
Source File: ChatRightsEditActivity.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
private boolean checkDiscard() {
    boolean changed;
    if (currentType == TYPE_BANNED) {
        String newBannedRights = ChatObject.getBannedRightsString(bannedRights);
        changed = !currentBannedRights.equals(newBannedRights);
    } else {
        changed = !initialRank.equals(currentRank);
    }
    if (changed) {
        AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
        builder.setTitle(LocaleController.getString("UserRestrictionsApplyChanges", R.string.UserRestrictionsApplyChanges));
        TLRPC.Chat chat = MessagesController.getInstance(currentAccount).getChat(chatId);
        builder.setMessage(AndroidUtilities.replaceTags(LocaleController.formatString("UserRestrictionsApplyChangesText", R.string.UserRestrictionsApplyChangesText, chat.title)));
        builder.setPositiveButton(LocaleController.getString("ApplyTheme", R.string.ApplyTheme), (dialogInterface, i) -> onDonePressed());
        builder.setNegativeButton(LocaleController.getString("PassportDiscard", R.string.PassportDiscard), (dialog, which) -> finishFragment());
        showDialog(builder.create());
        return false;
    }
    return true;
}
 
Example 5
Source File: ChatUsersActivity.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
public ChatUsersActivity(Bundle args) {
    super(args);
    chatId = arguments.getInt("chat_id");
    type = arguments.getInt("type");
    needOpenSearch = arguments.getBoolean("open_search");
    selectType = arguments.getInt("selectType");
    currentChat = getMessagesController().getChat(chatId);
    if (currentChat != null && currentChat.default_banned_rights != null) {
        defaultBannedRights.view_messages = currentChat.default_banned_rights.view_messages;
        defaultBannedRights.send_stickers = currentChat.default_banned_rights.send_stickers;
        defaultBannedRights.send_media = currentChat.default_banned_rights.send_media;
        defaultBannedRights.embed_links = currentChat.default_banned_rights.embed_links;
        defaultBannedRights.send_messages = currentChat.default_banned_rights.send_messages;
        defaultBannedRights.send_games = currentChat.default_banned_rights.send_games;
        defaultBannedRights.send_inline = currentChat.default_banned_rights.send_inline;
        defaultBannedRights.send_gifs = currentChat.default_banned_rights.send_gifs;
        defaultBannedRights.pin_messages = currentChat.default_banned_rights.pin_messages;
        defaultBannedRights.send_polls = currentChat.default_banned_rights.send_polls;
        defaultBannedRights.invite_users = currentChat.default_banned_rights.invite_users;
        defaultBannedRights.change_info = currentChat.default_banned_rights.change_info;
    }
    initialBannedRights = ChatObject.getBannedRightsString(defaultBannedRights);
    isChannel = ChatObject.isChannel(currentChat) && !currentChat.megagroup;
}
 
Example 6
Source File: ChatUsersActivity.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
private boolean checkDiscard() {
    String newBannedRights = ChatObject.getBannedRightsString(defaultBannedRights);
    if (!newBannedRights.equals(initialBannedRights) || initialSlowmode != selectedSlowmode) {
        AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
        builder.setTitle(LocaleController.getString("UserRestrictionsApplyChanges", R.string.UserRestrictionsApplyChanges));
        if (isChannel) {
            builder.setMessage(LocaleController.getString("ChannelSettingsChangedAlert", R.string.ChannelSettingsChangedAlert));
        } else {
            builder.setMessage(LocaleController.getString("GroupSettingsChangedAlert", R.string.GroupSettingsChangedAlert));
        }
        builder.setPositiveButton(LocaleController.getString("ApplyTheme", R.string.ApplyTheme), (dialogInterface, i) -> processDone());
        builder.setNegativeButton(LocaleController.getString("PassportDiscard", R.string.PassportDiscard), (dialog, which) -> finishFragment());
        showDialog(builder.create());
        return false;
    }
    return true;
}
 
Example 7
Source File: ChatUsersActivity.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
private void processDone() {
    if (type != TYPE_KICKED) {
        return;
    }
    if (!ChatObject.isChannel(currentChat) && selectedSlowmode != initialSlowmode && info != null) {
        MessagesController.getInstance(currentAccount).convertToMegaGroup(getParentActivity(), chatId, this, param -> {
            if (param != 0) {
                chatId = param;
                currentChat = MessagesController.getInstance(currentAccount).getChat(param);
                processDone();
            }
        });
        return;
    }
    String newBannedRights = ChatObject.getBannedRightsString(defaultBannedRights);
    if (!newBannedRights.equals(initialBannedRights)) {
        getMessagesController().setDefaultBannedRole(chatId, defaultBannedRights, ChatObject.isChannel(currentChat), this);
        TLRPC.Chat chat = getMessagesController().getChat(chatId);
        if (chat != null) {
            chat.default_banned_rights = defaultBannedRights;
        }
    }
    if (selectedSlowmode != initialSlowmode && info != null) {
        info.slowmode_seconds = getSecondsForIndex(selectedSlowmode);
        info.flags |= 131072;
        getMessagesController().setChannelSlowMode(chatId, info.slowmode_seconds);
    }
    finishFragment();
}
 
Example 8
Source File: ChatUsersActivity.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
private void processDone() {
    if (type != TYPE_KICKED) {
        return;
    }
    if (!ChatObject.isChannel(currentChat) && selectedSlowmode != initialSlowmode && info != null) {
        MessagesController.getInstance(currentAccount).convertToMegaGroup(getParentActivity(), chatId, this, param -> {
            if (param != 0) {
                chatId = param;
                currentChat = MessagesController.getInstance(currentAccount).getChat(param);
                processDone();
            }
        });
        return;
    }
    String newBannedRights = ChatObject.getBannedRightsString(defaultBannedRights);
    if (!newBannedRights.equals(initialBannedRights)) {
        getMessagesController().setDefaultBannedRole(chatId, defaultBannedRights, ChatObject.isChannel(currentChat), this);
        TLRPC.Chat chat = getMessagesController().getChat(chatId);
        if (chat != null) {
            chat.default_banned_rights = defaultBannedRights;
        }
    }
    if (selectedSlowmode != initialSlowmode && info != null) {
        info.slowmode_seconds = getSecondsForIndex(selectedSlowmode);
        info.flags |= 131072;
        getMessagesController().setChannelSlowMode(chatId, info.slowmode_seconds);
    }
    finishFragment();
}