π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Advanced option to disable curated memories
laurenspriem8a73b19a3e62
diff --git a/mobile/lib/services/memories_cache_service.dart b/mobile/lib/services/memories_cache_service.dartindex c2878edb64..711d297514 100644--- a/mobile/lib/services/memories_cache_service.dart+++ b/mobile/lib/services/memories_cache_service.dart@@ -89,7 +89,14 @@ class MemoriesCacheService {}bool get enableSmartMemories =>- flagService.hasGrantedMLConsent && localSettings.isMLLocalIndexingEnabled;+ flagService.hasGrantedMLConsent &&+ localSettings.isMLLocalIndexingEnabled &&+ localSettings.isSmartMemoriesEnabled;++ bool get curatedMemoriesOption =>+ showAnyMemories &&+ flagService.hasGrantedMLConsent &&+ localSettings.isMLLocalIndexingEnabled;void _checkIfTimeToUpdateCache() {if (!enableSmartMemories) {@@ -443,10 +450,12 @@ class MemoriesCacheService {}}- Future<void> clearMemoriesCache() async {- final file = File(await _getCachePath());- if (file.existsSync()) {- await file.delete();+ Future<void> clearMemoriesCache({bool fromDisk = true}) async {+ if (fromDisk) {+ final file = File(await _getCachePath());+ if (file.existsSync()) {+ await file.delete();+ }}_cachedMemories = null;}diff --git a/mobile/lib/ui/settings/gallery_settings_screen.dart b/mobile/lib/ui/settings/gallery_settings_screen.dartindex fc8a8a705a..6ab49e0b22 100644--- a/mobile/lib/ui/settings/gallery_settings_screen.dart+++ b/mobile/lib/ui/settings/gallery_settings_screen.dart@@ -3,6 +3,7 @@ import "dart:async";import "package:flutter/material.dart";import "package:photos/core/event_bus.dart";import "package:photos/events/hide_shared_items_from_home_gallery_event.dart";+import "package:photos/events/memories_changed_event.dart";import "package:photos/generated/l10n.dart";import "package:photos/service_locator.dart";import "package:photos/services/memory_home_widget_service.dart";@@ -103,21 +104,42 @@ class _GallerySettingsScreenState extends State<GallerySettingsScreen> {trailingWidget: ToggleSwitchWidget(value: () => memoriesCacheService.showAnyMemories,onChanged: () async {- unawaited(- memoriesCacheService.setShowAnyMemories(- !memoriesCacheService.showAnyMemories,- ),+ await memoriesCacheService.setShowAnyMemories(+ !memoriesCacheService.showAnyMemories,);unawaited(MemoryHomeWidgetService.instance.initMemoryHW(true),);+ setState(() {});},),),const SizedBox(height: 24,),+ memoriesCacheService.curatedMemoriesOption+ ? MenuItemWidget(+ captionedTextWidget: const CaptionedTextWidget(+ title: "Curated memories",+ ),+ menuItemColor: colorScheme.fillFaint,+ singleBorderRadius: 8,+ alignCaptionedTextToLeft: true,+ trailingWidget: ToggleSwitchWidget(+ value: () =>+ localSettings.isSmartMemoriesEnabled,+ onChanged: () async {+ unawaited(_toggleUpdateMemories());+ },+ ),+ )+ : const SizedBox(),+ memoriesCacheService.curatedMemoriesOption+ ? const SizedBox(+ height: 24,+ )+ : const SizedBox(),MenuItemWidget(captionedTextWidget: CaptionedTextWidget(title: S.of(context).hideSharedItemsFromHomeGallery,@@ -156,3 +178,14 @@ class _GallerySettingsScreenState extends State<GallerySettingsScreen> {);}}++Future<void> _toggleUpdateMemories() async {+ await localSettings.setSmartMemories(+ !localSettings.isSmartMemoriesEnabled,+ );+ await memoriesCacheService.clearMemoriesCache(+ fromDisk: false,+ );+ await memoriesCacheService.getMemories();+ Bus.instance.fire(MemoriesChangedEvent());+}diff --git a/mobile/lib/utils/local_settings.dart b/mobile/lib/utils/local_settings.dartindex 9fcd9e9adc..9ef36640b9 100644--- a/mobile/lib/utils/local_settings.dart+++ b/mobile/lib/utils/local_settings.dart@@ -15,6 +15,7 @@ class LocalSettings {static const _kHasSeenMLEnablingBanner = "ls.has_seen_ml_enabling_banner";static const kRateUsShownCount = "rate_us_shown_count";static const kEnableMultiplePart = "ls.enable_multiple_part";+ static const kCuratedMemoriesEnabled = "ls.curated_memories_enabled";static const kRateUsPromptThreshold = 2;static const shouldLoopVideoKey = "video.should_loop";static const onGuestViewKey = "on_guest_view";@@ -80,6 +81,14 @@ class LocalSettings {bool get isMLLocalIndexingEnabled =>_prefs.getBool(_kisMLLocalIndexingEnabled) ?? enoughRamForLocalIndexing;+ bool get isSmartMemoriesEnabled =>+ _prefs.getBool(kCuratedMemoriesEnabled) ?? true;++ Future<bool> setSmartMemories(bool value) async {+ await _prefs.setBool(kCuratedMemoriesEnabled, value);+ return value;+ }+bool get userEnabledMultiplePart =>_prefs.getBool(kEnableMultiplePart) ?? false;