Skip to content

Offline gym log for Android. No account, no ads, no internet.

Plan import: read a set type on the exercise and name all five types in the AI request

Federico Livadb667fa8ca3a
diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb
index 103bfa6..1793635 100644
--- a/lib/l10n/app_en.arb
+++ b/lib/l10n/app_en.arb
@@ -971,7 +971,7 @@
"setTypeDropInfo": "Straight after a set, lower the weight and keep going without resting.",
"setTypeFailureInfo": "Keep going until you can't do another clean rep. Log the reps you actually did.",
"setTypeRestPauseInfo": "Rest 10 to 20 seconds after the set, then squeeze out a few more reps.",
- "planFormatNotes": "Use the exercise names exactly as they appear in the list. \"sets\", \"reps\" (a number or a range like \"8-12\"), \"weight\" (in the unit given), \"rest\" in seconds and \"days\" are optional. For exercises marked cardio or time in the list, use \"time\" (seconds, or like \"30:00\") and \"distance\" (in km) instead of \"reps\"; to give each set its own values, list them in \"plan\", one entry per set with its own \"reps\" and \"weight\" (add \"type\": \"warmup\" for warm-up sets). \"superset\": true links an exercise with the next one. For several weeks, group the routines inside \"weeks\" like the second example.",
+ "planFormatNotes": "Use the exercise names exactly as they appear in the list. \"sets\", \"reps\" (a number or a range like \"8-12\"), \"weight\" (in the unit given), \"rest\" in seconds and \"days\" are optional. For exercises marked cardio or time in the list, use \"time\" (seconds, or like \"30:00\") and \"distance\" (in km) instead of \"reps\"; to give each set its own values, list them in \"plan\", one entry per set with its own \"reps\" and \"weight\". \"type\" marks the kind of set: \"warmup\", \"drop\", \"failure\", \"restpause\" or \"cluster\"; on the exercise it applies to all its working sets, inside \"plan\" to that set only. \"superset\": true links an exercise with the next one. For several weeks, group the routines inside \"weeks\" like the second example.",
"planSets": "Plan sets",
"planSetsHint": "Choose the type, reps and weight of each set. Leave the weight on Auto to start from your last session.",
"planHintReps": "Choose the type and reps of each set. Auto starts from your last session.",
diff --git a/lib/l10n/app_it.arb b/lib/l10n/app_it.arb
index 26fd4a1..7a31ee7 100644
--- a/lib/l10n/app_it.arb
+++ b/lib/l10n/app_it.arb
@@ -771,7 +771,7 @@
"setTypeDropInfo": "Subito dopo una serie, riduci il peso e continua senza riposare.",
"setTypeFailureInfo": "Continua finché non riesci a fare un'altra ripetizione pulita. Segna quelle fatte davvero.",
"setTypeRestPauseInfo": "Riposa da 10 a 20 secondi dopo la serie, poi strappa qualche ripetizione in più.",
- "planFormatNotes": "Usa i nomi degli esercizi esattamente come nella lista. \"sets\", \"reps\", \"weight\" (nell'unità indicata), \"rest\" in secondi e \"days\" sono facoltativi. \"superset\": true collega un esercizio al successivo. Per più settimane, raggruppa le routine dentro \"weeks\" come nel secondo esempio.",
+ "planFormatNotes": "Usa i nomi degli esercizi esattamente come nella lista. \"sets\", \"reps\" (un numero o un intervallo come \"8-12\"), \"weight\" (nell'unità indicata), \"rest\" in secondi e \"days\" sono facoltativi. Per gli esercizi segnati cardio o a tempo nella lista, usa \"time\" (secondi, o come \"30:00\") e \"distance\" (in km) al posto di \"reps\"; per dare a ogni serie i suoi valori, elencale in \"plan\", una voce per serie con le sue \"reps\" e il suo \"weight\". \"type\" indica il tipo di serie: \"warmup\", \"drop\", \"failure\", \"restpause\" o \"cluster\"; sull'esercizio vale per tutte le sue serie di lavoro, dentro \"plan\" solo per quella serie. \"superset\": true collega un esercizio al successivo. Per più settimane, raggruppa le routine dentro \"weeks\" come nel secondo esempio.",
"planSets": "Pianifica le serie",
"planSetsHint": "Scegli tipo, ripetizioni e peso di ogni serie. Lascia il peso su Auto per partire dall'ultima sessione.",
"planHintReps": "Scegli il tipo e le ripetizioni di ogni serie. Auto parte dalla tua ultima sessione.",
diff --git a/lib/l10n/app_localizations.dart b/lib/l10n/app_localizations.dart
index 3c626ca..2aadfae 100644
--- a/lib/l10n/app_localizations.dart
+++ b/lib/l10n/app_localizations.dart
@@ -5117,7 +5117,7 @@ abstract class AppLocalizations {
/// No description provided for @planFormatNotes.
///
/// In en, this message translates to:
- /// **'Use the exercise names exactly as they appear in the list. \"sets\", \"reps\" (a number or a range like \"8-12\"), \"weight\" (in the unit given), \"rest\" in seconds and \"days\" are optional. For exercises marked cardio or time in the list, use \"time\" (seconds, or like \"30:00\") and \"distance\" (in km) instead of \"reps\"; to give each set its own values, list them in \"plan\", one entry per set with its own \"reps\" and \"weight\" (add \"type\": \"warmup\" for warm-up sets). \"superset\": true links an exercise with the next one. For several weeks, group the routines inside \"weeks\" like the second example.'**
+ /// **'Use the exercise names exactly as they appear in the list. \"sets\", \"reps\" (a number or a range like \"8-12\"), \"weight\" (in the unit given), \"rest\" in seconds and \"days\" are optional. For exercises marked cardio or time in the list, use \"time\" (seconds, or like \"30:00\") and \"distance\" (in km) instead of \"reps\"; to give each set its own values, list them in \"plan\", one entry per set with its own \"reps\" and \"weight\". \"type\" marks the kind of set: \"warmup\", \"drop\", \"failure\", \"restpause\" or \"cluster\"; on the exercise it applies to all its working sets, inside \"plan\" to that set only. \"superset\": true links an exercise with the next one. For several weeks, group the routines inside \"weeks\" like the second example.'**
String get planFormatNotes;
/// No description provided for @planSets.
diff --git a/lib/l10n/app_localizations_en.dart b/lib/l10n/app_localizations_en.dart
index edd3d45..486e860 100644
--- a/lib/l10n/app_localizations_en.dart
+++ b/lib/l10n/app_localizations_en.dart
@@ -2805,7 +2805,7 @@ class AppLocalizationsEn extends AppLocalizations {
@override
String get planFormatNotes =>
- 'Use the exercise names exactly as they appear in the list. \"sets\", \"reps\" (a number or a range like \"8-12\"), \"weight\" (in the unit given), \"rest\" in seconds and \"days\" are optional. For exercises marked cardio or time in the list, use \"time\" (seconds, or like \"30:00\") and \"distance\" (in km) instead of \"reps\"; to give each set its own values, list them in \"plan\", one entry per set with its own \"reps\" and \"weight\" (add \"type\": \"warmup\" for warm-up sets). \"superset\": true links an exercise with the next one. For several weeks, group the routines inside \"weeks\" like the second example.';
+ 'Use the exercise names exactly as they appear in the list. \"sets\", \"reps\" (a number or a range like \"8-12\"), \"weight\" (in the unit given), \"rest\" in seconds and \"days\" are optional. For exercises marked cardio or time in the list, use \"time\" (seconds, or like \"30:00\") and \"distance\" (in km) instead of \"reps\"; to give each set its own values, list them in \"plan\", one entry per set with its own \"reps\" and \"weight\". \"type\" marks the kind of set: \"warmup\", \"drop\", \"failure\", \"restpause\" or \"cluster\"; on the exercise it applies to all its working sets, inside \"plan\" to that set only. \"superset\": true links an exercise with the next one. For several weeks, group the routines inside \"weeks\" like the second example.';
@override
String get planSets => 'Plan sets';
diff --git a/lib/l10n/app_localizations_it.dart b/lib/l10n/app_localizations_it.dart
index 92fad9d..a962228 100644
--- a/lib/l10n/app_localizations_it.dart
+++ b/lib/l10n/app_localizations_it.dart
@@ -2806,7 +2806,7 @@ class AppLocalizationsIt extends AppLocalizations {
@override
String get planFormatNotes =>
- 'Usa i nomi degli esercizi esattamente come nella lista. \"sets\", \"reps\", \"weight\" (nell\'unità indicata), \"rest\" in secondi e \"days\" sono facoltativi. \"superset\": true collega un esercizio al successivo. Per più settimane, raggruppa le routine dentro \"weeks\" come nel secondo esempio.';
+ 'Usa i nomi degli esercizi esattamente come nella lista. \"sets\", \"reps\" (un numero o un intervallo come \"8-12\"), \"weight\" (nell\'unità indicata), \"rest\" in secondi e \"days\" sono facoltativi. Per gli esercizi segnati cardio o a tempo nella lista, usa \"time\" (secondi, o come \"30:00\") e \"distance\" (in km) al posto di \"reps\"; per dare a ogni serie i suoi valori, elencale in \"plan\", una voce per serie con le sue \"reps\" e il suo \"weight\". \"type\" indica il tipo di serie: \"warmup\", \"drop\", \"failure\", \"restpause\" o \"cluster\"; sull\'esercizio vale per tutte le sue serie di lavoro, dentro \"plan\" solo per quella serie. \"superset\": true collega un esercizio al successivo. Per più settimane, raggruppa le routine dentro \"weeks\" come nel secondo esempio.';
@override
String get planSets => 'Pianifica le serie';
diff --git a/lib/services/plan_share.dart b/lib/services/plan_share.dart
index a1fedd1..68d5049 100644
--- a/lib/services/plan_share.dart
+++ b/lib/services/plan_share.dart
@@ -31,6 +31,7 @@ class PlanItem {
this.loggingNote = '',
this.sec,
this.km,
+ this.kind = 0,
});
final String name;
final int? sets;
@@ -51,6 +52,7 @@ class PlanItem {
final String loggingNote;
final int? sec;
final double? km;
+ final int kind;
}
class PlanRoutine {
@@ -346,6 +348,7 @@ List<PlanItem> _items(Object? raw, bool lb) {
},
sec: _seconds(_value(entry, _timeKeys)),
km: _double(_value(entry, _distanceKeys)),
+ kind: _kind(_value(entry, ['type', 'kind', 'settype', 'tipo'])),
));
}
return _mergeRepeats(out);
@@ -365,12 +368,26 @@ List<PlanSet> _expanded(PlanItem item) {
km: p.km ?? item.km,
),
for (var i = working; i < (item.sets ?? working); i++)
- PlanSet(reps: item.reps, repsMax: item.repsMax, weightKg: item.weightKg, sec: item.sec, km: item.km),
+ PlanSet(
+ reps: item.reps,
+ repsMax: item.repsMax,
+ weightKg: item.weightKg,
+ kind: item.kind,
+ sec: item.sec,
+ km: item.km,
+ ),
];
}
return [
for (var i = 0; i < (item.sets ?? 1); i++)
- PlanSet(reps: item.reps, repsMax: item.repsMax, weightKg: item.weightKg, sec: item.sec, km: item.km),
+ PlanSet(
+ reps: item.reps,
+ repsMax: item.repsMax,
+ weightKg: item.weightKg,
+ kind: item.kind,
+ sec: item.sec,
+ km: item.km,
+ ),
];
}
@@ -407,6 +424,7 @@ List<PlanItem> _mergeRepeats(List<PlanItem> items) {
loggingNote: first.loggingNote.isEmpty ? item.loggingNote : first.loggingNote,
sec: first.sec ?? item.sec,
km: first.km ?? item.km,
+ kind: first.kind,
);
}
return out;
diff --git a/lib/state/fit_state.dart b/lib/state/fit_state.dart
index 8d876dc..f5efceb 100644
--- a/lib/state/fit_state.dart
+++ b/lib/state/fit_state.dart
@@ -1298,7 +1298,14 @@ class FitState extends FitCore
return [
...explicit,
for (var i = working; i < wanted.clamp(0, 20); i++)
- PlannedSet(reps: item.reps, repsMax: item.repsMax, weightKg: item.weightKg, sec: item.sec, km: item.km),
+ PlannedSet(
+ reps: item.reps,
+ repsMax: item.repsMax,
+ weightKg: item.weightKg,
+ kind: setKindFrom(item.kind),
+ sec: item.sec,
+ km: item.km,
+ ),
];
}
diff --git a/test/plan_share_test.dart b/test/plan_share_test.dart
index d98a0c6..ad37274 100644
--- a/test/plan_share_test.dart
+++ b/test/plan_share_test.dart
@@ -119,6 +119,25 @@ void main() {
expect(again.single.items.first.plan.first.repsMax, 12);
});
+ test('el tipo de serie puesto en el ejercicio llega a sus series de trabajo', () {
+ fit.importPlan('{"name":"X","exercises":[{"name":"Barbell Bench Press","sets":3,"reps":10,"weight":60,"type":"drop"}]}');
+ final routine = fit.routines.single;
+ final sets = fit.plannedSets(routine, routine.exerciseIds.single);
+ expect(sets.map((s) => s.kind).toList(), [SetKind.drop, SetKind.drop, SetKind.drop]);
+ expect(sets.map((s) => s.weightKg).toList(), [60, 60, 60]);
+ final again = parsePlan(fit.exportPlanJson(fit.routines));
+ expect(again.single.items.single.plan.map((p) => p.kind).toList(), [2, 2, 2]);
+ });
+
+ test('una serie del plan conserva su propio tipo y el resto toma el del ejercicio', () {
+ fit.importPlan('{"name":"X","exercises":[{"name":"Barbell Bench Press","sets":3,"reps":8,"type":"restpause",'
+ '"plan":[{"reps":12,"weight":30,"type":"warmup"},{"reps":8}]}]}');
+ final routine = fit.routines.single;
+ final sets = fit.plannedSets(routine, routine.exerciseIds.single);
+ expect(sets.map((s) => s.kind).toList(), [SetKind.warmup, SetKind.normal, SetKind.restPause, SetKind.restPause]);
+ expect(sets.map((s) => s.reps).toList(), [12, 8, 8, 8]);
+ });
+
test('un ejercicio solo con tiempo no se pierde como si no tuviera datos', () {
fit.importPlan('{"name":"X","exercises":[{"name":"Treadmill Run","time":600}]}');
final routine = fit.routines.single;