π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mobile][photos] Clarify recoverable delete copy
Priyanshu Dangare6fce24028342
diff --git a/mobile/apps/photos/lib/ui/actions/file/file_actions.dart b/mobile/apps/photos/lib/ui/actions/file/file_actions.dartindex ac8c4a8be7..06b00e2761 100644--- a/mobile/apps/photos/lib/ui/actions/file/file_actions.dart+++ b/mobile/apps/photos/lib/ui/actions/file/file_actions.dart@@ -35,28 +35,25 @@ Future<void> showSingleFileDeleteSheet((await isAndroidSDKVersionLowerThan(android11SDKINT) ||await PhotoManager.canManageMedia())) {if (!context.mounted) return;- await showBottomSheetComponent<bool>(- context: context,- useRootNavigator: Platform.isIOS,- builder: (_) => DeleteConfirmationSheet(- count: 1,- isLocal: isLocal,- isRemote: false,- onDeleteFromLocal: () async {- final deletedFiles = await deleteFilesOnDeviceOnly(context, [file]);- final didDelete = deletedFiles.isNotEmpty;- if (didDelete && ((isLocal && !isRemote) || isLocalOnlyContext)) {- onFileRemoved?.call(file);- }- return didDelete;- },- onDeleteFromRemote: () async {- throw AssertionError("delete from remote in local gallery mode");- },- onDeleteFromBoth: () async {- throw AssertionError("delete from both in local gallery mode");- },- ),+ await showDeleteConfirmationSheet(+ context,+ count: 1,+ isLocal: isLocal,+ isRemote: false,+ onDeleteFromLocal: () async {+ final deletedFiles = await deleteFilesOnDeviceOnly(context, [file]);+ if (deletedFiles.isNotEmpty &&+ ((isLocal && !isRemote) || isLocalOnlyContext)) {+ onFileRemoved?.call(file);+ }+ return deletedFiles.isNotEmpty;+ },+ onDeleteFromRemote: () async {+ throw AssertionError("delete from remote in local gallery mode");+ },+ onDeleteFromBoth: () async {+ throw AssertionError("delete from both in local gallery mode");+ },);} else {if (!context.mounted) return;@@ -71,39 +68,35 @@ Future<void> showSingleFileDeleteSheet(if (!isLocal && !isRemote) {throw AssertionError("Unexpected state");}- final didDelete = await showBottomSheetComponent<bool>(- context: context,- useRootNavigator: Platform.isIOS,- builder: (_) => DeleteConfirmationSheet(- isLocal: isLocal,- isRemote: isRemote,- count: 1,- onDeleteFromLocal: () async {- final deletedFiles = await deleteFilesOnDeviceOnly(context, [file]);- final didDelete = deletedFiles.isNotEmpty;- if (didDelete && ((isLocal && !isRemote) || isLocalOnlyContext)) {- onFileRemoved?.call(file);- }- return didDelete;- },- onDeleteFromRemote: () async {- await deleteFilesFromRemoteOnly(context, [file]);- if (!context.mounted) return false;- showShortToast(context, l10n.movedToTrash);- if (((isRemote && !isLocal) || !isLocalOnlyContext)) {- onFileRemoved?.call(file);- }- return true;- },- onDeleteFromBoth: () async {- final deletedFiles = await deleteFilesFromEverywhere(context, [file]);- final didDelete = deletedFiles.isNotEmpty;- if (didDelete) {- onFileRemoved?.call(file);- }- return didDelete;- },- ),+ final didDelete = await showDeleteConfirmationSheet(+ context,+ isLocal: isLocal,+ isRemote: isRemote,+ count: 1,+ onDeleteFromLocal: () async {+ final deletedFiles = await deleteFilesOnDeviceOnly(context, [file]);+ if (deletedFiles.isNotEmpty &&+ ((isLocal && !isRemote) || isLocalOnlyContext)) {+ onFileRemoved?.call(file);+ }+ return deletedFiles.isNotEmpty;+ },+ onDeleteFromRemote: () async {+ await deleteFilesFromRemoteOnly(context, [file]);+ if (!context.mounted) return false;+ showShortToast(context, l10n.movedToTrash);+ if (((isRemote && !isLocal) || !isLocalOnlyContext)) {+ onFileRemoved?.call(file);+ }+ return true;+ },+ onDeleteFromBoth: () async {+ final deletedFiles = await deleteFilesFromEverywhere(context, [file]);+ if (deletedFiles.isNotEmpty) {+ onFileRemoved?.call(file);+ }+ return deletedFiles.isNotEmpty;+ },);if (didDelete == true && isLocal) {if (!context.mounted) return;diff --git a/mobile/apps/photos/lib/utils/delete_file_util.dart b/mobile/apps/photos/lib/utils/delete_file_util.dartindex 77920ce5c4..a91b4d7ccf 100644--- a/mobile/apps/photos/lib/utils/delete_file_util.dart+++ b/mobile/apps/photos/lib/utils/delete_file_util.dart@@ -923,28 +923,23 @@ Future<void> showDeleteSheet(await PhotoManager.canManageMedia())) {if (!context.mounted) return;didDelete =- await showBottomSheetComponent<bool>(- context: context,- useRootNavigator: Platform.isIOS,- builder: (_) => DeleteConfirmationSheet(- count: localGalleryDeletableFiles.length,- isLocal: true,- isRemote: false,- onDeleteFromLocal: () async {- return deleteOnDeviceOnlyAction(- context,- localGalleryDeletableFiles,- );- },- onDeleteFromRemote: () async {- throw AssertionError(- "delete from remote in local gallery mode",- );- },- onDeleteFromBoth: () async {- throw AssertionError("delete from both in local gallery mode");- },- ),+ await showDeleteConfirmationSheet(+ context,+ count: localGalleryDeletableFiles.length,+ isLocal: true,+ isRemote: false,+ onDeleteFromLocal: () async {+ return await deleteOnDeviceOnlyAction(+ context,+ localGalleryDeletableFiles,+ );+ },+ onDeleteFromRemote: () async {+ throw AssertionError("delete from remote in local gallery mode");+ },+ onDeleteFromBoth: () async {+ throw AssertionError("delete from both in local gallery mode");+ },) ==true;} else {@@ -973,40 +968,34 @@ Future<void> showDeleteSheet(}var didDeleteLocalFiles = false;- final actionResult = await showBottomSheetComponent<bool>(- context: context,- useRootNavigator: Platform.isIOS,- builder: (_) => DeleteConfirmationSheet(- isLocal: hasLocalFiles,- isRemote: hasRemoteFiles,- count: deletableFiles.length,- onDeleteFromLocal: () async {- final didDelete = await deleteOnDeviceOnlyAction(- context,- deletableFiles,- );- didDeleteLocalFiles = didDelete;- return didDelete;- },- onDeleteFromRemote: () async {- final didDelete = await deleteFromRemoteOnlyAction(- context,- deletableFiles,- );- if (didDelete && context.mounted) {- showShortToast(context, l10n.movedToTrash);- }- return didDelete;- },- onDeleteFromBoth: () async {- final didDelete = await deleteFromEverywhereAction(- context,- deletableFiles,- );- didDeleteLocalFiles = didDelete;- return didDelete;- },- ),+ final actionResult = await showDeleteConfirmationSheet(+ context,+ isLocal: hasLocalFiles,+ isRemote: hasRemoteFiles,+ count: deletableFiles.length,+ onDeleteFromLocal: () async {+ final didDelete = await deleteOnDeviceOnlyAction(context, deletableFiles);+ didDeleteLocalFiles = didDelete;+ return didDelete;+ },+ onDeleteFromRemote: () async {+ final didDelete = await deleteFromRemoteOnlyAction(+ context,+ deletableFiles,+ );+ if (didDelete && context.mounted) {+ showShortToast(context, l10n.movedToTrash);+ }+ return didDelete;+ },+ onDeleteFromBoth: () async {+ final didDelete = await deleteFromEverywhereAction(+ context,+ deletableFiles,+ );+ didDeleteLocalFiles = didDelete;+ return didDelete;+ },);if (actionResult == true) {selectedFiles.clearAll();@@ -1115,18 +1104,49 @@ class _MoreOptionsButtonState extends State<_MoreOptionsButton> {}}-class DeleteConfirmationSheet extends StatefulWidget {+Future<bool?> showDeleteConfirmationSheet(+ BuildContext context, {+ required bool isLocal,+ required bool isRemote,+ required int count,+ required Future<bool> Function() onDeleteFromLocal,+ required Future<bool> Function() onDeleteFromRemote,+ required Future<bool> Function() onDeleteFromBoth,+}) async {+ final isTrashAction =+ Platform.isIOS ||+ (Platform.isAndroid &&+ flagService.internalUser &&+ !await isAndroidSDKVersionLowerThan(android11SDKINT));+ if (!context.mounted) return null;+ return showBottomSheetComponent<bool>(+ context: context,+ useRootNavigator: Platform.isIOS,+ builder: (_) => _DeleteConfirmationSheet(+ isLocal: isLocal,+ isRemote: isRemote,+ isTrashAction: isTrashAction,+ count: count,+ onDeleteFromLocal: onDeleteFromLocal,+ onDeleteFromRemote: onDeleteFromRemote,+ onDeleteFromBoth: onDeleteFromBoth,+ ),+ );+}++class _DeleteConfirmationSheet extends StatefulWidget {final bool isLocal;final bool isRemote;+ final bool isTrashAction;final int count;final Future<bool> Function() onDeleteFromLocal;final Future<bool> Function() onDeleteFromRemote;final Future<bool> Function() onDeleteFromBoth;- const DeleteConfirmationSheet({- super.key,+ const _DeleteConfirmationSheet({required this.isLocal,required this.isRemote,+ required this.isTrashAction,required this.count,required this.onDeleteFromLocal,required this.onDeleteFromRemote,@@ -1135,11 +1155,11 @@ class DeleteConfirmationSheet extends StatefulWidget {@overrideState<StatefulWidget> createState() {- return DeleteConfirmationSheetState();+ return _DeleteConfirmationSheetState();}}-class DeleteConfirmationSheetState extends State<DeleteConfirmationSheet> {+class _DeleteConfirmationSheetState extends State<_DeleteConfirmationSheet> {var _isMoreOptionsShown = false;var _isSetAsDefaultSelected = false;@@ -1179,12 +1199,14 @@ class DeleteConfirmationSheetState extends State<DeleteConfirmationSheet> {Widget build(BuildContext context) {final l10n = context.strings;final title = l10n.deleteItemsQuestion(count: widget.count);- var body = l10n.selectedFilesSavedOnDeviceOnly;+ var body = widget.isTrashAction+ ? l10n.filesCanBeRestoredFromTrash(count: widget.count)+ : l10n.selectedFilesSavedOnDeviceOnly;if (widget.count == 1 && widget.isLocal && widget.isRemote) {body = l10n.singleFileInBothLocalAndRemote;} else if (widget.count == 1 && widget.isRemote) {body = l10n.singleFileInRemoteOnly;- } else if (widget.count == 1 && widget.isLocal) {+ } else if (widget.count == 1 && widget.isLocal && !widget.isTrashAction) {body = l10n.singleFileDeleteFromDevice;} else if (widget.isLocal && widget.isRemote) {body = l10n.someSelectedFilesBackedUpToEnte;diff --git a/mobile/packages/strings/lib/l10n/arb/strings_en.arb b/mobile/packages/strings/lib/l10n/arb/strings_en.arbindex e29b1e048a..7abadc9c84 100644--- a/mobile/packages/strings/lib/l10n/arb/strings_en.arb+++ b/mobile/packages/strings/lib/l10n/arb/strings_en.arb@@ -1660,6 +1660,16 @@}},"fileSavedToGallery": "File saved to gallery",+ "filesCanBeRestoredFromTrash": "{count, plural, one{Item not backed up. It can be restored from Trash.} other{Items not backed up. They can be restored from Trash.}}",+ "@filesCanBeRestoredFromTrash": {+ "description": "Delete confirmation message for device-only items that will be moved to trash.",+ "placeholders": {+ "count": {+ "type": "int",+ "example": "2"+ }+ }+ },"filesDeleted": "Files deleted","filesDeletedPermanently": "{count, plural, one{{count} item deleted permanently} other{{count} items deleted permanently}}","@filesDeletedPermanently": {