Java Code Examples for org.telegram.messenger.MessagesController#DialogFilter
The following examples show how to use
org.telegram.messenger.MessagesController#DialogFilter .
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: FiltersSetupActivity.java From Telegram with GNU General Public License v2.0 | 6 votes |
public void swapElements(int fromIndex, int toIndex) { int idx1 = fromIndex - filtersStartRow; int idx2 = toIndex - filtersStartRow; int count = filtersEndRow - filtersStartRow; if (idx1 < 0 || idx2 < 0 || idx1 >= count || idx2 >= count) { return; } ArrayList<MessagesController.DialogFilter> filters = getMessagesController().dialogFilters; MessagesController.DialogFilter filter1 = filters.get(idx1); MessagesController.DialogFilter filter2 = filters.get(idx2); int temp = filter1.order; filter1.order = filter2.order; filter2.order = temp; filters.set(idx1, filter2); filters.set(idx2, filter1); orderChanged = true; notifyItemMoved(fromIndex, toIndex); }
Example 2
Source File: FiltersSetupActivity.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
@Override public void onFragmentDestroy() { getNotificationCenter().removeObserver(this, NotificationCenter.dialogFiltersUpdated); getNotificationCenter().removeObserver(this, NotificationCenter.suggestedFiltersLoaded); if (orderChanged) { getNotificationCenter().postNotificationName(NotificationCenter.dialogFiltersUpdated); getMessagesStorage().saveDialogFiltersOrder(); TLRPC.TL_messages_updateDialogFiltersOrder req = new TLRPC.TL_messages_updateDialogFiltersOrder(); ArrayList<MessagesController.DialogFilter> filters = getMessagesController().dialogFilters; for (int a = 0, N = filters.size(); a < N; a++) { MessagesController.DialogFilter filter = filters.get(a); req.order.add(filters.get(a).id); } getConnectionsManager().sendRequest(req, (response, error) -> { }); } super.onFragmentDestroy(); }
Example 3
Source File: DialogsAdapter.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
@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 4
Source File: FiltersSetupActivity.java From Telegram with GNU General Public License v2.0 | 6 votes |
@Override public void onFragmentDestroy() { getNotificationCenter().removeObserver(this, NotificationCenter.dialogFiltersUpdated); getNotificationCenter().removeObserver(this, NotificationCenter.suggestedFiltersLoaded); if (orderChanged) { getNotificationCenter().postNotificationName(NotificationCenter.dialogFiltersUpdated); getMessagesStorage().saveDialogFiltersOrder(); TLRPC.TL_messages_updateDialogFiltersOrder req = new TLRPC.TL_messages_updateDialogFiltersOrder(); ArrayList<MessagesController.DialogFilter> filters = getMessagesController().dialogFilters; for (int a = 0, N = filters.size(); a < N; a++) { MessagesController.DialogFilter filter = filters.get(a); req.order.add(filters.get(a).id); } getConnectionsManager().sendRequest(req, (response, error) -> { }); } super.onFragmentDestroy(); }
Example 5
Source File: FilterCreateActivity.java From Telegram with GNU General Public License v2.0 | 6 votes |
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 6
Source File: FilterCreateActivity.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
private static void processAddFilter(MessagesController.DialogFilter filter, int newFilterFlags, String newFilterName, ArrayList<Integer> newAlwaysShow, ArrayList<Integer> newNeverShow, boolean creatingNew, boolean atBegin, boolean hasUserChanged, boolean resetUnreadCounter, BaseFragment fragment, Runnable onFinish) { if (filter.flags != newFilterFlags || hasUserChanged) { filter.pendingUnreadCount = -1; if (resetUnreadCounter) { filter.unreadCount = -1; } } filter.flags = newFilterFlags; filter.name = newFilterName; filter.neverShow = newNeverShow; filter.alwaysShow = newAlwaysShow; if (creatingNew) { fragment.getMessagesController().addFilter(filter, atBegin); } else { fragment.getMessagesController().onFilterUpdate(filter); } fragment.getMessagesStorage().saveDialogFilter(filter, atBegin, true); if (onFinish != null) { onFinish.run(); } }
Example 7
Source File: FilterCreateActivity.java From Telegram with GNU General Public License v2.0 | 6 votes |
private static void processAddFilter(MessagesController.DialogFilter filter, int newFilterFlags, String newFilterName, ArrayList<Integer> newAlwaysShow, ArrayList<Integer> newNeverShow, boolean creatingNew, boolean atBegin, boolean hasUserChanged, boolean resetUnreadCounter, BaseFragment fragment, Runnable onFinish) { if (filter.flags != newFilterFlags || hasUserChanged) { filter.pendingUnreadCount = -1; if (resetUnreadCounter) { filter.unreadCount = -1; } } filter.flags = newFilterFlags; filter.name = newFilterName; filter.neverShow = newNeverShow; filter.alwaysShow = newAlwaysShow; if (creatingNew) { fragment.getMessagesController().addFilter(filter, atBegin); } else { fragment.getMessagesController().onFilterUpdate(filter); } fragment.getMessagesStorage().saveDialogFilter(filter, atBegin, true); if (onFinish != null) { onFinish.run(); } }
Example 8
Source File: FilterTabsView.java From Telegram with GNU General Public License v2.0 | 6 votes |
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 9
Source File: FiltersListBottomSheet.java From Telegram with GNU General Public License v2.0 | 5 votes |
public static ArrayList<MessagesController.DialogFilter> getCanAddDialogFilters(BaseFragment fragment, ArrayList<Long> selectedDialogs) { ArrayList<MessagesController.DialogFilter> result = new ArrayList<>(); ArrayList<MessagesController.DialogFilter> filters = fragment.getMessagesController().dialogFilters; for (int a = 0, N = filters.size(); a < N; a++) { MessagesController.DialogFilter filter = filters.get(a); if (!getDialogsCount(fragment, filter, selectedDialogs, true, true).isEmpty()) { result.add(filter); } } return result; }
Example 10
Source File: FiltersListBottomSheet.java From Telegram with GNU General Public License v2.0 | 5 votes |
public static ArrayList<Integer> getDialogsCount(BaseFragment fragment, MessagesController.DialogFilter filter, ArrayList<Long> selectedDialogs, boolean always, boolean check) { ArrayList<Integer> dids = new ArrayList<>(); for (int b = 0, N2 = selectedDialogs.size(); b < N2; b++) { long did = selectedDialogs.get(b); int lowerId = (int) did; if (lowerId == 0) { int highId = (int) (did >> 32); TLRPC.EncryptedChat encryptedChat = fragment.getMessagesController().getEncryptedChat(highId); if (encryptedChat != null) { lowerId = encryptedChat.user_id; if (dids.contains(lowerId)) { continue; } } else { continue; } } if (filter != null && (always && filter.alwaysShow.contains(lowerId) || !always && filter.neverShow.contains(lowerId))) { continue; } dids.add(lowerId); if (check) { break; } } return dids; }
Example 11
Source File: FiltersListBottomSheet.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
@Override public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { BottomSheet.BottomSheetCell cell = (BottomSheet.BottomSheetCell) holder.itemView; if (position < dialogFilters.size()) { cell.getImageView().setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_dialogIcon), PorterDuff.Mode.MULTIPLY)); MessagesController.DialogFilter filter = dialogFilters.get(position); cell.setTextColor(Theme.getColor(Theme.key_dialogTextBlack)); int icon; if ((filter.flags & MessagesController.DIALOG_FILTER_FLAG_ALL_CHATS) == (MessagesController.DIALOG_FILTER_FLAG_CONTACTS | MessagesController.DIALOG_FILTER_FLAG_NON_CONTACTS)) { icon = R.drawable.menu_private; } else if ((filter.flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_READ) != 0 && (filter.flags & MessagesController.DIALOG_FILTER_FLAG_ALL_CHATS) == MessagesController.DIALOG_FILTER_FLAG_ALL_CHATS) { icon = R.drawable.menu_unread; } else if ((filter.flags & MessagesController.DIALOG_FILTER_FLAG_ALL_CHATS) == MessagesController.DIALOG_FILTER_FLAG_CHANNELS) { icon = R.drawable.menu_broadcast; } else if ((filter.flags & MessagesController.DIALOG_FILTER_FLAG_ALL_CHATS) == MessagesController.DIALOG_FILTER_FLAG_GROUPS) { icon = R.drawable.menu_groups; } else if ((filter.flags & MessagesController.DIALOG_FILTER_FLAG_ALL_CHATS) == MessagesController.DIALOG_FILTER_FLAG_CONTACTS) { icon = R.drawable.menu_contacts; } else if ((filter.flags & MessagesController.DIALOG_FILTER_FLAG_ALL_CHATS) == MessagesController.DIALOG_FILTER_FLAG_BOTS) { icon = R.drawable.menu_bots; } else { icon = R.drawable.menu_folders; } cell.setTextAndIcon(filter.name, icon); } else { cell.getImageView().setColorFilter(null); Drawable drawable1 = context.getResources().getDrawable(R.drawable.poll_add_circle); Drawable drawable2 = context.getResources().getDrawable(R.drawable.poll_add_plus); drawable1.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_switchTrackChecked), PorterDuff.Mode.MULTIPLY)); drawable2.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_checkboxCheck), PorterDuff.Mode.MULTIPLY)); CombinedDrawable combinedDrawable = new CombinedDrawable(drawable1, drawable2); cell.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlueText4)); cell.setTextAndIcon(LocaleController.getString("CreateNewFilter", R.string.CreateNewFilter), combinedDrawable); } }
Example 12
Source File: FilterTabsView.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
public void swapElements(int fromIndex, int toIndex) { int idx1 = fromIndex - 1; int idx2 = toIndex - 1; int count = tabs.size() - 1; if (idx1 < 0 || idx2 < 0 || idx1 >= count || idx2 >= count) { return; } ArrayList<MessagesController.DialogFilter> filters = MessagesController.getInstance(UserConfig.selectedAccount).dialogFilters; MessagesController.DialogFilter filter1 = filters.get(idx1); MessagesController.DialogFilter filter2 = filters.get(idx2); int temp = filter1.order; filter1.order = filter2.order; filter2.order = temp; filters.set(idx1, filter2); filters.set(idx2, filter1); Tab tab1 = tabs.get(fromIndex); Tab tab2 = tabs.get(toIndex); temp = tab1.id; tab1.id = tab2.id; tab2.id = temp; delegate.onPageReorder(tab2.id, tab1.id); if (currentPosition == fromIndex) { currentPosition = toIndex; selectedTabId = tab1.id; } else if (currentPosition == toIndex) { currentPosition = fromIndex; selectedTabId = tab2.id; } if (previousPosition == fromIndex) { previousPosition = toIndex; previousId = tab1.id; } else if (previousPosition == toIndex) { previousPosition = fromIndex; previousId = tab2.id; } tabs.set(fromIndex, tab2); tabs.set(toIndex, tab1); updateTabsWidths(); orderChanged = true; notifyItemMoved(fromIndex, toIndex); }
Example 13
Source File: DialogCell.java From Telegram with GNU General Public License v2.0 | 4 votes |
public void checkCurrentDialogIndex(boolean frozen) { ArrayList<TLRPC.Dialog> dialogsArray = DialogsActivity.getDialogsArray(currentAccount, dialogsType, folderId, frozen); if (index < dialogsArray.size()) { TLRPC.Dialog dialog = dialogsArray.get(index); TLRPC.Dialog nextDialog = index + 1 < dialogsArray.size() ? dialogsArray.get(index + 1) : null; TLRPC.DraftMessage newDraftMessage = MediaDataController.getInstance(currentAccount).getDraft(currentDialogId); MessageObject newMessageObject; if (currentDialogFolderId != 0) { newMessageObject = findFolderTopMessage(); } else { newMessageObject = MessagesController.getInstance(currentAccount).dialogMessage.get(dialog.id); } if (currentDialogId != dialog.id || message != null && message.getId() != dialog.top_message || newMessageObject != null && newMessageObject.messageOwner.edit_date != currentEditDate || unreadCount != dialog.unread_count || mentionCount != dialog.unread_mentions_count || markUnread != dialog.unread_mark || message != newMessageObject || message == null && newMessageObject != null || newDraftMessage != draftMessage || drawPin != dialog.pinned) { boolean dialogChanged = currentDialogId != dialog.id; currentDialogId = dialog.id; if (dialog instanceof TLRPC.TL_dialogFolder) { TLRPC.TL_dialogFolder dialogFolder = (TLRPC.TL_dialogFolder) dialog; currentDialogFolderId = dialogFolder.folder.id; } else { currentDialogFolderId = 0; } if (dialogsType == 7 || dialogsType == 8) { MessagesController.DialogFilter filter = MessagesController.getInstance(currentAccount).selectedDialogFilter[dialogsType == 8 ? 1 : 0]; fullSeparator = dialog instanceof TLRPC.TL_dialog && nextDialog != null && filter != null && filter.pinnedDialogs.indexOfKey(dialog.id) >= 0 && filter.pinnedDialogs.indexOfKey(nextDialog.id) < 0; fullSeparator2 = false; } else { fullSeparator = dialog instanceof TLRPC.TL_dialog && dialog.pinned && nextDialog != null && !nextDialog.pinned; fullSeparator2 = dialog instanceof TLRPC.TL_dialogFolder && nextDialog != null && !nextDialog.pinned; } update(0); if (dialogChanged) { reorderIconProgress = drawPin && drawReorder ? 1.0f : 0.0f; } checkOnline(); } } }
Example 14
Source File: FiltersListBottomSheet.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
public MessagesController.DialogFilter getItem(int position) { if (position < dialogFilters.size()) { return dialogFilters.get(position); } return null; }
Example 15
Source File: FiltersSetupActivity.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
public void setFilter(MessagesController.DialogFilter filter, boolean divider) { currentFilter = filter; StringBuilder info = new StringBuilder(); if ((filter.flags & MessagesController.DIALOG_FILTER_FLAG_ALL_CHATS) == MessagesController.DIALOG_FILTER_FLAG_ALL_CHATS) { info.append(LocaleController.getString("FilterAllChats", R.string.FilterAllChats)); } else { if ((filter.flags & MessagesController.DIALOG_FILTER_FLAG_CONTACTS) != 0) { if (info.length() != 0) { info.append(", "); } info.append(LocaleController.getString("FilterContacts", R.string.FilterContacts)); } if ((filter.flags & MessagesController.DIALOG_FILTER_FLAG_NON_CONTACTS) != 0) { if (info.length() != 0) { info.append(", "); } info.append(LocaleController.getString("FilterNonContacts", R.string.FilterNonContacts)); } if ((filter.flags & MessagesController.DIALOG_FILTER_FLAG_GROUPS) != 0) { if (info.length() != 0) { info.append(", "); } info.append(LocaleController.getString("FilterGroups", R.string.FilterGroups)); } if ((filter.flags & MessagesController.DIALOG_FILTER_FLAG_CHANNELS) != 0) { if (info.length() != 0) { info.append(", "); } info.append(LocaleController.getString("FilterChannels", R.string.FilterChannels)); } if ((filter.flags & MessagesController.DIALOG_FILTER_FLAG_BOTS) != 0) { if (info.length() != 0) { info.append(", "); } info.append(LocaleController.getString("FilterBots", R.string.FilterBots)); } } if (!filter.alwaysShow.isEmpty() || !filter.neverShow.isEmpty()) { if (info.length() != 0) { info.append(", "); } info.append(LocaleController.formatPluralString("Exception", filter.alwaysShow.size() + filter.neverShow.size())); } if (info.length() == 0) { info.append(LocaleController.getString("FilterNoChats", R.string.FilterNoChats)); } textView.setText(Emoji.replaceEmoji(filter.name, textView.getPaint().getFontMetricsInt(), AndroidUtilities.dp(20), false)); valueTextView.setText(info); //valueTextView.setVisibility(VISIBLE); needDivider = divider; }
Example 16
Source File: FilterCreateActivity.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
public FilterCreateActivity(MessagesController.DialogFilter dialogFilter) { this(dialogFilter, null); }
Example 17
Source File: FiltersListBottomSheet.java From Telegram with GNU General Public License v2.0 | 4 votes |
public MessagesController.DialogFilter getItem(int position) { if (position < dialogFilters.size()) { return dialogFilters.get(position); } return null; }
Example 18
Source File: FiltersSetupActivity.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
public MessagesController.DialogFilter getCurrentFilter() { return currentFilter; }
Example 19
Source File: FiltersListBottomSheet.java From Telegram-FOSS with GNU General Public License v2.0 | votes |
void didSelectFilter(MessagesController.DialogFilter filter);
Example 20
Source File: FiltersListBottomSheet.java From Telegram with GNU General Public License v2.0 | votes |
void didSelectFilter(MessagesController.DialogFilter filter);