Offline gym log for Android. No account, no ads, no internet.
Dart androidbodybuildingdartexercisesf-droidfitnessfluttergymgym-apphealthprivacyself-hostedworkoutworkout-appworkout-tracker
Ring the rest alarm in the background and leave the Now Bar at zero
InlitX9631c622660b
diff --git a/android/app/src/main/kotlin/com/gymmane/app/LiveNotifier.kt b/android/app/src/main/kotlin/com/gymmane/app/LiveNotifier.ktindex 061edbb..b6b9847 100644--- a/android/app/src/main/kotlin/com/gymmane/app/LiveNotifier.kt+++ b/android/app/src/main/kotlin/com/gymmane/app/LiveNotifier.kt@@ -38,6 +38,7 @@ object LiveNotifier {private var font: Typeface? = nullprivate var flashId = -1private var flashUntil = 0L+ private var endedRest = 0Lprivate val tick = Runnable { repost() }fun update(ctx: Context, a: Map<*, *>) {@@ -62,9 +63,10 @@ object LiveNotifier {val detail = a["detail"] as? String ?: ""val restLabel = a["restLabel"] as? String ?: ""val next = a["next"] as? String- val resting = a["resting"] as? Boolean ?: falseval paused = a["paused"] as? Boolean ?: falseval restEnd = (a["restEnd"] as? Number)?.toLong() ?: 0L+ val restOver = (a["resting"] as? Boolean ?: false) && restEnd <= now+ val resting = (a["resting"] as? Boolean ?: false) && !restOverval startedAt = (a["startedAt"] as? Number)?.toLong() ?: 0Lval index = (a["index"] as? Number)?.toInt() ?: 0val total = (a["total"] as? Number)?.toInt() ?: 0@@ -72,8 +74,12 @@ object LiveNotifier {val done = (a["done"] as? List<*>)?.map { it == true } ?: emptyList()val progress = (a["progress"] as? Number)?.toInt() ?: 0val chip = a["chip"] as? String+ if (restOver && endedRest != restEnd) {+ endedRest = restEnd+ dart?.invokeMethod("action", "restEnd")+ }val flash = if (now < flashUntil) a["flash"] as? String else null- val actions = (a["actions"] as? List<*>)?.mapNotNull { it as? Map<*, *> } ?: emptyList()+ val actions = (a[if (restOver) "afterRest" else "actions"] as? List<*>)?.mapNotNull { it as? Map<*, *> } ?: emptyList()val accent = ctx.getColor(if (paused) R.color.live_pause else R.color.live_accent)val green = ctx.getColor(R.color.live_done)val left = if (resting) ((restEnd - now + 999) / 1000).coerceAtLeast(0) else 0L@@ -160,6 +166,7 @@ object LiveNotifier {wait = 1000L - (now - startedAt).mod(1000L) + 15L}}+ if (resting && !paused) wait = minOf(wait, restEnd - now + 15)if (flashUntil > now) wait = minOf(wait, flashUntil - now + 15)if (wait != Long.MAX_VALUE) main.postDelayed(tick, wait)}diff --git a/lib/services/live_workout.dart b/lib/services/live_workout.dartindex 599e2fd..ebe6455 100644--- a/lib/services/live_workout.dart+++ b/lib/services/live_workout.dart@@ -93,20 +93,21 @@ class LiveWorkout {: '${pendingIdx < 0 ? ex.sets.length : pendingIdx + 1}/${ex.sets.length}';final finished = [for (final e in s.exercises) e.sets.isNotEmpty && e.sets.every((st) => st.done)];final flashing = _flashAt != null && DateTime.now().difference(_flashAt!) < const Duration(seconds: 2);- final actions = <(String, String)>[- if (paused)- ('pause', '▶ ${t.liveResume}')- else ...[- if (resting) ...[- ('add', '+15 s'),- ('skip', '${t.liveSkipRest} ›'),- ] else if (pendingIdx >= 0)- ('done', '✓ ${t.liveDoneSet}')- else if (nextEx != null)- ('next', '${t.liveNext} ›'),- ('pause', '❚❚ ${t.livePause}'),- ],- ];+ List<(String, String)> actionsFor(bool resting) => [+ if (paused)+ ('pause', '▶ ${t.liveResume}')+ else ...[+ if (resting) ...[+ ('add', '+15 s'),+ ('skip', '${t.liveSkipRest} ›'),+ ] else if (pendingIdx >= 0)+ ('done', '✓ ${t.liveDoneSet}')+ else if (nextEx != null)+ ('next', '${t.liveNext} ›'),+ ('pause', '❚❚ ${t.livePause}'),+ ],+ ];+ final actions = actionsFor(resting);final key = [name, detail, index, total, resting ? restEnd.millisecondsSinceEpoch : 0, paused, position,@@ -151,6 +152,9 @@ class LiveWorkout {'actions': [for (final (id, label) in actions) {'id': id, 'label': label},],+ 'afterRest': [+ for (final (id, label) in actionsFor(false)) {'id': id, 'label': label},+ ],});} catch (e) {_lastKey = '';@@ -176,6 +180,8 @@ class LiveWorkout {fit.skipRest();case 'next':fit.goNextPending();+ case 'restEnd':+ fit.restElapsed();}}diff --git a/lib/services/rest_alarm.dart b/lib/services/rest_alarm.dartindex 04e4cc1..7cb0912 100644--- a/lib/services/rest_alarm.dart+++ b/lib/services/rest_alarm.dart@@ -212,8 +212,13 @@ class RestAlarm {}Future<void> fireNow() async {- await cancel();final visible = WidgetsBinding.instance.lifecycleState == AppLifecycleState.resumed;+ final custom = customSoundPath?.isNotEmpty ?? false;+ if (_ready && !visible && !custom && Platform.isAndroid) {+ _generation++;+ return;+ }+ await cancel();if (_ready && !visible) {try {