org.telegram.messenger.ChatObject Java Examples

The following examples show how to use org.telegram.messenger.ChatObject. 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-FOSS with GNU General Public License v2.0 6 votes vote down vote up
public void searchUsers(final String query) {
    if (searchRunnable != null) {
        Utilities.searchQueue.cancelRunnable(searchRunnable);
        searchRunnable = null;
    }
    if (TextUtils.isEmpty(query)) {
        searchResult.clear();
        searchResultMap.clear();
        searchResultNames.clear();
        searchAdapterHelper.mergeResults(null);
        searchAdapterHelper.queryServerSearch(null, type != 0, false, true, false, false, ChatObject.isChannel(currentChat) ? chatId : 0, false, type, 0);
        notifyDataSetChanged();
    } else {
        Utilities.searchQueue.postRunnable(searchRunnable = () -> processSearch(query), 300);
    }
}
 
Example #2
Source File: ChatEditActivity.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
@Override
public boolean onFragmentCreate() {
    currentChat = MessagesController.getInstance(currentAccount).getChat(chatId);
    if (currentChat == null) {
        currentChat = MessagesStorage.getInstance(currentAccount).getChatSync(chatId);
        if (currentChat != null) {
            MessagesController.getInstance(currentAccount).putChat(currentChat, true);
        } else {
            return false;
        }
        if (info == null) {
            info = MessagesStorage.getInstance(currentAccount).loadChatInfo(chatId, new CountDownLatch(1), false, false);
            if (info == null) {
                return false;
            }
        }
    }

    isChannel = ChatObject.isChannel(currentChat) && !currentChat.megagroup;
    imageUpdater.parentFragment = this;
    imageUpdater.delegate = this;
    signMessages = currentChat.signatures;
    NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.chatInfoDidLoad);
    return super.onFragmentCreate();
}
 
Example #3
Source File: ProfileActivity.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected ActionBar createActionBar(Context context)
{
    ActionBar actionBar = new ActionBar(context)
    {
        @Override
        public boolean onTouchEvent(MotionEvent event)
        {
            return super.onTouchEvent(event);
        }
    };

    actionBar.setItemsBackgroundColor(AvatarDrawable.getButtonColorForId(user_id != 0 || ChatObject.isChannel(chat_id, currentAccount) && !currentChat.megagroup ? 5 : chat_id), false);
    actionBar.setItemsColor(Theme.getColor(Theme.key_actionBarDefaultIcon), false);
    actionBar.setItemsColor(Theme.getColor(Theme.key_actionBarActionModeDefaultIcon), true);
    actionBar.setBackButtonDrawable(new BackDrawable(false));
    actionBar.setCastShadows(false);
    actionBar.setAddToContainer(false);
    actionBar.setOccupyStatusBar(Build.VERSION.SDK_INT >= 21 && !AndroidUtilities.isTablet());
    return actionBar;
}
 
Example #4
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 #5
Source File: ChatEditActivity.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
private boolean checkDiscard() {
    String about = info != null && info.about != null ? info.about : "";
    if (info != null && ChatObject.isChannel(currentChat) && info.hidden_prehistory != historyHidden ||
            imageUpdater.uploadingImage != null ||
            nameTextView != null && !currentChat.title.equals(nameTextView.getText().toString()) ||
            descriptionTextView != null && !about.equals(descriptionTextView.getText().toString()) ||
            signMessages != currentChat.signatures ||
            uploadedAvatar != null || avatar == null && currentChat.photo instanceof TLRPC.TL_chatPhoto) {
        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 #6
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 #7
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 #8
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 #9
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 #10
Source File: ChatActivityEnterView.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public void checkChannelRights()
{
    if (parentFragment == null)
    {
        return;
    }
    TLRPC.Chat chat = parentFragment.getCurrentChat();
    if (ChatObject.isChannel(chat))
    {
        audioVideoButtonContainer.setAlpha(chat.banned_rights == null || !chat.banned_rights.send_media ? 1.0f : 0.5f);
        if (emojiView != null)
        {
            emojiView.setStickersBanned(chat.banned_rights != null && chat.banned_rights.send_stickers, chat.id);
        }
    }
}
 
Example #11
Source File: ChatUsersActivity.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
public void searchUsers(final String query) {
    if (searchRunnable != null) {
        Utilities.searchQueue.cancelRunnable(searchRunnable);
        searchRunnable = null;
    }
    if (TextUtils.isEmpty(query)) {
        searchResult.clear();
        searchResultMap.clear();
        searchResultNames.clear();
        searchAdapterHelper.mergeResults(null);
        searchAdapterHelper.queryServerSearch(null, type != 0, false, true, false, false, ChatObject.isChannel(currentChat) ? chatId : 0, false, type, 0);
        notifyDataSetChanged();
    } else {
        Utilities.searchQueue.postRunnable(searchRunnable = () -> processSearch(query), 300);
    }
}
 
Example #12
Source File: ChatActivityEnterView.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public void checkChannelRights()
{
    if (parentFragment == null)
    {
        return;
    }
    TLRPC.Chat chat = parentFragment.getCurrentChat();
    if (ChatObject.isChannel(chat))
    {
        audioVideoButtonContainer.setAlpha(chat.banned_rights == null || !chat.banned_rights.send_media ? 1.0f : 0.5f);
        if (emojiView != null)
        {
            emojiView.setStickersBanned(chat.banned_rights != null && chat.banned_rights.send_stickers, chat.id);
        }
    }
}
 
Example #13
Source File: ChatAttachAlert.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
private void sendPressed(boolean notify, int scheduleDate) {
    if (buttonPressed) {
        return;
    }
    if (baseFragment instanceof ChatActivity) {
        ChatActivity chatActivity = (ChatActivity) baseFragment;
        TLRPC.Chat chat = chatActivity.getCurrentChat();
        TLRPC.User user = chatActivity.getCurrentUser();
        if (user != null || ChatObject.isChannel(chat) && chat.megagroup || !ChatObject.isChannel(chat)) {
            MessagesController.getNotificationsSettings(currentAccount).edit().putBoolean("silent_" + chatActivity.getDialogId(), !notify).commit();
        }
    }
    applyCaption();
    buttonPressed = true;
    delegate.didPressedButton(7, true, notify, scheduleDate);
}
 
Example #14
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 #15
Source File: AlertsCreator.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
public static boolean checkSlowMode(Context context, int currentAccount, long did, boolean few) {
    int lowerId = (int) did;
    if (lowerId < 0) {
        TLRPC.Chat chat = MessagesController.getInstance(currentAccount).getChat(-lowerId);
        if (chat != null && chat.slowmode_enabled && !ChatObject.hasAdminRights(chat)) {
            if (!few) {
                TLRPC.ChatFull chatFull = MessagesController.getInstance(currentAccount).getChatFull(chat.id);
                if (chatFull == null) {
                    chatFull = MessagesStorage.getInstance(currentAccount).loadChatInfo(chat.id, new CountDownLatch(1), false, false);
                }
                if (chatFull != null && chatFull.slowmode_next_send_date >= ConnectionsManager.getInstance(currentAccount).getCurrentTime()) {
                    few = true;
                }
            }
            if (few) {
                AlertsCreator.createSimpleAlert(context, chat.title, LocaleController.getString("SlowmodeSendError", R.string.SlowmodeSendError)).show();
                return true;
            }
        }
    }
    return false;
}
 
Example #16
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 #17
Source File: AlertsCreator.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
public static boolean checkSlowMode(Context context, int currentAccount, long did, boolean few) {
    int lowerId = (int) did;
    if (lowerId < 0) {
        TLRPC.Chat chat = MessagesController.getInstance(currentAccount).getChat(-lowerId);
        if (chat != null && chat.slowmode_enabled && !ChatObject.hasAdminRights(chat)) {
            if (!few) {
                TLRPC.ChatFull chatFull = MessagesController.getInstance(currentAccount).getChatFull(chat.id);
                if (chatFull == null) {
                    chatFull = MessagesStorage.getInstance(currentAccount).loadChatInfo(chat.id, new CountDownLatch(1), false, false);
                }
                if (chatFull != null && chatFull.slowmode_next_send_date >= ConnectionsManager.getInstance(currentAccount).getCurrentTime()) {
                    few = true;
                }
            }
            if (few) {
                AlertsCreator.createSimpleAlert(context, chat.title, LocaleController.getString("SlowmodeSendError", R.string.SlowmodeSendError)).show();
                return true;
            }
        }
    }
    return false;
}
 
Example #18
Source File: ProfileActivity.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
private void leaveChatPressed()
{
    AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
    if (ChatObject.isChannel(chat_id, currentAccount) && !currentChat.megagroup)
    {
        builder.setMessage(ChatObject.isChannel(chat_id, currentAccount) ? LocaleController.getString("ChannelLeaveAlert", R.string.ChannelLeaveAlert) : LocaleController.getString("AreYouSureDeleteAndExit", R.string.AreYouSureDeleteAndExit));
    }
    else
    {
        builder.setMessage(LocaleController.getString("AreYouSureDeleteAndExit", R.string.AreYouSureDeleteAndExit));
    }
    builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
    builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), (dialogInterface, i) -> kickUser(0));
    builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
    showDialog(builder.create());
}
 
Example #19
Source File: ProfileActivity.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected ActionBar createActionBar(Context context)
{
    ActionBar actionBar = new ActionBar(context)
    {
        @Override
        public boolean onTouchEvent(MotionEvent event)
        {
            return super.onTouchEvent(event);
        }
    };

    actionBar.setItemsBackgroundColor(AvatarDrawable.getButtonColorForId(user_id != 0 || ChatObject.isChannel(chat_id, currentAccount) && !currentChat.megagroup ? 5 : chat_id), false);
    actionBar.setItemsColor(Theme.getColor(Theme.key_actionBarDefaultIcon), false);
    actionBar.setItemsColor(Theme.getColor(Theme.key_actionBarActionModeDefaultIcon), true);
    actionBar.setBackButtonDrawable(new BackDrawable(false));
    actionBar.setCastShadows(false);
    actionBar.setAddToContainer(false);
    actionBar.setOccupyStatusBar(Build.VERSION.SDK_INT >= 21 && !AndroidUtilities.isTablet());
    return actionBar;
}
 
Example #20
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 #21
Source File: ChatAttachAlert.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
private void openAudioLayout() {
    if (audioLayout == null) {
        layouts[3] = audioLayout = new ChatAttachAlertAudioLayout(this, getContext());
        audioLayout.setDelegate((audios, caption, notify, scheduleDate) -> ((ChatActivity) baseFragment).sendAudio(audios, caption, notify, scheduleDate));
    }
    if (baseFragment instanceof ChatActivity) {
        ChatActivity chatActivity = (ChatActivity) baseFragment;
        TLRPC.Chat currentChat = chatActivity.getCurrentChat();
        audioLayout.setMaxSelectedFiles(currentChat != null && !ChatObject.hasAdminRights(currentChat) && currentChat.slowmode_enabled || editingMessageObject != null ? 1 : -1);
    }
    showLayout(audioLayout);
}
 
Example #22
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();
}
 
Example #23
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 #24
Source File: ChatUsersActivity.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
private void removeUser(int userId) {
    if (!ChatObject.isChannel(currentChat)) {
        return;
    }
    TLRPC.User user = getMessagesController().getUser(userId);
    getMessagesController().deleteUserFromChat(chatId, user, null);
    finishFragment();
}
 
Example #25
Source File: GroupCreateFinalActivity.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
public GroupCreateFinalActivity(Bundle args) {
    super(args);
    chatType = args.getInt("chatType", ChatObject.CHAT_TYPE_CHAT);
    avatarDrawable = new AvatarDrawable();
    currentGroupCreateAddress = args.getString("address");
    currentGroupCreateLocation = args.getParcelable("location");
}
 
Example #26
Source File: ChatEditActivity.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) {
            if (info == null && descriptionTextView != null) {
                descriptionTextView.setText(chatFull.about);
            }
            info = chatFull;
            historyHidden = !ChatObject.isChannel(currentChat) || info.hidden_prehistory;
            updateFields(false);
        }
    }
}
 
Example #27
Source File: ChatEditTypeActivity.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
private boolean trySetUsername() {
    if (getParentActivity() == null) {
        return false;
    }
    if (!isPrivate && ((currentChat.username == null && usernameTextView.length() != 0) || (currentChat.username != null && !currentChat.username.equalsIgnoreCase(usernameTextView.getText().toString())))) {
        if (usernameTextView.length() != 0 && !lastNameAvailable) {
            Vibrator v = (Vibrator) getParentActivity().getSystemService(Context.VIBRATOR_SERVICE);
            if (v != null) {
                v.vibrate(200);
            }
            AndroidUtilities.shakeView(checkTextView, 2, 0);
            return false;
        }
    }

    String oldUserName = currentChat.username != null ? currentChat.username : "";
    String newUserName = isPrivate ? "" : usernameTextView.getText().toString();
    if (!oldUserName.equals(newUserName)) {
        if (!ChatObject.isChannel(currentChat)) {
            getMessagesController().convertToMegaGroup(getParentActivity(), chatId, this, param -> {
                if (param != 0) {
                    chatId = param;
                    currentChat = getMessagesController().getChat(param);
                    processDone();
                }
            });
            return false;
        } else {
            getMessagesController().updateChannelUserName(chatId, newUserName);
            currentChat.username = newUserName;
        }
    }
    return true;
}
 
Example #28
Source File: ChatLinkActivity.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
public ChatLinkActivity(int chatId) {
    super();

    currentChatId = chatId;
    currentChat = MessagesController.getInstance(currentAccount).getChat(chatId);
    isChannel = ChatObject.isChannel(currentChat) && !currentChat.megagroup;
}
 
Example #29
Source File: GroupInviteActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    switch (holder.getItemViewType()) {
        case 0:
            TextSettingsCell textCell = (TextSettingsCell) holder.itemView;
            if (position == copyLinkRow) {
                textCell.setText(LocaleController.getString("CopyLink", R.string.CopyLink), true);
            } else if (position == shareLinkRow) {
                textCell.setText(LocaleController.getString("ShareLink", R.string.ShareLink), false);
            } else if (position == revokeLinkRow) {
                textCell.setText(LocaleController.getString("RevokeLink", R.string.RevokeLink), true);
            }
            break;
        case 1:
            TextInfoPrivacyCell privacyCell = (TextInfoPrivacyCell) holder.itemView;
            if (position == shadowRow) {
                privacyCell.setText("");
                privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
            } else if (position == linkInfoRow) {
                TLRPC.Chat chat = MessagesController.getInstance(currentAccount).getChat(chat_id);
                if (ChatObject.isChannel(chat) && !chat.megagroup) {
                    privacyCell.setText(LocaleController.getString("ChannelLinkInfo", R.string.ChannelLinkInfo));
                } else {
                    privacyCell.setText(LocaleController.getString("LinkInfo", R.string.LinkInfo));
                }
                privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow));
            }
            break;
        case 2:
            TextBlockCell textBlockCell = (TextBlockCell) holder.itemView;
            textBlockCell.setText(invite != null ? invite.link : "error", false);
            break;
    }
}
 
Example #30
Source File: ChannelEditActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private void updateRowsIds() {
    rowCount = 0;
    if (ChatObject.canEditInfo(currentChat)) {
        infoRow = rowCount++;
    } else {
        infoRow = -1;
    }
    permissionsRow = -1;
    /*if (currentChat.creator) {
        permissionsRow = rowCount++;
    }*/
    eventLogRow = rowCount++;
    managementRow = rowCount++;
    blockedUsersRow = rowCount++;
    membersSectionRow = rowCount++;
    if (info != null && info.participants != null && !info.participants.participants.isEmpty()) {
        membersStartRow = rowCount;
        rowCount += info.participants.participants.size();
        membersEndRow = rowCount;
        membersSection2Row = rowCount++;
        if (!usersEndReached) {
            loadMoreMembersRow = rowCount++;
        } else {
            loadMoreMembersRow = -1;
        }
    } else {
        membersStartRow = -1;
        membersEndRow = -1;
        loadMoreMembersRow = -1;
        membersSection2Row = -1;
    }
}