Skip to content

Commit

Permalink
feat: Send media from webpage to chat
Browse files Browse the repository at this point in the history
Thanks to @NekoUpdates
  • Loading branch information
tehcneko authored and omg-xtao committed May 5, 2024
1 parent a4622d4 commit a4197df
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 0 deletions.
25 changes: 25 additions & 0 deletions TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -10265,6 +10265,31 @@ protected void didSendPressed() {
dismiss(true);
chatActivityEnterView.getSendButton().callOnClick();
}

@Override
protected void sendWebpageMedia(boolean notify, int scheduleDate) {
if (checkSlowModeAlert()) {
SendMessagesHelper.SendMessageParams params;
if (messagePreviewParams.webpage.document != null) {
params = SendMessagesHelper.SendMessageParams.of((TLRPC.TL_document) messagePreviewParams.webpage.document, null, null, dialog_id, replyingMessageObject, getThreadMessage(), null, null, null, null, notify, scheduleDate, 0, messagePreviewParams.webpage, null, false);
} else {
params = SendMessagesHelper.SendMessageParams.of((TLRPC.TL_photo) messagePreviewParams.webpage.photo, null, dialog_id, replyingMessageObject, getThreadMessage(), null, null, null, null, notify, scheduleDate, 0, messagePreviewParams.webpage, false);
}
params.quick_reply_shortcut = quickReplyShortcut;
params.quick_reply_shortcut_id = getQuickReplyId();
getSendMessagesHelper().sendMessage(params);
dismiss(true);
if (threadMessageId == 0 || isTopic) {
if (isTopic) {
replyingMessageObject = threadMessageObject;
} else {
replyingMessageObject = null;
}
replyingQuote = null;
chatActivityEnterView.setReplyingMessageObject(null, null);
}
}
}
};
messagePreviewParams.attach(forwardingPreviewView);
TLRPC.Peer defPeer = chatInfo != null ? chatInfo.default_send_as : null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1081,6 +1081,20 @@ public void updateBackground() {
applyChanges.setOnClickListener(v -> dismiss(true));
menu.addView(applyChanges, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 48));

ActionBarMenuSubItem sendMessagesView = new ActionBarMenuSubItem(context, false, false, resourcesProvider);
sendMessagesView.setTextAndIcon(LocaleController.getString(messagePreviewParams.webpage.document != null ? messagePreviewParams.isVideo ? R.string.PreviewSendVideo : R.string.PreviewSendFile : R.string.PreviewSendPhoto), R.drawable.msg_send);
menu.addView(sendMessagesView, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 48));
sendMessagesView.setOnClickListener(v -> {
if (chatActivity.isInScheduleMode()) {
AlertsCreator.createScheduleDatePickerDialog(
chatActivity.getParentActivity(),
chatActivity.getDialogId(),
MessagePreviewView.this::sendWebpageMedia);
} else {
sendWebpageMedia(true, 0);
}
});

ActionBarMenuSubItem deleteLink = new ActionBarMenuSubItem(context, true, false, true, resourcesProvider);
deleteLink.setTextAndIcon(LocaleController.getString(R.string.DoNotLinkPreview), R.drawable.msg_delete);
deleteLink.setColors(getThemedColor(Theme.key_text_RedBold), getThemedColor(Theme.key_text_RedRegular));
Expand Down Expand Up @@ -1921,6 +1935,10 @@ protected void didSendPressed() {

}

protected void sendWebpageMedia(boolean notify, int scheduleDate) {

}

private static class TabsView extends View {
private static class Tab {
final int id;
Expand Down
3 changes: 3 additions & 0 deletions TMessagesProj/src/main/res/values-zh-rCN/strings_na.xml
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,7 @@
<string name="DisablePreviewVideoSoundShortcut">禁用预览视频音量快捷键</string>
<string name="DisablePreviewVideoSoundShortcutNotice">禁用音量键快捷开启预览视频的声音</string>
<string name="DisableAutoWebLogin">禁用官方网页自动登录</string>
<string name="PreviewSendPhoto">发送图片</string>
<string name="PreviewSendVideo">发送视频</string>
<string name="PreviewSendFile">发送文件</string>
</resources>
3 changes: 3 additions & 0 deletions TMessagesProj/src/main/res/values/strings_na.xml
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,7 @@
<string name="DisablePreviewVideoSoundShortcut">Disable preview video sound shortcut</string>
<string name="DisablePreviewVideoSoundShortcutNotice">Disable volume keys to enable preview video sound</string>
<string name="DisableAutoWebLogin">Disable auto web login</string>
<string name="PreviewSendPhoto">Send Photo</string>
<string name="PreviewSendVideo">Send Video</string>
<string name="PreviewSendFile">Send File</string>
</resources>

0 comments on commit a4197df

Please sign in to comment.