π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mob][photos] Warn about missing locations in shared photo backups
r4khul65f3cdc19147
diff --git a/mobile/apps/photos/changes/shared-photo-location-warning.md b/mobile/apps/photos/changes/shared-photo-location-warning.mdnew file mode 100644index 0000000000..b01a69ed99--- /dev/null+++ b/mobile/apps/photos/changes/shared-photo-location-warning.md@@ -0,0 +1 @@+- Added a reminder that photos shared from another app may not include their locations, with an option to hide the reminder.diff --git a/mobile/apps/photos/lib/settings/local_settings.dart b/mobile/apps/photos/lib/settings/local_settings.dartindex ce56ac9848..8033629b9e 100644--- a/mobile/apps/photos/lib/settings/local_settings.dart+++ b/mobile/apps/photos/lib/settings/local_settings.dart@@ -130,6 +130,8 @@ class LocalSettings {static const _kAppMode = "ls.app_mode";static const _kShowLocalGalleryModeOption = "ls.show_offline_mode_option";static const _kDeletePreference = "delete_preference";+ static const _kSharedPhotoLocationWarningDismissed =+ "shared_photo_location_warning_dismissed";static const _kMediaManagementHintDeleteAttempts ="media_management_hint_delete_attempts";static const _kMediaManagementHintDismissedAt =@@ -882,6 +884,13 @@ class LocalSettings {);}+ bool get isSharedPhotoLocationWarningDismissed =>+ _prefs.getBool(_kSharedPhotoLocationWarningDismissed) ?? false;++ Future<void> dismissSharedPhotoLocationWarning() async {+ await _prefs.setBool(_kSharedPhotoLocationWarningDismissed, true);+ }+DeletePreference? getDeletePreference() {if (!_prefs.containsKey(_kDeletePreference)) {return null;diff --git a/mobile/apps/photos/lib/ui/collections/album/vertical_list.dart b/mobile/apps/photos/lib/ui/collections/album/vertical_list.dartindex 6d31068a2c..74bdf41fa5 100644--- a/mobile/apps/photos/lib/ui/collections/album/vertical_list.dart+++ b/mobile/apps/photos/lib/ui/collections/album/vertical_list.dart@@ -21,6 +21,7 @@ import "package:photos/ui/actions/collection/collection_sharing_actions.dart";import "package:photos/ui/collections/album/column_item.dart";import "package:photos/ui/collections/album/new_list_item.dart";import 'package:photos/ui/collections/collection_action_sheet.dart';+import "package:photos/ui/collections/shared_media_backup_sheet.dart";import 'package:photos/ui/notification/toast.dart';import "package:photos/ui/sharing/share_collection_page.dart";import 'package:photos/ui/viewer/gallery/collection_page.dart';@@ -67,6 +68,8 @@ class AlbumVerticalListWidget extends StatefulWidget {class _AlbumVerticalListWidgetState extends State<AlbumVerticalListWidget> {final _logger = Logger("CollectionsListWidgetState");+ bool _hasConfirmedSharedMediaBackup = false;+ bool _isConfirmingSharedMediaBackup = false;final CollectionActions _collectionActions = CollectionActions(CollectionsService.instance,@@ -325,6 +328,9 @@ class _AlbumVerticalListWidgetState extends State<AlbumVerticalListWidget> {Future<void> _nameAlbum(BuildContext context, String albumName) async {if (albumName.isNotEmpty) {+ if (!await _confirmSharedMediaBackup(context) || !context.mounted) {+ return;+ }bool hasVerifiedLock = false;late final Collection? collection;@@ -500,6 +506,9 @@ class _AlbumVerticalListWidgetState extends State<AlbumVerticalListWidget> {int collectionID,bool showProgressDialog,) async {+ if (!await _confirmSharedMediaBackup(context) || !context.mounted) {+ return false;+ }final bool result = await _collectionActions.addToCollection(context,collectionID,@@ -514,6 +523,22 @@ class _AlbumVerticalListWidgetState extends State<AlbumVerticalListWidget> {return result;}+ Future<bool> _confirmSharedMediaBackup(BuildContext context) async {+ final sharedFiles = widget.sharedFiles;+ if (sharedFiles == null || _hasConfirmedSharedMediaBackup) return true;+ if (_isConfirmingSharedMediaBackup) return false;+ _isConfirmingSharedMediaBackup = true;+ try {+ _hasConfirmedSharedMediaBackup = await confirmSharedMediaBackup(+ context,+ sharedFiles,+ );+ return _hasConfirmedSharedMediaBackup;+ } finally {+ _isConfirmingSharedMediaBackup = false;+ }+ }+Future<bool> _moveFilesToCollection(BuildContext context,int toCollectionID,diff --git a/mobile/apps/photos/lib/ui/collections/shared_media_backup_sheet.dart b/mobile/apps/photos/lib/ui/collections/shared_media_backup_sheet.dartnew file mode 100644index 0000000000..b6b1761dac--- /dev/null+++ b/mobile/apps/photos/lib/ui/collections/shared_media_backup_sheet.dart@@ -0,0 +1,71 @@+import "package:ente_components/ente_components.dart";+import "package:ente_strings/ente_strings.dart";+import "package:flutter/material.dart";+import "package:photos/service_locator.dart";+import "package:receive_sharing_intent/receive_sharing_intent.dart";++Future<bool> confirmSharedMediaBackup(+ BuildContext context,+ List<SharedMediaFile> files,+) async {+ final hasPhotos = files.any(+ (file) =>+ file.type == SharedMediaType.image ||+ (file.mimeType?.startsWith("image/") ?? false),+ );+ if (!hasPhotos || localSettings.isSharedPhotoLocationWarningDismissed) {+ return true;+ }++ var dontShowAgain = false;+ final confirmed = await showBottomSheetComponent<bool>(+ context: context,+ builder: (sheetContext) => StatefulBuilder(+ builder: (context, setState) {+ final l10n = context.strings;+ return SingleChildScrollView(+ child: BottomSheetComponent(+ title: l10n.sharedPhotoLocationWarningTitle,+ message: l10n.sharedPhotoLocationWarningMessage(+ addFromDevice: l10n.addFromDevice,+ ),+ illustration: Image.asset("assets/warning-grey.png"),+ closeTooltip: l10n.close,+ closeResult: false,+ actions: [+ ButtonComponent(+ label: l10n.add,+ shouldSurfaceExecutionStates: false,+ onTap: () => Navigator.of(sheetContext).pop(true),+ ),+ ConstrainedBox(+ constraints: const BoxConstraints(minHeight: 48),+ child: Center(+ child: MergeSemantics(+ child: Semantics(+ checked: dontShowAgain,+ child: LabeledControlComponent(+ control: CheckboxComponent(+ selected: dontShowAgain,+ onChanged: (value) =>+ setState(() => dontShowAgain = value),+ ),+ label: l10n.dontShowAgain,+ foreground: context.componentColors.textLight,+ onTap: () =>+ setState(() => dontShowAgain = !dontShowAgain),+ ),+ ),+ ),+ ),+ ),+ ],+ ),+ );+ },+ ),+ );+ if (confirmed != true) return false;+ if (dontShowAgain) await localSettings.dismissSharedPhotoLocationWarning();+ return true;+}diff --git a/mobile/packages/strings/lib/l10n/arb/strings_en.arb b/mobile/packages/strings/lib/l10n/arb/strings_en.arbindex ba78865e75..1e565ae4f8 100644--- a/mobile/packages/strings/lib/l10n/arb/strings_en.arb+++ b/mobile/packages/strings/lib/l10n/arb/strings_en.arb@@ -1109,6 +1109,10 @@"doesGroupContainMultiplePeople": "Does this grouping contain multiple people?","dog": "Dog","done": "Done",+ "dontShowAgain": "Donβt show again",+ "@dontShowAgain": {+ "description": "Checkbox label for hiding an informational notice after confirming the action"+ },"doNotSignOut": "Do not sign out","@doNotSignOut": {"description": "Do not sign out button label"@@ -4130,6 +4134,12 @@}},"sharedPhotoNotifications": "New shared photos and albums",+ "sharedPhotoLocationWarningTitle": "May lack location",+ "sharedPhotoLocationWarningMessage": "Photos shared from other apps may lose their location data. Use β{addFromDevice}β in an album to preserve it.",+ "@sharedPhotoLocationWarningMessage": {+ "description": "Precaution before backing up photos shared from another app. addFromDevice is the localized action label.",+ "placeholders": {"addFromDevice": {"type": "String"}}+ },"sharedPhotoNotificationsExplanation": "New photos and albums you are in or shared with you","sharedWith": "Shared with","shareItemCount": "{count, plural, one{Share {count} item} other{Share {count} items}}",