π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mob][photos] Pad minutes in hour-long video durations
r4khul8c0402a6be2c
diff --git a/mobile/apps/photos/changes/video-duration-minute-padding.md b/mobile/apps/photos/changes/video-duration-minute-padding.mdnew file mode 100644index 0000000000..3cd8e56b8d--- /dev/null+++ b/mobile/apps/photos/changes/video-duration-minute-padding.md@@ -0,0 +1 @@+- Fixed video durations over an hour showing minutes without a leading zero in the gallery.diff --git a/mobile/apps/photos/lib/ui/viewer/file/file_icons_widget.dart b/mobile/apps/photos/lib/ui/viewer/file/file_icons_widget.dartindex e9f23fa271..2301d07516 100644--- a/mobile/apps/photos/lib/ui/viewer/file/file_icons_widget.dart+++ b/mobile/apps/photos/lib/ui/viewer/file/file_icons_widget.dart@@ -93,7 +93,7 @@ class VideoOverlayDuration extends StatelessWidget {size: iconSize,);} else {- final String formattedDuration = _getFormattedDuration(duration!);+ final String formattedDuration = secondsToDuration(duration!);onDarkBackground = Padding(padding: const EdgeInsets.symmetric(horizontal: 1),child: Text(@@ -121,17 +121,6 @@ class VideoOverlayDuration extends StatelessWidget {},);}-- String _getFormattedDuration(int duration) {- final String formattedDuration = Duration(- seconds: duration,- ).toString().split('.').first;- final List<String> separated = formattedDuration.split(':');- final String hour = (separated[0] == '0') ? '' : separated[0] + ':';- final String minute = int.parse(separated[1]).toString() + ':';- final String second = separated[2];- return hour + minute + second;- }}class OwnerAvatarOverlayIcon extends StatelessWidget {diff --git a/mobile/packages/ente_pure_utils/test/date_time_util_test.dart b/mobile/packages/ente_pure_utils/test/date_time_util_test.dartindex 2c731a1f02..d13ef0333d 100644--- a/mobile/packages/ente_pure_utils/test/date_time_util_test.dart+++ b/mobile/packages/ente_pure_utils/test/date_time_util_test.dart@@ -31,4 +31,18 @@ void main() {expect(nextStart.isUtc, isTrue);});});++ group('secondsToDuration', () {+ test('omits hours under an hour', () {+ expect(secondsToDuration(5), '0:05');+ expect(secondsToDuration(303), '5:03');+ expect(secondsToDuration(3599), '59:59');+ });++ test('pads minutes when hours are shown', () {+ expect(secondsToDuration(3600), '1:00:00');+ expect(secondsToDuration(3754), '1:02:34');+ expect(secondsToDuration(90061), '25:01:01');+ });+ });}