Todo editing
This commit is contained in:
@@ -5,6 +5,7 @@ import 'package:intl/intl.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import 'Data.dart';
|
||||
import 'DebugHelper.dart';
|
||||
import 'Dialogs.dart';
|
||||
import 'User.dart' as User;
|
||||
|
||||
@@ -25,6 +26,7 @@ class NotificationManager{
|
||||
fltrNotification.initialize(initilizationsSettings, onSelectNotification: notificationSelected);
|
||||
|
||||
await fltrNotification.cancel(0);
|
||||
await fltrNotification.cancel(2);
|
||||
|
||||
int notification_interval = await Settings.getNotificationInterval();
|
||||
bool adaptive_notification = await Settings.getAdaptiveNotification();
|
||||
@@ -68,6 +70,16 @@ class NotificationManager{
|
||||
fltrNotification.cancel(1);
|
||||
}
|
||||
|
||||
User.todos.forEach((element) {
|
||||
if(element.notificationTime!=null){
|
||||
if(element.notificationTime!.isAfter(DateTime.now())){
|
||||
fltrNotification.schedule(2, "Time for ${element.task!.name}", "${element.metadata}", element.notificationTime, generalNotificationDetails);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
if(adaptive_notification && adaptive_notification_availabel){
|
||||
print("Smart!, Using adaptive huh?");
|
||||
//Calculate you little thing! CALCULATE!'
|
||||
@@ -110,20 +122,20 @@ class NotificationManager{
|
||||
}
|
||||
}
|
||||
}
|
||||
print("Time Map : ${timeMap.length}");
|
||||
print(timeMap);
|
||||
Debug.LogResponse("${timeMap.length}",src:'Time Map');
|
||||
Debug.LogResponse(timeMap);
|
||||
timeMap.forEach((key, value) {
|
||||
DateTime now = DateTime.now();
|
||||
DateTime todayStart = DateTime(now.year,now.month,now.day,0,0,0);
|
||||
DateTime thisTime = todayStart.add(Duration(minutes: key));
|
||||
if(value.length < (totalDays.clamp(0, 30) / 3).ceil()){
|
||||
print("${timeFormat.format(thisTime)} this happened only ${value.length} times, Ignoring...");
|
||||
Debug.Log("${timeFormat.format(thisTime)} this happened only ${value.length} times, Ignoring...");
|
||||
}else {
|
||||
print(timeFormat.format(thisTime));
|
||||
Debug.Log(timeFormat.format(thisTime));
|
||||
if(thisTime.isBefore(DateTime.now())) {
|
||||
thisTime = thisTime.add(Duration(days: 1));
|
||||
}
|
||||
print("Scheduling at $thisTime");
|
||||
Debug.LogResponse("Scheduling at $thisTime");
|
||||
fltrNotification.schedule(0, "Don't forget to add new activity", "Adaptive notifications suggests that you may have done by now to track.", thisTime, generalNotificationDetails);
|
||||
|
||||
}
|
||||
@@ -131,18 +143,18 @@ class NotificationManager{
|
||||
}else if(notification_interval>0) {
|
||||
|
||||
var scheduledTime = DateTime.now().add(Duration(hours: notification_interval));
|
||||
fltrNotification.schedule(1, "What did you do in last $notification_interval hours?", "Click here to track your last activities...",
|
||||
fltrNotification.schedule(0, "What did you do in last $notification_interval hours?", "Click here to track your last activities...",
|
||||
scheduledTime, generalNotificationDetails,);
|
||||
print("Sent notification schedule");
|
||||
}
|
||||
|
||||
await Future.delayed(Duration(seconds: 2));
|
||||
try{ final List<PendingNotificationRequest> pendingNotificationRequests =await fltrNotification.pendingNotificationRequests();
|
||||
print("Notifications");
|
||||
Debug.LogResponse("Notifications");
|
||||
pendingNotificationRequests.forEach((element) {
|
||||
print("${element.id} : ${element.title} -> ${element.body} \n payload:${element.payload}");
|
||||
Debug.LogResponse("${element.id} : ${element.title} -> ${element.body} \n payload:${element.payload}");
|
||||
});}catch(e){
|
||||
print("Error printing notifications \n $e");
|
||||
Debug.LogError("Error printing notifications \n $e");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user