Java Code Examples for org.telegram.tgnet.TLRPC#Chat
The following examples show how to use
org.telegram.tgnet.TLRPC#Chat .
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: MentionsAdapter.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
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 2
Source File: ChatAttachAlert.java From Telegram with GNU General Public License v2.0 | 6 votes |
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 3
Source File: DialogsSearchAdapter.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
private void setRecentSearch(ArrayList<RecentSearchObject> arrayList, LongSparseArray<RecentSearchObject> hashMap) { recentSearchObjects = arrayList; recentSearchObjectsById = hashMap; for (int a = 0; a < recentSearchObjects.size(); a++) { RecentSearchObject recentSearchObject = recentSearchObjects.get(a); if (recentSearchObject.object instanceof TLRPC.User) { MessagesController.getInstance(currentAccount).putUser((TLRPC.User) recentSearchObject.object, true); } else if (recentSearchObject.object instanceof TLRPC.Chat) { MessagesController.getInstance(currentAccount).putChat((TLRPC.Chat) recentSearchObject.object, true); } else if (recentSearchObject.object instanceof TLRPC.EncryptedChat) { MessagesController.getInstance(currentAccount).putEncryptedChat((TLRPC.EncryptedChat) recentSearchObject.object, true); } } notifyDataSetChanged(); }
Example 4
Source File: MusicBrowserService.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
@Override public void onPlayFromSearch(String query, Bundle extras) { if (query == null || query.length() == 0) { return; } query = query.toLowerCase(); for (int a = 0; a < dialogs.size(); a++) { int did = dialogs.get(a); if (did > 0) { TLRPC.User user = users.get(did); if (user == null) { continue; } if (user.first_name != null && user.first_name.startsWith(query) || user.last_name != null && user.last_name.startsWith(query)) { onPlayFromMediaId(did + "_" + 0, null); break; } } else { TLRPC.Chat chat = chats.get(-did); if (chat == null) { continue; } if (chat.title != null && chat.title.toLowerCase().contains(query)) { onPlayFromMediaId(did + "_" + 0, null); break; } } } }
Example 5
Source File: DialogsSearchAdapter.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
@Override public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { HintDialogCell cell = (HintDialogCell) holder.itemView; TLRPC.TL_topPeer peer = MediaDataController.getInstance(currentAccount).hints.get(position); TLRPC.Dialog dialog = new TLRPC.TL_dialog(); TLRPC.Chat chat = null; TLRPC.User user = null; int did = 0; if (peer.peer.user_id != 0) { did = peer.peer.user_id; user = MessagesController.getInstance(currentAccount).getUser(peer.peer.user_id); } else if (peer.peer.channel_id != 0) { did = -peer.peer.channel_id; chat = MessagesController.getInstance(currentAccount).getChat(peer.peer.channel_id); } else if (peer.peer.chat_id != 0) { did = -peer.peer.chat_id; chat = MessagesController.getInstance(currentAccount).getChat(peer.peer.chat_id); } cell.setTag(did); String name = ""; if (user != null) { name = UserObject.getFirstName(user); } else if (chat != null) { name = chat.title; } cell.setDialog(did, true, name); }
Example 6
Source File: ImageLocation.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
public static ImageLocation getForChat(TLRPC.Chat chat, boolean big) { if (chat == null || chat.photo == null) { return null; } TLRPC.FileLocation fileLocation = big ? chat.photo.photo_big : chat.photo.photo_small; if (fileLocation == null) { return null; } TLRPC.InputPeer inputPeer; if (ChatObject.isChannel(chat)) { if (chat.access_hash == 0) { return null; } inputPeer = new TLRPC.TL_inputPeerChannel(); inputPeer.channel_id = chat.id; inputPeer.access_hash = chat.access_hash; } else { inputPeer = new TLRPC.TL_inputPeerChat(); inputPeer.chat_id = chat.id; } int dc_id; if (chat.photo.dc_id != 0) { dc_id = chat.photo.dc_id; } else { dc_id = fileLocation.dc_id; } return getForPhoto(fileLocation, 0, null, null, inputPeer, big, dc_id, null, null); }
Example 7
Source File: DialogsSearchAdapter.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
@Override public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { HintDialogCell cell = (HintDialogCell) holder.itemView; TLRPC.TL_topPeer peer = DataQuery.getInstance(currentAccount).hints.get(position); TLRPC.TL_dialog dialog = new TLRPC.TL_dialog(); TLRPC.Chat chat = null; TLRPC.User user = null; int did = 0; if (peer.peer.user_id != 0) { did = peer.peer.user_id; user = MessagesController.getInstance(currentAccount).getUser(peer.peer.user_id); } else if (peer.peer.channel_id != 0) { did = -peer.peer.channel_id; chat = MessagesController.getInstance(currentAccount).getChat(peer.peer.channel_id); } else if (peer.peer.chat_id != 0) { did = -peer.peer.chat_id; chat = MessagesController.getInstance(currentAccount).getChat(peer.peer.chat_id); } cell.setTag(did); String name = ""; if (user != null) { name = ContactsController.formatName(user.first_name, user.last_name); } else if (chat != null) { name = chat.title; } cell.setDialog(did, true, name); }
Example 8
Source File: ChatAvatarContainer.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
public void checkAndUpdateAvatar() { if (parentFragment == null) { return; } TLRPC.User user = parentFragment.getCurrentUser(); TLRPC.Chat chat = parentFragment.getCurrentChat(); if (user != null) { avatarDrawable.setInfo(user); if (UserObject.isUserSelf(user)) { avatarDrawable.setSmallSize(true); avatarDrawable.setAvatarType(AvatarDrawable.AVATAR_TYPE_SAVED); if (avatarImageView != null) { avatarImageView.setImage(null, null, avatarDrawable, user); } } else { avatarDrawable.setSmallSize(false); if (avatarImageView != null) { avatarImageView.setImage(ImageLocation.getForUser(user, false), "50_50", avatarDrawable, user); } } } else if (chat != null) { avatarDrawable.setInfo(chat); if (avatarImageView != null) { avatarImageView.setImage(ImageLocation.getForChat(chat, false), "50_50", avatarDrawable, chat); } } }
Example 9
Source File: HintDialogCell.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
public void setDialog(int uid, boolean counter, CharSequence name) { dialog_id = uid; TLRPC.FileLocation photo = null; if (uid > 0) { TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(uid); if (name != null) { nameTextView.setText(name); } else if (user != null) { nameTextView.setText(ContactsController.formatName(user.first_name, user.last_name)); } else { nameTextView.setText(""); } avatarDrawable.setInfo(user); if (user != null && user.photo != null) { photo = user.photo.photo_small; } } else { TLRPC.Chat chat = MessagesController.getInstance(currentAccount).getChat(-uid); if (name != null) { nameTextView.setText(name); } else if (chat != null) { nameTextView.setText(chat.title); } else { nameTextView.setText(""); } avatarDrawable.setInfo(chat); if (chat != null && chat.photo != null) { photo = chat.photo.photo_small; } } imageView.setImage(photo, "50_50", avatarDrawable); if (counter) { checkUnreadCounter(0); } else { countLayout = null; } }
Example 10
Source File: SharingLiveLocationCell.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
public void setDialog(LocationActivity.LiveLocation info, Location userLocation) { liveLocation = info; int lower_id = info.id; 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)); avatarImageView.setImage(ImageLocation.getForUser(user, false), "50_50", avatarDrawable, user); } } else { TLRPC.Chat chat = MessagesController.getInstance(currentAccount).getChat(-lower_id); if (chat != null) { avatarDrawable.setInfo(chat); nameTextView.setText(chat.title); avatarImageView.setImage(ImageLocation.getForChat(chat, false), "50_50", avatarDrawable, chat); } } GeoPoint position = info.marker.getPosition(); location.setLatitude(position.getLatitude()); location.setLongitude(position.getLongitude()); String time = LocaleController.formatLocationUpdateDate(info.object.edit_date != 0 ? info.object.edit_date : info.object.date); if (userLocation != null) { distanceTextView.setText(String.format("%s - %s", time, LocaleController.formatDistance(location.distanceTo(userLocation)))); } else { distanceTextView.setText(time); } }
Example 11
Source File: ChatAttachAlertPollLayout.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
private void updateRows() { rowCount = 0; paddingRow = rowCount++; questionHeaderRow = rowCount++; questionRow = rowCount++; questionSectionRow = rowCount++; answerHeaderRow = rowCount++; if (answersCount != 0) { answerStartRow = rowCount; rowCount += answersCount; } else { answerStartRow = -1; } if (answersCount != answers.length) { addAnswerRow = rowCount++; } else { addAnswerRow = -1; } answerSectionRow = rowCount++; settingsHeaderRow = rowCount++; TLRPC.Chat chat = ((ChatActivity) parentAlert.baseFragment).getCurrentChat(); if (!ChatObject.isChannel(chat) || chat.megagroup) { anonymousRow = rowCount++; } else { anonymousRow = -1; } if (quizOnly != 1) { multipleRow = rowCount++; } else { multipleRow = -1; } if (quizOnly == 0) { quizRow = rowCount++; } else { quizRow = -1; } settingsSectionRow = rowCount++; if (quizPoll) { solutionRow = rowCount++; solutionInfoRow = rowCount++; } else { solutionRow = -1; solutionInfoRow = -1; } emptyRow = rowCount++; }
Example 12
Source File: LocationSharingService.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
private void updateNotification(boolean post) { if (builder == null) { return; } String param; ArrayList<LocationController.SharingLocationInfo> infos = getInfos(); if (infos.size() == 1) { LocationController.SharingLocationInfo info = infos.get(0); int lower_id = (int) info.messageObject.getDialogId(); int currentAccount = info.messageObject.currentAccount; if (lower_id > 0) { TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(lower_id); param = UserObject.getFirstName(user); } else { TLRPC.Chat chat = MessagesController.getInstance(currentAccount).getChat(-lower_id); if (chat != null) { param = chat.title; } else { param = ""; } } } else { param = LocaleController.formatPluralString("Chats", infos.size()); } String str = String.format(LocaleController.getString("AttachLiveLocationIsSharing", R.string.AttachLiveLocationIsSharing), LocaleController.getString("AttachLiveLocation", R.string.AttachLiveLocation), param); builder.setTicker(str); builder.setContentText(str); if (post) { NotificationManagerCompat.from(ApplicationLoader.applicationContext).notify(6, builder.build()); } }
Example 13
Source File: ChatAvatarContainer.java From Telegram with GNU General Public License v2.0 | 4 votes |
public ChatAvatarContainer(Context context, ChatActivity chatActivity, boolean needTime) { super(context); parentFragment = chatActivity; if (parentFragment != null) { sharedMediaPreloader = new SharedMediaLayout.SharedMediaPreloader(chatActivity); } avatarImageView = new BackupImageView(context); avatarImageView.setRoundRadius(AndroidUtilities.dp(21)); addView(avatarImageView); if (parentFragment != null && !parentFragment.isInScheduleMode()) { avatarImageView.setOnClickListener(v -> openProfile(true)); } titleTextView = new SimpleTextView(context); titleTextView.setTextColor(Theme.getColor(Theme.key_actionBarDefaultTitle)); titleTextView.setTextSize(18); titleTextView.setGravity(Gravity.LEFT); titleTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); titleTextView.setLeftDrawableTopPadding(-AndroidUtilities.dp(1.3f)); addView(titleTextView); subtitleTextView = new SimpleTextView(context); subtitleTextView.setTextColor(Theme.getColor(Theme.key_actionBarDefaultSubtitle)); subtitleTextView.setTag(Theme.key_actionBarDefaultSubtitle); subtitleTextView.setTextSize(14); subtitleTextView.setGravity(Gravity.LEFT); addView(subtitleTextView); if (needTime) { timeItem = new ImageView(context); timeItem.setPadding(AndroidUtilities.dp(10), AndroidUtilities.dp(10), AndroidUtilities.dp(5), AndroidUtilities.dp(5)); timeItem.setScaleType(ImageView.ScaleType.CENTER); timeItem.setImageDrawable(timerDrawable = new TimerDrawable(context)); addView(timeItem); timeItem.setOnClickListener(v -> parentFragment.showDialog(AlertsCreator.createTTLAlert(getContext(), parentFragment.getCurrentEncryptedChat()).create())); timeItem.setContentDescription(LocaleController.getString("SetTimer", R.string.SetTimer)); } if (parentFragment != null && !parentFragment.isInScheduleMode()) { setOnClickListener(v -> openProfile(false)); TLRPC.Chat chat = parentFragment.getCurrentChat(); statusDrawables[0] = new TypingDotsDrawable(); statusDrawables[1] = new RecordStatusDrawable(); statusDrawables[2] = new SendingFileDrawable(); statusDrawables[3] = new PlayingGameDrawable(); statusDrawables[4] = new RoundStatusDrawable(); for (int a = 0; a < statusDrawables.length; a++) { statusDrawables[a].setIsChat(chat != null); } } }
Example 14
Source File: ChatObject.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
public static boolean canAddViaLink(TLRPC.Chat chat) { return chat != null && (chat.creator || chat.admin_rights != null && chat.admin_rights.invite_link); }
Example 15
Source File: ChatObject.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
public static boolean canPost(TLRPC.Chat chat) { return chat != null && (chat.creator || chat.admin_rights != null && chat.admin_rights.post_messages); }
Example 16
Source File: AdminedChannelCell.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
public TLRPC.Chat getCurrentChannel() { return currentChannel; }
Example 17
Source File: AdminedChannelCell.java From Telegram with GNU General Public License v2.0 | 4 votes |
public TLRPC.Chat getCurrentChannel() { return currentChannel; }
Example 18
Source File: ChatObject.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
public static boolean canAddAdmins(TLRPC.Chat chat) { return canUserDoAction(chat, ACTION_ADD_ADMINS); }
Example 19
Source File: ChatObject.java From Telegram with GNU General Public License v2.0 | 4 votes |
public static boolean canChangeChatInfo(TLRPC.Chat chat) { return canUserDoAction(chat, ACTION_CHANGE_INFO); }
Example 20
Source File: ChatObject.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
public static boolean isKickedFromChat(TLRPC.Chat chat) { return chat == null || chat instanceof TLRPC.TL_chatEmpty || chat instanceof TLRPC.TL_chatForbidden || chat instanceof TLRPC.TL_channelForbidden || chat.kicked || chat.deactivated || chat.banned_rights != null && chat.banned_rights.view_messages; }