Show icon for live photo in photo viewer

This commit is contained in:
Neeraj Gupta 2023-08-25 13:27:46 +05:30
parent 83a6dbb51e
commit 56113ef02b
6 changed files with 23 additions and 18 deletions

View file

@ -25,9 +25,6 @@ const subGalleryMultiplier = 10;
const String oldSharedMediaIdentifier = 'ente-shared://';
const String sharedMediaIdentifier = 'ente-shared-media://';
const int maxLivePhotoToastCount = 2;
const String livePhotoToastCounterKey = "show_live_photo_toast";
const thumbnailDiskLoadDeferDuration = Duration(milliseconds: 40);
const thumbnailServerLoadDeferDuration = Duration(milliseconds: 80);

View file

@ -941,6 +941,8 @@ class MessageLookup extends MessageLookupByLibrary {
"preserveMore": MessageLookupByLibrary.simpleMessage("Preserve more"),
"pressAndHoldToPlayVideo": MessageLookupByLibrary.simpleMessage(
"Press and hold to play video"),
"pressAndHoldToPlayVideoDetailed": MessageLookupByLibrary.simpleMessage(
"Press and hold on the image to play video"),
"privacy": MessageLookupByLibrary.simpleMessage("Privacy"),
"privacyPolicyTitle":
MessageLookupByLibrary.simpleMessage("Privacy Policy"),

View file

@ -1,7 +1,6 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'intl/messages_all.dart';
// **************************************************************************
@ -5826,6 +5825,16 @@ class S {
);
}
/// `Press and hold on the image to play video`
String get pressAndHoldToPlayVideoDetailed {
return Intl.message(
'Press and hold on the image to play video',
name: 'pressAndHoldToPlayVideoDetailed',
desc: '',
args: [],
);
}
/// `Download failed`
String get downloadFailed {
return Intl.message(

View file

@ -814,6 +814,7 @@
"fileFailedToSaveToGallery": "Failed to save file to gallery",
"download": "Download",
"pressAndHoldToPlayVideo": "Press and hold to play video",
"pressAndHoldToPlayVideoDetailed": "Press and hold on the image to play video",
"downloadFailed": "Download failed",
"deduplicateFiles": "Deduplicate Files",
"deselectAll": "Deselect all",

View file

@ -102,6 +102,16 @@ class FileAppBarState extends State<FileAppBar> {
?.isHidden() ??
false;
}
if (widget.file.isLiveOrMotionPhoto) {
actions.add(
IconButton(
icon: const Icon(Icons.album_outlined),
onPressed: () {
showShortToast(context, S.of(context).pressAndHoldToPlayVideoDetailed);
},
),
);
}
// only show fav option for files owned by the user
if (isOwnedByUser && !isFileHidden && isFileUploaded) {
actions.add(FavoriteWidget(widget.file));

View file

@ -4,7 +4,6 @@ import 'package:chewie/chewie.dart';
import 'package:flutter/material.dart';
import 'package:logging/logging.dart';
import 'package:motion_photos/motion_photos.dart';
import 'package:photos/core/constants.dart';
import "package:photos/generated/l10n.dart";
import "package:photos/models/file/extensions/file_props.dart";
import 'package:photos/models/file/file.dart';
@ -13,7 +12,6 @@ import "package:photos/services/file_magic_service.dart";
import 'package:photos/ui/viewer/file/zoomable_image.dart';
import 'package:photos/utils/file_util.dart';
import 'package:photos/utils/toast_util.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:video_player/video_player.dart';
class ZoomableLiveImage extends StatefulWidget {
@ -47,7 +45,6 @@ class _ZoomableLiveImageState extends State<ZoomableLiveImage>
@override
void initState() {
_enteFile = widget.enteFile;
Future.microtask(() => _showHintForMotionPhotoPlay).ignore();
super.initState();
}
@ -208,15 +205,4 @@ class _ZoomableLiveImageState extends State<ZoomableLiveImage>
});
}
void _showHintForMotionPhotoPlay() async {
if (!_enteFile.isLiveOrMotionPhoto) {
return;
}
final preferences = await SharedPreferences.getInstance();
final int promptTillNow = preferences.getInt(livePhotoToastCounterKey) ?? 0;
if (promptTillNow < maxLivePhotoToastCount && mounted) {
showShortToast(context, S.of(context).pressAndHoldToPlayVideo);
preferences.setInt(livePhotoToastCounterKey, promptTillNow + 1);
}
}
}