Skip to content

Commit

Permalink
Step for #182
Browse files Browse the repository at this point in the history
  • Loading branch information
brodeurlv committed Jan 10, 2021
1 parent eef8803 commit 6ea4d57
Show file tree
Hide file tree
Showing 11 changed files with 80 additions and 27 deletions.
23 changes: 21 additions & 2 deletions app/src/main/java/com/easyfitness/DAO/record/DAOFonte.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.easyfitness.DAO.record;

import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;

import com.easyfitness.DAO.DAOMachine;
Expand All @@ -10,11 +9,11 @@
import com.easyfitness.DAO.Weight;
import com.easyfitness.enums.DistanceUnit;
import com.easyfitness.enums.ExerciseType;
import com.easyfitness.enums.ProgramRecordStatus;
import com.easyfitness.enums.RecordType;
import com.easyfitness.enums.WeightUnit;
import com.easyfitness.graph.GraphData;
import com.easyfitness.utils.DateConverter;
import com.easyfitness.enums.ProgramRecordStatus;

import java.util.ArrayList;
import java.util.Date;
Expand All @@ -26,6 +25,8 @@ public class DAOFonte extends DAORecord {
public static final int MAX1_FCT = 1;
public static final int MAX5_FCT = 2;
public static final int NBSERIE_FCT = 3;
public static final int TOTAL_REP_FCT = 4;
public static final int MAX_REP_FCT = 5;
public static final int ONEREPMAX_FCT = 4;

private static final String TABLE_ARCHI = KEY + "," + DATE + "," + EXERCISE + "," + SETS + "," + REPS + "," + WEIGHT + "," + WEIGHT_UNIT + "," + PROFILE_KEY + "," + NOTES + "," + EXERCISE_KEY + "," + TIME;
Expand Down Expand Up @@ -114,6 +115,24 @@ public List<GraphData> getBodyBuildingFunctionRecords(Profile pProfile, String p
+ " AND " + RECORD_TYPE + "!=" + RecordType.TEMPLATE_TYPE.ordinal()
+ " GROUP BY " + LOCAL_DATE
+ " ORDER BY " + DATE_TIME + " ASC";
} else if (pFunction == DAOFonte.TOTAL_REP_FCT) {
selectQuery = "SELECT SUM(" + SETS + "*" + REPS + "), " + LOCAL_DATE + " FROM "
+ TABLE_NAME
+ " WHERE " + EXERCISE + "=\"" + pMachine + "\""
+ " AND " + PROFILE_KEY + "=" + pProfile.getId()
+ " AND " + TEMPLATE_RECORD_STATUS + "!=" + ProgramRecordStatus.PENDING.ordinal()
+ " AND " + RECORD_TYPE + "!=" + RecordType.TEMPLATE_TYPE.ordinal()
+ " GROUP BY " + LOCAL_DATE
+ " ORDER BY " + DATE_TIME + " ASC";
} else if (pFunction == DAOFonte.MAX_REP_FCT) {
selectQuery = "SELECT MAX(" + REPS + ") , " + LOCAL_DATE + " FROM "
+ TABLE_NAME
+ " WHERE " + EXERCISE + "=\"" + pMachine + "\""
+ " AND " + PROFILE_KEY + "=" + pProfile.getId()
+ " AND " + TEMPLATE_RECORD_STATUS + "!=" + ProgramRecordStatus.PENDING.ordinal()
+ " AND " + RECORD_TYPE + "!=" + RecordType.TEMPLATE_TYPE.ordinal()
+ " GROUP BY " + LOCAL_DATE
+ " ORDER BY " + DATE_TIME + " ASC";
}

// Formation de tableau de valeur
Expand Down
40 changes: 27 additions & 13 deletions app/src/main/java/com/easyfitness/fonte/FonteGraphFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
import com.easyfitness.SettingsFragment;
import com.easyfitness.enums.DistanceUnit;
import com.easyfitness.enums.ExerciseType;
import com.easyfitness.enums.Unit;
import com.easyfitness.enums.UnitType;
import com.easyfitness.enums.WeightUnit;
import com.easyfitness.graph.BarGraph;
import com.easyfitness.graph.DateGraph;
Expand Down Expand Up @@ -244,15 +246,27 @@ private void drawGraph() {
ArrayList<BarEntry> yBarVals = new ArrayList<>();
String desc = "";

UnitType unitType = UnitType.NONE;

if (m.getType() == ExerciseType.STRENGTH) {
if (lFunction.equals(mActivity.getResources().getString(R.string.maxRep1))) {
lDAOFunction = DAOFonte.MAX1_FCT;
unitType = UnitType.WEIGHT;
} else if (lFunction.equals(mActivity.getResources().getString(R.string.maxRep5d))) {
lDAOFunction = DAOFonte.MAX5_FCT;
unitType = UnitType.WEIGHT;
} else if (lFunction.equals(mActivity.getResources().getString(R.string.sum))) {
lDAOFunction = DAOFonte.SUM_FCT;
unitType = UnitType.WEIGHT;
} else if (lFunction.equals(mActivity.getResources().getString(R.string.sumReps))) {
lDAOFunction = DAOFonte.TOTAL_REP_FCT;
unitType = UnitType.NONE;
} else if (lFunction.equals(mActivity.getResources().getString(R.string.maxReps))) {
lDAOFunction = DAOFonte.MAX_REP_FCT;
unitType = UnitType.NONE;
} else if (lFunction.equals(mActivity.getResources().getString(R.string.oneRepMax))) {
lDAOFunction = DAOFonte.ONEREPMAX_FCT;
unitType = UnitType.WEIGHT;
}
// Recupere les enregistrements
List<GraphData> valueList = mDbFonte.getBodyBuildingFunctionRecords(getProfile(), lMachine, lDAOFunction);
Expand All @@ -262,13 +276,19 @@ private void drawGraph() {
return;
}

WeightUnit defaultUnit = SettingsFragment.getDefaultWeightUnit(getMainActivity());

for (int i = 0; i < valueList.size(); i++) {
if (unitType==UnitType.WEIGHT) {
WeightUnit defaultUnit = SettingsFragment.getDefaultWeightUnit(getMainActivity());
desc = lMachine + "/" + lFunction + "(" + defaultUnit.toString() + ")";
Entry value = new Entry((float) valueList.get(i).getX(), UnitConverter.weightConverter((float) valueList.get(i).getY(), WeightUnit.KG, defaultUnit));//-minDate)/86400000));

yVals.add(value);
for (int i = 0; i < valueList.size(); i++) {
Entry value = new Entry((float) valueList.get(i).getX(), UnitConverter.weightConverter((float) valueList.get(i).getY(), WeightUnit.KG, defaultUnit));
yVals.add(value);
}
} else if (unitType==UnitType.NONE) {
desc = lMachine + "/" + lFunction;
for (int i = 0; i < valueList.size(); i++) {
Entry value = new Entry((float) valueList.get(i).getX(), (float) valueList.get(i).getY());
yVals.add(value);
}
}

mBarGraph.getChart().setVisibility(View.GONE);
Expand Down Expand Up @@ -333,10 +353,7 @@ private void drawGraph() {
// Recupere les enregistrements
List<GraphData> valueList = mDbStatic.getStaticFunctionRecords(getProfile(), lMachine, lDAOFunction);

if (valueList == null || valueList.size() <= 0) {
// mLineChart.clear(); Already cleared
return;
}
if (valueList == null || valueList.size() <= 0) return;

if (lDAOFunction == DAOStatic.MAX_FCT) {
WeightUnit defaultUnit = SettingsFragment.getDefaultWeightUnit(getMainActivity());
Expand Down Expand Up @@ -383,11 +400,8 @@ public String getName() {
}

private void refreshData() {
//View fragmentView = getView();

if (mFragmentView != null) {
if (getProfile() != null) {
//functionList.setOnItemSelectedListener(onItemSelectedList);
if (mAdapterMachine == null) {
mMachinesArray = mDbFonte.getAllMachinesStrList();
//Data are refreshed on show
Expand Down
6 changes: 4 additions & 2 deletions app/src/main/res/values-cs/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@
<string name="drawer_open">Otevřít panel navigace</string>
<string name="drawer_close">Zavřít panel navigace</string>

<string name="maxRep1">Maximum (Opak >= 1)</string>
<string name="maxRep1">Max Hmotnost (Opak >= 1)</string>
<string name="maxRep5d">Maximum (Opak >= 5)</string>
<string name="sum">Suma</string>
<string name="sum">Hmotnost Suma</string>

<string name="sumDistance">Vzdálenost</string>
<string name="sumDuration">Trvání</string>
Expand Down Expand Up @@ -287,5 +287,7 @@
<string name="pref_preferredSizeUnitTitle">Zvolit preferovanou velikost jednotky</string>
<string name="program_completed">Jste dokončili program! Chcete ji zavřít?</string>
<string name="maxLengthPerDate">Maximální délka trvání jednoho Datum</string>
<string name="maxReps">Max Opk</string>
<string name="sumReps">Opk Suma</string>

</resources>
4 changes: 3 additions & 1 deletion app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@

<string name="maxRep1">Maximum (Wied. >= 1)</string>
<string name="maxRep5d">Maximum (Wied. >= 5)</string>
<string name="sum">Summe</string>
<string name="sum">Gewicht Summe</string>

<string name="all">Alle</string>

Expand Down Expand Up @@ -286,5 +286,7 @@
<string name="pref_preferredSizeUnitTitle">Wähle deine gewünschte Größe Einheit</string>
<string name="program_completed">Sie haben Ihr Programm abgeschlossen! Wollen Sie es schließen?</string>
<string name="maxLengthPerDate">Max Dauer pro Datum</string>
<string name="maxReps">Max Wied.</string>
<string name="sumReps">Wied. Summe</string>
</resources>

4 changes: 3 additions & 1 deletion app/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@

<string name="maxRep1">Máximo (Reps >= 1)</string>
<string name="maxRep5d">Máximo (Reps >= 5)</string>
<string name="sum">Suma</string>
<string name="sum">Suma de peso</string>
<string-array name="graph_functions">
<item>@string/maxRep1</item>
<item>@string/maxRep5d</item>
Expand Down Expand Up @@ -293,5 +293,7 @@
<string name="pref_preferredSizeUnitTitle">Selecciona tu unidad de tamaño preferida</string>
<string name="program_completed">Ha completado su programa! ¿Quieres cerrarla?</string>
<string name="maxLengthPerDate">Duración máxima por Fecha</string>
<string name="maxReps">Máx de Reps</string>
<string name="sumReps">Suma de Reps</string>

</resources>
4 changes: 3 additions & 1 deletion app/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@

<string name="maxRep1">Maximum (Reps >= 1)</string>
<string name="maxRep5d">Maximum (Reps >= 5)</string>
<string name="sum">Somme</string>
<string name="sum">Somme du poids</string>

<string name="all">All</string>

Expand Down Expand Up @@ -277,4 +277,6 @@
<string name="pref_preferredSizeUnitTitle">Sélectionne ton unité de taille préférée</string>
<string name="program_completed">Vous avez terminé votre programme! Voulez-vous le fermer?</string>
<string name="maxLengthPerDate">Durée maximum par date</string>
<string name="maxReps">Max reps</string>
<string name="sumReps">Somme Répétitions</string>
</resources>
4 changes: 3 additions & 1 deletion app/src/main/res/values-it/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
<string name="drawer_close">Chiudi menu</string>

<string name="maxRep1">Massimale (Ripetizioni >= 1)</string>
<string name="maxRep5d">Maximum (Ripetizioni >= 5)</string>
<string name="maxRep5d">Massimale (Ripetizioni >= 5)</string>
<string name="sum">Totale</string>

<string name="sumDistance">Distanza</string>
Expand Down Expand Up @@ -318,4 +318,6 @@
<string name="remove_image">Rimuovi immagine</string>
<string name="program_completed">Hai completato il programma! Vuoi chiuderlo?</string>
<string name="author_label">Autore:</string>
<string name="maxReps">Mass. di Ripetizioni</string>
<string name="sumReps">Totale di Ripetizioni</string>
</resources>
4 changes: 3 additions & 1 deletion app/src/main/res/values-nl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@

<string name="maxRep1">Maximum (Reps >= 1)</string>
<string name="maxRep5d">Maximum (Reps >= 5)</string>
<string name="sum">Sum</string>
<string name="sum">Gewicht Sum</string>

<string name="sumDistance">Distance</string>
<string name="sumDuration">Duration</string>
Expand Down Expand Up @@ -287,6 +287,8 @@
<string name="pref_preferredSizeUnitTitle">Selecteer je gewenste grootte unit</string>
<string name="program_completed">U hebt uw programma afgerond! Wilt u om te sluiten?</string>
<string name="maxLengthPerDate">Max duur per Date</string>
<string name="maxReps">Max Herhalingen</string>
<string name="sumReps">Sum Herhalingen</string>

</resources>

4 changes: 3 additions & 1 deletion app/src/main/res/values-pt-rBR/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@

<string name="maxRep1">Máximo (Reps >= 1)</string>
<string name="maxRep5d">Máximo (Reps >= 5)</string>
<string name="sum">Soma</string>
<string name="sum">Soma de peso</string>
<string-array name="graph_functions">
<item>@string/maxRep1</item>
<item>@string/maxRep5d</item>
Expand Down Expand Up @@ -307,4 +307,6 @@
<string name="remove_image">Remover imagem</string>
<string name="program_completed">Você completou seu programa! Você quer fechá-lo?</string>
<string name="maxLengthPerDate">Max. duração por Data</string>
<string name="maxReps">Máx de Reps</string>
<string name="sumReps">Soma de Reps</string>
</resources>
3 changes: 2 additions & 1 deletion app/src/main/res/values/about.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="MissingTranslation">
<string name="app_version" translatable="false">0.19.5</string>
<string name="app_version" translatable="false">0.19.5BETA</string>
<string name="database_version_label" translatable="false">Database version: </string>
<string name="author_label">Author: </string>
<string name="author" translatable="false">Charles Combes</string>
Expand All @@ -11,6 +11,7 @@
<string name="revision_history_label" translatable="false">Revision History: </string>
<string name="revision_history" translatable="false">\n
v0.19.5: December 27, 2020\n
\t- Enhancement: Updated graph function - view rep count (#182)\n
\t- Bug: Unable to import after fresh install (#180)\n
\t- Bug: Fix wrong names for exported files (#183)\n
</string>
Expand Down
11 changes: 8 additions & 3 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,20 @@
<item>6</item>
</string-array>

<string name="maxRep1">Maximum (Reps >= 1)</string>
<string name="maxRep5d">Maximum (Reps >= 5)</string>
<string name="sum">Sum</string>
<string name="maxRep1">Max Weight (Reps >= 1)</string>
<string name="maxRep5d">Max Weight (Reps >= 5)</string>
<string name="sum">Weight Sum</string>
<string name="sumReps">Reps Sum</string>
<string name="maxReps">Max Reps</string>
<string name="oneRepMax">1RM (Reps &lt;= 10)</string>


<string-array name="graph_functions" translatable="false">
<item>@string/maxRep1</item>
<item>@string/maxRep5d</item>
<item>@string/sum</item>
<item>@string/sumReps</item>
<item>@string/maxReps</item>
<item>@string/oneRepMax</item>
</string-array>

Expand Down

0 comments on commit 6ea4d57

Please sign in to comment.