Offline gym log for Android. No account, no ads, no internet.
Dart androidbodybuildingdartexercisesf-droidfitnessfluttergymgym-apphealthprivacyself-hostedworkoutworkout-appworkout-tracker
Import workouts from Liftosaur
InlitX328648990fa6
diff --git a/lib/services/workout_import.dart b/lib/services/workout_import.dartindex 6ba50a3..9d709a5 100644--- a/lib/services/workout_import.dart+++ b/lib/services/workout_import.dart@@ -12,6 +12,7 @@ enum ImportFormat {strong,lyfta,fitbod,+ liftosaur,fitnotes,gymmane,openGym,@@ -84,6 +85,7 @@ class _Fmt {this.durationSec,this.setType,this.warmupFlag,+ this.unit,});final List<String> date;@@ -99,7 +101,8 @@ class _Fmt {final List<String>? durationSec;final List<String>? setType;final List<String>? warmupFlag;- List<String> get rpe => const ['rpe'];+ final List<String>? unit;+ List<String> get rpe => const ['rpe', 'completed rpe'];List<String> get setSec => const ['duration_seconds', 'seconds', 'duration (s)', 'time (s)', 'set duration'];List<String> get setClock => const ['time', 'set time'];List<String> get km => const ['distance_km', 'distance (km)', 'km'];@@ -152,6 +155,17 @@ const _formats = <ImportFormat, _Fmt>{weightLb: ['weight(lbs)', 'weight(lb)', 'weight (lbs)'],warmupFlag: ['iswarmup'],),+ ImportFormat.liftosaur: _Fmt(+ date: ['workout datetime'],+ group: ['day name'],+ exercise: ['exercise'],+ reps: ['completed reps'],+ weightKg: [],+ weightLb: [],+ weightPlain: ['completed weight value'],+ unit: ['completed weight unit'],+ warmupFlag: ['is warmup set?'],+ ),ImportFormat.fitnotes: _Fmt(date: ['date'],exercise: ['exercise'],@@ -205,6 +219,7 @@ ImportFormat detectFormat(String csv) {final cols = _header(csv);if (cols.isEmpty) return ImportFormat.unknown;if (cols.contains('exercise_title') && cols.contains('start_time')) return ImportFormat.hevy;+ if (cols.contains('workout datetime') && cols.contains('is warmup set?')) return ImportFormat.liftosaur;if (cols.contains('exercise name') && cols.contains('set order')) return ImportFormat.strong;if (cols.contains('exercise') &&cols.contains('set type') &&@@ -247,6 +262,7 @@ bool needsUnitChoice(String csv) {}final fmt = _formats[format];if (fmt == null) return false;+ if (_pick(cols, fmt.unit ?? const []) != null) return false;if (_pick(cols, fmt.weightKg) != null || _pick(cols, fmt.weightLb) != null) return false;return _pick(cols, fmt.weightPlain ?? const []) != null;}@@ -360,7 +376,8 @@ ImportResult parseImport(String csv, {bool isLb = false}) {if (_norm(cell(row, fmt.setOrder)).startsWith('rest')) continue;if (_norm(cell(row, fmt.setType)).startsWith('warmup') ||_norm(cell(row, fmt.setType)).startsWith('warm_up') ||- _norm(cell(row, fmt.warmupFlag)) == 'true') {+ _norm(cell(row, fmt.warmupFlag)) == 'true' ||+ _norm(cell(row, fmt.warmupFlag)) == '1') {continue;}@@ -373,7 +390,7 @@ ImportResult parseImport(String csv, {bool isLb = false}) {kg: kgCol == null ? '' : cell(row, [kgCol]),lb: lbCol == null ? '' : cell(row, [lbCol]),plain: plainCol == null ? '' : cell(row, [plainCol]),- plainIsLb: isLb,+ plainIsLb: fmt.unit == null ? isLb : _norm(cell(row, fmt.unit)).startsWith('lb'),);final group = cell(row, fmt.group);diff --git a/test/liftosaur_import_test.dart b/test/liftosaur_import_test.dartnew file mode 100644index 0000000..c8816e0--- /dev/null+++ b/test/liftosaur_import_test.dart@@ -0,0 +1,32 @@+import 'package:flutter_test/flutter_test.dart';+import 'package:gymmane/services/workout_import.dart';++void main() {+ const header = 'Workout DateTime,Program,Day Name,Exercise,Is Warmup Set?,Required Reps,Completed Reps,Is AMRAP?,'+ 'Required RPE,Completed RPE,Log RPE?,Required Weight Value,Required Weight Unit,Completed Weight Value,'+ 'Completed Weight Unit,Ask Weight?,Completed Reps Time,Target Muscles,Synergist Muscles,Notes\n';+ const csv = '$header'+ '2026-03-01T10:00:00.000Z,My Program,Day 1,Squat,1,5,5,0,,,0,95,lb,95,lb,0,2026-03-01T10:02:00.000Z,,,\n'+ '2026-03-01T10:00:00.000Z,My Program,Day 1,Squat,0,5,5,0,,8,1,225,lb,225,lb,0,2026-03-01T10:05:00.000Z,,,\n'+ '2026-03-01T10:00:00.000Z,My Program,Day 1,Squat,0,5,4,0,,,0,225,lb,225,lb,0,2026-03-01T10:09:00.000Z,,,\n'+ '2026-03-01T10:00:00.000Z,My Program,Day 1,Bench Press,0,8,8,0,,,0,60,kg,60,kg,0,2026-03-01T10:20:00.000Z,,,"felt good"\n'+ '2026-03-03T10:00:00.000Z,My Program,Day 2,Deadlift,0,5,5,0,,,0,100,kg,100,kg,0,2026-03-03T10:05:00.000Z,,,\n';++ test('a Liftosaur history export is recognised', () {+ expect(detectFormat(csv), ImportFormat.liftosaur);+ expect(needsUnitChoice(csv), isFalse);+ });++ test('sets are read with their own unit and warm-ups are skipped', () {+ final result = parseImport(csv);+ expect(result.sessions, hasLength(2));+ final first = result.sessions.first;+ expect(first.exercises.map((e) => e.name), ['Squat', 'Bench Press']);+ final squat = first.exercises.first.sets;+ expect(squat.map((s) => s.reps), [5, 4]);+ expect(squat.first.weightKg, closeTo(102.06, 0.05));+ expect(squat.first.rpe, 8);+ expect(first.exercises.last.sets.single.weightKg, 60);+ expect(result.sessions.last.exercises.single.sets.single.weightKg, 100);+ });+}