π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Setting to disable memories notifications
laurenspriemff9494d43828
diff --git a/mobile/lib/services/memories_cache_service.dart b/mobile/lib/services/memories_cache_service.dartindex a32e7ed8c0..4277144713 100644--- a/mobile/lib/services/memories_cache_service.dart+++ b/mobile/lib/services/memories_cache_service.dart@@ -92,6 +92,17 @@ class MemoriesCacheService {Bus.instance.fire(MemoriesSettingChanged());}+ Future<void> toggleOnThisDayNotifications() async {+ final oldValue = localSettings.isOnThisDayNotificationsEnabled;+ await localSettings.setOnThisDayNotificationsEnabled(!oldValue);+ _logger.info("Turning onThisDayNotifications ${oldValue ? "off" : "on"}");+ if (oldValue) {+ await _clearAllScheduledOnThisDayNotifications();+ } else {+ queueUpdateCache();+ }+ }+bool get enableSmartMemories =>flagService.hasGrantedMLConsent &&localSettings.isMLLocalIndexingEnabled &&@@ -238,11 +249,20 @@ class MemoriesCacheService {return newCache;}+ Future<void> _clearAllScheduledOnThisDayNotifications() async {+ await NotificationService.instance+ .clearAllScheduledNotifications(containingPayload: "onThisDay");+ }+Future<void> _scheduleOnThisDayNotifications(List<SmartMemory> allMemories,) async {- await NotificationService.instance- .clearAllScheduledNotifications(containingPayload: "onThisDay");+ if (!localSettings.isOnThisDayNotificationsEnabled) {+ _logger+ .info("On this day notifications are disabled, skipping scheduling");+ return;+ }+ await _clearAllScheduledOnThisDayNotifications();final scheduledDates = <DateTime>{};for (final memory in allMemories) {if (memory.type != MemoryType.onThisDay) {diff --git a/mobile/lib/ui/settings/notification_settings_screen.dart b/mobile/lib/ui/settings/notification_settings_screen.dartindex f6dfc3eabc..e0bfbd12bd 100644--- a/mobile/lib/ui/settings/notification_settings_screen.dart+++ b/mobile/lib/ui/settings/notification_settings_screen.dart@@ -1,5 +1,6 @@import 'package:flutter/material.dart';import "package:photos/generated/l10n.dart";+import "package:photos/service_locator.dart";import "package:photos/services/notification_service.dart";import 'package:photos/theme/ente_theme.dart';import 'package:photos/ui/components/buttons/icon_button_widget.dart';@@ -9,6 +10,7 @@ import 'package:photos/ui/components/menu_section_description_widget.dart';import 'package:photos/ui/components/title_bar_title_widget.dart';import 'package:photos/ui/components/title_bar_widget.dart';import 'package:photos/ui/components/toggle_switch_widget.dart';+import "package:photos/ui/settings/common_settings.dart";class NotificationSettingsScreen extends StatelessWidget {const NotificationSettingsScreen({super.key});@@ -77,6 +79,33 @@ class NotificationSettingsScreen extends StatelessWidget {.of(context).sharedPhotoNotificationsExplanation,),+ sectionOptionSpacing,+ MenuItemWidget(+ captionedTextWidget: CaptionedTextWidget(+ title: S.of(context).onThisDayMemories,+ ),+ menuItemColor: colorScheme.fillFaint,+ trailingWidget: ToggleSwitchWidget(+ value: () =>+ NotificationService.instance+ .hasGrantedPermissions() &&+ localSettings+ .isOnThisDayNotificationsEnabled,+ onChanged: () async {+ await NotificationService.instance+ .requestPermissions();+ await memoriesCacheService+ .toggleOnThisDayNotifications();+ },+ ),+ singleBorderRadius: 8,+ alignCaptionedTextToLeft: true,+ isGestureDetectorDisabled: true,+ ),+ const MenuSectionDescriptionWidget(+ content:+ "Receive reminders about memories from this day in previous years.",+ ),],),],diff --git a/mobile/lib/utils/local_settings.dart b/mobile/lib/utils/local_settings.dartindex 71e5c0fe64..da7fabb312 100644--- a/mobile/lib/utils/local_settings.dart+++ b/mobile/lib/utils/local_settings.dart@@ -26,6 +26,8 @@ class LocalSettings {static const kRateUsShownCount = "rate_us_shown_count";static const kEnableMultiplePart = "ls.enable_multiple_part";static const kCuratedMemoriesEnabled = "ls.curated_memories_enabled";+ static const kOnThisDayNotificationsEnabled =+ "ls.on_this_day_notifications_enabled";static const kRateUsPromptThreshold = 2;static const shouldLoopVideoKey = "video.should_loop";static const onGuestViewKey = "on_guest_view";@@ -119,6 +121,14 @@ class LocalSettings {return value;}+ bool get isOnThisDayNotificationsEnabled =>+ _prefs.getBool(kOnThisDayNotificationsEnabled) ?? true;++ Future<bool> setOnThisDayNotificationsEnabled(bool value) async {+ await _prefs.setBool(kOnThisDayNotificationsEnabled, value);+ return value;+ }+bool get userEnabledMultiplePart =>_prefs.getBool(kEnableMultiplePart) ?? false;