diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java index 24128834b..f25080456 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java @@ -276,6 +276,7 @@ import xyz.nextalone.gen.Config; import xyz.nextalone.nnngram.config.ConfigManager; import xyz.nextalone.nnngram.helpers.MentionReadHelper; +import xyz.nextalone.nnngram.helpers.VideoDurationHelper; import xyz.nextalone.nnngram.utils.Defines; import xyz.nextalone.nnngram.utils.NeteaseEmbed; import xyz.nextalone.nnngram.utils.StringUtils; @@ -5742,7 +5743,9 @@ public void updatePlayingMessageProgress() { } } if (lastTime != duration) { - String str = AndroidUtilities.formatShortDuration((int) duration); + String str = VideoDurationHelper.enabled() + ? VideoDurationHelper.format(duration) + : AndroidUtilities.formatShortDuration((int) duration); infoWidth = (int) Math.ceil(Theme.chat_infoPaint.measureText(str)); infoLayout = new StaticLayout(str, Theme.chat_infoPaint, infoWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); lastTime = duration; @@ -5778,7 +5781,9 @@ public void updatePlayingMessageProgress() { } if (lastTime != duration) { lastTime = duration; - String timeString = AndroidUtilities.formatLongDuration((int) duration); + String timeString = VideoDurationHelper.enabled() + ? VideoDurationHelper.format(duration, true) + : AndroidUtilities.formatLongDuration((int) duration); timeWidthAudio = (int) Math.ceil(Theme.chat_timePaint.measureText(timeString)); durationLayout = new StaticLayout(timeString, Theme.chat_timePaint, timeWidthAudio, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); } @@ -25053,19 +25058,25 @@ public void drawOverlays(Canvas canvas) { fullWidth = (currentPosition.flags & mask) == mask; } if (((documentAttachType == DOCUMENT_ATTACH_TYPE_VIDEO || documentAttachType == DOCUMENT_ATTACH_TYPE_GIF) && (buttonState == 1 || buttonState == 2 || buttonState == 0 || buttonState == 3 || buttonState == -1) || currentMessageObject.needDrawBluredPreview()) && !currentMessageObject.isRepostVideoPreview) { - if (autoPlayingMedia) { + if (autoPlayingMedia || (VideoDurationHelper.enabled() && documentAttachType == DOCUMENT_ATTACH_TYPE_VIDEO)) { updatePlayingMessageProgress(); } - if ((infoLayout != null || loadingProgressLayout != null) && (!forceNotDrawTime || autoPlayingMedia || drawVideoImageButton || animatingLoadingProgressProgress != 0 || (fullWidth && docTitleLayout != null) || (loadingProgressLayout != null && currentPosition != null && (buttonState == 1 || (buttonState == 3 && miniButtonState == 1)))) && (currentMessageObject != null && !currentMessageObject.sendPreview)) { + if ((infoLayout != null || loadingProgressLayout != null) && (!forceNotDrawTime || autoPlayingMedia || drawVideoImageButton || animatingLoadingProgressProgress != 0 || (fullWidth && docTitleLayout != null) || (loadingProgressLayout != null && currentPosition != null && (buttonState == 1 || (buttonState == 3 && miniButtonState == 1))) || (VideoDurationHelper.enabled() && documentAttachType == DOCUMENT_ATTACH_TYPE_VIDEO)) && (currentMessageObject != null && !currentMessageObject.sendPreview)) { boolean drawLoadingProgress; float alpha = 0; boolean drawDocTitleLayout; float loadingProgressAlpha = 1f; if (!fullWidth) { - drawLoadingProgress = true; - drawDocTitleLayout = false; - loadingProgressAlpha = animatingLoadingProgressProgress; + if (VideoDurationHelper.enabled() && documentAttachType == DOCUMENT_ATTACH_TYPE_VIDEO && infoLayout != null) { + drawLoadingProgress = (buttonState == 1 || miniButtonState == 1 || animatingLoadingProgressProgress != 0) && loadingProgressLayout != null; + drawDocTitleLayout = false; + loadingProgressAlpha = drawLoadingProgress ? animatingLoadingProgressProgress : 1f; + } else { + drawLoadingProgress = true; + drawDocTitleLayout = false; + loadingProgressAlpha = animatingLoadingProgressProgress; + } } else { drawLoadingProgress = (buttonState == 1 || miniButtonState == 1 || animatingLoadingProgressProgress != 0) && !currentMessageObject.isSecretMedia() && (documentAttachType == DOCUMENT_ATTACH_TYPE_VIDEO || documentAttachType == DOCUMENT_ATTACH_TYPE_GIF || documentAttachType == DOCUMENT_ATTACH_TYPE_DOCUMENT); diff --git a/TMessagesProj/src/main/java/xyz/nextalone/nnngram/activity/ChatSettingActivity.java b/TMessagesProj/src/main/java/xyz/nextalone/nnngram/activity/ChatSettingActivity.java index 0c9470594..2b113006a 100644 --- a/TMessagesProj/src/main/java/xyz/nextalone/nnngram/activity/ChatSettingActivity.java +++ b/TMessagesProj/src/main/java/xyz/nextalone/nnngram/activity/ChatSettingActivity.java @@ -123,6 +123,7 @@ public class ChatSettingActivity extends BaseActivity { private int showForwardDateRow; private int hideTimeForStickerRow; private int showMessageIDRow; + private int showVideoDurationRow; private int hideQuickSendMediaBottomRow; private int quickSendMediaPopupRow; private int customQuickMessageRow; @@ -341,6 +342,11 @@ protected void onItemClick(View view, int position, float x, float y) { if (view instanceof TextCheckCell) { ((TextCheckCell) view).setChecked(Config.showMessageID); } + } else if (position == showVideoDurationRow) { + Config.toggleShowVideoDuration(); + if (view instanceof TextCheckCell) { + ((TextCheckCell) view).setChecked(Config.showVideoDuration); + } } else if (position == hideQuickSendMediaBottomRow) { Config.toggleHideQuickSendMediaBottom(); if (view instanceof TextCheckCell) { @@ -592,6 +598,7 @@ protected void updateRows() { showForwardDateRow = addRow("showForwardDate"); hideTimeForStickerRow = addRow("hideTimeForSticker"); showMessageIDRow = addRow("showMessageID"); + showVideoDurationRow = addRow("showVideoDuration"); quickToggleAnonymous = addRow("quickToggleAnonymous"); hideSendAsButtonRow = addRow("hideSendAsButton"); hideQuickSendMediaBottomRow = addRow("hideQuickSendMediaBottom"); @@ -759,6 +766,8 @@ public void onBindViewHolder(RecyclerView.ViewHolder holder, int position, boole textCell.setTextAndCheck(LocaleController.getString("showForwardName", R.string.hideTimeForSticker), Config.hideTimeForSticker, true); } else if (position == showMessageIDRow) { textCell.setTextAndCheck(LocaleController.getString("showMessageID", R.string.showMessageID), Config.showMessageID, true); + } else if (position == showVideoDurationRow) { + textCell.setTextAndCheck(LocaleController.getString("showVideoDuration", R.string.showVideoDuration), Config.showVideoDuration, true); } else if (position == hideQuickSendMediaBottomRow) { textCell.setTextAndCheck(LocaleController.getString("DisableQuickSendMediaBottom", R.string.DisableQuickSendMediaBottom), Config.hideQuickSendMediaBottom, true); diff --git a/TMessagesProj/src/main/java/xyz/nextalone/nnngram/helpers/VideoDurationHelper.java b/TMessagesProj/src/main/java/xyz/nextalone/nnngram/helpers/VideoDurationHelper.java new file mode 100644 index 000000000..287b0d5e1 --- /dev/null +++ b/TMessagesProj/src/main/java/xyz/nextalone/nnngram/helpers/VideoDurationHelper.java @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2019-2025 qwq233 + * https://github.com/qwq233/Nullgram + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this software. + * If not, see + * + */ +package xyz.nextalone.nnngram.helpers; + +import org.telegram.messenger.AndroidUtilities; + +import xyz.nextalone.gen.Config; + +public class VideoDurationHelper { + + public static boolean enabled() { + return Config.showVideoDuration; + } + + public static String format(double durationSec) { + return format(durationSec, false); + } + + public static String format(double durationSec, boolean isLong) { + if (durationSec < 0) { + durationSec = 0; + } + int seconds = (int) Math.ceil(durationSec); + return AndroidUtilities.formatDuration(seconds, isLong); + } +} diff --git a/TMessagesProj/src/main/java/xyz/nextalone/nnngram/utils/Defines.kt b/TMessagesProj/src/main/java/xyz/nextalone/nnngram/utils/Defines.kt index 9397c50fb..9b089052e 100644 --- a/TMessagesProj/src/main/java/xyz/nextalone/nnngram/utils/Defines.kt +++ b/TMessagesProj/src/main/java/xyz/nextalone/nnngram/utils/Defines.kt @@ -71,6 +71,7 @@ object Defines { @BooleanConfig const val avatarBackgroundDarken = "avatarBackgroundDarken" @BooleanConfig const val hideTimeForSticker = "hideTimeForSticker" @BooleanConfig const val showMessageID = "showMessageID" + @BooleanConfig const val showVideoDuration = "showVideoDuration" @BooleanConfig const val hideQuickSendMediaBottom = "hideQuickSendMediaButtom" @BooleanConfig(true) const val quickSendMediaPopup = "quickSendMediaPopup" const val quickSendMediaLastDismissedId = "quickSendMediaLastDismissedId" diff --git a/TMessagesProj/src/main/res/values-zh-rTW/strings_nullgram.xml b/TMessagesProj/src/main/res/values-zh-rTW/strings_nullgram.xml index ab2d0947a..5de966a42 100644 --- a/TMessagesProj/src/main/res/values-zh-rTW/strings_nullgram.xml +++ b/TMessagesProj/src/main/res/values-zh-rTW/strings_nullgram.xml @@ -155,6 +155,7 @@ 加深個人頭像顏色 隱藏貼圖的時間 顯示訊息 ID + 預覽時顯示影片時長 隱藏快速傳送媒體按鈕 將大頭貼設為背景 使用系統 Emoji 符號 diff --git a/TMessagesProj/src/main/res/values-zh/strings_nullgram.xml b/TMessagesProj/src/main/res/values-zh/strings_nullgram.xml index 1e03a16b7..3bc6eaad3 100644 --- a/TMessagesProj/src/main/res/values-zh/strings_nullgram.xml +++ b/TMessagesProj/src/main/res/values-zh/strings_nullgram.xml @@ -155,6 +155,7 @@ 暗色头像 隐藏贴纸发送时间 显示信息 ID + 预览时显示视频时长 隐藏快速发送媒体按钮 大头像为背景 使用系统 Emoji 样式 diff --git a/TMessagesProj/src/main/res/values/strings_nullgram.xml b/TMessagesProj/src/main/res/values/strings_nullgram.xml index 83344d302..7a0e0ea6c 100644 --- a/TMessagesProj/src/main/res/values/strings_nullgram.xml +++ b/TMessagesProj/src/main/res/values/strings_nullgram.xml @@ -159,6 +159,7 @@ Darken profile picture Hide Time For Sticker Show Message ID + Show video duration in preview Hide Quick Send Media Bottom Large Avatar As Background Use System Emoji