M app/src/main/java/ca/momi/lift/AssignedExcers.java => app/src/main/java/ca/momi/lift/AssignedExcers.java +61 -39
@@ 15,9 15,9 @@
package ca.momi.lift;
import android.content.Context;
-import android.preference.PreferenceGroup;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
public class AssignedExcers {
@@ 31,13 31,20 @@ public class AssignedExcers {
public List<String> routineDescriber = new ArrayList<>();
- public int workoutOptionsnum;
-
-
+ private int workoutOptionsnum;
public static final String PHRAK_GSPL = "Phrakâs GSLP";
public static final String FIVE_x_5 = "5x5";
public static final String FIVE_31_BBB = "531BBB";
+ public static final String BARBELL_ROW = "Bent-over Row";
+ public static final String BENCH = "Bench Press";
+ public static final String CHINUPS = "Chinup";
+ public static final String OVERHEAD = "Overhead Press";
+ public static final String SUPPLEMENT = " - Supplement";
+ public static final String SQUAT = "Squat";
+ public static final String DEADLIFT = "Deadlift";
+ public static final String ASSISTANCE = "Assistance";
+ public static final String[] UPPER_BODY = {BENCH, CHINUPS, OVERHEAD, BARBELL_ROW};
public static List<String> routNames () {
List<String> routineNames = new ArrayList<>();
@@ 48,6 55,21 @@ public class AssignedExcers {
return routineNames;
}
+ public static double getSmallestWeightForUOM(){
+ if (MainActivity.uom.equals("lb")){
+ return MainActivity.smallestWeightLb;
+ } else {
+ return MainActivity.smallestWeightKg;
+ }
+ }
+
+ public static boolean isUpperBody(String name){
+
+ if (Arrays.asList(UPPER_BODY).contains(name)){
+ return true;
+ }
+ return false;
+ }
static public double getPercentOfWeight(double weight, double percent) {
double pWeight = weight * percent;
@@ 95,7 117,7 @@ public class AssignedExcers {
public int[] getReps (String excersize){
if (this.program.equals(FIVE_x_5)) {
- if (excersize.equals("Deadlift")) {
+ if (excersize.equals(DEADLIFT)) {
int[] A = {5};
return A;
} else {
@@ 106,7 128,7 @@ public class AssignedExcers {
if(Routine531BBB.isSupplement(excersize)) {
int[] A = {10, 10, 10, 10, 10};
return A;
- } else if(excersize.equals("Assistance")){
+ } else if(excersize.equals(ASSISTANCE)){
int[] A = {25};
return A;
} else {
@@ 168,71 190,71 @@ public class AssignedExcers {
case FIVE_x_5:
switch (routName) {
case "Bench Press, Barbell Row":
- excersizes.add("Squat");
- excersizes.add("Bench Press");
- excersizes.add("Bent-over Row");
+ excersizes.add(SQUAT);
+ excersizes.add(BENCH);
+ excersizes.add(BARBELL_ROW);
break;
case "Overhead Press, Deadlift":
- excersizes.add("Squat");
- excersizes.add("Overhead Press");
- excersizes.add("Deadlift");
+ excersizes.add(SQUAT);
+ excersizes.add(OVERHEAD);
+ excersizes.add(DEADLIFT);
break;
}
return excersizes;
case "madcow":
switch (routName) {
case "Day 1":
- excersizes.add("Squat");
- excersizes.add("Bench Press");
- excersizes.add("Bent-over Row");
+ excersizes.add(SQUAT);
+ excersizes.add(BENCH);
+ excersizes.add(BARBELL_ROW);
break;
case "Day 2":
- excersizes.add("Squat");
- excersizes.add("Overhead Press");
- excersizes.add("Deadlift");
+ excersizes.add(SQUAT);
+ excersizes.add(OVERHEAD);
+ excersizes.add(DEADLIFT);
break;
case "Day 3":
- excersizes.add("Squat");
- excersizes.add("Bench Press");
- excersizes.add("Bent-over Row");
+ excersizes.add(SQUAT);
+ excersizes.add(BENCH);
+ excersizes.add(BARBELL_ROW);
break;
}
return excersizes;
case FIVE_31_BBB:
switch (routName) {
case "Day 1":
- excersizes.add("Overhead Press");
- excersizes.add("Bench Press - Supplement");
- excersizes.add("Assistance");
+ excersizes.add(OVERHEAD);
+ excersizes.add(BENCH + SUPPLEMENT);
+ excersizes.add(ASSISTANCE);
break;
case "Day 2":
- excersizes.add("Deadlift");
- excersizes.add("Squat - Supplement");
- excersizes.add("Assistance");
+ excersizes.add(DEADLIFT);
+ excersizes.add(SQUAT + SUPPLEMENT);
+ excersizes.add(ASSISTANCE);
break;
case "Day 3":
- excersizes.add("Bench Press");
- excersizes.add("Overhead Press - Supplement");
- excersizes.add("Assistance");
+ excersizes.add(BENCH);
+ excersizes.add(OVERHEAD + SUPPLEMENT);
+ excersizes.add(ASSISTANCE);
break;
case "Day 4":
- excersizes.add("Squat");
- excersizes.add("Deadlift - Supplement");
- excersizes.add("Assistance");
+ excersizes.add(SQUAT);
+ excersizes.add(DEADLIFT + SUPPLEMENT);
+ excersizes.add(ASSISTANCE);
break;
}
return excersizes;
case PHRAK_GSPL:
switch (routName) {
case "Day A":
- excersizes.add("Barbell Rows");
- excersizes.add("Bench Press");
- excersizes.add("Squats");
+ excersizes.add(BARBELL_ROW);
+ excersizes.add(BENCH);
+ excersizes.add(SQUAT);
break;
case "Day B":
- excersizes.add("Chinups");
- excersizes.add("Overhead Press");
- excersizes.add("Deadlifts");
+ excersizes.add(CHINUPS);
+ excersizes.add(OVERHEAD);
+ excersizes.add(DEADLIFT);
break;
}
return excersizes;
M app/src/main/java/ca/momi/lift/Routine531BBB.java => app/src/main/java/ca/momi/lift/Routine531BBB.java +70 -48
@@ 28,7 28,13 @@ public class Routine531BBB {
return ((weight))*0.9;
}
-
+ static private double getWeightInc(String excersize){
+ if (AssignedExcers.isUpperBody(excersize)){
+ return AssignedExcers.getSmallestWeightForUOM();
+ } else {
+ return 2*AssignedExcers.getSmallestWeightForUOM();
+ }
+ }
static private double getfailureWeight(double curweight) {
return AssignedExcers.getPercentOfWeight(curweight, 0.9);
@@ 89,81 95,97 @@ public class Routine531BBB {
return 0;
}
- static private double downSetsPercentage(int month){
- switch (month){
- case 0:
- return 0.5;
- case 1:
- return 0.6;
- case 2:
- return 0.6;
- }
- return 0;
+ static private double downSetsPercentage(){
+ // this abstraction exists so that we can get user's down set percentage from settings and
+ // do more complex calculations.
+ // That setting has not been implemented so here we are....
+ return 0.5;
}
+
+
static public List<NextExcersize> nextRoutineWeights (Context context){
SharedPreferences sharedPref = context.getSharedPreferences(PREFERENCE_FILE_KEY, Context.MODE_PRIVATE);
AssignedExcers assExcer = new AssignedExcers();
int numPreviousExcersizes = ExternalStore.getNumLastWorkoutFiles();
- int TOTAL_ROUTINE = 4;
+ final int TOTAL_ROUTINE = 4;
int nextExcersize = numPreviousExcersizes % TOTAL_ROUTINE + 1;
List<String> slistNewExcersizes = assExcer.getExcersizes("Day "+nextExcersize);
- int IDX_OF_LAST_WEEK = 3;
+ final int curWeek = numPreviousExcersizes / TOTAL_ROUTINE;
+ final int month= curWeek / TOTAL_ROUTINE;
- int week = numPreviousExcersizes / TOTAL_ROUTINE;
+ final int WEEKS_IN_MONTH = 4;
+ // First week of the month would be 0, second week 1, etc.
+ int curWeekRelativeMonth = curWeek - month * WEEKS_IN_MONTH;
- int month= week / 4;
List<NextExcersize> nextExcersizes = new ArrayList<>();
- // If haven't been running for more than a week, just return the weight. No need to check
- // for failure.
- // if (numPreviousExcersizes - IDX_OF_LAST_WEEK =< 0){
- // Always increment
- for (int i = 0; i < slistNewExcersizes.size(); i++){
- if (slistNewExcersizes.get(i).equals("Assistance")) {
- int[] reps = assExcer.getReps(slistNewExcersizes.get(i));
+ boolean lastDaySavedFailed = false;
- nextExcersizes.add(new NextExcersize(slistNewExcersizes.get(i), zeroArray(reps.length)));
+ for (int i = 0; i < slistNewExcersizes.size(); i++){
+ if (slistNewExcersizes.get(i).equals(AssignedExcers.ASSISTANCE)) {
+ int[] reps = assExcer.getReps(slistNewExcersizes.get(i));
+
+ nextExcersizes.add(new NextExcersize(slistNewExcersizes.get(i), zeroArray(reps.length)));
+ }
+ else {
+ // Bug with supplement
+ String curExcersize = slistNewExcersizes.get(i);
+
+ if (isSupplement(curExcersize)) {
+ curExcersize = curExcersize.substring(0, curExcersize.lastIndexOf(AssignedExcers.SUPPLEMENT));
}
- else {
- // Bug with supplement
- String curExcersize = slistNewExcersizes.get(i);
- if (isSupplement(curExcersize)) {
- curExcersize = curExcersize.substring(0, curExcersize.lastIndexOf(" - Supplement"));
+ double excerWeight = Double.valueOf(sharedPref.getString(curExcersize + "1RM", "0"));
- }
+ String lastDay = sharedPref.getString("Last Day Saved", "null");
+ if (lastDay.equals(String.valueOf(nextExcersize)) & i == 0){
+ // If this is true, user already opened this activity. As such, we had already incremented
+ // weight. Only check on the first item in excersizes list.
+ lastDaySavedFailed = true;
+ }
- double excerWeight = Double.valueOf(sharedPref.getString(curExcersize + "1RM", "0"));
- double trainingMax = getTrainingMax531(excerWeight);
- int[] reps = assExcer.getReps(slistNewExcersizes.get(i));
- double[] weights = new double[reps.length];
- if (isSupplement(slistNewExcersizes.get(i))){
- for (int idx =0; idx< reps.length; idx++){
- weights[idx] = AssignedExcers.getPercentOfWeight(trainingMax, downSetsPercentage(month));
- }
- } else {
- int WARMUP_SETS = 3;
- for (int idx =0; idx< WARMUP_SETS; idx++){
- weights[idx] = AssignedExcers.getPercentOfWeight(trainingMax, getPercentageWarmUp(idx));
- }
- for(int idx=0; idx < reps.length - WARMUP_SETS; idx++){
- weights[idx + WARMUP_SETS] = AssignedExcers.getPercentOfWeight(trainingMax, getPercentWorkSet(week,idx));
- }
+ if (curWeekRelativeMonth == 0 & (nextExcersize == 1 || nextExcersize == 2) & !lastDaySavedFailed){
+ // If first week of the new month, increment weight and save to memory.
+ // Only increment on days 1 or 2 because if I allowed all days you work out first
+ // week, I would increment weight twice in the first week of the month.
+ // Todo: ask user if they want to progress or look at previous data.
+ SharedPreferences.Editor editor = sharedPref.edit();
+ editor.putString("Last Day Saved", String.valueOf(nextExcersize));
+
+ excerWeight += getWeightInc(curExcersize);
+ editor.putString(curExcersize + "1RM", String.valueOf(excerWeight));
+ editor.apply();
+ }
+ double trainingMax = getTrainingMax531(excerWeight);
+ int[] reps = assExcer.getReps(slistNewExcersizes.get(i));
+ double[] weights = new double[reps.length];
+ if (isSupplement(slistNewExcersizes.get(i))){
+ for (int idx =0; idx< reps.length; idx++){
+ weights[idx] = AssignedExcers.getPercentOfWeight(trainingMax, downSetsPercentage());
+ }
+ } else {
+ int WARMUP_SETS = 3;
+ for (int idx =0; idx< WARMUP_SETS; idx++){
+ weights[idx] = AssignedExcers.getPercentOfWeight(trainingMax, getPercentageWarmUp(idx));
+ }
+ for(int idx=0; idx < reps.length - WARMUP_SETS; idx++){
+ weights[idx + WARMUP_SETS] = AssignedExcers.getPercentOfWeight(trainingMax, getPercentWorkSet(curWeekRelativeMonth,idx));
}
- nextExcersizes.add(new NextExcersize(slistNewExcersizes.get(i), weights));
- }
+ }
+ nextExcersizes.add(new NextExcersize(slistNewExcersizes.get(i), weights));
}
+ }
+
- // }
return nextExcersizes;
M app/src/main/java/ca/momi/lift/Routine5x5.java => app/src/main/java/ca/momi/lift/Routine5x5.java +3 -11
@@ 150,18 150,10 @@ public class Routine5x5 {
}
private static double getWeightInc(String excersize){
- if (Excersize.uom == "lb") {
- if (excersize.equals("Deadlift")){
- return 2 * MainActivity.smallestWeightLb;
- }
- return MainActivity.smallestWeightLb;
- } else {
- // Must be kg
- if (excersize.equals("Deadlift")){
- return 2 * MainActivity.smallestWeightKg;
- }
- return MainActivity.smallestWeightKg;
+ if (excersize.equals(AssignedExcers.DEADLIFT)){
+ return 2 * AssignedExcers.getSmallestWeightForUOM();
}
+ return AssignedExcers.getSmallestWeightForUOM();
}
M app/src/main/java/ca/momi/lift/RoutinePhrak.java => app/src/main/java/ca/momi/lift/RoutinePhrak.java +1 -2
@@ 81,8 81,7 @@ public class RoutinePhrak {
String name = excer.excersizeName;
// Check if upper body workout
- if (name.equals("Barbell Rows") || name.equals("Bench Press") || name.equals("Chinups")
- || name.equals("Overhead Press")){
+ if (AssignedExcers.isUpperBody(name)){
if (excer.uom.equals("lb")){
return MainActivity.smallestWeightLb;
} else {