~anjan/lift

f7a42f4475263669b7afd9d93617b8df92fc5848 — Anjandev Momi 4 years ago 5d67ac4
531: display maxes and week in comments
M app/src/main/java/ca/momi/lift/AssignedExcers.java => app/src/main/java/ca/momi/lift/AssignedExcers.java +8 -0
@@ 46,6 46,14 @@ public class AssignedExcers {
    public static final String ASSISTANCE = "Assistance";
    public static final String[] UPPER_BODY = {BENCH, CHINUPS, OVERHEAD, BARBELL_ROW};


    public static String getComment(Context context) {
        if (MainActivity.program.equals(FIVE_31_BBB)) {
            return Routine531BBB.getComment(context);
        }
        return null;
    }

    public static List<String> routNames () {
        List<String> routineNames = new ArrayList<>();
        routineNames.add(FIVE_x_5);

M app/src/main/java/ca/momi/lift/LastWorkout.java => app/src/main/java/ca/momi/lift/LastWorkout.java +3 -1
@@ 16,6 16,8 @@

package ca.momi.lift;

import android.content.res.Resources;

import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;


@@ 78,7 80,7 @@ public class LastWorkout {
            curSets.add(new Set(reps, weight));
        }

        if (!curExcersizeLine.equals("---")) {
        if (!curExcersizeLine.equals(Resources.getSystem().getString(R.string.start_comment))) {
            excersizes = setSetsDoneAndAddExcer(excersizes, curSets, curExcersizeLine);
        }


M app/src/main/java/ca/momi/lift/Routine531BBB.java => app/src/main/java/ca/momi/lift/Routine531BBB.java +34 -10
@@ 16,14 16,18 @@ package ca.momi.lift;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Resources;

import java.util.ArrayList;
import java.util.List;
import java.util.ResourceBundle;

import static ca.momi.lift.MainActivity.PREFERENCE_FILE_KEY;

public class Routine531BBB {

    final static int  TOTAL_ROUTINE = 4;

    static private double getTrainingMax531(Double weight){
        return ((weight))*0.9;
    }


@@ 108,24 112,16 @@ public class Routine531BBB {
        AssignedExcers assExcer = new AssignedExcers();

        int numPreviousExcersizes = ExternalStore.getNumLastWorkoutFiles();
        final int TOTAL_ROUTINE = 4;
        int nextExcersize = numPreviousExcersizes % TOTAL_ROUTINE + 1;

        List<String> slistNewExcersizes = assExcer.getExcersizes("Day "+nextExcersize);

        final int curWeek = numPreviousExcersizes / TOTAL_ROUTINE;

        final int month= curWeek / 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;


        List<NextExcersize> nextExcersizes = new ArrayList<>();

        boolean lastDaySavedFailed = false;

        int curWeekRelativeMonth = getCurWeekRelativeMonth();

        for (int i = 0; i < slistNewExcersizes.size(); i++){
            if (slistNewExcersizes.get(i).equals(AssignedExcers.ASSISTANCE)) {
                int[] reps = assExcer.getReps(slistNewExcersizes.get(i));


@@ 195,6 191,17 @@ public class Routine531BBB {

    }

    private static int getCurWeekRelativeMonth() {
        int numPreviousExcersizes = ExternalStore.getNumLastWorkoutFiles();

        final int curWeek = numPreviousExcersizes / TOTAL_ROUTINE;

        final int month= curWeek / TOTAL_ROUTINE;

        final int WEEKS_IN_MONTH = 4;
        // First week of the month would be 0, second week 1, etc.
        return curWeek - month * WEEKS_IN_MONTH;
    }

    private static double[] zeroArray(int length){



@@ 216,4 223,21 @@ public class Routine531BBB {
        return excersize.substring(excersize.length()-"Supplement".length()).equals("Supplement");
    }

    public static String getComment(Context context) {

        String comment = "";

        SharedPreferences sharedPref = context.getSharedPreferences(PREFERENCE_FILE_KEY, Context.MODE_PRIVATE);
        Resources res = context.getResources();

        comment += res.getString(R.string.Week) + ": " + getCurWeekRelativeMonth() + "\n";
        comment += res.getString(R.string.Squat531Max) + ": " + sharedPref.getString(R.string.Squat + "1RM", "0") + "\n";
        comment += res.getString(R.string.Bench531Max) + ": " + sharedPref.getString(R.string.Bench + "1RM", "0") + "\n";
        comment += res.getString(R.string.Deadlift531Max) + ": " + sharedPref.getString(R.string.Deadlift + "1RM", "0") + "\n";
        comment += res.getString(R.string.Overhead531Max) + ": " + sharedPref.getString(R.string.Overhead + "1RM", "0") + "\n";


        return comment;
    }

}

M app/src/main/java/ca/momi/lift/Workout.java => app/src/main/java/ca/momi/lift/Workout.java +12 -2
@@ 409,9 409,19 @@ public class Workout extends AppCompatActivity {
            workoutSessionText += ExternalStore.makeExcersizeString(listOfExcersizes[i]);
        }


        workoutSessionText += getResources().getString(R.string.start_comment);

        String routComment = AssignedExcers.getComment(v.getContext());

        if (routComment != null){
            workoutSessionText += routComment;
        }


        // OnPause text is always the last word. Otherwise parser doesnt work
        if (onPause) {
            workoutSessionText += "---\n" +
                    LastWorkout.onPausetxt;
            workoutSessionText += LastWorkout.onPausetxt;
        }

        if (currentWorkTimer != null & !onPause) {

M app/src/main/res/layout/activity_settings.xml => app/src/main/res/layout/activity_settings.xml +4 -4
@@ 60,7 60,7 @@
        android:layout_marginLeft="16dp"
        android:layout_marginTop="8dp"
        android:ems="10"
        android:hint="Squat Real 1RM Weight"
        android:hint="@string/Squat531Max"
        android:inputType="numberDecimal"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/programs" />


@@ 73,7 73,7 @@
        android:layout_marginLeft="16dp"
        android:layout_marginTop="8dp"
        android:ems="10"
        android:hint="Overhead Real 1RM Weight"
        android:hint="@string/Overhead531Max"
        android:inputType="numberDecimal"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/begSquat" />


@@ 86,7 86,7 @@
        android:layout_marginLeft="16dp"
        android:layout_marginTop="8dp"
        android:ems="10"
        android:hint="Deadlift Real 1RM Weight"
        android:hint="@string/Deadlift531Max"
        android:inputType="numberDecimal"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/begOverhead" />


@@ 99,7 99,7 @@
        android:layout_marginLeft="16dp"
        android:layout_marginTop="8dp"
        android:ems="10"
        android:hint="Bench Real  1RM Weight"
        android:hint="@string/Bench531Max"
        android:inputType="numberDecimal"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/begDeadLift" />

M app/src/main/res/values/strings.xml => app/src/main/res/values/strings.xml +10 -0
@@ 51,4 51,14 @@

    Home icons made by Kiranshastry (https://www.flaticon.com/authors/kiranshastry) from www.flaticon.com
    </string>
    <string name="start_comment">---\n</string>
    <string name="Squat531Max">Squat Real 1RM Weight</string>
    <string name="Deadlift531Max">Deadlift Real 1RM Weight</string>
    <string name="Bench531Max">Bench Real 1RM Weight</string>
    <string name="Overhead531Max">Overhead Real 1RM Weight</string>
    <string name="Squat">Squat</string>
    <string name="Bench">Bench Press</string>
    <string name="Overhead">Overhead Press</string>
    <string name="Deadlift">Deadlift</string>
    <string name="Week">Week</string>
</resources>