feat: Send Mp4 Document As Video

Co-authored-by: megapro17 <megapro17@gmail.com>
This commit is contained in:
xtaodada 2024-03-18 21:48:22 +08:00
parent 4af7e74970
commit 0864a3f09f
Signed by: xtaodada
GPG Key ID: 4CBB3F4FA8C85659
6 changed files with 30 additions and 7 deletions

View File

@ -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;

View File

@ -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)));

View File

@ -566,6 +566,12 @@ object NaConfig {
ConfigItem.configTypeString,
"https://p2p.belloworld.it/"
)
val sendMp4DocumentAsVideo =
addConfig(
"SendMp4DocumentAsVideo",
ConfigItem.configTypeBool,
false
)
private fun addConfig(
k: String,

View File

@ -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>

View File

@ -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>

View File

@ -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>