From d6bc1ed0588f0449bc3e719e434e0c03515a4bce Mon Sep 17 00:00:00 2001 From: xtaodada Date: Mon, 18 Mar 2024 21:48:22 +0800 Subject: [PATCH] feat: Send Mp4 Document As Video Co-authored-by: megapro17 --- .../telegram/messenger/SendMessagesHelper.java | 16 +++++++++++++++- .../NekoExperimentalSettingsActivity.java | 1 + .../main/kotlin/xyz/nextalone/nagram/NaConfig.kt | 6 ++++++ .../src/main/res/values-es-rES/strings_na.xml | 12 ++++++------ .../src/main/res/values-zh-rCN/strings_na.xml | 1 + TMessagesProj/src/main/res/values/strings_na.xml | 1 + 6 files changed, 30 insertions(+), 7 deletions(-) diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/SendMessagesHelper.java b/TMessagesProj/src/main/java/org/telegram/messenger/SendMessagesHelper.java index e51ebb8a2..3381594e8 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/SendMessagesHelper.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/SendMessagesHelper.java @@ -94,6 +94,8 @@ import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; +import xyz.nextalone.nagram.NaConfig; + public class SendMessagesHelper extends BaseController implements NotificationCenter.NotificationCenterDelegate { public static final int MEDIA_TYPE_DICE = 11; @@ -8137,7 +8139,7 @@ public boolean retriedToSend; videoEditedInfo = info.videoEditedInfo != null ? info.videoEditedInfo : createCompressionSettings(info.path); } - if (!forceDocument && (videoEditedInfo != null || info.path.endsWith("mp4"))) { + if (NaConfig.INSTANCE.getSendMp4DocumentAsVideo().Bool() || (!forceDocument && (videoEditedInfo != null || info.path.endsWith("mp4")))) { if (info.path == null && info.searchImage != null) { if (info.searchImage.photo instanceof TLRPC.TL_photo) { info.path = FileLoader.getInstance(accountInstance.getCurrentAccount()).getPathToAttach(info.searchImage.photo, true).getAbsolutePath(); @@ -8206,6 +8208,12 @@ public boolean retriedToSend; attributeVideo.supports_streaming = true; } document.attributes.add(attributeVideo); + + // na: Fix filename + TLRPC.TL_documentAttributeFilename fileName = new TLRPC.TL_documentAttributeFilename(); + fileName.file_name = new File(path).getName(); + document.attributes.add(fileName); + if (videoEditedInfo != null && (videoEditedInfo.needConvert() || !info.isVideo)) { if (info.isVideo && videoEditedInfo.muted) { fillVideoAttribute(info.path, attributeVideo, videoEditedInfo); @@ -8891,6 +8899,12 @@ public boolean retriedToSend; } attributeVideo.round_message = isRound; document.attributes.add(attributeVideo); + + // na: Fix filename + TLRPC.TL_documentAttributeFilename fileName = new TLRPC.TL_documentAttributeFilename(); + fileName.file_name = new File(path).getName(); + document.attributes.add(fileName); + if (videoEditedInfo != null && videoEditedInfo.notReadyYet) { attributeVideo.w = videoEditedInfo.resultWidth; attributeVideo.h = videoEditedInfo.resultHeight; diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoExperimentalSettingsActivity.java b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoExperimentalSettingsActivity.java index 522137645..571654882 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoExperimentalSettingsActivity.java +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoExperimentalSettingsActivity.java @@ -100,6 +100,7 @@ public class NekoExperimentalSettingsActivity extends BaseNekoXSettingsActivity private final AbstractConfigCell customArtworkApiRow = cellGroup.appendCell(new ConfigCellTextInput(null, NaConfig.INSTANCE.getCustomArtworkApi(), "", null)); private final AbstractConfigCell fakeHighPerformanceDeviceRow = cellGroup.appendCell(new ConfigCellTextCheck(NaConfig.INSTANCE.getFakeHighPerformanceDevice())); private final AbstractConfigCell disableEmojiDrawLimitRow = cellGroup.appendCell(new ConfigCellTextCheck(NaConfig.INSTANCE.getDisableEmojiDrawLimit())); + private final AbstractConfigCell sendMp4DocumentAsVideoRow = cellGroup.appendCell(new ConfigCellTextCheck(NaConfig.INSTANCE.getSendMp4DocumentAsVideo())); private final AbstractConfigCell divider1 = cellGroup.appendCell(new ConfigCellDivider()); private final AbstractConfigCell header3 = cellGroup.appendCell(new ConfigCellHeader(LocaleController.getString(R.string.ExternalStickerCache))); diff --git a/TMessagesProj/src/main/kotlin/xyz/nextalone/nagram/NaConfig.kt b/TMessagesProj/src/main/kotlin/xyz/nextalone/nagram/NaConfig.kt index fe1094526..de602f185 100644 --- a/TMessagesProj/src/main/kotlin/xyz/nextalone/nagram/NaConfig.kt +++ b/TMessagesProj/src/main/kotlin/xyz/nextalone/nagram/NaConfig.kt @@ -566,6 +566,12 @@ object NaConfig { ConfigItem.configTypeString, "https://p2p.belloworld.it/" ) + val sendMp4DocumentAsVideo = + addConfig( + "SendMp4DocumentAsVideo", + ConfigItem.configTypeBool, + false + ) private fun addConfig( k: String, diff --git a/TMessagesProj/src/main/res/values-es-rES/strings_na.xml b/TMessagesProj/src/main/res/values-es-rES/strings_na.xml index 4c70a2139..a6d973725 100644 --- a/TMessagesProj/src/main/res/values-es-rES/strings_na.xml +++ b/TMessagesProj/src/main/res/values-es-rES/strings_na.xml @@ -125,11 +125,11 @@ Deshabilitar botón flotante de diálogos Deshabilitar Flag Secure Centrar el título en la barra de acción - Mostrar respuestas rápidas en comandos de bot + Mostrar respuestas rápidas en comandos del bot Tipo de servicio Push - En App - Google FCM - Empuje unificado - Mostrar notificaciones residentes - Unificado Push Gateway + En la App + FCM de Google + Unified Push + Mostrar notificación permanente + Gateway de Unified Push diff --git a/TMessagesProj/src/main/res/values-zh-rCN/strings_na.xml b/TMessagesProj/src/main/res/values-zh-rCN/strings_na.xml index e9d451655..a4865dc9e 100644 --- a/TMessagesProj/src/main/res/values-zh-rCN/strings_na.xml +++ b/TMessagesProj/src/main/res/values-zh-rCN/strings_na.xml @@ -132,4 +132,5 @@ Unified Push 显示常驻通知 Unified Push Gateway + MP4 视频作为文件发送时可预览 diff --git a/TMessagesProj/src/main/res/values/strings_na.xml b/TMessagesProj/src/main/res/values/strings_na.xml index ee733c6b0..954ae8760 100644 --- a/TMessagesProj/src/main/res/values/strings_na.xml +++ b/TMessagesProj/src/main/res/values/strings_na.xml @@ -132,4 +132,5 @@ Unified Push Show resident notifications Unified Push Gateway + Send mp4 document as video