Java Code Examples for org.telegram.tgnet.TLRPC#User
The following examples show how to use
org.telegram.tgnet.TLRPC#User .
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: MentionCell.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
public void setUser(TLRPC.User user) { if (user == null) { nameTextView.setText(""); usernameTextView.setText(""); imageView.setImageDrawable(null); return; } avatarDrawable.setInfo(user); if (user.photo != null && user.photo.photo_small != null) { imageView.setImage(user.photo.photo_small, "50_50", avatarDrawable); } else { imageView.setImageDrawable(avatarDrawable); } nameTextView.setText(UserObject.getUserName(user)); if (user.username != null) { usernameTextView.setText("@" + user.username); } else { usernameTextView.setText(""); } imageView.setVisibility(VISIBLE); usernameTextView.setVisibility(VISIBLE); }
Example 2
Source File: GroupCreateActivity.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
@Override public String getLetter(int position) { if (position < 0 || position >= contacts.size()) { return null; } TLRPC.User user = contacts.get(position); if (user == null) { return null; } if (LocaleController.nameDisplayOrder == 1) { if (!TextUtils.isEmpty(user.first_name)) { return user.first_name.substring(0, 1).toUpperCase(); } else if (!TextUtils.isEmpty(user.last_name)) { return user.last_name.substring(0, 1).toUpperCase(); } } else { if (!TextUtils.isEmpty(user.last_name)) { return user.last_name.substring(0, 1).toUpperCase(); } else if (!TextUtils.isEmpty(user.first_name)) { return user.first_name.substring(0, 1).toUpperCase(); } } return ""; }
Example 3
Source File: SharingLiveLocationCell.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
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 4
Source File: DrawerProfileCell.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
public void setUser(TLRPC.User user, boolean accounts) { if (user == null) { return; } TLRPC.FileLocation photo = null; if (user.photo != null) { photo = user.photo.photo_small; } accountsShowed = accounts; arrowView.setImageResource(accountsShowed ? R.drawable.collapse_up : R.drawable.collapse_down); nameTextView.setText(UserObject.getUserName(user)); phoneTextView.setText(PhoneFormat.getInstance().format("+" + user.phone)); AvatarDrawable avatarDrawable = new AvatarDrawable(user); avatarDrawable.setColor(Theme.getColor(Theme.key_avatar_backgroundInProfileBlue)); avatarImageView.setImage(photo, "50_50", avatarDrawable); }
Example 5
Source File: ContactAddActivity.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
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 6
Source File: ChannelAdminLogActivity.java From Telegram with GNU General Public License v2.0 | 6 votes |
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 7
Source File: ChatAttachAlertContactsLayout.java From Telegram with GNU General Public License v2.0 | 6 votes |
@Override public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { if (holder.getItemViewType() == 0) { UserCell userCell = (UserCell) holder.itemView; boolean divider = position != getItemCount() - 2; Object object = getItem(position); TLRPC.User user = null; if (object instanceof ContactsController.Contact) { ContactsController.Contact contact = (ContactsController.Contact) object; if (contact.user != null) { user = contact.user; } else { userCell.setCurrentId(contact.contact_id); userCell.setData(null, searchResultNames.get(position - 1), contact.phones.isEmpty() ? "" : PhoneFormat.getInstance().format(contact.phones.get(0)), divider); } } else { user = (TLRPC.User) object; } if (user != null) { userCell.setData(user, searchResultNames.get(position - 1), PhoneFormat.getInstance().format("+" + user.phone), divider); } } }
Example 8
Source File: ChannelAdminLogActivity.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
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 9
Source File: DialogOrContactPickerActivity.java From Telegram with GNU General Public License v2.0 | 6 votes |
private void showBlockAlert(TLRPC.User user) { if (user == null) { return; } AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); builder.setTitle(LocaleController.getString("BlockUser", R.string.BlockUser)); builder.setMessage(AndroidUtilities.replaceTags(LocaleController.formatString("AreYouSureBlockContact2", R.string.AreYouSureBlockContact2, ContactsController.formatName(user.first_name, user.last_name)))); builder.setPositiveButton(LocaleController.getString("BlockContact", R.string.BlockContact), (dialogInterface, i) -> { if (MessagesController.isSupportUser(user)) { AlertsCreator.showSimpleToast(DialogOrContactPickerActivity.this, LocaleController.getString("ErrorOccurred", R.string.ErrorOccurred)); } else { MessagesController.getInstance(currentAccount).blockUser(user.id); AlertsCreator.showSimpleToast(DialogOrContactPickerActivity.this, LocaleController.getString("UserBlocked", R.string.UserBlocked)); } finishFragment(); }); builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); AlertDialog dialog = builder.create(); showDialog(dialog); TextView button = (TextView) dialog.getButton(DialogInterface.BUTTON_POSITIVE); if (button != null) { button.setTextColor(Theme.getColor(Theme.key_dialogTextRed2)); } }
Example 10
Source File: FileRefController.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
private byte[] getFileReference(TLRPC.User user, TLRPC.InputFileLocation location, boolean[] needReplacement, TLRPC.InputFileLocation[] replacement) { if (user == null || user.photo == null || !(location instanceof TLRPC.TL_inputFileLocation)) { return null; } byte[] result = getFileReference(user.photo.photo_small, location, needReplacement); if (getPeerReferenceReplacement(user, null, false, location, replacement, needReplacement)) { return new byte[0]; } if (result == null) { result = getFileReference(user.photo.photo_big, location, needReplacement); if (getPeerReferenceReplacement(user, null, true, location, replacement, needReplacement)) { return new byte[0]; } } return result; }
Example 11
Source File: CheckBoxUserCell.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
public void setUser(TLRPC.User user, boolean checked, boolean divider) { currentUser = user; textView.setText(ContactsController.formatName(user.first_name, user.last_name)); checkBox.setChecked(checked, false); TLRPC.FileLocation photo = null; avatarDrawable.setInfo(user); if (user != null && user.photo != null) { photo = user.photo.photo_small; } imageView.setImage(photo, "50_50", avatarDrawable); needDivider = divider; setWillNotDraw(!divider); }
Example 12
Source File: BlockedUsersActivity.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
@Override public void didSelectContact(final TLRPC.User user, String param, ContactsActivity activity) { if (user == null) { return; } MessagesController.getInstance(currentAccount).blockUser(user.id); }
Example 13
Source File: UserObject.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
public static String getFirstName(TLRPC.User user, boolean allowShort) { if (user == null || isDeleted(user)) { return "DELETED"; } String name = user.first_name; if (TextUtils.isEmpty(name)) { name = user.last_name; } else if (!allowShort && name.length() <= 2) { return ContactsController.formatName(user.first_name, user.last_name); } return !TextUtils.isEmpty(name) ? name : LocaleController.getString("HiddenName", R.string.HiddenName); }
Example 14
Source File: VoIPHelper.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
public static void startCall(TLRPC.User user, final Activity activity, TLRPC.TL_userFull userFull){ if(userFull!=null && userFull.phone_calls_private){ new AlertDialog.Builder(activity) .setTitle(LocaleController.getString("VoipFailed", R.string.VoipFailed)) .setMessage(AndroidUtilities.replaceTags(LocaleController.formatString("CallNotAvailable", R.string.CallNotAvailable, ContactsController.formatName(user.first_name, user.last_name)))) .setPositiveButton(LocaleController.getString("OK", R.string.OK), null) .show(); return; } if (ConnectionsManager.getInstance(UserConfig.selectedAccount).getConnectionState() != ConnectionsManager.ConnectionStateConnected) { boolean isAirplaneMode = Settings.System.getInt(activity.getContentResolver(), Settings.System.AIRPLANE_MODE_ON, 0) != 0; AlertDialog.Builder bldr = new AlertDialog.Builder(activity) .setTitle(isAirplaneMode ? LocaleController.getString("VoipOfflineAirplaneTitle", R.string.VoipOfflineAirplaneTitle) : LocaleController.getString("VoipOfflineTitle", R.string.VoipOfflineTitle)) .setMessage(isAirplaneMode ? LocaleController.getString("VoipOfflineAirplane", R.string.VoipOfflineAirplane) : LocaleController.getString("VoipOffline", R.string.VoipOffline)) .setPositiveButton(LocaleController.getString("OK", R.string.OK), null); if (isAirplaneMode) { final Intent settingsIntent = new Intent(Settings.ACTION_AIRPLANE_MODE_SETTINGS); if (settingsIntent.resolveActivity(activity.getPackageManager()) != null) { bldr.setNeutralButton(LocaleController.getString("VoipOfflineOpenSettings", R.string.VoipOfflineOpenSettings), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { activity.startActivity(settingsIntent); } }); } } bldr.show(); return; } if (Build.VERSION.SDK_INT >= 23 && activity.checkSelfPermission(Manifest.permission.RECORD_AUDIO) != PackageManager.PERMISSION_GRANTED) { activity.requestPermissions(new String[]{Manifest.permission.RECORD_AUDIO}, 101); } else { initiateCall(user, activity); } }
Example 15
Source File: ChangeNameActivity.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private void saveName() { TLRPC.User currentUser = UserConfig.getInstance(currentAccount).getCurrentUser(); if (currentUser == null || lastNameField.getText() == null || firstNameField.getText() == null) { return; } String newFirst = firstNameField.getText().toString(); String newLast = lastNameField.getText().toString(); if (currentUser.first_name != null && currentUser.first_name.equals(newFirst) && currentUser.last_name != null && currentUser.last_name.equals(newLast)) { return; } TLRPC.TL_account_updateProfile req = new TLRPC.TL_account_updateProfile(); req.flags = 3; currentUser.first_name = req.first_name = newFirst; currentUser.last_name = req.last_name = newLast; TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(UserConfig.getInstance(currentAccount).getClientUserId()); if (user != null) { user.first_name = req.first_name; user.last_name = req.last_name; } UserConfig.getInstance(currentAccount).saveConfig(true); NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.mainUserInfoChanged); NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.updateInterfaces, MessagesController.UPDATE_MASK_NAME); ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> { }); }
Example 16
Source File: MentionsAdapter.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
private void showUsersResult(ArrayList<TLRPC.User> newResult, SparseArray<TLRPC.User> newMap, boolean notify) { searchResultUsernames = newResult; searchResultUsernamesMap = newMap; if (cancelDelayRunnable != null) { AndroidUtilities.cancelRunOnUIThread(cancelDelayRunnable); cancelDelayRunnable = null; } if (notify) { notifyDataSetChanged(); delegate.needChangePanelVisibility(!searchResultUsernames.isEmpty()); } }
Example 17
Source File: PeopleNearbyActivity.java From Telegram with GNU General Public License v2.0 | 4 votes |
@Override public void didReceivedNotification(int id, int account, Object... args) { if (id == NotificationCenter.newLocationAvailable) { sendRequest(false, 0); } else if (id == NotificationCenter.newPeopleNearbyAvailable) { TLRPC.TL_updatePeerLocated update = (TLRPC.TL_updatePeerLocated) args[0]; for (int b = 0, N2 = update.peers.size(); b < N2; b++) { TLRPC.PeerLocated object = update.peers.get(b); if (object instanceof TLRPC.TL_peerLocated) { TLRPC.TL_peerLocated peerLocated = (TLRPC.TL_peerLocated) object; boolean found = false; ArrayList<TLRPC.TL_peerLocated> arrayList; if (peerLocated.peer instanceof TLRPC.TL_peerUser) { arrayList = users; } else { arrayList = chats; } for (int a = 0, N = arrayList.size(); a < N; a++) { TLRPC.TL_peerLocated old = arrayList.get(a); if (old.peer.user_id != 0 && old.peer.user_id == peerLocated.peer.user_id || old.peer.chat_id != 0 && old.peer.chat_id == peerLocated.peer.chat_id || old.peer.channel_id != 0 && old.peer.channel_id == peerLocated.peer.channel_id) { arrayList.set(a, peerLocated); found = true; } } if (!found) { arrayList.add(peerLocated); } } } checkForExpiredLocations(true); updateRows(); } else if (id == NotificationCenter.needDeleteDialog) { if (fragmentView == null || isPaused) { return; } long dialogId = (Long) args[0]; TLRPC.User user = (TLRPC.User) args[1]; TLRPC.Chat chat = (TLRPC.Chat) args[2]; boolean revoke = (Boolean) args[3]; Runnable deleteRunnable = () -> { if (chat != null) { if (ChatObject.isNotInChat(chat)) { getMessagesController().deleteDialog(dialogId, 0, revoke); } else { getMessagesController().deleteUserFromChat((int) -dialogId, getMessagesController().getUser(getUserConfig().getClientUserId()), null, false, revoke); } } else { getMessagesController().deleteDialog(dialogId, 0, revoke); } }; if (undoView != null) { undoView.showWithAction(dialogId, UndoView.ACTION_DELETE, deleteRunnable); } else { deleteRunnable.run(); } } }
Example 18
Source File: GroupCreateUserCell.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
public TLRPC.User getUser() { return currentUser; }
Example 19
Source File: UserObject.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
public static String getFirstName(TLRPC.User user) { return getFirstName(user, true); }
Example 20
Source File: ContactsActivity.java From Telegram with GNU General Public License v2.0 | 4 votes |
public void setIgnoreUsers(SparseArray<TLRPC.User> users) { ignoreUsers = users; }