Skip to content

Commit

Permalink
Countdown steps: Separate from Interval rest step
Browse files Browse the repository at this point in the history
No auto conversion for Resting steps
  • Loading branch information
gerhardol committed Aug 7, 2019
1 parent 8b0bdd7 commit 5537eeb
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 25 deletions.
13 changes: 7 additions & 6 deletions app/res/xml/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -242,17 +242,18 @@

<CheckBoxPreference
android:defaultValue="true"
android:dependency="@string/pref_step_countdown_active"
android:persistent="true"
android:key="@string/pref_convert_interval_distance_rest_to_recovery"
android:title="@string/Convert_rest_on_Interval_tab"
android:summary="@string/Convert_reststep_with_type_distance_to_recoverystep_for_Intervaltab" />
android:key="@string/pref_convert_advanced_distance_rest_to_recovery"
android:title="@string/Convert_rest_on_Advanced_tab"
android:summary="@string/Convert_reststep_with_type_distance_to_recoverystep_for_Advancedtab" />

<CheckBoxPreference
android:defaultValue="true"
android:persistent="true"
android:key="@string/pref_convert_advanced_distance_rest_to_recovery"
android:title="@string/Convert_rest_on_Advanced_tab"
android:summary="@string/Convert_reststep_with_type_distance_to_recoverystep_for_Advancedtab" />
android:key="@string/pref_convert_interval_distance_rest_to_recovery"
android:title="@string/Convert_rest_on_Interval_tab"
android:summary="@string/Convert_reststep_with_type_distance_to_recoverystep_for_Intervaltab" />

<org.runnerup.widget.TextPreference
android:inputType="number"
Expand Down
4 changes: 1 addition & 3 deletions app/src/main/org/runnerup/view/ManageWorkoutsActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,7 @@ private void importData(final String fileName, final Uri data) throws Exception
if (is == null) {
throw new Exception("Failed to get input stream");
}
final boolean convertRestToRecovery = true; // we just test to import, value of this doesnt matter
Workout w = WorkoutSerializer.readJSON(new BufferedReader(new InputStreamReader(is)),
convertRestToRecovery);
Workout w = WorkoutSerializer.readJSON(new BufferedReader(new InputStreamReader(is)));
is.close();
if (w == null)
throw new Exception("Failed to parse content");
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/org/runnerup/workout/WorkoutBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ public static void prepareWorkout(Resources res, SharedPreferences prefs, Workou
if (prefs.getBoolean(res.getString(R.string.pref_step_countdown_active), true))
{
final boolean convertRestToRecovery = prefs.getBoolean(res.getString(
R.string.pref_convert_interval_distance_rest_to_recovery), true);
R.string.pref_convert_advanced_distance_rest_to_recovery), true);
long val = 15; // default
String vals = prefs.getString(res.getString(R.string.pref_step_countdown_time), "15");
try {
Expand Down
13 changes: 5 additions & 8 deletions app/src/main/org/runnerup/workout/WorkoutSerializer.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ private static class jsonstep
Step step;
}

public static Workout readJSON(Reader in, boolean convertRestToRecovery) throws JSONException {
public static Workout readJSON(Reader in) throws JSONException {
JSONObject obj = SyncHelper.parse(in);
obj = obj.getJSONObject("com.garmin.connect.workout.json.UserWorkoutJson");
Workout w = new Workout();
Expand All @@ -83,7 +83,7 @@ public static Workout readJSON(Reader in, boolean convertRestToRecovery) throws
ArrayList<jsonstep> list = new ArrayList<>(4);
while ((step = steps.optJSONObject(stepNo)) != null)
{
jsonstep js = parseStep(step, convertRestToRecovery);
jsonstep js = parseStep(step);
list.add(js);
stepNo++;
}
Expand Down Expand Up @@ -417,7 +417,7 @@ else if (unit.equalsIgnoreCase("metersPerMillisecond")) {
}
}

private static jsonstep parseStep(JSONObject obj, boolean convertRestToRecovery) throws JSONException {
private static jsonstep parseStep(JSONObject obj) throws JSONException {
jsonstep js = new jsonstep();
js.order = obj.getInt("stepOrder");
js.group = getInt(obj, "groupId");
Expand All @@ -433,8 +433,7 @@ private static jsonstep parseStep(JSONObject obj, boolean convertRestToRecovery)
break;
}
case RESTING:
boolean rest = !convertRestToRecovery || duration.first != Dimension.DISTANCE ||
duration.second == null;
boolean rest = duration.first != Dimension.DISTANCE || duration.second == null;
js.step = Step.createRestStep(duration.first, duration.second, !rest);
break;
case ACTIVE:
Expand Down Expand Up @@ -465,10 +464,8 @@ public static Workout readFile(Context ctx, String name) throws FileNotFoundExce
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ctx);
File fin = getFile(ctx, name);
Log.e("WorkoutSerializer", "reading " + fin.getPath());
final boolean convertRestToRecovery = prefs.getBoolean(ctx.getResources().getString(
R.string.pref_convert_advanced_distance_rest_to_recovery), true);

Workout w = readJSON(new FileReader(fin), convertRestToRecovery);
Workout w = readJSON(new FileReader(fin));
w.sport = prefs.getInt(ctx.getResources().getString(R.string.pref_sport), Constants.DB.ACTIVITY.SPORT_RUNNING);
w.setWorkoutType(Constants.WORKOUT_TYPE.ADVANCED);
return w;
Expand Down
6 changes: 3 additions & 3 deletions common/src/main/res/values-sv/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@
<string name="Downloadeditremove_workouts">Ladda ned/redigera/ta bort träningspass</string>
<string name="Note_you_need_to_connect_to_the_account_too">Obs, du måste ansluta till kontot också</string>
<string name="Use_your_headset_to_startpauseresume_RunnerUp">Använd dina lurar för att starta/pausa/återuppta RunnerUp</string>
<string name="Convert_reststep_with_type_distance_to_recoverystep_for_Intervaltab">För Interval-tabben och nedräkningssteg, använd \"Återhämting\" för \"Vila\" (paus) steg</string>
<string name="Convert_reststep_with_type_distance_to_recoverystep_for_Advancedtab">Använd \"Återhämting\" för \"Vila\" (paus) steg för träningspass</string>
<string name="Convert_reststep_with_type_distance_to_recoverystep_for_Intervaltab">För Interval-tabben, använd \"Återhämting\" för \"Vila\" (paus) steg</string>
<string name="Convert_reststep_with_type_distance_to_recoverystep_for_Advancedtab">För inlagda nedräkningssteg, använd \"Återhämting\" för \"Vila\" (paus) steg</string>
<string name="Export_database_to_sdcard_eg_for_upgrade">Exportera databas till sdkort (t.ex. före uppgradering)</string>
<string name="Import_database_from_sdcard_eg_after_upgrade">Importera databas från sdkort (t.ex. efter uppgradering)</string>
<string name="Coach_to_help_you_reach_target_if_having_set_target">Coach för att hjälpa dig nå målet (om mål är satt)</string>
Expand All @@ -197,7 +197,7 @@
<string name="Autopause_after_s">Autopausa efter (s)</string>
<string name="Autopause_min_pace_minkm">Autopaus tempo (min/km)</string>
<string name="Convert_rest_on_Interval_tab">Interval vilosteg</string>
<string name="Convert_rest_on_Advanced_tab">Vilosteg i pass</string>
<string name="Convert_rest_on_Advanced_tab">Återhämtning i nedräkningssteg</string>
<string name="Target_pace_moving_average_seconds">Målåterkoppling flytande medelvärde (s)</string>
<string name="Target_pace_grace_seconds">Målåterkoppling anståndstid (s)</string>
<string name="Autolap_during_intervals">Autovarv i pass</string>
Expand Down
8 changes: 4 additions & 4 deletions common/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@
<string name="Downloadeditremove_workouts">Download/edit/remove workouts</string>
<string name="Note_you_need_to_connect_to_the_account_too">You need to connect to a RunnerUp Live account</string>
<string name="Use_your_headset_to_startpauseresume_RunnerUp">Use your headset to start/pause/resume RunnerUp</string>
<string name="Convert_reststep_with_type_distance_to_recoverystep_for_Intervaltab">On the Interval tab and countdown steps, use \"Recovery\" instead of \"Rest\" (pause) steps</string>
<string name="Convert_reststep_with_type_distance_to_recoverystep_for_Advancedtab">For advanced workouts, use \"Recovery\" instead of \"Rest\" (pause) steps</string>
<string name="Convert_reststep_with_type_distance_to_recoverystep_for_Intervaltab">On the Interval tab, use \"Recovery\" instead of \"Rest\" (pause) steps</string>
<string name="Convert_reststep_with_type_distance_to_recoverystep_for_Advancedtab">For inserted countdown steps, use \"Recovery\" instead of \"Rest\" (pause) steps</string>
<string name="Export_database_to_sdcard_eg_for_upgrade">Export database to storage</string>
<string name="Import_database_from_sdcard_eg_after_upgrade">Import database from storage</string>
<string name="Coach_to_help_you_reach_target_if_having_set_target">Coach to help you reach target (if having set target)</string>
Expand All @@ -198,14 +198,14 @@
<string name="Autopause_after_s">Autopause after (s)</string>
<string name="Autopause_min_pace_minkm">Autopause min pace (min/km)</string>
<string name="Convert_rest_on_Interval_tab">Interval rest steps</string>
<string name="Convert_rest_on_Advanced_tab">Workout rest steps</string>
<string name="Convert_rest_on_Advanced_tab">Recovery in countdown steps</string>
<string name="Target_pace_moving_average_seconds">Target feedback moving average (s)</string>
<string name="Target_pace_grace_seconds">Target feedback grace period (s)</string>
<string name="Autolap_during_intervals">Autolap in workouts</string>
<string name="Autolap_basic_summary">Autolap in basic workouts</string>
<string name="Autolap_during_intervals_summary">Autolap in last step and \"Active\" steps</string>
<string name="Add_countdown_after_step_that_ends_with_user_press">Countdown after key press</string>
<string name="Add_countdown_after_step_that_ends_with_user_press_summary">Add \"Recovery\" or \"Rest\" countdown step after steps that ends with user key press</string>
<string name="Add_countdown_after_step_that_ends_with_user_press_summary">Add a countdown \"Recovery\" or \"Rest\" step after a step that ends with user key press</string>
<string name="Step_countdown_time_s">Step countdown time (s)</string>
<string name="Smooth_pace_graph">Smooth pace graph</string>
<string name="Smooth_pace_filters">Smooth pace filter (s)</string>
Expand Down

0 comments on commit 5537eeb

Please sign in to comment.