org.telegram.messenger.MessagesController Java Examples

The following examples show how to use org.telegram.messenger.MessagesController. 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: NotificationsSettingsActivity.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public void updateServerNotificationsSettings(boolean group) {
    SharedPreferences preferences = MessagesController.getNotificationsSettings(currentAccount);
    TLRPC.TL_account_updateNotifySettings req = new TLRPC.TL_account_updateNotifySettings();
    req.settings = new TLRPC.TL_inputPeerNotifySettings();
    req.settings.flags = 5;
    if (!group) {
        req.peer = new TLRPC.TL_inputNotifyUsers();
        req.settings.mute_until = preferences.getBoolean("EnableAll", true) ? 0 : Integer.MAX_VALUE;
        req.settings.show_previews = preferences.getBoolean("EnablePreviewAll", true);
    } else {
        req.peer = new TLRPC.TL_inputNotifyChats();
        req.settings.mute_until = preferences.getBoolean("EnableGroup", true) ? 0 : Integer.MAX_VALUE;
        req.settings.show_previews = preferences.getBoolean("EnablePreviewGroup", true);
    }
    ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> {

    });
}
 
Example #2
Source File: StickersActivity.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
private CharSequence addStickersBotSpan(String text) {
    final String botName = "@stickers";
    final int index = text.indexOf(botName);
    if (index != -1) {
        try {
            SpannableStringBuilder stringBuilder = new SpannableStringBuilder(text);
            URLSpanNoUnderline urlSpan = new URLSpanNoUnderline("@stickers") {
                @Override
                public void onClick(View widget) {
                    MessagesController.getInstance(currentAccount).openByUserName("stickers", StickersActivity.this, 3);
                }
            };
            stringBuilder.setSpan(urlSpan, index, index + botName.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
            return stringBuilder;
        } catch (Exception e) {
            FileLog.e(e);
            return text;
        }
    } else {
        return text;
    }
}
 
Example #3
Source File: ChannelAdminLogActivity.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
private String getMessageContent(MessageObject messageObject, int previousUid, boolean name) {
    String str = "";
    if (name) {
        if (previousUid != messageObject.messageOwner.from_id) {
            if (messageObject.messageOwner.from_id > 0) {
                TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(messageObject.messageOwner.from_id);
                if (user != null) {
                    str = ContactsController.formatName(user.first_name, user.last_name) + ":\n";
                }
            } else if (messageObject.messageOwner.from_id < 0) {
                TLRPC.Chat chat = MessagesController.getInstance(currentAccount).getChat(-messageObject.messageOwner.from_id);
                if (chat != null) {
                    str = chat.title + ":\n";
                }
            }
        }
    }
    if (messageObject.type == 0 && messageObject.messageOwner.message != null) {
        str += messageObject.messageOwner.message;
    } else if (messageObject.messageOwner.media != null && messageObject.messageOwner.message != null) {
        str += messageObject.messageOwner.message;
    } else {
        str += messageObject.messageText;
    }
    return str;
}
 
Example #4
Source File: SharingLiveLocationCell.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public void setDialog(LocationController.SharingLocationInfo info) {
    currentInfo = info;
    int lower_id = (int) info.did;
    TLRPC.FileLocation photo = null;
    if (lower_id > 0) {
        TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(lower_id);
        if (user != null) {
            avatarDrawable.setInfo(user);
            nameTextView.setText(ContactsController.formatName(user.first_name, user.last_name));
            if (user.photo != null && user.photo.photo_small != null) {
                photo = user.photo.photo_small;
            }
        }
    } else {
        TLRPC.Chat chat = MessagesController.getInstance(currentAccount).getChat(-lower_id);
        if (chat != null) {
            avatarDrawable.setInfo(chat);
            nameTextView.setText(chat.title);
            if (chat.photo != null && chat.photo.photo_small != null) {
                photo = chat.photo.photo_small;
            }
        }
    }
    avatarImageView.setImage(photo, null, avatarDrawable);
}
 
Example #5
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 #6
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 #7
Source File: ContactAddActivity.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
private void updateAvatarLayout() {
    if (nameTextView == null) {
        return;
    }
    TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(user_id);
    if (user == null) {
        return;
    }
    nameTextView.setText(PhoneFormat.getInstance().format("+" + user.phone));
    onlineTextView.setText(LocaleController.formatUserStatus(currentAccount, user));

    TLRPC.FileLocation photo = null;
    if (user.photo != null) {
        photo = user.photo.photo_small;
    }
    avatarImage.setImage(photo, "50_50", avatarDrawable = new AvatarDrawable(user));
}
 
Example #8
Source File: DialogsEmptyCell.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    int totalHeight;
    if (getParent() instanceof View) {
        View view = (View) getParent();
        totalHeight = view.getMeasuredHeight();
        if (view.getPaddingTop() != 0 && Build.VERSION.SDK_INT >= 21) {
            totalHeight -= AndroidUtilities.statusBarHeight;
        }
    } else {
        totalHeight = MeasureSpec.getSize(heightMeasureSpec);
    }
    if (totalHeight == 0) {
        totalHeight = AndroidUtilities.displaySize.y - ActionBar.getCurrentActionBarHeight() - (Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0);
    }
    if (currentType == 0 || currentType == 2 || currentType == 3) {
        ArrayList<TLRPC.RecentMeUrl> arrayList = MessagesController.getInstance(currentAccount).hintDialogs;
        if (!arrayList.isEmpty()) {
            totalHeight -= AndroidUtilities.dp(72) * arrayList.size() + arrayList.size() - 1 + AndroidUtilities.dp(12 + 38);
        }
        super.onMeasure(MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(totalHeight, MeasureSpec.EXACTLY));
    } else {
        super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(166), MeasureSpec.EXACTLY));
    }
}
 
Example #9
Source File: FilterCreateActivity.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
public FilterCreateActivity(MessagesController.DialogFilter dialogFilter, ArrayList<Integer> alwaysShow) {
    super();
    filter = dialogFilter;
    if (filter == null) {
        filter = new MessagesController.DialogFilter();
        filter.id = 2;
        while (getMessagesController().dialogFiltersById.get(filter.id) != null) {
            filter.id++;
        }
        filter.name = "";
        creatingNew = true;
    }
    newFilterName = filter.name;
    newFilterFlags = filter.flags;
    newAlwaysShow = new ArrayList<>(filter.alwaysShow);
    if (alwaysShow != null) {
        newAlwaysShow.addAll(alwaysShow);
    }
    newNeverShow = new ArrayList<>(filter.neverShow);
    newPinned = filter.pinnedDialogs.clone();
}
 
Example #10
Source File: SettingsActivity.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.updateInterfaces) {
        int mask = (Integer) args[0];
        if ((mask & MessagesController.UPDATE_MASK_AVATAR) != 0 || (mask & MessagesController.UPDATE_MASK_NAME) != 0) {
            updateUserData();
        }
    } else if (id == NotificationCenter.featuredStickersDidLoaded) {
        if (listAdapter != null) {
            listAdapter.notifyItemChanged(stickersRow);
        }
    } else if (id == NotificationCenter.userInfoDidLoaded) {
        Integer uid = (Integer) args[0];
        if (uid == UserConfig.getInstance(currentAccount).getClientUserId() && listAdapter != null) {
            listAdapter.notifyItemChanged(bioRow);
        }
    } else if (id == NotificationCenter.emojiDidLoaded) {
        if (listView != null) {
            listView.invalidateViews();
        }
    }
}
 
Example #11
Source File: CallLogActivity.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
private void confirmAndDelete(final CallLogRow row)
{
    if (getParentActivity() == null)
        return;
    new AlertDialog.Builder(getParentActivity())
            .setTitle(LocaleController.getString("AppName", R.string.AppName))
            .setMessage(LocaleController.getString("ConfirmDeleteCallLog", R.string.ConfirmDeleteCallLog))
            .setPositiveButton(LocaleController.getString("Delete", R.string.Delete), (dialog, which) ->
            {
                ArrayList<Integer> ids = new ArrayList<>();
                for (TLRPC.Message msg : row.calls)
                {
                    ids.add(msg.id);
                }
                MessagesController.getInstance(currentAccount).deleteMessages(ids, null, null, 0, false);
            })
            .setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null)
            .show()
            .setCanceledOnTouchOutside(true);
}
 
Example #12
Source File: WebviewActivity.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
private void reloadStats(String params) {
    if (loadStats) {
        return;
    }
    loadStats = true;
    TLRPC.TL_messages_getStatsURL req = new TLRPC.TL_messages_getStatsURL();
    req.peer = MessagesController.getInstance(currentAccount).getInputPeer((int) currentDialogId);
    req.params = params != null ? params : "";
    req.dark = Theme.getCurrentTheme().isDark();
    ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
        loadStats = false;
        if (response != null) {
            TLRPC.TL_statsURL url = (TLRPC.TL_statsURL) response;
            webView.loadUrl(currentUrl = url.url);
        }
    }));
}
 
Example #13
Source File: ContactsActivity.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void onRequestPermissionsResultFragment(int requestCode, String[] permissions, int[] grantResults) {
    if (requestCode == 1) {
        for (int a = 0; a < permissions.length; a++) {
            if (grantResults.length <= a) {
                continue;
            }
            switch (permissions[a]) {
                case Manifest.permission.READ_CONTACTS:
                    if (grantResults[a] == PackageManager.PERMISSION_GRANTED) {
                        ContactsController.getInstance(currentAccount).forceImportContacts();
                    } else {
                        MessagesController.getGlobalNotificationsSettings().edit().putBoolean("askAboutContacts", askAboutContacts = false).commit();
                    }
                    break;
            }
        }
    }
}
 
Example #14
Source File: GroupInviteActivity.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 info = (TLRPC.ChatFull) args[0];
        int guid = (int) args[1];
        if (info.id == chat_id && guid == classGuid) {
            invite = MessagesController.getInstance(currentAccount).getExportedInvite(chat_id);
            if (!(invite instanceof TLRPC.TL_chatInviteExported)) {
                generateLink(false);
            } else {
                loading = false;
                if (listAdapter != null) {
                    listAdapter.notifyDataSetChanged();
                }
            }
        }
    }
}
 
Example #15
Source File: BlockedUsersActivity.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    if (holder.getItemViewType() == 0) {
        TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(MessagesController.getInstance(currentAccount).blockedUsers.keyAt(position));
        if (user != null) {
            String number;
            if (user.bot) {
                number = LocaleController.getString("Bot", R.string.Bot).substring(0, 1).toUpperCase() + LocaleController.getString("Bot", R.string.Bot).substring(1);
            } else if (user.phone != null && user.phone.length() != 0) {
                number = PhoneFormat.getInstance().format("+" + user.phone);
            } else {
                number = LocaleController.getString("NumberUnknown", R.string.NumberUnknown);
            }
            ((UserCell) holder.itemView).setData(user, null, number, 0);
        }
    }
}
 
Example #16
Source File: GroupCreateActivity.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.contactsDidLoaded) {
        if (emptyView != null) {
            emptyView.showTextView();
        }
        if (adapter != null) {
            adapter.notifyDataSetChanged();
        }
    } else if (id == NotificationCenter.updateInterfaces) {
        if (listView != null) {
            int mask = (Integer) args[0];
            int count = listView.getChildCount();
            if ((mask & MessagesController.UPDATE_MASK_AVATAR) != 0 || (mask & MessagesController.UPDATE_MASK_NAME) != 0 || (mask & MessagesController.UPDATE_MASK_STATUS) != 0) {
                for (int a = 0; a < count; a++) {
                    View child = listView.getChildAt(a);
                    if (child instanceof GroupCreateUserCell) {
                        ((GroupCreateUserCell) child).update(mask);
                    }
                }
            }
        }
    } else if (id == NotificationCenter.chatDidCreated) {
        removeSelfFromStack();
    }
}
 
Example #17
Source File: DrawerLayoutAdapter.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
public void setAccountsShown(boolean value, boolean animated) {
    if (accountsShown == value || itemAnimator.isRunning()) {
        return;
    }
    accountsShown = value;
    if (profileCell != null) {
        profileCell.setAccountsShown(accountsShown, animated);
    }
    MessagesController.getGlobalMainSettings().edit().putBoolean("accountsShown", accountsShown).commit();
    if (animated) {
        itemAnimator.setShouldClipChildren(false);
        if (accountsShown) {
            notifyItemRangeInserted(2, getAccountRowsCount());
        } else {
            notifyItemRangeRemoved(2, getAccountRowsCount());
        }
    } else {
        notifyDataSetChanged();
    }
}
 
Example #18
Source File: LoginActivity.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
private void onAuthSuccess(TLRPC.TL_auth_authorization res)
{
    ConnectionsManager.getInstance(currentAccount).setUserId(res.user.id);
    UserConfig.getInstance(currentAccount).clearConfig();
    MessagesController.getInstance(currentAccount).cleanup();
    UserConfig.getInstance(currentAccount).syncContacts = syncContacts;
    UserConfig.getInstance(currentAccount).setCurrentUser(res.user);
    UserConfig.getInstance(currentAccount).saveConfig(true);
    MessagesStorage.getInstance(currentAccount).cleanup(true);
    ArrayList<TLRPC.User> users = new ArrayList<>();
    users.add(res.user);
    MessagesStorage.getInstance(currentAccount).putUsersAndChats(users, null, true, true);
    MessagesController.getInstance(currentAccount).putUser(res.user, false);
    ContactsController.getInstance(currentAccount).checkAppAccount();
    MessagesController.getInstance(currentAccount).getBlockedUsers(true);
    MessagesController.getInstance(currentAccount).checkProxyInfo(true);
    ConnectionsManager.getInstance(currentAccount).updateDcSettings();
    needFinishActivity();
}
 
Example #19
Source File: FilterTabsView.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
public void setIsEditing(boolean value) {
    isEditing = value;
    editingForwardAnimation = true;
    listView.invalidateViews();
    invalidate();
    if (!isEditing && orderChanged) {
        MessagesStorage.getInstance(UserConfig.selectedAccount).saveDialogFiltersOrder();
        TLRPC.TL_messages_updateDialogFiltersOrder req = new TLRPC.TL_messages_updateDialogFiltersOrder();
        ArrayList<MessagesController.DialogFilter> filters = MessagesController.getInstance(UserConfig.selectedAccount).dialogFilters;
        for (int a = 0, N = filters.size(); a < N; a++) {
            MessagesController.DialogFilter filter = filters.get(a);
            req.order.add(filters.get(a).id);
        }
        ConnectionsManager.getInstance(UserConfig.selectedAccount).sendRequest(req, (response, error) -> {

        });
        orderChanged = false;
    }
}
 
Example #20
Source File: DialogsAdapter.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void notifyItemMoved(int fromPosition, int toPosition) {
    ArrayList<TLRPC.Dialog> dialogs = DialogsActivity.getDialogsArray(currentAccount, dialogsType, folderId, false);
    int fromIndex = fixPosition(fromPosition);
    int toIndex = fixPosition(toPosition);
    TLRPC.Dialog fromDialog = dialogs.get(fromIndex);
    TLRPC.Dialog toDialog = dialogs.get(toIndex);
    if (dialogsType == 7 || dialogsType == 8) {
        MessagesController.DialogFilter filter = MessagesController.getInstance(currentAccount).selectedDialogFilter[dialogsType == 8 ? 1 : 0];
        int idx1 = filter.pinnedDialogs.get(fromDialog.id);
        int idx2 = filter.pinnedDialogs.get(toDialog.id);
        filter.pinnedDialogs.put(fromDialog.id, idx2);
        filter.pinnedDialogs.put(toDialog.id, idx1);
    } else {
        int oldNum = fromDialog.pinnedNum;
        fromDialog.pinnedNum = toDialog.pinnedNum;
        toDialog.pinnedNum = oldNum;
    }
    Collections.swap(dialogs, fromIndex, toIndex);
    super.notifyItemMoved(fromPosition, toPosition);
}
 
Example #21
Source File: ChatUsersActivity.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    switch (holder.getItemViewType()) {
        case 0:
            ManageChatUserCell userCell = (ManageChatUserCell) holder.itemView;
            userCell.setTag(position);
            TLRPC.ChatParticipant participant = getItem(position);
            TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(participant.user_id);
            if (user != null) {
                userCell.setData(user, null, null);
            }
            break;
        case 1:
            TextInfoPrivacyCell privacyCell = (TextInfoPrivacyCell) holder.itemView;
            if (position == participantsInfoRow) {
                privacyCell.setText("");
            }
            break;
    }
}
 
Example #22
Source File: BlockedUsersActivity.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    if (holder.getItemViewType() == 0) {
        TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(MessagesController.getInstance(currentAccount).blockedUsers.keyAt(position));
        if (user != null) {
            String number;
            if (user.bot) {
                number = LocaleController.getString("Bot", R.string.Bot).substring(0, 1).toUpperCase() + LocaleController.getString("Bot", R.string.Bot).substring(1);
            } else if (user.phone != null && user.phone.length() != 0) {
                number = PhoneFormat.getInstance().format("+" + user.phone);
            } else {
                number = LocaleController.getString("NumberUnknown", R.string.NumberUnknown);
            }
            ((UserCell) holder.itemView).setData(user, null, number, 0);
        }
    }
}
 
Example #23
Source File: ChatActivityEnterView.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
private void setEmojiButtonImage()
{
    int currentPage;
    if (emojiView == null)
    {
        currentPage = MessagesController.getGlobalEmojiSettings().getInt("selected_page", 0);
    }
    else
    {
        currentPage = emojiView.getCurrentPage();
    }
    if (currentPage == 0 || !allowStickers && !allowGifs)
    {
        emojiButton.setImageResource(R.drawable.ic_msg_panel_smiles);
    }
    else if (currentPage == 1)
    {
        emojiButton.setImageResource(R.drawable.ic_msg_panel_stickers);
    }
    else if (currentPage == 2)
    {
        emojiButton.setImageResource(R.drawable.ic_msg_panel_gif);
    }
}
 
Example #24
Source File: ChannelAdminLogActivity.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
private void loadAdmins() {
    TLRPC.TL_channels_getParticipants req = new TLRPC.TL_channels_getParticipants();
    req.channel = MessagesController.getInputChannel(currentChat);
    req.filter = new TLRPC.TL_channelParticipantsAdmins();
    req.offset = 0;
    req.limit = 200;
    int reqId = ConnectionsManager.getInstance(currentAccount).sendRequest(req, new RequestDelegate() {
        @Override
        public void run(final TLObject response, final TLRPC.TL_error error) {
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public void run() {
                    if (error == null) {
                        TLRPC.TL_channels_channelParticipants res = (TLRPC.TL_channels_channelParticipants) response;
                        MessagesController.getInstance(currentAccount).putUsers(res.users, false);
                        admins = res.participants;
                        if (visibleDialog instanceof AdminLogFilterAlert) {
                            ((AdminLogFilterAlert) visibleDialog).setCurrentAdmins(admins);
                        }
                    }
                }
            });
        }
    });
    ConnectionsManager.getInstance(currentAccount).bindRequestToGuid(reqId, classGuid);
}
 
Example #25
Source File: ProfileActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void didSelectDialogs(DialogsActivity fragment, ArrayList<Long> dids, CharSequence message, boolean param)
{
    long did = dids.get(0);
    Bundle args = new Bundle();
    args.putBoolean("scrollToTopOnResume", true);
    int lower_part = (int) did;
    if (lower_part != 0)
    {
        if (lower_part > 0)
        {
            args.putInt("user_id", lower_part);
        }
        else if (lower_part < 0)
        {
            args.putInt("chat_id", -lower_part);
        }
    }
    else
    {
        args.putInt("enc_id", (int) (did >> 32));
    }
    if (!MessagesController.getInstance(currentAccount).checkCanOpenChat(args, fragment))
    {
        return;
    }

    NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.closeChats);
    NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.closeChats);
    presentFragment(new ChatActivity(args), true);
    removeSelfFromStack();
    TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(user_id);
    SendMessagesHelper.getInstance(currentAccount).sendMessage(user, did, null, null, null);
}
 
Example #26
Source File: BlockedUsersActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean onFragmentCreate() {
    super.onFragmentCreate();
    NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.updateInterfaces);
    NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.blockedUsersDidLoaded);
    MessagesController.getInstance(currentAccount).getBlockedUsers(false);
    return true;
}
 
Example #27
Source File: WebviewActivity.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
public WebviewActivity(String url, String botName, String gameName, String startParam, MessageObject messageObject) {
    super();
    currentUrl = url;
    currentBot = botName;
    currentGame = gameName;
    currentMessageObject = messageObject;
    short_param = startParam;
    linkToCopy = "https://" + MessagesController.getInstance(currentAccount).linkPrefix + "/" + currentBot + (TextUtils.isEmpty(startParam) ? "" : "?game=" + startParam);
    type = TYPE_GAME;
}
 
Example #28
Source File: IntroActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void onDestroy()
{
    super.onDestroy();
    destroyed = true;
    NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.suggestedLangpack);
    SharedPreferences preferences = MessagesController.getGlobalMainSettings();
    preferences.edit().putLong("intro_crashed_time", 0).apply();
}
 
Example #29
Source File: SetAdminsActivity.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:
            TextCheckCell checkCell = (TextCheckCell) holder.itemView;
            chat = MessagesController.getInstance(currentAccount).getChat(chat_id);
            checkCell.setTextAndCheck(LocaleController.getString("SetAdminsAll", R.string.SetAdminsAll), chat != null && !chat.admins_enabled, false);
            break;
        case 1:
            TextInfoPrivacyCell privacyCell = (TextInfoPrivacyCell) holder.itemView;
            if (position == allAdminsInfoRow) {
                if (chat.admins_enabled) {
                    privacyCell.setText(LocaleController.getString("SetAdminsNotAllInfo", R.string.SetAdminsNotAllInfo));
                } else {
                    privacyCell.setText(LocaleController.getString("SetAdminsAllInfo", R.string.SetAdminsAllInfo));
                }
                if (usersStartRow != -1) {
                    privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow));
                } else {
                    privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
                }
            } else if (position == usersEndRow) {
                privacyCell.setText("");
                privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
            }
            break;
        case 2:
            UserCell userCell = (UserCell) holder.itemView;
            TLRPC.ChatParticipant part = participants.get(position - usersStartRow);
            TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(part.user_id);
            userCell.setData(user, null, null, 0);
            chat = MessagesController.getInstance(currentAccount).getChat(chat_id);
            userCell.setChecked(!(part instanceof TLRPC.TL_chatParticipant) || chat != null && !chat.admins_enabled, false);
            userCell.setCheckDisabled(chat == null || !chat.admins_enabled || part.user_id == UserConfig.getInstance(currentAccount).getClientUserId());
            break;
    }
}
 
Example #30
Source File: ProfileActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
public void setPlayProfileAnimation(boolean value)
{
    SharedPreferences preferences = MessagesController.getGlobalMainSettings();
    if (!AndroidUtilities.isTablet() && preferences.getBoolean("view_animations", true))
    {
        playProfileAnimation = value;
    }
}