Skip to content

armgit / ente

Public Imported from GitHub
0

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

[mob][photos] Add support for album slideshow for Device albums (#12904)

Aman Raj82209d94c0ad
diff --git a/mobile/apps/photos/changes/device-album-slideshow.md b/mobile/apps/photos/changes/device-album-slideshow.md
new file mode 100644
index 0000000000..e8a17d9ec2
--- /dev/null
+++ b/mobile/apps/photos/changes/device-album-slideshow.md
@@ -0,0 +1 @@
+- Added Slideshow to on-device albums.
diff --git a/mobile/apps/photos/lib/ui/viewer/album_slideshow/album_slideshow.dart b/mobile/apps/photos/lib/ui/viewer/album_slideshow/album_slideshow.dart
index ce36267d4e..836d0fc6f4 100644
--- a/mobile/apps/photos/lib/ui/viewer/album_slideshow/album_slideshow.dart
+++ b/mobile/apps/photos/lib/ui/viewer/album_slideshow/album_slideshow.dart
@@ -11,8 +11,11 @@ Future<bool> showAlbumSlideshow(
BuildContext context, {
required Iterable<EnteFile> files,
required String title,
+ bool includeBackupExcludedFiles = false,
}) async {
- final ignoredIDs = await IgnoredFilesService.instance.idToIgnoreReasonMap;
+ final ignoredIDs = includeBackupExcludedFiles
+ ? null
+ : await IgnoredFilesService.instance.idToIgnoreReasonMap;
if (!context.mounted) return false;
final uploadedFileIDs = <int>{};
@@ -26,6 +29,7 @@ Future<bool> showAlbumSlideshow(
final uploadedFileID = file.uploadedFileID;
if (uploadedFileID == null &&
+ ignoredIDs != null &&
IgnoredFilesService.instance.shouldSkipUpload(ignoredIDs, file)) {
continue;
}
diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/gallery_app_bar_widget.dart b/mobile/apps/photos/lib/ui/viewer/gallery/gallery_app_bar_widget.dart
index c58ed016fc..74b34eb6b7 100644
--- a/mobile/apps/photos/lib/ui/viewer/gallery/gallery_app_bar_widget.dart
+++ b/mobile/apps/photos/lib/ui/viewer/gallery/gallery_app_bar_widget.dart
@@ -11,6 +11,7 @@ import 'package:logging/logging.dart';
import 'package:photos/core/configuration.dart';
import "package:photos/core/constants.dart";
import 'package:photos/core/event_bus.dart';
+import "package:photos/db/device_files_db.dart";
import "package:photos/db/files_db.dart";
import "package:photos/events/collection_meta_event.dart";
import "package:photos/events/guest_view_event.dart";
@@ -498,13 +499,31 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {
List<Widget> _getDefaultActions(BuildContext context) {
final List<Widget> actions = <Widget>[];
- if (widget.selectedFiles.files.isNotEmpty ||
- !Configuration.instance.hasConfiguredAccount()) {
+ if (widget.selectedFiles.files.isNotEmpty) {
return actions;
}
final strings = context.strings;
final colorScheme = getEnteColorScheme(context);
+ if (!Configuration.instance.hasConfiguredAccount()) {
+ if (widget.showOverflowMenu && widget.deviceCollection != null) {
+ actions.add(
+ galleryAppBarPopupMenuAction<AlbumPopupAction>(
+ tooltip: strings.more,
+ icon: const HugeIcon(icon: HugeIcons.strokeRoundedMoreVertical),
+ optionsBuilder: () => [
+ _slideshowMenuOption(strings, colorScheme.contentLight),
+ ],
+ onSelected: (AlbumPopupAction value) async {
+ if (value == AlbumPopupAction.albumSlideshow) {
+ await _startAlbumSlideshow();
+ }
+ },
+ ),
+ );
+ }
+ return actions;
+ }
if (galleryType == GalleryType.magic) {
actions.add(
@@ -706,6 +725,7 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {
(galleryType.canArchive() && !isHidden) ||
(!isArchived && galleryType.canHide()) ||
widget.collection != null ||
+ widget.deviceCollection != null ||
galleryType.canDelete() ||
galleryType == GalleryType.sharedCollection ||
(galleryType == GalleryType.localFolder && !_isICloudSharedAlbum) ||
@@ -828,15 +848,7 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {
iconColor,
),
),
- if (_isAlbumSlideshowAvailable)
- _menuOption(
- AlbumPopupAction.albumSlideshow,
- strings.slideshow,
- galleryAppBarMenuIcon(
- HugeIcons.strokeRoundedPresentation03,
- iconColor,
- ),
- ),
+ if (_isAlbumSlideshowAvailable) _slideshowMenuOption(strings, iconColor),
if (canAutoAdd)
_menuOption(
AlbumPopupAction.autoAddPhotos,
@@ -927,7 +939,19 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {
_isDeviceFolderBackedUp &&
widget.onDisableDeviceFolderBackup != null;
- bool get _isAlbumSlideshowAvailable => widget.collection != null;
+ bool get _isAlbumSlideshowAvailable =>
+ widget.collection != null || widget.deviceCollection != null;
+
+ EntePopupMenuOption<AlbumPopupAction> _slideshowMenuOption(
+ StringsLocalizations strings,
+ Color iconColor,
+ ) {
+ return _menuOption(
+ AlbumPopupAction.albumSlideshow,
+ strings.slideshow,
+ galleryAppBarMenuIcon(HugeIcons.strokeRoundedPresentation03, iconColor),
+ );
+ }
EntePopupMenuOption<AlbumPopupAction> _menuOption(
AlbumPopupAction value,
@@ -986,7 +1010,16 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {
}
Future<void> _startAlbumSlideshow() async {
- final galleryFiles = await _loadAllCollectionFiles();
+ final dialog = createProgressDialog(context, context.strings.pleaseWait);
+ await dialog.show();
+ List<EnteFile>? galleryFiles;
+ try {
+ galleryFiles = await _loadAllGalleryFiles();
+ } catch (e, s) {
+ _logger.severe("Failed to load files for album slideshow", e, s);
+ } finally {
+ await dialog.hide();
+ }
if (!mounted) return;
if (galleryFiles == null) {
showToast(context, context.strings.somethingWentWrong);
@@ -996,15 +1029,27 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {
await showAlbumSlideshow(
context,
files: galleryFiles,
- title: widget.collection!.displayName,
+ title: widget.deviceCollection?.name ?? widget.collection!.displayName,
+ includeBackupExcludedFiles: widget.deviceCollection != null,
);
}
- Future<List<EnteFile>?> _loadAllCollectionFiles() async {
+ Future<List<EnteFile>?> _loadAllGalleryFiles() async {
if (widget.files != null) {
return widget.files!;
}
+ final deviceCollection = widget.deviceCollection;
+ if (deviceCollection != null) {
+ final filesResult = await FilesDB.instance.getFilesInDeviceCollection(
+ deviceCollection,
+ Configuration.instance.getUserID(),
+ galleryLoadStartTime,
+ galleryLoadEndTime,
+ );
+ return filesResult.files;
+ }
+
final collection = widget.collection;
if (collection == null) {
return null;
@@ -1276,7 +1321,7 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {
Future<void> _onGalleryGuestViewClick() async {
if (await LocalAuthentication().isDeviceSupported()) {
- final collectionFiles = await _loadAllCollectionFiles();
+ final collectionFiles = await _loadAllGalleryFiles();
if (!mounted) return;
if (collectionFiles == null) {
showToast(context, context.strings.somethingWentWrong);