Offline gym log for Android. No account, no ads, no internet.
Dart androidbodybuildingdartexercisesf-droidfitnessfluttergymgym-apphealthprivacyself-hostedworkoutworkout-appworkout-tracker
Schedule reminders as exact alarms when the system allows it
InlitX963c1602411c
diff --git a/lib/services/progress_reminder.dart b/lib/services/progress_reminder.dartindex bb2847c..6755e04 100644--- a/lib/services/progress_reminder.dart+++ b/lib/services/progress_reminder.dart@@ -44,7 +44,7 @@ class ProgressReminder {body: t.notifPhotoBody(intervalDays),scheduledDate: when,notificationDetails: NotificationDetails(android: _android, iOS: _darwin),- androidScheduleMode: AndroidScheduleMode.inexactAllowWhileIdle,+ androidScheduleMode: await reminderMode(_plugin),);} catch (e) {debugPrint('No se pudo programar el recordatorio de fotos: $e');diff --git a/lib/services/train_reminder.dart b/lib/services/train_reminder.dartindex 0c1a5ae..8ea9632 100644--- a/lib/services/train_reminder.dart+++ b/lib/services/train_reminder.dart@@ -47,6 +47,7 @@ class TrainReminder {}) async {if (!enabled) return;await cancel();+ final mode = await reminderMode(_plugin);final now = DateTime.now();var slot = 0;for (var i = skipToday ? 1 : 0; i < _horizonDays && slot < _slots; i++) {@@ -60,7 +61,7 @@ class TrainReminder {body: t.notifTrainBody,scheduledDate: atLocal(day),notificationDetails: NotificationDetails(android: _android, iOS: _darwin),- androidScheduleMode: AndroidScheduleMode.inexactAllowWhileIdle,+ androidScheduleMode: mode,);slot++;} catch (e) {@@ -71,6 +72,14 @@ class TrainReminder {}}+Future<AndroidScheduleMode> reminderMode(FlutterLocalNotificationsPlugin plugin) async {+ try {+ final android = plugin.resolvePlatformSpecificImplementation<AndroidFlutterLocalNotificationsPlugin>();+ if (await android?.canScheduleExactNotifications() ?? false) return AndroidScheduleMode.exactAllowWhileIdle;+ } catch (_) {}+ return AndroidScheduleMode.inexactAllowWhileIdle;+}+tz.TZDateTime atLocal(DateTime wallClock) {final utc = wallClock.toUtc();return tz.TZDateTime.utc(utc.year, utc.month, utc.day, utc.hour, utc.minute, utc.second);