Skip to content

armgit / ente

Public Imported from GitHub
0

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

Fix delete all button sizing and add selection actions for hidden cleanup

ashilkn3d23a475a269
diff --git a/mobile/apps/photos/lib/l10n/intl_en.arb b/mobile/apps/photos/lib/l10n/intl_en.arb
index 68b153435a..d0d4cad645 100644
--- a/mobile/apps/photos/lib/l10n/intl_en.arb
+++ b/mobile/apps/photos/lib/l10n/intl_en.arb
@@ -2527,7 +2527,8 @@
"cleanupHiddenFilesDescription": "Some files in hidden albums still exist in non-hidden albums making them visible outside of the hidden section. Cleaning up will remove them from non-hidden albums.",
"cleanupComplete": "Cleanup complete",
"deleteHiddenFilesFromDevice": "Delete hidden files from device",
- "deleteHiddenFilesFromDeviceDescription": "Delete local copies of hidden files from your device while keeping them safe in the cloud.",
+ "deleteHiddenFilesFromDeviceDescription": "Delete local copies of hidden files from your device",
+ "deleteOnDeviceFiles": "Delete on device files",
"noHiddenFilesOnDevice": "No hidden files on device",
"deleteSelectedFromDevice": "Delete selected from device",
"deleteFromDeviceConfirmation": "Are you sure you want to delete {count, plural, =1{1 file} other{{count} files}} from your device? The files will remain safe in the cloud.",
diff --git a/mobile/apps/photos/lib/models/gallery_type.dart b/mobile/apps/photos/lib/models/gallery_type.dart
index 6fe9fefd42..88e8187131 100644
--- a/mobile/apps/photos/lib/models/gallery_type.dart
+++ b/mobile/apps/photos/lib/models/gallery_type.dart
@@ -23,6 +23,7 @@ enum GalleryType {
cluster,
sharedPublicCollection,
magic,
+ cleanupHiddenFromDevice,
}
extension GalleyTypeExtension on GalleryType {
@@ -48,6 +49,7 @@ extension GalleyTypeExtension on GalleryType {
case GalleryType.cluster:
case GalleryType.sharedPublicCollection:
case GalleryType.deleteSuggestions:
+ case GalleryType.cleanupHiddenFromDevice:
return false;
}
}
@@ -74,6 +76,7 @@ extension GalleyTypeExtension on GalleryType {
case GalleryType.sharedPublicCollection:
case GalleryType.magic:
case GalleryType.deleteSuggestions:
+ case GalleryType.cleanupHiddenFromDevice:
return false;
}
}
@@ -101,6 +104,7 @@ extension GalleyTypeExtension on GalleryType {
case GalleryType.sharedCollection:
case GalleryType.sharedPublicCollection:
case GalleryType.deleteSuggestions:
+ case GalleryType.cleanupHiddenFromDevice:
return false;
}
}
@@ -126,6 +130,7 @@ extension GalleyTypeExtension on GalleryType {
case GalleryType.trash:
case GalleryType.sharedPublicCollection:
case GalleryType.deleteSuggestions:
+ case GalleryType.cleanupHiddenFromDevice:
return false;
}
}
@@ -151,6 +156,7 @@ extension GalleyTypeExtension on GalleryType {
case GalleryType.quickLink:
case GalleryType.sharedPublicCollection:
case GalleryType.deleteSuggestions:
+ case GalleryType.cleanupHiddenFromDevice:
return false;
}
}
@@ -176,6 +182,7 @@ extension GalleyTypeExtension on GalleryType {
case GalleryType.sharedPublicCollection:
case GalleryType.magic:
case GalleryType.deleteSuggestions:
+ case GalleryType.cleanupHiddenFromDevice:
return false;
}
}
@@ -202,6 +209,7 @@ extension GalleyTypeExtension on GalleryType {
case GalleryType.cluster:
case GalleryType.sharedPublicCollection:
case GalleryType.deleteSuggestions:
+ case GalleryType.cleanupHiddenFromDevice:
return false;
}
}
@@ -232,6 +240,7 @@ extension GalleyTypeExtension on GalleryType {
case GalleryType.sharedCollection:
case GalleryType.sharedPublicCollection:
case GalleryType.deleteSuggestions:
+ case GalleryType.cleanupHiddenFromDevice:
return false;
}
}
@@ -263,6 +272,7 @@ extension GalleyTypeExtension on GalleryType {
case GalleryType.sharedCollection:
case GalleryType.sharedPublicCollection:
case GalleryType.deleteSuggestions:
+ case GalleryType.cleanupHiddenFromDevice:
return false;
}
}
@@ -293,6 +303,7 @@ extension GalleyTypeExtension on GalleryType {
case GalleryType.localFolder:
case GalleryType.hiddenSection:
case GalleryType.hiddenOwnedCollection:
+ case GalleryType.cleanupHiddenFromDevice:
return false;
}
}
@@ -320,11 +331,15 @@ extension GalleyTypeExtension on GalleryType {
}
bool showEditLocation() {
- return this != GalleryType.sharedCollection && this != GalleryType.cluster;
+ return this != GalleryType.sharedCollection &&
+ this != GalleryType.cluster &&
+ this != GalleryType.cleanupHiddenFromDevice;
}
bool showBulkEditTime() {
- return this != GalleryType.sharedCollection && this != GalleryType.cluster;
+ return this != GalleryType.sharedCollection &&
+ this != GalleryType.cluster &&
+ this != GalleryType.cleanupHiddenFromDevice;
}
}
@@ -423,6 +438,7 @@ extension GalleryAppBarExtn on GalleryType {
case GalleryType.magic:
case GalleryType.sharedPublicCollection:
case GalleryType.deleteSuggestions:
+ case GalleryType.cleanupHiddenFromDevice:
return false;
case GalleryType.uncategorized:
case GalleryType.cluster:
diff --git a/mobile/apps/photos/lib/services/notification_service.dart b/mobile/apps/photos/lib/services/notification_service.dart
index 2bc4193d37..f124ff74c5 100644
--- a/mobile/apps/photos/lib/services/notification_service.dart
+++ b/mobile/apps/photos/lib/services/notification_service.dart
@@ -23,7 +23,8 @@ class NotificationService {
final FlutterLocalNotificationsPlugin _notificationsPlugin =
FlutterLocalNotificationsPlugin();
final _logger = Logger("NotificationService");
- void Function(NotificationResponse notificationResponse)? _onNotificationTapped;
+ void Function(NotificationResponse notificationResponse)?
+ _onNotificationTapped;
bool _pluginInitialized = false;
bool _launchDetailsHandled = false;
diff --git a/mobile/apps/photos/lib/services/video_preview_service.dart b/mobile/apps/photos/lib/services/video_preview_service.dart
index d30f37ac0a..64921a438f 100644
--- a/mobile/apps/photos/lib/services/video_preview_service.dart
+++ b/mobile/apps/photos/lib/services/video_preview_service.dart
@@ -113,7 +113,7 @@ class VideoPreviewService {
static const String _videoStreamingEnabled = "videoStreamingEnabled";
bool get isVideoStreamingEnabled {
- if(isOfflineMode) {
+ if (isOfflineMode) {
return false;
}
if (flagService.internalUser) {
diff --git a/mobile/apps/photos/lib/ui/viewer/actions/file_selection_actions_widget.dart b/mobile/apps/photos/lib/ui/viewer/actions/file_selection_actions_widget.dart
index c8831d549b..ad0c630c53 100644
--- a/mobile/apps/photos/lib/ui/viewer/actions/file_selection_actions_widget.dart
+++ b/mobile/apps/photos/lib/ui/viewer/actions/file_selection_actions_widget.dart
@@ -180,6 +180,14 @@ class _FileSelectionActionsWidgetState
onTap: _permanentlyDelete,
),
);
+ } else if (widget.type == GalleryType.cleanupHiddenFromDevice) {
+ items.add(
+ SelectionActionButton(
+ icon: Icons.delete_outline,
+ labelText: AppLocalizations.of(context).deleteFromDevice,
+ onTap: _deleteSelectedFromDevice,
+ ),
+ );
} else if (widget.type == GalleryType.deleteSuggestions) {
items.add(
SelectionActionButton(
@@ -1046,6 +1054,52 @@ class _FileSelectionActionsWidgetState
}
}
+ Future<void> _deleteSelectedFromDevice() async {
+ final filesToDelete = widget.selectedFiles.files.toList();
+ final count = filesToDelete.length;
+ final l10n = AppLocalizations.of(context);
+
+ final actionResult = await showActionSheet(
+ context: context,
+ buttons: [
+ ButtonWidget(
+ labelText: l10n.deleteSelectedFromDevice,
+ buttonType: ButtonType.critical,
+ buttonSize: ButtonSize.large,
+ shouldStickToDarkTheme: true,
+ buttonAction: ButtonAction.first,
+ shouldSurfaceExecutionStates: true,
+ isInAlert: true,
+ onTap: () async {
+ try {
+ await deleteFilesOnDeviceOnly(context, filesToDelete);
+ } catch (e) {
+ if (context.mounted) {
+ await showGenericErrorDialog(context: context, error: e);
+ }
+ rethrow;
+ }
+ },
+ ),
+ ButtonWidget(
+ labelText: l10n.cancel,
+ buttonType: ButtonType.secondary,
+ buttonSize: ButtonSize.large,
+ shouldStickToDarkTheme: true,
+ buttonAction: ButtonAction.cancel,
+ isInAlert: true,
+ ),
+ ],
+ title: l10n.deleteFromDevice,
+ body: l10n.deleteFromDeviceConfirmation(count: count),
+ actionSheetType: ActionSheetType.defaultActionSheet,
+ );
+
+ if (actionResult?.action == ButtonAction.first) {
+ widget.selectedFiles.clearAll();
+ }
+ }
+
Future<void> _download(List<EnteFile> files) async {
final totalFiles = files.length;
int downloadedFiles = 0;
diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/cleanup_hidden_from_device_page.dart b/mobile/apps/photos/lib/ui/viewer/gallery/cleanup_hidden_from_device_page.dart
index 9c5e149e7a..60bf7e98ce 100644
--- a/mobile/apps/photos/lib/ui/viewer/gallery/cleanup_hidden_from_device_page.dart
+++ b/mobile/apps/photos/lib/ui/viewer/gallery/cleanup_hidden_from_device_page.dart
@@ -1,18 +1,23 @@
+import "dart:ui";
+
import "package:flutter/material.dart";
import "package:photos/core/event_bus.dart";
import "package:photos/events/files_updated_event.dart";
import "package:photos/events/local_photos_updated_event.dart";
import "package:photos/generated/l10n.dart";
import "package:photos/models/file_load_result.dart";
+import "package:photos/models/gallery_type.dart";
import "package:photos/models/selected_files.dart";
import "package:photos/services/collections_service.dart";
import "package:photos/services/hidden_service.dart";
-import "package:photos/theme/ente_theme.dart";
+import "package:photos/ui/common/bottom_shadow.dart";
import "package:photos/ui/components/action_sheet_widget.dart";
import "package:photos/ui/components/buttons/button_widget.dart";
import "package:photos/ui/components/models/button_type.dart";
+import "package:photos/ui/viewer/actions/file_selection_overlay_bar.dart";
import "package:photos/ui/viewer/gallery/empty_state.dart";
import "package:photos/ui/viewer/gallery/gallery.dart";
+import "package:photos/ui/viewer/gallery/gallery_app_bar_widget.dart";
import "package:photos/ui/viewer/gallery/state/gallery_boundaries_provider.dart";
import "package:photos/ui/viewer/gallery/state/gallery_files_inherited_widget.dart";
import "package:photos/ui/viewer/gallery/state/selection_state.dart";
@@ -54,8 +59,7 @@ class _CleanupHiddenFromDevicePageState
@override
Widget build(BuildContext context) {
- final colorScheme = getEnteColorScheme(context);
- final textTheme = getEnteTextTheme(context);
+ final filesAreSelected = _selectedFiles.files.isNotEmpty;
final gallery = Gallery(
asyncLoader: (creationStartTime, creationEndTime, {limit, asc}) async {
@@ -67,7 +71,6 @@ class _CleanupHiddenFromDevicePageState
removalEventTypes: const {EventType.deletedFromDevice},
tagPrefix: "cleanup_hidden_from_device",
selectedFiles: _selectedFiles,
- inSelectionMode: true,
enableFileGrouping: false,
emptyState: EmptyState(
text: AppLocalizations.of(context).noHiddenFilesOnDevice,
@@ -77,43 +80,100 @@ class _CleanupHiddenFromDevicePageState
return GalleryBoundariesProvider(
child: GalleryFilesState(
child: Scaffold(
- appBar: AppBar(
- elevation: 0,
- title: Text(
- AppLocalizations.of(context).deleteHiddenFilesFromDevice,
- style: textTheme.h3Bold,
+ appBar: PreferredSize(
+ preferredSize: const Size.fromHeight(50.0),
+ child: GalleryAppBarWidget(
+ GalleryType.cleanupHiddenFromDevice,
+ AppLocalizations.of(context).deleteOnDeviceFiles,
+ _selectedFiles,
),
- actions: [
- if (_selectedFiles.files.isNotEmpty)
- TextButton(
- onPressed: _deleteSelected,
- child: Text(
- "${AppLocalizations.of(context).delete} (${_selectedFiles.files.length})",
- style: textTheme.bodyBold.copyWith(
- color: colorScheme.primary500,
- ),
- ),
- ),
- ],
),
body: SelectionState(
selectedFiles: _selectedFiles,
- child: gallery,
+ child: Stack(
+ alignment: Alignment.bottomCenter,
+ children: [
+ gallery,
+ const BottomShadowWidget(
+ offsetDy: 20,
+ ),
+ AnimatedContainer(
+ duration: const Duration(milliseconds: 300),
+ curve: Curves.easeInOut,
+ height: filesAreSelected ? 0 : 80,
+ child: AnimatedOpacity(
+ duration: const Duration(milliseconds: 100),
+ opacity: filesAreSelected ? 0.0 : 1.0,
+ curve: Curves.easeIn,
+ child: IgnorePointer(
+ ignoring: filesAreSelected,
+ child: SafeArea(
+ minimum: const EdgeInsets.only(bottom: 6),
+ child: _deleteAllButton(context),
+ ),
+ ),
+ ),
+ ),
+ FileSelectionOverlayBar(
+ GalleryType.cleanupHiddenFromDevice,
+ _selectedFiles,
+ ),
+ ],
+ ),
),
),
),
);
}
- Future<void> _deleteSelected() async {
- final count = _selectedFiles.files.length;
- final l10n = AppLocalizations.of(context);
+ Widget _deleteAllButton(BuildContext context) {
+ return Row(
+ crossAxisAlignment: CrossAxisAlignment.end,
+ mainAxisAlignment: MainAxisAlignment.center,
+ children: [
+ ClipRRect(
+ borderRadius: BorderRadius.circular(24),
+ child: InkWell(
+ onTap: _deleteAll,
+ child: BackdropFilter(
+ filter: ImageFilter.blur(sigmaX: 20, sigmaY: 20),
+ child: Container(
+ height: 40,
+ decoration: const BoxDecoration(
+ color: Color.fromRGBO(255, 101, 101, 0.2),
+ ),
+ child: Center(
+ child: Padding(
+ padding: const EdgeInsets.symmetric(
+ vertical: 8.0,
+ horizontal: 16,
+ ),
+ child: Text(
+ AppLocalizations.of(context).deleteAll,
+ style: Theme.of(context).textTheme.titleSmall!.copyWith(
+ color: const Color.fromRGBO(255, 101, 101, 1),
+ ),
+ ),
+ ),
+ ),
+ ),
+ ),
+ ),
+ ),
+ ],
+ );
+ }
+
+ Future<void> _deleteAll() async {
+ final allFiles = await CollectionsService.instance.getHiddenFilesOnDevice();
+ if (allFiles.isEmpty) return;
+ final l10n = AppLocalizations.of(context);
final actionResult = await showActionSheet(
context: context,
buttons: [
ButtonWidget(
- labelText: l10n.deleteSelectedFromDevice,
+ labelText: l10n.deleteAll,
buttonType: ButtonType.critical,
buttonSize: ButtonSize.large,
shouldStickToDarkTheme: true,
@@ -122,9 +182,7 @@ class _CleanupHiddenFromDevicePageState
isInAlert: true,
onTap: () async {
try {
- final filesToDelete = _selectedFiles.files.toList();
- await deleteFilesOnDeviceOnly(context, filesToDelete);
- _selectedFiles.clearAll();
+ await deleteFilesOnDeviceOnly(context, allFiles);
} catch (e) {
if (context.mounted) {
await showGenericErrorDialog(context: context, error: e);
@@ -143,12 +201,15 @@ class _CleanupHiddenFromDevicePageState
),
],
title: l10n.deleteFromDevice,
- body: l10n.deleteFromDeviceConfirmation(count: count),
+ body: l10n.deleteFromDeviceConfirmation(count: allFiles.length),
actionSheetType: ActionSheetType.defaultActionSheet,
);
if (actionResult?.action == ButtonAction.first) {
widget.onCleanupComplete?.call();
+ if (context.mounted) {
+ Navigator.of(context).pop();
+ }
}
}
}