Skip to content

armgit / ente

Public Imported from GitHub
0

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

[mobile/photos] Add collection-level guest view

Neerajaae3e3cf1f84
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 e37293bbbd..1afd17ba8a 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
@@ -5,6 +5,8 @@ import 'dart:math' as math;
import "package:flutter/cupertino.dart";
import "package:flutter/foundation.dart";
import 'package:flutter/material.dart';
+import "package:flutter_svg/flutter_svg.dart";
+import "package:local_auth/local_auth.dart";
import 'package:logging/logging.dart';
import 'package:photos/core/configuration.dart';
import "package:photos/core/constants.dart";
@@ -12,6 +14,7 @@ import 'package:photos/core/event_bus.dart';
import "package:photos/core/network/network.dart";
import "package:photos/db/files_db.dart";
import "package:photos/events/collection_meta_event.dart";
+import "package:photos/events/guest_view_event.dart";
import "package:photos/events/magic_sort_change_event.dart";
import 'package:photos/events/subscription_purchased_event.dart';
import "package:photos/gateways/cast_gw.dart";
@@ -48,6 +51,7 @@ import 'package:photos/ui/sharing/album_participants_page.dart';
import "package:photos/ui/sharing/manage_links_widget.dart";
import 'package:photos/ui/sharing/share_collection_page.dart';
import 'package:photos/ui/tools/free_space_page.dart';
+import "package:photos/ui/viewer/file/detail_page.dart";
import "package:photos/ui/viewer/gallery/hooks/add_photos_sheet.dart";
import 'package:photos/ui/viewer/gallery/hooks/pick_cover_photo.dart';
import "package:photos/ui/viewer/gallery/state/inherited_search_filter_data.dart";
@@ -107,6 +111,7 @@ enum AlbumPopupAction {
sortByMostRelevant,
editLocation,
deleteLocation,
+ galleryGuestView,
}
class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {
@@ -165,6 +170,7 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {
InheritedSearchFilterData.maybeOf(context);
final isHierarchicalSearchable =
inheritedSearchFilterData?.isHierarchicalSearchable ?? false;
+
return galleryType == GalleryType.homepage
? const SizedBox.shrink()
: isHierarchicalSearchable
@@ -610,6 +616,21 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {
? Icons.download
: Icons.cloud_download_outlined,
),
+ // Gallery Guest View option - Internal user only
+ if (flagService.albumGuestView && widget.collection != null)
+ EntePopupMenuItem(
+ AppLocalizations.of(context).guestView + " (i)",
+ value: AlbumPopupAction.galleryGuestView,
+ iconWidget: SvgPicture.asset(
+ "assets/icons/guest_view_icon.svg",
+ width: 20,
+ height: 20,
+ colorFilter: ColorFilter.mode(
+ getEnteColorScheme(context).textBase,
+ BlendMode.srcIn,
+ ),
+ ),
+ ),
];
if (items.isEmpty) {
@@ -684,6 +705,9 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {
editLocation();
} else if (value == AlbumPopupAction.deleteLocation) {
await deleteLocation();
+ } else if (value == AlbumPopupAction.galleryGuestView &&
+ flagService.albumGuestView) {
+ await _onGalleryGuestViewClick();
} else {
showToast(context, AppLocalizations.of(context).somethingWentWrong);
}
@@ -1089,4 +1113,57 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {
return false;
}
}
+
+ Future<void> _onGalleryGuestViewClick() async {
+ if (!flagService.albumGuestView) return;
+
+ if (await LocalAuthentication().isDeviceSupported()) {
+ // Get all files from the collection with proper sort order
+ late final List<EnteFile> collectionFiles;
+ if (widget.files != null) {
+ // If files are already provided, use them
+ collectionFiles = widget.files!;
+ } else if (widget.collection != null) {
+ // Fetch all files from the collection
+ final filesResult = await FilesDB.instance.getFilesInCollection(
+ widget.collection!.id,
+ galleryLoadStartTime,
+ galleryLoadEndTime,
+ asc: widget.collection!.pubMagicMetadata.asc ?? false,
+ );
+ collectionFiles = filesResult.files;
+ } else {
+ showToast(context, AppLocalizations.of(context).somethingWentWrong);
+ return;
+ }
+
+ if (collectionFiles.isEmpty) {
+ showToast(
+ context,
+ AppLocalizations.of(context).nothingToSeeHere,
+ );
+ return;
+ }
+
+ // Use the same logic as selected files guest view
+ final page = DetailPage(
+ DetailPageConfiguration(
+ collectionFiles,
+ 0,
+ "guest_view",
+ ),
+ );
+ await localSettings.setOnGuestView(true);
+ routeToPage(context, page, forceCustomPageRoute: true).ignore();
+ WidgetsBinding.instance.addPostFrameCallback((_) {
+ Bus.instance.fire(GuestViewEvent(true, false));
+ });
+ } else {
+ await showErrorDialog(
+ context,
+ AppLocalizations.of(context).noSystemLockFound,
+ AppLocalizations.of(context).guestViewEnablePreSteps,
+ );
+ }
+ }
}
diff --git a/mobile/apps/photos/plugins/ente_feature_flag/lib/src/service.dart b/mobile/apps/photos/plugins/ente_feature_flag/lib/src/service.dart
index b308588a94..4f95686c64 100644
--- a/mobile/apps/photos/plugins/ente_feature_flag/lib/src/service.dart
+++ b/mobile/apps/photos/plugins/ente_feature_flag/lib/src/service.dart
@@ -64,6 +64,8 @@ class FlagService {
String get customDomain => flags.customDomain;
+ bool get albumGuestView => internalUser;
+
bool hasSyncedAccountFlags() {
return _prefs.containsKey("remote_flags");
}
diff --git a/mobile/apps/photos/scripts/internal_changes.txt b/mobile/apps/photos/scripts/internal_changes.txt
index dcc6925cc3..d301e21426 100644
--- a/mobile/apps/photos/scripts/internal_changes.txt
+++ b/mobile/apps/photos/scripts/internal_changes.txt
@@ -1,3 +1,4 @@
+- Neeraj: (i) Add collection-level guest view option in album overflow menu
- Neeraj: (i) Add allow joining album option in manage links
- Neeraj: Fix lock error + improve logViewer
- Laurens: text embedding caching for memories and discover