Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[mob][photos] almost fully functional toggle for toggling video loop

ashilkn26cb81a7206a
diff --git a/mobile/lib/core/configuration.dart b/mobile/lib/core/configuration.dart
index 16a65d497f..70db6c3d96 100644
--- a/mobile/lib/core/configuration.dart
+++ b/mobile/lib/core/configuration.dart
@@ -71,6 +71,7 @@ class Configuration {
"has_selected_all_folders_for_backup";
static const anonymousUserIDKey = "anonymous_user_id";
static const endPointKey = "endpoint";
+ static const shouldLoopVideoKey = "should_loop_video";
static final _logger = Logger("Configuration");
String? _cachedToken;
@@ -661,6 +662,14 @@ class Configuration {
await _preferences.setBool(hasSelectedAllFoldersForBackupKey, value);
}
+ Future<void> setShouldLoopVideo(bool value) async {
+ await _preferences.setBool(shouldLoopVideoKey, value);
+ }
+
+ bool shouldLoopVideo() {
+ return _preferences.getBool(shouldLoopVideoKey) ?? true;
+ }
+
Future<void> _migrateSecurityStorageToFirstUnlock() async {
final hasMigratedSecureStorage =
_preferences.getBool(hasMigratedSecureStorageKey) ?? false;
diff --git a/mobile/lib/ui/viewer/file/file_app_bar.dart b/mobile/lib/ui/viewer/file/file_app_bar.dart
index 362868eeec..92d6d54239 100644
--- a/mobile/lib/ui/viewer/file/file_app_bar.dart
+++ b/mobile/lib/ui/viewer/file/file_app_bar.dart
@@ -6,6 +6,7 @@ import "package:flutter_svg/flutter_svg.dart";
import "package:local_auth/local_auth.dart";
import 'package:logging/logging.dart';
import 'package:media_extension/media_extension.dart';
+import "package:photos/core/configuration.dart";
import "package:photos/core/event_bus.dart";
import "package:photos/events/guest_view_event.dart";
import "package:photos/generated/l10n.dart";
@@ -55,6 +56,7 @@ class FileAppBarState extends State<FileAppBar> {
final List<Widget> _actions = [];
late final StreamSubscription<GuestViewEvent> _guestViewEventSubscription;
bool isGuestView = false;
+ bool shouldLoopVideo = Configuration.instance.shouldLoopVideo();
@override
void didUpdateWidget(FileAppBar oldWidget) {
@@ -315,6 +317,29 @@ class FileAppBarState extends State<FileAppBar> {
),
),
);
+
+ if (widget.file.isVideo) {
+ items.add(
+ PopupMenuItem(
+ value: 7,
+ child: Row(
+ children: [
+ Icon(
+ Icons.repeat_rounded,
+ color: Theme.of(context).iconTheme.color,
+ ),
+ const Padding(
+ padding: EdgeInsets.all(8),
+ ),
+ shouldLoopVideo
+ ? const Text("Video loop on")
+ : const Text("Video loop off"),
+ ],
+ ),
+ ),
+ );
+ }
+
if (items.isNotEmpty) {
_actions.add(
PopupMenuButton(
@@ -334,6 +359,8 @@ class FileAppBarState extends State<FileAppBar> {
await _handleUnHideRequest(context);
} else if (value == 6) {
await _onTapGuestView();
+ } else if (value == 7) {
+ _onToggleVideoLoop();
}
},
),
@@ -342,6 +369,13 @@ class FileAppBarState extends State<FileAppBar> {
return _actions;
}
+ _onToggleVideoLoop() {
+ Configuration.instance.setShouldLoopVideo(!shouldLoopVideo);
+ setState(() {
+ shouldLoopVideo = !shouldLoopVideo;
+ });
+ }
+
Future<void> _handleHideRequest(BuildContext context) async {
try {
final hideResult =
diff --git a/mobile/lib/ui/viewer/file/video_widget_native.dart b/mobile/lib/ui/viewer/file/video_widget_native.dart
index 58e3367122..268bdec5e2 100644
--- a/mobile/lib/ui/viewer/file/video_widget_native.dart
+++ b/mobile/lib/ui/viewer/file/video_widget_native.dart
@@ -4,6 +4,7 @@ import "dart:io";
import "package:flutter/material.dart";
import "package:logging/logging.dart";
import "package:native_video_player/native_video_player.dart";
+import "package:photos/core/configuration.dart";
import "package:photos/core/constants.dart";
import "package:photos/core/event_bus.dart";
import "package:photos/events/guest_view_event.dart";
@@ -347,7 +348,9 @@ class _VideoWidgetNativeState extends State<VideoWidgetNative>
}
void _onPlaybackEnded() {
- _controller?.play();
+ if (Configuration.instance.shouldLoopVideo()) {
+ _controller?.play();
+ }
}
void _loadNetworkVideo() {