Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright (C) 2019-2025 qwq233 <qwq233@qwq2333.top>
* 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
* <https://www.gnu.org/licenses/>
*/
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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@
<string name="DarkenAvatarBackground">加深個人頭像顏色</string>
<string name="hideTimeForSticker">隱藏貼圖的時間</string>
<string name="showMessageID">顯示訊息 ID</string>
<string name="showVideoDuration">預覽時顯示影片時長</string>
<string name="hideQuickSendMediaBottom">隱藏快速傳送媒體按鈕</string>
<string name="largeAvatarAsBackground">將大頭貼設為背景</string>
<string name="useSystemEmoji">使用系統 Emoji 符號</string>
Expand Down
1 change: 1 addition & 0 deletions TMessagesProj/src/main/res/values-zh/strings_nullgram.xml
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@
<string name="DarkenAvatarBackground">暗色头像</string>
<string name="hideTimeForSticker">隐藏贴纸发送时间</string>
<string name="showMessageID">显示信息 ID</string>
<string name="showVideoDuration">预览时显示视频时长</string>
<string name="hideQuickSendMediaBottom">隐藏快速发送媒体按钮</string>
<string name="largeAvatarAsBackground">大头像为背景</string>
<string name="useSystemEmoji">使用系统 Emoji 样式</string>
Expand Down
1 change: 1 addition & 0 deletions TMessagesProj/src/main/res/values/strings_nullgram.xml
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@
<string name="DarkenAvatarBackground">Darken profile picture</string>
<string name="hideTimeForSticker">Hide Time For Sticker</string>
<string name="showMessageID">Show Message ID</string>
<string name="showVideoDuration">Show video duration in preview</string>
<string name="hideQuickSendMediaBottom">Hide Quick Send Media Bottom</string>
<string name="largeAvatarAsBackground">Large Avatar As Background</string>
<string name="useSystemEmoji">Use System Emoji</string>
Expand Down