Java Code Examples for org.telegram.tgnet.TLRPC#FileLocation
The following examples show how to use
org.telegram.tgnet.TLRPC#FileLocation .
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: FileLoadOperation.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
public FileLoadOperation(TLRPC.FileLocation photoLocation, String extension, int size) { if (photoLocation instanceof TLRPC.TL_fileEncryptedLocation) { location = new TLRPC.TL_inputEncryptedFileLocation(); location.id = photoLocation.volume_id; location.volume_id = photoLocation.volume_id; location.access_hash = photoLocation.secret; location.local_id = photoLocation.local_id; iv = new byte[32]; System.arraycopy(photoLocation.iv, 0, iv, 0, iv.length); key = photoLocation.key; initialDatacenterId = datacenterId = photoLocation.dc_id; } else if (photoLocation instanceof TLRPC.TL_fileLocation) { location = new TLRPC.TL_inputFileLocation(); location.volume_id = photoLocation.volume_id; location.secret = photoLocation.secret; location.local_id = photoLocation.local_id; initialDatacenterId = datacenterId = photoLocation.dc_id; allowDisordererFileSave = true; } currentType = ConnectionsManager.FileTypePhoto; totalBytesCount = size; ext = extension != null ? extension : "jpg"; }
Example 2
Source File: ImageLocation.java From Telegram with GNU General Public License v2.0 | 6 votes |
public static ImageLocation getForUser(TLRPC.User user, boolean big) { if (user == null || user.access_hash == 0 || user.photo == null) { return null; } TLRPC.FileLocation fileLocation = big ? user.photo.photo_big : user.photo.photo_small; if (fileLocation == null) { return null; } TLRPC.TL_inputPeerUser inputPeer = new TLRPC.TL_inputPeerUser(); inputPeer.user_id = user.id; inputPeer.access_hash = user.access_hash; int dc_id; if (user.photo.dc_id != 0) { dc_id = user.photo.dc_id; } else { dc_id = fileLocation.dc_id; } return getForPhoto(fileLocation, 0, null, null, inputPeer, big, dc_id, null, null); }
Example 3
Source File: ImageLoader.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private void generateThumb(int mediaType, File originalPath, TLRPC.FileLocation thumbLocation, String filter) { if (mediaType != FileLoader.MEDIA_DIR_IMAGE && mediaType != FileLoader.MEDIA_DIR_VIDEO && mediaType != FileLoader.MEDIA_DIR_DOCUMENT || originalPath == null || thumbLocation == null) { return; } String name = FileLoader.getAttachFileName(thumbLocation); ThumbGenerateTask task = thumbGenerateTasks.get(name); if (task == null) { task = new ThumbGenerateTask(mediaType, originalPath, thumbLocation, filter); thumbGeneratingQueue.postRunnable(task); } }
Example 4
Source File: ShareDialogCell.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
public void setDialog(int uid, boolean checked, CharSequence name) { TLRPC.FileLocation photo = null; if (uid > 0) { TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(uid); avatarDrawable.setInfo(user); if (UserObject.isUserSelf(user)) { nameTextView.setText(LocaleController.getString("SavedMessages", R.string.SavedMessages)); avatarDrawable.setSavedMessages(1); } else { if (name != null) { nameTextView.setText(name); } else if (user != null) { nameTextView.setText(ContactsController.formatName(user.first_name, user.last_name)); } else { nameTextView.setText(""); } 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); checkBox.setChecked(checked, false); }
Example 5
Source File: AdminedChannelCell.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
public void setChannel(TLRPC.Chat channel, boolean last) { TLRPC.FileLocation photo = null; if (channel.photo != null) { photo = channel.photo.photo_small; } final String url = MessagesController.getInstance(currentAccount).linkPrefix + "/"; currentChannel = channel; avatarDrawable.setInfo(channel); nameTextView.setText(channel.title); SpannableStringBuilder stringBuilder = new SpannableStringBuilder(url + channel.username); stringBuilder.setSpan(new URLSpanNoUnderline(""), url.length(), stringBuilder.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); statusTextView.setText(stringBuilder); avatarImageView.setImage(photo, "50_50", avatarDrawable); isLast = last; }
Example 6
Source File: AccountSelectCell.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
public void setAccount(int account, boolean check) { accountNumber = account; TLRPC.User user = UserConfig.getInstance(accountNumber).getCurrentUser(); avatarDrawable.setInfo(user); textView.setText(ContactsController.formatName(user.first_name, user.last_name)); TLRPC.FileLocation avatar; if (user.photo != null && user.photo.photo_small != null && user.photo.photo_small.volume_id != 0 && user.photo.photo_small.local_id != 0) { avatar = user.photo.photo_small; } else { avatar = null; } imageView.getImageReceiver().setCurrentAccount(account); imageView.setImage(avatar, "50_50", avatarDrawable); checkImageView.setVisibility(check && account == UserConfig.selectedAccount ? VISIBLE : INVISIBLE); }
Example 7
Source File: FileRefController.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
private byte[] getFileReference(TLRPC.FileLocation fileLocation, TLRPC.InputFileLocation location, boolean[] needReplacement) { if (fileLocation == null || !(location instanceof TLRPC.TL_inputFileLocation)) { return null; } if (fileLocation.local_id == location.local_id && fileLocation.volume_id == location.volume_id) { if (fileLocation.file_reference == null && needReplacement != null) { needReplacement[0] = true; } return fileLocation.file_reference; } return null; }
Example 8
Source File: HintDialogCell.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
public void update() { int uid = (int) dialog_id; TLRPC.FileLocation photo = null; if (uid > 0) { TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(uid); avatarDrawable.setInfo(user); } else { TLRPC.Chat chat = MessagesController.getInstance(currentAccount).getChat(-uid); avatarDrawable.setInfo(chat); } }
Example 9
Source File: FileLoader.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private void loadFile(final TLRPC.Document document, final SecureDocument secureDocument, final WebFile webDocument, final TLRPC.FileLocation location, final String locationExt, final int locationSize, final boolean force, final int cacheType) { String fileName; if (location != null) { fileName = getAttachFileName(location, locationExt); } else if (document != null) { fileName = getAttachFileName(document); } else if (webDocument != null) { fileName = getAttachFileName(webDocument); } else { fileName = null; } if (!TextUtils.isEmpty(fileName) && !fileName.contains("" + Integer.MIN_VALUE)) { loadOperationPathsUI.put(fileName, true); } fileLoaderQueue.postRunnable(new Runnable() { @Override public void run() { loadFileInternal(document, secureDocument, webDocument, location, locationExt, locationSize, force, null, 0, cacheType); } }); }
Example 10
Source File: AccountSelectCell.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
public void setAccount(int account, boolean check) { accountNumber = account; TLRPC.User user = UserConfig.getInstance(accountNumber).getCurrentUser(); avatarDrawable.setInfo(user); textView.setText(ContactsController.formatName(user.first_name, user.last_name)); TLRPC.FileLocation avatar; if (user.photo != null && user.photo.photo_small != null && user.photo.photo_small.volume_id != 0 && user.photo.photo_small.local_id != 0) { avatar = user.photo.photo_small; } else { avatar = null; } imageView.getImageReceiver().setCurrentAccount(account); imageView.setImage(avatar, "50_50", avatarDrawable); checkImageView.setVisibility(check && account == UserConfig.selectedAccount ? VISIBLE : INVISIBLE); }
Example 11
Source File: VoIPBaseService.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
protected void showNotification(String name, TLRPC.FileLocation photo, Class<? extends Activity> activity) { Intent intent = new Intent(this, activity); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP); Notification.Builder builder = new Notification.Builder(this) .setContentTitle(LocaleController.getString("VoipOutgoingCall", R.string.VoipOutgoingCall)) .setContentText(name) .setSmallIcon(R.drawable.notification) .setContentIntent(PendingIntent.getActivity(this, 0, intent, 0)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { Intent endIntent = new Intent(this, VoIPActionsReceiver.class); endIntent.setAction(getPackageName() + ".END_CALL"); builder.addAction(R.drawable.ic_call_end_white_24dp, LocaleController.getString("VoipEndCall", R.string.VoipEndCall), PendingIntent.getBroadcast(this, 0, endIntent, PendingIntent.FLAG_UPDATE_CURRENT)); builder.setPriority(Notification.PRIORITY_MAX); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { builder.setShowWhen(false); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { builder.setColor(0xff2ca5e0); } if (Build.VERSION.SDK_INT >= 26) { NotificationsController.checkOtherNotificationsChannel(); builder.setChannelId(NotificationsController.OTHER_NOTIFICATIONS_CHANNEL); } if (photo!= null) { BitmapDrawable img = ImageLoader.getInstance().getImageFromMemory(photo, null, "50_50"); if (img != null) { builder.setLargeIcon(img.getBitmap()); } else { try { float scaleFactor = 160.0f / AndroidUtilities.dp(50); BitmapFactory.Options options = new BitmapFactory.Options(); options.inSampleSize = scaleFactor < 1 ? 1 : (int) scaleFactor; Bitmap bitmap = BitmapFactory.decodeFile(FileLoader.getPathToAttach(photo, true).toString(), options); if (bitmap != null) { builder.setLargeIcon(bitmap); } } catch (Throwable e) { FileLog.e(e); } } } ongoingCallNotification = builder.getNotification(); startForeground(ID_ONGOING_CALL_NOTIFICATION, ongoingCallNotification); }
Example 12
Source File: VoIPBaseService.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
protected void showNotification(String name, TLRPC.FileLocation photo, Class<? extends Activity> activity) { Intent intent = new Intent(this, activity); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP); Notification.Builder builder = new Notification.Builder(this) .setContentTitle(LocaleController.getString("VoipOutgoingCall", R.string.VoipOutgoingCall)) .setContentText(name) .setSmallIcon(R.drawable.notification) .setContentIntent(PendingIntent.getActivity(this, 0, intent, 0)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { Intent endIntent = new Intent(this, VoIPActionsReceiver.class); endIntent.setAction(getPackageName() + ".END_CALL"); builder.addAction(R.drawable.ic_call_end_white_24dp, LocaleController.getString("VoipEndCall", R.string.VoipEndCall), PendingIntent.getBroadcast(this, 0, endIntent, PendingIntent.FLAG_UPDATE_CURRENT)); builder.setPriority(Notification.PRIORITY_MAX); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { builder.setShowWhen(false); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { builder.setColor(0xff2ca5e0); } if (Build.VERSION.SDK_INT >= 26) { NotificationsController.checkOtherNotificationsChannel(); builder.setChannelId(NotificationsController.OTHER_NOTIFICATIONS_CHANNEL); } if (photo!= null) { BitmapDrawable img = ImageLoader.getInstance().getImageFromMemory(photo, null, "50_50"); if (img != null) { builder.setLargeIcon(img.getBitmap()); } else { try { float scaleFactor = 160.0f / AndroidUtilities.dp(50); BitmapFactory.Options options = new BitmapFactory.Options(); options.inSampleSize = scaleFactor < 1 ? 1 : (int) scaleFactor; Bitmap bitmap = BitmapFactory.decodeFile(FileLoader.getPathToAttach(photo, true).toString(), options); if (bitmap != null) { builder.setLargeIcon(bitmap); } } catch (Throwable e) { FileLog.e(e); } } } ongoingCallNotification = builder.getNotification(); startForeground(ID_ONGOING_CALL_NOTIFICATION, ongoingCallNotification); }
Example 13
Source File: ImageReceiver.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
public void setImage(TLObject fileLocation, String filter, TLRPC.FileLocation thumbLocation, String thumbFilter, int size, String ext, int cacheType) { setImage(fileLocation, null, filter, null, thumbLocation, thumbFilter, size, ext, cacheType); }
Example 14
Source File: ChatAttachAlertContactsLayout.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
public void update(int mask) { TLRPC.FileLocation photo = null; String newName = null; if (currentUser != null && currentUser.photo != null) { photo = currentUser.photo.photo_small; } if (mask != 0) { boolean continueUpdate = false; if ((mask & MessagesController.UPDATE_MASK_AVATAR) != 0) { if (lastAvatar != null && photo == null || lastAvatar == null && photo != null || lastAvatar != null && photo != null && (lastAvatar.volume_id != photo.volume_id || lastAvatar.local_id != photo.local_id)) { continueUpdate = true; } } if (currentUser != null && !continueUpdate && (mask & MessagesController.UPDATE_MASK_STATUS) != 0) { int newStatus = 0; if (currentUser.status != null) { newStatus = currentUser.status.expires; } if (newStatus != lastStatus) { continueUpdate = true; } } if (!continueUpdate && currentName == null && lastName != null && (mask & MessagesController.UPDATE_MASK_NAME) != 0) { if (currentUser != null) { newName = UserObject.getUserName(currentUser); } if (!newName.equals(lastName)) { continueUpdate = true; } } if (!continueUpdate) { return; } } if (currentUser != null) { avatarDrawable.setInfo(currentUser); if (currentUser.status != null) { lastStatus = currentUser.status.expires; } else { lastStatus = 0; } } else if (currentName != null) { avatarDrawable.setInfo(currentId, currentName.toString(), null); } else { avatarDrawable.setInfo(currentId, "#", null); } if (currentName != null) { lastName = null; nameTextView.setText(currentName); } else { if (currentUser != null) { lastName = newName == null ? UserObject.getUserName(currentUser) : newName; } else { lastName = ""; } nameTextView.setText(lastName); } if (currentStatus != null) { statusTextView.setText(currentStatus); } else if (currentUser != null) { if (TextUtils.isEmpty(currentUser.phone)) { statusTextView.setText(LocaleController.getString("NumberUnknown", R.string.NumberUnknown)); } else { statusTextView.setText(PhoneFormat.getInstance().format("+" + currentUser.phone)); } } lastAvatar = photo; if (currentUser != null) { avatarImageView.setImage(ImageLocation.getForUser(currentUser, false), "50_50", avatarDrawable, currentUser); } else { avatarImageView.setImageDrawable(avatarDrawable); } }
Example 15
Source File: VoIPBaseService.java From Telegram with GNU General Public License v2.0 | 4 votes |
protected void showNotification(String name, TLRPC.FileLocation photo, Class<? extends Activity> activity) { Intent intent = new Intent(this, activity); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP); Notification.Builder builder = new Notification.Builder(this) .setContentTitle(LocaleController.getString("VoipOutgoingCall", R.string.VoipOutgoingCall)) .setContentText(name) .setSmallIcon(R.drawable.notification) .setContentIntent(PendingIntent.getActivity(this, 0, intent, 0)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { Intent endIntent = new Intent(this, VoIPActionsReceiver.class); endIntent.setAction(getPackageName() + ".END_CALL"); builder.addAction(R.drawable.ic_call_end_white_24dp, LocaleController.getString("VoipEndCall", R.string.VoipEndCall), PendingIntent.getBroadcast(this, 0, endIntent, PendingIntent.FLAG_UPDATE_CURRENT)); builder.setPriority(Notification.PRIORITY_MAX); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { builder.setShowWhen(false); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { builder.setColor(0xff2ca5e0); } if (Build.VERSION.SDK_INT >= 26) { NotificationsController.checkOtherNotificationsChannel(); builder.setChannelId(NotificationsController.OTHER_NOTIFICATIONS_CHANNEL); } if (photo!= null) { BitmapDrawable img = ImageLoader.getInstance().getImageFromMemory(photo, null, "50_50"); if (img != null) { builder.setLargeIcon(img.getBitmap()); } else { try { float scaleFactor = 160.0f / AndroidUtilities.dp(50); BitmapFactory.Options options = new BitmapFactory.Options(); options.inSampleSize = scaleFactor < 1 ? 1 : (int) scaleFactor; Bitmap bitmap = BitmapFactory.decodeFile(FileLoader.getPathToAttach(photo, true).toString(), options); if (bitmap != null) { builder.setLargeIcon(bitmap); } } catch (Throwable e) { FileLog.e(e); } } } ongoingCallNotification = builder.getNotification(); startForeground(ID_ONGOING_CALL_NOTIFICATION, ongoingCallNotification); }
Example 16
Source File: FileLoader.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
private void cancelLoadFile(final TLRPC.Document document, final SecureDocument secureDocument, final WebFile webDocument, final TLRPC.FileLocation location, final String locationExt) { if (location == null && document == null && webDocument == null && secureDocument == null) { return; } final String fileName; if (location != null) { fileName = getAttachFileName(location, locationExt); } else if (document != null) { fileName = getAttachFileName(document); } else if (secureDocument != null) { fileName = getAttachFileName(secureDocument); } else if (webDocument != null) { fileName = getAttachFileName(webDocument); } else { fileName = null; } if (fileName == null) { return; } loadOperationPathsUI.remove(fileName); fileLoaderQueue.postRunnable(new Runnable() { @Override public void run() { FileLoadOperation operation = loadOperationPaths.remove(fileName); if (operation != null) { int datacenterId = operation.getDatacenterId(); if (MessageObject.isVoiceDocument(document) || MessageObject.isVoiceWebDocument(webDocument)) { LinkedList<FileLoadOperation> audioLoadOperationQueue = getAudioLoadOperationQueue(datacenterId); if (!audioLoadOperationQueue.remove(operation)) { currentAudioLoadOperationsCount.put(datacenterId, currentAudioLoadOperationsCount.get(datacenterId) - 1); } } else if (secureDocument != null || location != null || MessageObject.isImageWebDocument(webDocument)) { LinkedList<FileLoadOperation> photoLoadOperationQueue = getPhotoLoadOperationQueue(datacenterId); if (!photoLoadOperationQueue.remove(operation)) { currentPhotoLoadOperationsCount.put(datacenterId, currentPhotoLoadOperationsCount.get(datacenterId) - 1); } } else { LinkedList<FileLoadOperation> loadOperationQueue = getLoadOperationQueue(datacenterId); if (!loadOperationQueue.remove(operation)) { currentLoadOperationsCount.put(datacenterId, currentLoadOperationsCount.get(datacenterId) - 1); } activeFileLoadOperation.remove(operation); } operation.cancel(); } } }); }
Example 17
Source File: BackupImageView.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
public void setImage(TLObject path, String filter, TLRPC.FileLocation thumb, int size) { setImage(path, null, filter, null, null, thumb, null, null, size); }
Example 18
Source File: PollVotesAlert.java From Telegram with GNU General Public License v2.0 | 4 votes |
public void update(int mask) { TLRPC.FileLocation photo = null; String newName = null; if (currentUser != null && currentUser.photo != null) { photo = currentUser.photo.photo_small; } if (mask != 0) { boolean continueUpdate = false; if ((mask & MessagesController.UPDATE_MASK_AVATAR) != 0) { if (lastAvatar != null && photo == null || lastAvatar == null && photo != null || lastAvatar != null && photo != null && (lastAvatar.volume_id != photo.volume_id || lastAvatar.local_id != photo.local_id)) { continueUpdate = true; } } if (currentUser != null && !continueUpdate && (mask & MessagesController.UPDATE_MASK_STATUS) != 0) { int newStatus = 0; if (currentUser.status != null) { newStatus = currentUser.status.expires; } if (newStatus != lastStatus) { continueUpdate = true; } } if (!continueUpdate && lastName != null && (mask & MessagesController.UPDATE_MASK_NAME) != 0) { if (currentUser != null) { newName = UserObject.getUserName(currentUser); } if (!newName.equals(lastName)) { continueUpdate = true; } } if (!continueUpdate) { return; } } avatarDrawable.setInfo(currentUser); if (currentUser.status != null) { lastStatus = currentUser.status.expires; } else { lastStatus = 0; } if (currentUser != null) { lastName = newName == null ? UserObject.getUserName(currentUser) : newName; } else { lastName = ""; } nameTextView.setText(lastName); lastAvatar = photo; if (currentUser != null) { avatarImageView.setImage(ImageLocation.getForUser(currentUser, false), "50_50", avatarDrawable, currentUser); } else { avatarImageView.setImageDrawable(avatarDrawable); } }
Example 19
Source File: SharedPhotoVideoCell.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
public void setItem(int a, int index, MessageObject messageObject) { messageObjects[a] = messageObject; indeces[a] = index; if (messageObject != null) { photoVideoViews[a].setVisibility(VISIBLE); PhotoVideoView photoVideoView = photoVideoViews[a]; photoVideoView.imageView.getImageReceiver().setParentMessageObject(messageObject); photoVideoView.imageView.getImageReceiver().setVisible(!PhotoViewer.isShowingImage(messageObject), false); if (messageObject.isVideo()) { photoVideoView.videoInfoContainer.setVisibility(VISIBLE); int duration = 0; for (int b = 0; b < messageObject.getDocument().attributes.size(); b++) { TLRPC.DocumentAttribute attribute = messageObject.getDocument().attributes.get(b); if (attribute instanceof TLRPC.TL_documentAttributeVideo) { duration = attribute.duration; break; } } int minutes = duration / 60; int seconds = duration - minutes * 60; photoVideoView.videoTextView.setText(String.format("%d:%02d", minutes, seconds)); if (messageObject.getDocument().thumb != null) { TLRPC.FileLocation location = messageObject.getDocument().thumb.location; photoVideoView.imageView.setImage(null, null, null, ApplicationLoader.applicationContext.getResources().getDrawable(R.drawable.photo_placeholder_in), null, location, "b", null, 0); } else { photoVideoView.imageView.setImageResource(R.drawable.photo_placeholder_in); } } else if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaPhoto && messageObject.messageOwner.media.photo != null && !messageObject.photoThumbs.isEmpty()) { photoVideoView.videoInfoContainer.setVisibility(INVISIBLE); TLRPC.PhotoSize photoSize = FileLoader.getClosestPhotoSizeWithSize(messageObject.photoThumbs, 80); photoVideoView.imageView.setImage(null, null, null, ApplicationLoader.applicationContext.getResources().getDrawable(R.drawable.photo_placeholder_in), null, photoSize.location, "b", null, 0); } else { photoVideoView.videoInfoContainer.setVisibility(INVISIBLE); photoVideoView.imageView.setImageResource(R.drawable.photo_placeholder_in); } } else { photoVideoViews[a].clearAnimation(); photoVideoViews[a].setVisibility(INVISIBLE); messageObjects[a] = null; } }
Example 20
Source File: VoIPBaseService.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
protected void showNotification(String name, TLRPC.FileLocation photo, Class<? extends Activity> activity) { Intent intent = new Intent(this, activity); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP); Notification.Builder builder = new Notification.Builder(this) .setContentTitle(LocaleController.getString("VoipOutgoingCall", R.string.VoipOutgoingCall)) .setContentText(name) .setSmallIcon(R.drawable.notification) .setContentIntent(PendingIntent.getActivity(this, 0, intent, 0)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { Intent endIntent = new Intent(this, VoIPActionsReceiver.class); endIntent.setAction(getPackageName() + ".END_CALL"); builder.addAction(R.drawable.ic_call_end_white_24dp, LocaleController.getString("VoipEndCall", R.string.VoipEndCall), PendingIntent.getBroadcast(this, 0, endIntent, PendingIntent.FLAG_UPDATE_CURRENT)); builder.setPriority(Notification.PRIORITY_MAX); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { builder.setShowWhen(false); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { builder.setColor(0xff2ca5e0); } if (Build.VERSION.SDK_INT >= 26) { NotificationsController.checkOtherNotificationsChannel(); builder.setChannelId(NotificationsController.OTHER_NOTIFICATIONS_CHANNEL); } if (photo!= null) { BitmapDrawable img = ImageLoader.getInstance().getImageFromMemory(photo, null, "50_50"); if (img != null) { builder.setLargeIcon(img.getBitmap()); } else { try { float scaleFactor = 160.0f / AndroidUtilities.dp(50); BitmapFactory.Options options = new BitmapFactory.Options(); options.inSampleSize = scaleFactor < 1 ? 1 : (int) scaleFactor; Bitmap bitmap = BitmapFactory.decodeFile(FileLoader.getPathToAttach(photo, true).toString(), options); if (bitmap != null) { builder.setLargeIcon(bitmap); } } catch (Throwable e) { FileLog.e(e); } } } ongoingCallNotification = builder.getNotification(); startForeground(ID_ONGOING_CALL_NOTIFICATION, ongoingCallNotification); }