From 2998bd53537bcb83ed89dacaff28ac62b529a58b Mon Sep 17 00:00:00 2001 From: Krzysztof kuhy Rudnicki Date: Tue, 10 Nov 2026 17:40:13 +0100 Subject: [PATCH] Give enum-only run files covered members Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01WzxdWZ9CKZsNxtD5Jr9bYD --- .../workout_app/lib/services/foreground_run_client.dart | 5 ++++- .../workout_app/lib/services/run_controller.dart | 8 ++------ .../workout_app/lib/services/run_phase.dart | 5 ++++- .../workout_app/lib/services/run_recorder.dart | 4 ++-- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/stronglift_replacement/workout_app/lib/services/foreground_run_client.dart b/stronglift_replacement/workout_app/lib/services/foreground_run_client.dart index 2fc2e33..5d48d58 100644 --- a/stronglift_replacement/workout_app/lib/services/foreground_run_client.dart +++ b/stronglift_replacement/workout_app/lib/services/foreground_run_client.dart @@ -16,7 +16,10 @@ enum RunServiceState { failed, /// This platform has no foreground services (Linux desktop, tests). - unsupported, + unsupported; + + /// True while a service is up, notification shown or not. + bool get isUp => this == running || this == runningHidden; } /// Starting, feeding and stopping the recording's foreground service. diff --git a/stronglift_replacement/workout_app/lib/services/run_controller.dart b/stronglift_replacement/workout_app/lib/services/run_controller.dart index 88c8063..7fa6a96 100644 --- a/stronglift_replacement/workout_app/lib/services/run_controller.dart +++ b/stronglift_replacement/workout_app/lib/services/run_controller.dart @@ -54,8 +54,7 @@ class RunController extends ChangeNotifier { bool get saving => _saving; /// True from start to finish: the screen must not be left meanwhile. - bool get active => - recorder.phase == RunPhase.recording || recorder.phase == RunPhase.paused; + bool get active => recorder.phase.isActive; /// Asks for access, starts the service, begins recording. Future start() async { @@ -129,10 +128,7 @@ class RunController extends ChangeNotifier { } Future _stopService() async { - if (_serviceState != RunServiceState.running && - _serviceState != RunServiceState.runningHidden) { - return; - } + if (!_serviceState.isUp) return; await _service.stop(); _serviceState = RunServiceState.none; notifyListeners(); diff --git a/stronglift_replacement/workout_app/lib/services/run_phase.dart b/stronglift_replacement/workout_app/lib/services/run_phase.dart index e993480..8ca6176 100644 --- a/stronglift_replacement/workout_app/lib/services/run_phase.dart +++ b/stronglift_replacement/workout_app/lib/services/run_phase.dart @@ -13,7 +13,10 @@ enum RunPhase { paused, /// Over; [RunRecorder.finish] has returned the track. - finished, + finished; + + /// True from start to finish: recording or paused. + bool get isActive => this == recording || this == paused; } /// What is wrong with the recording right now (shown as an icon, logged). diff --git a/stronglift_replacement/workout_app/lib/services/run_recorder.dart b/stronglift_replacement/workout_app/lib/services/run_recorder.dart index 99c0e82..501602f 100644 --- a/stronglift_replacement/workout_app/lib/services/run_recorder.dart +++ b/stronglift_replacement/workout_app/lib/services/run_recorder.dart @@ -117,7 +117,7 @@ class RunRecorder extends ChangeNotifier { /// Ends the recording and returns the track, or null when there were too /// few usable fixes (then [issue] is [RunIssue.tooShort]). Future finish() async { - if (_phase != RunPhase.recording && _phase != RunPhase.paused) return null; + if (!_phase.isActive) return null; await _sub?.cancel(); _sub = null; _phase = RunPhase.finished; @@ -217,7 +217,7 @@ class RunRecorder extends ChangeNotifier { } void _onDone() { - if (_phase != RunPhase.recording && _phase != RunPhase.paused) return; + if (!_phase.isActive) return; log( 'RunRecorder: the location stream ended while still recording; ' 'finish the run to save what was captured.',