From eb2aa966988d2251436809c9996013fb26fd7f78 Mon Sep 17 00:00:00 2001 From: Gerhard Olsson Date: Sun, 15 Nov 2020 19:00:57 +0100 Subject: [PATCH 1/3] Import workout: Name incorrect * Strip prefix for file printouts * Incorrect suffixes if overwriting a workout --- .../runnerup/view/ManageWorkoutsActivity.java | 31 +++++++++---------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/app/src/main/org/runnerup/view/ManageWorkoutsActivity.java b/app/src/main/org/runnerup/view/ManageWorkoutsActivity.java index 54faab0b1..9f2197b3a 100644 --- a/app/src/main/org/runnerup/view/ManageWorkoutsActivity.java +++ b/app/src/main/org/runnerup/view/ManageWorkoutsActivity.java @@ -181,7 +181,7 @@ private String getFilename(Uri data) { return name; } - private void importData(final String fileName, final Uri data) throws Exception { + private void importData(String fileName, final Uri data) throws Exception { final ContentResolver cr = getContentResolver(); InputStream is = cr.openInputStream(data); if (is == null) { @@ -192,36 +192,35 @@ private void importData(final String fileName, final Uri data) throws Exception if (w == null) throw new Exception("Failed to parse content"); + if(fileName.endsWith(".json")) { + fileName = fileName.substring(0, fileName.length() - ".json".length()); + } + + final String prefix = getString(R.string.RunnerUp_workout) + ": "; + if (fileName.startsWith(prefix) && fileName.length() > prefix.length()) { + fileName = fileName.substring(prefix.length()); + } + final boolean exists = WorkoutSerializer.getFile(this, fileName).exists(); final boolean[] selected = { false }; + final String workoutName = fileName; AlertDialog.Builder builder = new AlertDialog.Builder(this) - .setTitle(getString(R.string.Import_workout) + ": " + fileName) + .setTitle(getString(R.string.Import_workout) + ": " + workoutName) .setPositiveButton(R.string.Yes, (dialog, which) -> { dialog.dismiss(); - String saveName = fileName; + String saveName = workoutName; try { if (exists && !selected[0]) { - String name = ""; - String[] tmp = fileName.split("\\."); - if (tmp.length > 0) { - for (int i = 0; i < tmp.length - 1; i++) - name = name.concat(tmp[i]); - } else { - name = fileName; - } - String ending = tmp.length > 0 ? ("." + tmp[tmp.length - 1]) : ""; - String newName = fileName; for (int i = 1; i < 25; i++) { - newName = name + "-" + i + ending; + saveName = workoutName + "-" + i; if (!WorkoutSerializer.getFile(ManageWorkoutsActivity.this, - newName).exists()) + saveName).exists()) break; } - saveName = newName; Toast.makeText(ManageWorkoutsActivity.this, getString(R.string.Saving_as) + " " + saveName, Toast.LENGTH_SHORT).show(); } From db6dd712e99c08a7d65f6bc5c0e8f6643c37ebc4 Mon Sep 17 00:00:00 2001 From: Gerhard Olsson Date: Sun, 15 Nov 2020 19:02:32 +0100 Subject: [PATCH 2/3] Add 4x4 default workout --- app/assets/bundled/app_workouts/4x4.json | 1 + 1 file changed, 1 insertion(+) create mode 100644 app/assets/bundled/app_workouts/4x4.json diff --git a/app/assets/bundled/app_workouts/4x4.json b/app/assets/bundled/app_workouts/4x4.json new file mode 100644 index 000000000..337eb93b7 --- /dev/null +++ b/app/assets/bundled/app_workouts/4x4.json @@ -0,0 +1 @@ +{"com.garmin.connect.workout.json.UserWorkoutJson":{"workoutSteps":[{"stepTypeKey":"warmup","endConditionTypeKey":"lap.button","endConditionUnitKey":"dimensionless","targetTypeKey":"no.target","targetValueUnitKey":"dimensionless","stepOrder":1,"groupId":1},{"stepTypeKey":"repeat","endConditionTypeKey":"iterations","endConditionValue":4,"endConditionUnitKey":"dimensionless","stepOrder":2,"groupId":2},{"stepTypeKey":"interval","endConditionTypeKey":"time","endConditionValue":240000,"endConditionUnitKey":"ms","targetTypeKey":"no.target","targetValueUnitKey":"dimensionless","stepOrder":3,"groupId":2,"parentGroupId":2},{"stepTypeKey":"recovery","endConditionTypeKey":"time","endConditionValue":180000,"endConditionUnitKey":"ms","targetTypeKey":"no.target","targetValueUnitKey":"dimensionless","stepOrder":4,"groupId":2,"parentGroupId":2},{"stepTypeKey":"cooldown","endConditionTypeKey":"lap.button","endConditionUnitKey":"dimensionless","targetTypeKey":"no.target","targetValueUnitKey":"dimensionless","stepOrder":5,"groupId":3}]}} \ No newline at end of file From b7e580cdea41c7b0b101158dacaaf061de456b17 Mon Sep 17 00:00:00 2001 From: Gerhard Olsson Date: Sun, 15 Nov 2020 21:28:40 +0100 Subject: [PATCH 3/3] Update to 2.2.7 --- app/assets/changes.html | 6 ++++++ build.gradle | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/assets/changes.html b/app/assets/changes.html index d8d6a7d2b..6a815c53d 100644 --- a/app/assets/changes.html +++ b/app/assets/changes.html @@ -5,6 +5,12 @@

What's new

+

v2.2.7

+

+

    +
  • #984 Edit workout steps
  • +
  • #985 Import workout: Prefix when importing from file
  • +

v2.2.6

    diff --git a/build.gradle b/build.gradle index 12efe799c..d1a028ffa 100644 --- a/build.gradle +++ b/build.gradle @@ -31,8 +31,8 @@ project.ext { mockitoVersion = '2.3.7' //The Git tag for the release must be identical for F-Droid - versionName = '2.2.6.0' - versionCode = 292 + versionName = '2.2.7.0' + versionCode = 294 latestBaseVersionCode = 15000000 travisBuild = System.getenv("TRAVIS") == "true"