From 66e144d6bdc4e278aff2ab2677cd1b40d53922d0 Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Fri, 5 May 2023 18:06:25 +0530 Subject: [PATCH 1/3] Upgrade motion photos package --- lib/generated/intl/messages_es.dart | 2 ++ lib/ui/viewer/file/zoomable_live_image.dart | 4 ++-- lib/utils/file_uploader_util.dart | 2 +- pubspec.lock | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/generated/intl/messages_es.dart b/lib/generated/intl/messages_es.dart index 4f3c7fd06..c15ca1700 100644 --- a/lib/generated/intl/messages_es.dart +++ b/lib/generated/intl/messages_es.dart @@ -427,6 +427,8 @@ class MessageLookup extends MessageLookupByLibrary { "customRadius": MessageLookupByLibrary.simpleMessage("Radio personalizado"), "darkTheme": MessageLookupByLibrary.simpleMessage("Oscuro"), + "dayToday": MessageLookupByLibrary.simpleMessage("Hoy"), + "dayYesterday": MessageLookupByLibrary.simpleMessage("Ayer"), "decrypting": MessageLookupByLibrary.simpleMessage("Descifrando..."), "decryptingVideo": MessageLookupByLibrary.simpleMessage("Descifrando video..."), diff --git a/lib/ui/viewer/file/zoomable_live_image.dart b/lib/ui/viewer/file/zoomable_live_image.dart index cb2ebd060..9ae072f9f 100644 --- a/lib/ui/viewer/file/zoomable_live_image.dart +++ b/lib/ui/viewer/file/zoomable_live_image.dart @@ -125,7 +125,7 @@ class _ZoomableLiveImageState extends State return; } _isLoadingVideoPlayer = true; - io.File? videoFile = _file.fileType == FileType.livePhoto + final io.File? videoFile = _file.fileType == FileType.livePhoto ? await _getLivePhotoVideo() : await _getMotionPhotoVideo(); @@ -178,7 +178,7 @@ class _ZoomableLiveImageState extends State }); if (imageFile != null) { final motionPhoto = MotionPhotos(imageFile.path); - final index = motionPhoto.getMotionVideoIndex(); + final index = await motionPhoto.getMotionVideoIndex(); if (index != null) { if (widget.file.pubMagicMetadata?.mvi == null && (widget.file.ownerID ?? 0) == Configuration.instance.getUserID()!) { diff --git a/lib/utils/file_uploader_util.dart b/lib/utils/file_uploader_util.dart index 3f0e71644..fcda90210 100644 --- a/lib/utils/file_uploader_util.dart +++ b/lib/utils/file_uploader_util.dart @@ -163,7 +163,7 @@ Future _getMediaUploadDataFromAssetFile(ente.File file) async { if (io.Platform.isAndroid && asset.type == AssetType.image) { try { motionPhotoStartingIndex = - MotionPhotos(sourceFile.path).getMotionVideoIndex()?.start; + (await MotionPhotos(sourceFile.path).getMotionVideoIndex())?.start; } catch (e) { _logger.severe('error while detecthing motion photo start index', e); } diff --git a/pubspec.lock b/pubspec.lock index efc2b2495..f1d87e341 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1186,7 +1186,7 @@ packages: description: path: "." ref: HEAD - resolved-ref: ceeaff6e16bd9e3c98e7da2b1109dc04a93098b9 + resolved-ref: "989ea86e513755d9a8cf945e7522100fc2877639" url: "https://github.com/ente-io/motion_photo.git" source: git version: "0.0.1" From 51bfb7f67c4bccac2fdb53cd6888af7a4e85b213 Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Sat, 6 May 2023 14:52:02 +0530 Subject: [PATCH 2/3] Fix: Show motion photo play toast for motion photos only --- lib/ui/viewer/file/zoomable_live_image.dart | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/ui/viewer/file/zoomable_live_image.dart b/lib/ui/viewer/file/zoomable_live_image.dart index 9ae072f9f..c8abacfd5 100644 --- a/lib/ui/viewer/file/zoomable_live_image.dart +++ b/lib/ui/viewer/file/zoomable_live_image.dart @@ -209,10 +209,14 @@ class _ZoomableLiveImageState extends State } void _showLivePhotoToast() async { + if (widget.file.fileType != FileType.livePhoto || + widget.file.pubMagicMetadata?.mvi != null) { + return; + } final preferences = await SharedPreferences.getInstance(); final int promptTillNow = preferences.getInt(livePhotoToastCounterKey) ?? 0; if (promptTillNow < maxLivePhotoToastCount && mounted) { - showToast(context, S.of(context).pressAndHoldToPlayVideo); + showShortToast(context, S.of(context).pressAndHoldToPlayVideo); preferences.setInt(livePhotoToastCounterKey, promptTillNow + 1); } } From c228604c6e0aaa0381217562447c1640ae8576c3 Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Sat, 6 May 2023 14:56:00 +0530 Subject: [PATCH 3/3] Fix: Schedule hintTask after widget is initiated --- lib/ui/viewer/file/zoomable_live_image.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ui/viewer/file/zoomable_live_image.dart b/lib/ui/viewer/file/zoomable_live_image.dart index c8abacfd5..43eaa01cc 100644 --- a/lib/ui/viewer/file/zoomable_live_image.dart +++ b/lib/ui/viewer/file/zoomable_live_image.dart @@ -49,7 +49,7 @@ class _ZoomableLiveImageState extends State @override void initState() { _file = widget.file; - _showLivePhotoToast(); + Future.microtask(() => _showHintForMotionPhotoPlay).ignore(); super.initState(); } @@ -208,7 +208,7 @@ class _ZoomableLiveImageState extends State }); } - void _showLivePhotoToast() async { + void _showHintForMotionPhotoPlay() async { if (widget.file.fileType != FileType.livePhoto || widget.file.pubMagicMetadata?.mvi != null) { return;