screen-locker/stronglift_replacement/workout_app/lib/services/run_phase.dart
Krzysztof kuhy Rudnicki d45e67a02c Persist and bridge GPS runs across death
Checkpoint codec and file store, gap bridging at 2:30-12:00 min/km, watchdog (suggest finish, 5 h auto end), recorder restore.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WzxdWW75Epgijvt2eJ1ErR
2026-11-17 20:54:40 +01:00

74 lines
1.9 KiB
Dart

/// The phases and problems of a GPS recording.
library;
import 'package:workout_app/services/position_source.dart';
/// Where a recording stands.
enum RunPhase {
/// Nothing recorded yet.
idle,
/// Fixes are being kept and credited.
recording,
/// Fixes are ignored; nothing is credited until [RunRecorder.resume].
paused,
/// Over; [RunRecorder.finish] has returned the track.
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).
enum RunIssue {
/// Nothing.
none,
/// Location permission refused; asking again may work.
denied,
/// Location permission refused for good; only system settings can fix it.
deniedForever,
/// The device's location switch is off.
serviceOff,
/// The newest fix came from a mock-location provider and was dropped.
mockedLocation,
/// The location stream reported an error.
streamError,
/// Finished with too few usable fixes to make a track; nothing was saved.
tooShort;
/// The issue a refused [access] raises (never [none]; a grant has none).
static RunIssue forAccess(LocationAccess access) => switch (access) {
LocationAccess.deniedForever => deniedForever,
LocationAccess.serviceOff => serviceOff,
_ => denied,
};
/// Whether this is a refused location access (no map, no start).
bool get isAccess =>
this == denied || this == deniedForever || this == serviceOff;
}
/// Why the recorder suggests the runner finish. It never ends a run itself
/// (the 5 h auto end is a separate callback).
enum RunSuggestion {
/// Under 50 m of progress in 10 minutes; repeats every 10 minutes.
stationary,
/// Faster than 25 km/h for a minute: probably in a vehicle.
vehicleSpeed,
/// No GPS fix for 5 minutes.
gpsLost,
/// The run was just restored from a checkpoint after the app died.
restored,
}