Skip to content

Commit

Permalink
feat: save photo and video messages from photo viewer
Browse files Browse the repository at this point in the history
Signed-off-by: Next Alone <12210746+NextAlone@users.noreply.github.com>
  • Loading branch information
NextAlone committed Jun 30, 2024
1 parent 62a1ec0 commit 1e2eb15
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32205,6 +32205,7 @@ private void processSaveMessage() {
media.add(info);
SendMessagesHelper.prepareSendingMedia(getAccountInstance(), media, getUserConfig().getClientUserId(), null, null, null, null, true, true, null, false, 0, 0, false, null, quickReplyShortcut, getQuickReplyId(), 0, false);
}
BulletinFactory.of(ChatActivity.this).showForwardedBulletinWithTag(getUserConfig().getClientUserId(), messages.size());
} else {
forwardMessages(messages, false, false, true, 0, getUserConfig().getClientUserId());
createUndoView();
Expand Down
31 changes: 29 additions & 2 deletions TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java
Original file line number Diff line number Diff line change
Expand Up @@ -5443,8 +5443,35 @@ public void dismiss() {
} else if (id == gallery_menu_qr) {
QrHelper.showQrDialog(parentFragment, resourcesProvider, qrResults, true);
} else if (id == gallery_menu_save_messages) {
var accountInstance = AccountInstance.getInstance(currentAccount);
accountInstance.getSendMessagesHelper().sendMessage(new ArrayList<>(Collections.singletonList(currentMessageObject)),accountInstance.getUserConfig().getClientUserId(),false, false, true, 0);
boolean noforwards = currentMessageObject != null && (MessagesController.getInstance(currentAccount).isChatNoForwards(currentMessageObject.getChatId()) || (currentMessageObject.messageOwner != null && currentMessageObject.messageOwner.noforwards) || currentMessageObject.hasRevealedExtendedMedia());
if (noforwards){
String path = currentMessageObject.messageOwner.attachPath;
if (path != null && !path.isEmpty()) {
File temp = new File(path);
if (!temp.exists()) {
path = null;
}
}
if (path == null || path.isEmpty()) {
path = parentChatActivity.getFileLoader().getPathToMessage(currentMessageObject.messageOwner).toString();
}
ArrayList<SendMessagesHelper.SendingMediaInfo> media = new ArrayList<>();
SendMessagesHelper.SendingMediaInfo info = new SendMessagesHelper.SendingMediaInfo();
info.path = path;
info.thumbPath = null;
info.videoEditedInfo = null;
info.isVideo = path.endsWith(".mp4");
info.caption = null;
info.entities = null;
info.masks = null;
info.ttl = 0;
media.add(info);
SendMessagesHelper.prepareSendingMedia(parentChatActivity.getAccountInstance(), media, parentChatActivity.getUserConfig().getClientUserId(), null, null, null, null, true, true, null, false, 0, 0, false, null, parentChatActivity.quickReplyShortcut, parentChatActivity.getQuickReplyId(), 0, false);
BulletinFactory.of(fragment).showForwardedBulletinWithTag(parentChatActivity.getUserConfig().getClientUserId(), 1);
} else {
var accountInstance = AccountInstance.getInstance(currentAccount);
accountInstance.getSendMessagesHelper().sendMessage(new ArrayList<>(Collections.singletonList(currentMessageObject)), accountInstance.getUserConfig().getClientUserId(), false, false, true, 0);
}
} else if (id == gallery_menu_copy_photo) {
MessageUtils.getInstance(currentAccount).addMessageToClipboard(currentMessageObject, () -> {
if (BulletinFactory.canShowBulletin(parentFragment)) {
Expand Down

0 comments on commit 1e2eb15

Please sign in to comment.