Skip to content

armgit / ente

Public Imported from GitHub
0

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

Merge branch 'main' into internal-15_06_2025

Neeraj Gupta9fedf8d6b70c
diff --cc mobile/lib/services/memories_cache_service.dart
index 971222a880,005146f8c7..17fd486f33
--- a/mobile/lib/services/memories_cache_service.dart
+++ b/mobile/lib/services/memories_cache_service.dart
@@@ -297,20 -275,17 +297,21 @@@ class MemoriesCacheService
);
continue;
}
+ final s = await LanguageService.s;
await NotificationService.instance.scheduleNotification(
- "On this day",
- "Look back on $numberOfMemories memories πŸŒ„",
+ s.onThisDay,
+ s.lookBackOnYourMemories,
id: memory.id.hashCode,
channelID: "onThisDay",
- channelName: "On this day",
+ channelName: s.onThisDay,
payload: memory.id,
dateTime: scheduleTime,
+ timeoutDurationAndroid: const Duration(hours: 16),
);
scheduledDates.add(scheduleTime);
+ _logger.info(
+ "Scheduled notification for memory ${memory.id} on $scheduleTime",
+ );
}
}
diff --cc mobile/lib/services/notification_service.dart
index 8d9fe3e3f7,f6153651b4..74efedd00d
--- a/mobile/lib/services/notification_service.dart
+++ b/mobile/lib/services/notification_service.dart
@@@ -150,63 -150,58 +150,98 @@@ class NotificationService
String channelName = "ente",
String payload = "ente://home",
required DateTime dateTime,
+ Duration? timeoutDurationAndroid,
}) async {
- _logger.info(
- "Scheduling notification with: $title, $message, $channelID, $channelName, $payload",
- );
- await initTimezones();
- if (!hasGrantedPermissions()) {
- _logger.warning("Notification permissions not granted");
- await requestPermissions();
+ try {
+ _logger.info(
+ "Scheduling notification with: $title, $message, $channelID, $channelName, $payload",
+ );
+ await initTimezones();
if (!hasGrantedPermissions()) {
- _logger.severe("Failed to get notification permissions");
- return;
+ _logger.warning("Notification permissions not granted");
+ await requestPermissions();
+ if (!hasGrantedPermissions()) {
+ _logger.severe("Failed to get notification permissions");
+ return;
+ }
+ } else {
+ _logger.info("Notification permissions already granted");
}
- } else {
- _logger.info("Notification permissions already granted");
+ final androidSpecs = AndroidNotificationDetails(
+ channelID,
+ channelName,
+ channelDescription: 'ente alerts',
+ importance: Importance.max,
+ priority: Priority.high,
+ category: AndroidNotificationCategory.reminder,
+ showWhen: false,
+ );
+ final iosSpecs = DarwinNotificationDetails(threadIdentifier: channelID);
+ final platformChannelSpecs =
+ NotificationDetails(android: androidSpecs, iOS: iosSpecs);
+ final scheduledDate = tz.TZDateTime.local(
+ dateTime.year,
+ dateTime.month,
+ dateTime.day,
+ dateTime.hour,
+ dateTime.minute,
+ dateTime.second,
+ );
+ // final tz.TZDateTime scheduledDate = tz.TZDateTime.now(tz.local).add(delay);
+ await _notificationsPlugin.zonedSchedule(
+ id,
+ title,
+ message,
+ scheduledDate,
+ platformChannelSpecs,
+ androidScheduleMode: AndroidScheduleMode.inexactAllowWhileIdle,
+ payload: payload,
+ );
+ _logger.info(
+ "Scheduled notification with: $title, $message, $channelID, $channelName, $payload for $dateTime",
+ );
+ } catch (e, s) {
+ // For now we're swallowing any exceptions here because we don't want the memories logic to get disturbed
+ _logger.severe(
+ "Something went wrong while scheduling notification",
+ e,
+ s,
+ );
}
+ final androidSpecs = AndroidNotificationDetails(
+ channelID,
+ channelName,
+ channelDescription: 'ente alerts',
+ importance: Importance.max,
+ priority: Priority.high,
+ category: AndroidNotificationCategory.reminder,
+ showWhen: false,
+ timeoutAfter: timeoutDurationAndroid?.inMilliseconds,
+ );
+ final iosSpecs = DarwinNotificationDetails(threadIdentifier: channelID);
+ final platformChannelSpecs =
+ NotificationDetails(android: androidSpecs, iOS: iosSpecs);
+ final scheduledDate = tz.TZDateTime.local(
+ dateTime.year,
+ dateTime.month,
+ dateTime.day,
+ dateTime.hour,
+ dateTime.minute,
+ dateTime.second,
+ );
+ // final tz.TZDateTime scheduledDate = tz.TZDateTime.now(tz.local).add(delay);
+ await _notificationsPlugin.zonedSchedule(
+ id,
+ title,
+ message,
+ scheduledDate,
+ platformChannelSpecs,
- uiLocalNotificationDateInterpretation:
- UILocalNotificationDateInterpretation.wallClockTime,
+ androidScheduleMode: AndroidScheduleMode.inexactAllowWhileIdle,
+ payload: payload,
+ );
+ _logger.info(
+ "Scheduled notification with: $title, $message, $channelID, $channelName, $payload",
+ );
}
Future<void> clearAllScheduledNotifications({
diff --cc mobile/lib/services/sync/remote_sync_service.dart
index 1706e35bee,7846120337..61000fdc0b
--- a/mobile/lib/services/sync/remote_sync_service.dart
+++ b/mobile/lib/services/sync/remote_sync_service.dart
@@@ -25,9 -25,7 +25,8 @@@ import 'package:photos/models/upload_st
import "package:photos/service_locator.dart";
import 'package:photos/services/app_lifecycle_service.dart';
import 'package:photos/services/collections_service.dart';
- import "package:photos/services/filedata/filedata_service.dart";
import 'package:photos/services/ignored_files_service.dart';
+import "package:photos/services/language_service.dart";
import 'package:photos/services/local_file_update_service.dart';
import "package:photos/services/notification_service.dart";
import "package:photos/services/preview_video_store.dart";
diff --cc mobile/lib/utils/local_settings.dart
index da7fabb312,b51c367d6d..ab63e2ab81
--- a/mobile/lib/utils/local_settings.dart
+++ b/mobile/lib/utils/local_settings.dart
@@@ -121,28 -119,8 +121,16 @@@ 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;
-
- Future<void> autoEnableMultiplePart(int rolloutPercentage) async {
- if (_prefs.containsKey(kEnableMultiplePart)) {
- return;
- }
- rolloutPercentage = rolloutPercentage.clamp(0, 100);
- final randomValue = DateTime.now().millisecondsSinceEpoch % 100;
- await _prefs.setBool(
- kEnableMultiplePart,
- randomValue < rolloutPercentage,
- );
- }
+ _prefs.getBool(kEnableMultiplePart) ?? true;
Future<bool> setUserEnabledMultiplePart(bool value) async {
await _prefs.setBool(kEnableMultiplePart, value);