Skip to content

Commit

Permalink
feat: Send Mp4 Document As Video
Browse files Browse the repository at this point in the history
Co-authored-by: megapro17 <megapro17@gmail.com>
  • Loading branch information
omg-xtao and megapro17 committed Mar 18, 2024
1 parent 4af7e74 commit 0864a3f
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 7 deletions.
Expand Up @@ -94,6 +94,8 @@
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;
Expand Down Expand Up @@ -8137,7 +8139,7 @@ public static void prepareSendingMedia(AccountInstance accountInstance, ArrayLis
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();
Expand Down Expand Up @@ -8206,6 +8208,12 @@ public static void prepareSendingMedia(AccountInstance accountInstance, ArrayLis
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);
Expand Down Expand Up @@ -8891,6 +8899,12 @@ public static void prepareSendingVideo(AccountInstance accountInstance, String v
}
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;
Expand Down
Expand Up @@ -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)));
Expand Down
Expand Up @@ -566,6 +566,12 @@ object NaConfig {
ConfigItem.configTypeString,
"https://p2p.belloworld.it/"
)
val sendMp4DocumentAsVideo =
addConfig(
"SendMp4DocumentAsVideo",
ConfigItem.configTypeBool,
false
)

private fun addConfig(
k: String,
Expand Down
12 changes: 6 additions & 6 deletions TMessagesProj/src/main/res/values-es-rES/strings_na.xml
Expand Up @@ -125,11 +125,11 @@
<string name="DisableDialogsFloatingButton">Deshabilitar botón flotante de diálogos</string>
<string name="DisableFlagSecure">Deshabilitar Flag Secure</string>
<string name="CenterActionBarTitle">Centrar el título en la barra de acción</string>
<string name="ShowQuickReplyInBotCommands">Mostrar respuestas rápidas en comandos de bot</string>
<string name="ShowQuickReplyInBotCommands">Mostrar respuestas rápidas en comandos del bot</string>
<string name="PushServiceType">Tipo de servicio Push</string>
<string name="PushServiceTypeInApp">En App</string>
<string name="PushServiceTypeFCM">Google FCM</string>
<string name="PushServiceTypeUnified">Empuje unificado</string>
<string name="PushServiceTypeInAppDialog">Mostrar notificaciones residentes</string>
<string name="PushServiceTypeUnifiedGateway">Unificado Push Gateway</string>
<string name="PushServiceTypeInApp">En la App</string>
<string name="PushServiceTypeFCM">FCM de Google</string>
<string name="PushServiceTypeUnified">Unified Push</string>
<string name="PushServiceTypeInAppDialog">Mostrar notificación permanente</string>
<string name="PushServiceTypeUnifiedGateway">Gateway de Unified Push</string>
</resources>
1 change: 1 addition & 0 deletions TMessagesProj/src/main/res/values-zh-rCN/strings_na.xml
Expand Up @@ -132,4 +132,5 @@
<string name="PushServiceTypeUnified">Unified Push</string>
<string name="PushServiceTypeInAppDialog">显示常驻通知</string>
<string name="PushServiceTypeUnifiedGateway">Unified Push Gateway</string>
<string name="SendMp4DocumentAsVideo">MP4 视频作为文件发送时可预览</string>
</resources>
1 change: 1 addition & 0 deletions TMessagesProj/src/main/res/values/strings_na.xml
Expand Up @@ -132,4 +132,5 @@
<string name="PushServiceTypeUnified">Unified Push</string>
<string name="PushServiceTypeInAppDialog">Show resident notifications</string>
<string name="PushServiceTypeUnifiedGateway">Unified Push Gateway</string>
<string name="SendMp4DocumentAsVideo">Send mp4 document as video</string>
</resources>

0 comments on commit 0864a3f

Please sign in to comment.