Offline gym log for Android. No account, no ads, no internet.
Dart androidbodybuildingdartexercisesf-droidfitnessfluttergymgym-apphealthprivacyself-hostedworkoutworkout-appworkout-tracker
Import more from other apps and delete only workouts
InlitXb6d594ebc6a5
diff --git a/lib/screens/plan_import_sheet.dart b/lib/screens/plan_import_sheet.dartindex eb3096e..d7c610c 100644--- a/lib/screens/plan_import_sheet.dart+++ b/lib/screens/plan_import_sheet.dart@@ -134,10 +134,7 @@ class _PlanImportSheetState extends State<_PlanImportSheet> {return Container(padding: sheetPad(context).add(EdgeInsets.only(bottom: MediaQuery.viewInsetsOf(context).bottom)),constraints: BoxConstraints(maxHeight: MediaQuery.sizeOf(context).height * 0.9),- decoration: BoxDecoration(- color: gc.bgRaised,- borderRadius: const BorderRadius.vertical(top: Radius.circular(28)),- ),+ decoration: sheetDecoration(gc),child: SingleChildScrollView(child: Column(mainAxisSize: MainAxisSize.min,@@ -177,7 +174,7 @@ class _PlanImportSheetState extends State<_PlanImportSheet> {if (preview != null && preview.routines > 0) ...[const SizedBox(height: 18),Text('${t.routineCount(preview.routines)} · ${t.exerciseCount(preview.added)}'.toUpperCase(),- style: AppTheme.f(10.5, weight: FontWeight.w700, color: gc.textTertiary, letterSpacing: 1.3)),+ style: AppTheme.f(10.5, weight: FontWeight.w700, color: gc.textTertiary, letterSpacing: 1.4)),const SizedBox(height: 10),for (final p in _plans)if (p.items.isNotEmpty) _planCard(gc, p),diff --git a/lib/screens/strava_sheet.dart b/lib/screens/strava_sheet.dartindex 923c1c0..4a2c3e0 100644--- a/lib/screens/strava_sheet.dart+++ b/lib/screens/strava_sheet.dart@@ -56,10 +56,7 @@ class _StravaSheetState extends State<_StravaSheet> {return Container(constraints: BoxConstraints(maxHeight: MediaQuery.sizeOf(context).height * 0.88),padding: sheetPad(context),- decoration: BoxDecoration(- color: gc.bgRaised,- borderRadius: const BorderRadius.vertical(top: Radius.circular(28)),- ),+ decoration: sheetDecoration(gc),child: SingleChildScrollView(child: Column(mainAxisSize: MainAxisSize.min,@@ -74,7 +71,7 @@ class _StravaSheetState extends State<_StravaSheet> {padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 3),decoration: BoxDecoration(color: gc.accentSoft, borderRadius: BorderRadius.circular(100)),child: Text(t.stravaBeta,- style: AppTheme.f(10.5, weight: FontWeight.w800, color: gc.accent, letterSpacing: 1.2)),+ style: AppTheme.f(10.5, weight: FontWeight.w700, color: gc.accent, letterSpacing: 1.4)),),]),const SizedBox(height: 8),diff --git a/lib/services/backup_zip.dart b/lib/services/backup_zip.dartindex ca98785..cbe0603 100644--- a/lib/services/backup_zip.dart+++ b/lib/services/backup_zip.dart@@ -20,6 +20,7 @@ const String _notesDir = 'media/notes';const String _timelineDir = 'timeline';const String _momentsDir = 'moments';const String _foodsDir = 'foods';+const String _passesDir = 'passes';const String _alarmDir = 'alarm';bool looksLikeZip(Uint8List b) =>@@ -98,6 +99,17 @@ Future<Uint8List> buildBackupZip() async {}data['foodMedia'] = foodMedia;+ final passMedia = <String, String>{};+ for (final pass in fit.gymPasses) {+ if (!pass.photo || passMedia.containsKey(pass.code)) continue;+ final bytes = await MediaStore.readBytes(pass.code);+ if (bytes == null || bytes.isEmpty) continue;+ final name = _uniqueName(used, slugify(pass.name), MediaStore.extOf(pass.code));+ archive.addFile(ArchiveFile.noCompress('$_passesDir/$name', bytes.length, bytes));+ passMedia[pass.code] = '$_passesDir/$name';+ }+ data['passMedia'] = passMedia;+final alarm = fit.alarmSound;final alarmPath = alarm == null ? null : AlarmStore.pathFor(alarm);if (alarm != null && alarmPath != null) {@@ -207,13 +219,33 @@ Future<bool> restoreBackupZip(Uint8List zipBytes) async {if (base != null) restoredFoods[e.key] = base;}+ final wantedPasses = <String, String>{};+ ((data['passMedia'] as Map?) ?? {}).forEach((k, v) {+ if (k is String && v is String && v.isNotEmpty) wantedPasses[k] = v;+ });+ final restoredPasses = <String, String>{};+ for (final e in wantedPasses.entries) {+ final bytes = archive.findFile(e.value)?.readBytes();+ if (bytes == null) continue;+ final base = await MediaStore.saveBytes('pass', MediaStore.extOf(e.value), bytes);+ if (base != null) restoredPasses[e.key] = base;+ }+final ok = fit.tryApplyBackup(data,restoredMedia: restored,restoredNoteMedia: restoredNotes,restoredShots: restoredShots,restoredMoments: restoredMoments,- restoredFoods: restoredFoods);- final added = {...restored.values, ...restoredNotes.values, ...restoredShots.values, ...restoredMoments.values, ...restoredFoods.values};+ restoredFoods: restoredFoods,+ restoredPasses: restoredPasses);+ final added = {+ ...restored.values,+ ...restoredNotes.values,+ ...restoredShots.values,+ ...restoredMoments.values,+ ...restoredFoods.values,+ ...restoredPasses.values,+ };if (!ok) {for (final name in added) {await MediaStore.delete(name);diff --git a/lib/services/fitnotes_backup.dart b/lib/services/fitnotes_backup.dartindex fb1c4d1..e126f0e 100644--- a/lib/services/fitnotes_backup.dart+++ b/lib/services/fitnotes_backup.dart@@ -40,7 +40,8 @@ ImportResult? parseFitNotes(List<int> bytes) {for (final log in db.rows('training_log')) {final reps = _int(log['reps']);- if (reps <= 0) continue;+ final sec = _int(log['duration_seconds']);+ if (reps <= 0 && sec <= 0) continue;final date = _date(_text(log['date']));if (date == null) continue;final exercise = exercises[_int(log['exercise_id'])];@@ -54,7 +55,7 @@ ImportResult? parseFitNotes(List<int> bytes) {session.exercises.add(e);return e;});- parsed.sets.add(ParsedSet(reps, _double(log['metric_weight'])));+ parsed.sets.add(ParsedSet(reps < 0 ? 0 : reps, _double(log['metric_weight']), sec: sec > 0 ? sec : null));}return ImportResult(diff --git a/lib/services/local_store.dart b/lib/services/local_store.dartindex baece82..ea3aa1d 100644--- a/lib/services/local_store.dart+++ b/lib/services/local_store.dart@@ -65,7 +65,7 @@ class Store {String exportCsv(List<LoggedSession> sessions) {final rows = StringBuffer(- 'date,exercise,muscle,set,reps,weight_kg,volume_kg,est_1rm_kg,distance_km,duration_s,rpe\n');+ 'date,exercise,muscle,set,reps,weight_kg,volume_kg,est_1rm_kg,distance_km,duration_s,rpe,note\n');final ordered = [...sessions]..sort((a, b) => a.date.compareTo(b.date));for (final s in ordered) {final day = s.date.toIso8601String().split('T').first;@@ -84,6 +84,7 @@ class Store {st.km == null ? '' : _num(st.km!),st.sec ?? '',st.rpe == null ? '' : _num(st.rpe!),+ _csv(st.note),].join(','));}}diff --git a/lib/services/workout_import.dart b/lib/services/workout_import.dartindex 384b214..065c056 100644--- a/lib/services/workout_import.dart+++ b/lib/services/workout_import.dart@@ -1,4 +1,5 @@import 'dart:convert';+import 'dart:math' as math;import 'package:archive/archive.dart';@@ -29,8 +30,11 @@ extension ImportFormatX on ImportFormat {}class ParsedSet {- ParsedSet(this.reps, this.weightKg, {this.rpe});+ ParsedSet(this.reps, this.weightKg, {this.rpe, this.note = '', this.sec, this.km});final int reps;+ final int? sec;+ final double? km;+ final String note;final double weightKg;final double? rpe;}@@ -96,6 +100,13 @@ class _Fmt {final List<String>? setType;final List<String>? warmupFlag;List<String> get rpe => const ['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'];+ List<String> get miles => const ['distance_miles', 'distance_mi', 'distance (mi)', 'distance (miles)', 'miles'];+ List<String> get meters => const ['distance_m', 'distance (m)', 'distance (meters)', 'distance (metres)', 'meters', 'metres'];+ List<String> get setOrder => const ['set order', 'set_order'];+ List<String> get note => const ['note', 'notes', 'set_notes'];List<String> get rir => const ['rir'];List<String> get effort => const ['rir/rpe', 'rpe/rir'];}@@ -334,9 +345,18 @@ ImportResult parseImport(String csv, {bool isLb = false}) {final sessions = <String, ParsedSession>{};final exercisesOf = <String, Map<String, ParsedExercise>>{};+ double num(String v) => double.tryParse(v.replaceAll(',', '.')) ?? 0;+ final clockCol = format == ImportFormat.fitnotes ? _pick(cols, fmt.setClock) : null;+for (final row in rows.skip(1)) {- final reps = int.tryParse(cell(row, fmt.reps)) ?? 0;- if (reps <= 0) continue;+ final reps = int.tryParse(cell(row, fmt.reps)) ?? num(cell(row, fmt.reps)).round();+ var sec = num(cell(row, fmt.setSec)).round();+ if (sec <= 0 && clockCol != null) sec = _parseDuration(cell(row, [clockCol]));+ var km = num(cell(row, fmt.km));+ if (km <= 0) km = num(cell(row, fmt.miles)) * 1.609344;+ if (km <= 0) km = num(cell(row, fmt.meters)) / 1000;+ if (reps <= 0 && sec <= 0 && km <= 0) continue;+ 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') {@@ -373,7 +393,11 @@ ImportResult parseImport(String csv, {bool isLb = false}) {return parsed;});exercise.sets.add(- ParsedSet(reps, kg, rpe: _effort(cell(row, fmt.rpe), cell(row, fmt.rir), cell(row, fmt.effort))));+ ParsedSet(math.max(0, reps), kg,+ rpe: _effort(cell(row, fmt.rpe), cell(row, fmt.rir), cell(row, fmt.effort)),+ note: _setNote(cell(row, fmt.note)),+ sec: sec > 0 ? sec : null,+ km: km > 0 ? double.parse(km.toStringAsFixed(3)) : null));}return ImportResult(format, sessions.values.toList());@@ -506,6 +530,11 @@ List<String> _header(String csv) {return _splitLine(line, _delimiter(csv)).map(_norm).toList();}+String _setNote(String raw) {+ final clean = raw.trim().replaceAll(RegExp(r'\s+'), ' ');+ return clean.length > 280 ? clean.substring(0, 280) : clean;+}+String _delimiter(String csv) => (_firstLine(csv) ?? '').contains(';') ? ';' : ',';int _parseDuration(String s) {diff --git a/lib/widgets/import_card.dart b/lib/widgets/import_card.dartnew file mode 100644index 0000000..8456d9a--- /dev/null+++ b/lib/widgets/import_card.dart@@ -0,0 +1,142 @@+import 'package:flutter/material.dart';+import 'package:phosphoricons_flutter/phosphoricons_flutter.dart';++import '../l10n/l10n.dart';+import '../theme/app_colors.dart';+import '../theme/app_theme.dart';+import 'ui_kit.dart';++const kImportApps = ['Hevy', 'Strong', 'FitNotes', 'Lyfta', 'openGym', 'CSV'];++class ImportCard extends StatelessWidget {+ const ImportCard({super.key, required this.onTap});++ final VoidCallback onTap;++ @override+ Widget build(BuildContext context) {+ final gc = context.gc;+ return Semantics(+ button: true,+ label: t.importCardTitle,+ child: Pressable(+ scale: 0.97,+ onTap: onTap,+ child: Container(+ clipBehavior: Clip.antiAlias,+ decoration: BoxDecoration(color: gc.bgRaised, borderRadius: BorderRadius.circular(24)),+ padding: const EdgeInsets.symmetric(vertical: 20),+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.stretch,+ children: [+ const AppMarquee(),+ const SizedBox(height: 18),+ Padding(+ padding: const EdgeInsets.symmetric(horizontal: 20),+ child: Row(+ children: [+ Expanded(+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ Text(t.importCardTitle,+ style: AppTheme.f(20,+ weight: FontWeight.w800, color: gc.text, letterSpacing: -0.4, height: 1.15)),+ const SizedBox(height: 4),+ Text(t.importCardBody,+ style: AppTheme.f(12.5, weight: FontWeight.w500, color: gc.textSecondary, height: 1.35)),+ ],+ ),+ ),+ const SizedBox(width: 12),+ Container(+ width: 40,+ height: 40,+ decoration: BoxDecoration(color: gc.bgRaised2, shape: BoxShape.circle),+ child: Icon(PhosphorIconsBold.arrowRight, size: 17, color: gc.text),+ ),+ ],+ ),+ ),+ ],+ ),+ ),+ ),+ );+ }+}++class AppMarquee extends StatefulWidget {+ const AppMarquee({super.key});++ @override+ State<AppMarquee> createState() => _AppMarqueeState();+}++class _AppMarqueeState extends State<AppMarquee> with SingleTickerProviderStateMixin {+ static const _tile = 104.0;+ static const _gap = 10.0;+ static const _period = (_tile + _gap) * 6;++ late final AnimationController _ctrl =+ AnimationController(vsync: this, duration: const Duration(seconds: 15));++ @override+ void didChangeDependencies() {+ super.didChangeDependencies();+ if (MediaQuery.disableAnimationsOf(context)) {+ _ctrl.stop();+ } else if (!_ctrl.isAnimating) {+ _ctrl.repeat();+ }+ }++ @override+ void dispose() {+ _ctrl.dispose();+ super.dispose();+ }++ @override+ Widget build(BuildContext context) {+ final gc = context.gc;+ final strip = Row(+ mainAxisSize: MainAxisSize.min,+ children: [+ for (var round = 0; round < 3; round++)+ for (final name in kImportApps)+ Padding(+ padding: const EdgeInsets.only(right: _gap),+ child: Container(+ width: _tile,+ height: 46,+ alignment: Alignment.center,+ decoration: BoxDecoration(color: gc.bgRaised2, borderRadius: BorderRadius.circular(15)),+ child: Text(name,+ maxLines: 1,+ style: AppTheme.f(15, weight: FontWeight.w800, color: gc.text, letterSpacing: -0.2)),+ ),+ ),+ ],+ );+ return RepaintBoundary(+ child: SizedBox(+ height: 46,+ child: ClipRect(+ child: OverflowBox(+ alignment: Alignment.centerLeft,+ maxWidth: double.infinity,+ child: AnimatedBuilder(+ animation: _ctrl,+ child: RepaintBoundary(child: strip),+ builder: (context, child) => Transform.translate(+ offset: Offset(-_ctrl.value * _period, 0),+ child: child,+ ),+ ),+ ),+ ),+ ),+ );+ }+}diff --git a/test/delete_entries_test.dart b/test/delete_entries_test.dartindex ab6aadf..36ff949 100644--- a/test/delete_entries_test.dart+++ b/test/delete_entries_test.dart@@ -119,4 +119,18 @@ void main() {expect(fit.importJson('{"profile":{"name":"Legacy"}}'), true);expect(fit.onboarded, true);});++ test('borrar solo los entrenos deja rutinas, peso y ajustes', () {+ log('Bench', 80);+ log('Bench', 85, daysAgo: 2);+ fit.addBodyweight(80);+ final routines = fit.routines.length;+ fit.setUnits('lb');+ fit.clearWorkouts();+ expect(fit.sessions, isEmpty);+ expect(fit.bodyweight, isNotEmpty);+ expect(fit.routines.length, routines);+ expect(fit.units, 'lb');+ fit.setUnits('kg');+ });}diff --git a/test/export_test.dart b/test/export_test.dartindex 75d29ff..58753d6 100644--- a/test/export_test.dart+++ b/test/export_test.dart@@ -17,7 +17,7 @@ void main() {]);final lines = csv.trim().split('\n');expect(lines.first,- 'date,exercise,muscle,set,reps,weight_kg,volume_kg,est_1rm_kg,distance_km,duration_s,rpe');+ 'date,exercise,muscle,set,reps,weight_kg,volume_kg,est_1rm_kg,distance_km,duration_s,rpe,note');expect(lines.length, 3);expect(lines[1], startsWith('2026-07-14,Barbell Bench Press,chest,1,10,60,600,'));expect(lines[2], contains(',2,8,70,560,'));@@ -30,7 +30,7 @@ void main() {final row = csv.trim().split('\n')[1];expect(row, contains('"Chest Dip, Assisted"'));- expect(row.replaceAll(RegExp('"[^"]*"'), 'X').split(',').length, 11);+ expect(row.replaceAll(RegExp('"[^"]*"'), 'X').split(',').length, 12);});test('a name with quotes is escaped, not mangled', () {@@ -69,6 +69,15 @@ void main() {test('no sessions still yields a valid header-only file', () {expect(store.exportCsv([]).trim(),- 'date,exercise,muscle,set,reps,weight_kg,volume_kg,est_1rm_kg,distance_km,duration_s,rpe');+ 'date,exercise,muscle,set,reps,weight_kg,volume_kg,est_1rm_kg,distance_km,duration_s,rpe,note');+ });++ test('a set note goes in the last column, escaped', () {+ final csv = store.exportCsv([+ _session(DateTime(2026, 11, 2), 'Squat', [LoggedSet(5, 100, note: 'knee, a bit sore'), LoggedSet(5, 100)]),+ ]);+ final lines = csv.trim().split('\n');+ expect(lines[1], endsWith(',"knee, a bit sore"'));+ expect(lines[2], endsWith(','));});}diff --git a/test/import_test.dart b/test/import_test.dartindex 93462b5..a835f3c 100644--- a/test/import_test.dart+++ b/test/import_test.dart@@ -274,4 +274,33 @@ void main() {expect(bench.sets.map((s) => s.weightKg), [60.0, 62.5]);});});++ group('deportes y cardio', () {+ const hevySports = '''+"title","start_time","end_time","description","exercise_title","superset_id","exercise_notes","set_index","set_type","weight_kg","reps","distance_km","duration_seconds","rpe"+"Club","10 Feb 2024, 18:00","10 Feb 2024, 19:30","","Badminton",,"",0,"normal",,,,3600,+"Domingo","11 Feb 2024, 10:00","11 Feb 2024, 11:40","","Soccer",,"",0,"normal",,,6.2,5400,+"Domingo","11 Feb 2024, 10:00","11 Feb 2024, 11:40","","Juggling Drill",,"",0,"normal",,,,600,+''';++ test('una fila solo con tiempo o distancia ya no se pierde', () {+ final r = parseImport(hevySports);+ expect(r.sessions, hasLength(2));+ final club = r.sessions.firstWhere((s) => s.exercises.first.name == 'Badminton');+ expect(club.exercises.single.sets.single.sec, 3600);+ expect(club.exercises.single.sets.single.reps, 0);+ final soccer = r.sessions.firstWhere((s) => s.exercises.first.name == 'Soccer');+ expect(soccer.exercises.first.sets.single.km, closeTo(6.2, 0.001));+ });++ test('los deportes caen en el catálogo y lo desconocido se guarda igual', () {+ fit.sessions.clear();+ expect(fit.importParsedSessions(parseImport(hevySports).sessions), 2);+ final ids = [for (final s in fit.sessions) for (final e in s.exercises) e.id];+ expect(ids, containsAll(['badminton', 'football']));+ expect(ids.where((id) => id.startsWith('imp:')), hasLength(1));+ final soccer = fit.sessions.expand((s) => s.exercises).firstWhere((e) => e.id == 'football');+ expect(soccer.sets.single.sec, 5400);+ });+ });}