From 6ea4d572afbb33baa769d89aea2bdd28b0dc3f9d Mon Sep 17 00:00:00 2001 From: brodeurlv Date: Sun, 10 Jan 2021 09:00:19 +0100 Subject: [PATCH] Step for #182 --- .../com/easyfitness/DAO/record/DAOFonte.java | 23 ++++++++++- .../easyfitness/fonte/FonteGraphFragment.java | 40 +++++++++++++------ app/src/main/res/values-cs/strings.xml | 6 ++- app/src/main/res/values-de/strings.xml | 4 +- app/src/main/res/values-es/strings.xml | 4 +- app/src/main/res/values-fr/strings.xml | 4 +- app/src/main/res/values-it/strings.xml | 4 +- app/src/main/res/values-nl/strings.xml | 4 +- app/src/main/res/values-pt-rBR/strings.xml | 4 +- app/src/main/res/values/about.xml | 3 +- app/src/main/res/values/strings.xml | 11 +++-- 11 files changed, 80 insertions(+), 27 deletions(-) diff --git a/app/src/main/java/com/easyfitness/DAO/record/DAOFonte.java b/app/src/main/java/com/easyfitness/DAO/record/DAOFonte.java index d8b48884..bfab5b34 100644 --- a/app/src/main/java/com/easyfitness/DAO/record/DAOFonte.java +++ b/app/src/main/java/com/easyfitness/DAO/record/DAOFonte.java @@ -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; @@ -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; @@ -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; @@ -114,6 +115,24 @@ public List 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 diff --git a/app/src/main/java/com/easyfitness/fonte/FonteGraphFragment.java b/app/src/main/java/com/easyfitness/fonte/FonteGraphFragment.java index 1f5cda08..1bd83226 100644 --- a/app/src/main/java/com/easyfitness/fonte/FonteGraphFragment.java +++ b/app/src/main/java/com/easyfitness/fonte/FonteGraphFragment.java @@ -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; @@ -244,15 +246,27 @@ private void drawGraph() { ArrayList 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 valueList = mDbFonte.getBodyBuildingFunctionRecords(getProfile(), lMachine, lDAOFunction); @@ -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); @@ -333,10 +353,7 @@ private void drawGraph() { // Recupere les enregistrements List 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()); @@ -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 diff --git a/app/src/main/res/values-cs/strings.xml b/app/src/main/res/values-cs/strings.xml index 20e82f1f..ba828f87 100644 --- a/app/src/main/res/values-cs/strings.xml +++ b/app/src/main/res/values-cs/strings.xml @@ -97,9 +97,9 @@ Otevřít panel navigace Zavřít panel navigace - Maximum (Opak >= 1) + Max Hmotnost (Opak >= 1) Maximum (Opak >= 5) - Suma + Hmotnost Suma Vzdálenost Trvání @@ -287,5 +287,7 @@ Zvolit preferovanou velikost jednotky Jste dokončili program! Chcete ji zavřít? Maximální délka trvání jednoho Datum + Max Opk + Opk Suma diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 4dbed1b1..51b489a3 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -93,7 +93,7 @@ Maximum (Wied. >= 1) Maximum (Wied. >= 5) - Summe + Gewicht Summe Alle @@ -286,5 +286,7 @@ Wähle deine gewünschte Größe Einheit Sie haben Ihr Programm abgeschlossen! Wollen Sie es schließen? Max Dauer pro Datum + Max Wied. + Wied. Summe diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 4294d7bc..de9d87de 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -99,7 +99,7 @@ Máximo (Reps >= 1) Máximo (Reps >= 5) - Suma + Suma de peso @string/maxRep1 @string/maxRep5d @@ -293,5 +293,7 @@ Selecciona tu unidad de tamaño preferida Ha completado su programa! ¿Quieres cerrarla? Duración máxima por Fecha + Máx de Reps + Suma de Reps diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 8b22a467..be5b91e8 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -84,7 +84,7 @@ Maximum (Reps >= 1) Maximum (Reps >= 5) - Somme + Somme du poids All @@ -277,4 +277,6 @@ Sélectionne ton unité de taille préférée Vous avez terminé votre programme! Voulez-vous le fermer? Durée maximum par date + Max reps + Somme Répétitions diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index 4bb129a9..ff5161ac 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -103,7 +103,7 @@ Chiudi menu Massimale (Ripetizioni >= 1) - Maximum (Ripetizioni >= 5) + Massimale (Ripetizioni >= 5) Totale Distanza @@ -318,4 +318,6 @@ Rimuovi immagine Hai completato il programma! Vuoi chiuderlo? Autore: + Mass. di Ripetizioni + Totale di Ripetizioni diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index d974e2a3..7f10b47a 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -100,7 +100,7 @@ Maximum (Reps >= 1) Maximum (Reps >= 5) - Sum + Gewicht Sum Distance Duration @@ -287,6 +287,8 @@ Selecteer je gewenste grootte unit U hebt uw programma afgerond! Wilt u om te sluiten? Max duur per Date + Max Herhalingen + Sum Herhalingen diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml index de4b07d9..8f58037b 100644 --- a/app/src/main/res/values-pt-rBR/strings.xml +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -101,7 +101,7 @@ Máximo (Reps >= 1) Máximo (Reps >= 5) - Soma + Soma de peso @string/maxRep1 @string/maxRep5d @@ -307,4 +307,6 @@ Remover imagem Você completou seu programa! Você quer fechá-lo? Max. duração por Data + Máx de Reps + Soma de Reps diff --git a/app/src/main/res/values/about.xml b/app/src/main/res/values/about.xml index 2fd0f1ea..c629632e 100644 --- a/app/src/main/res/values/about.xml +++ b/app/src/main/res/values/about.xml @@ -1,6 +1,6 @@ - 0.19.5 + 0.19.5BETA Database version: Author: Charles Combes @@ -11,6 +11,7 @@ Revision History: \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 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 3c193e4d..a4376dd4 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -142,15 +142,20 @@ 6 - Maximum (Reps >= 1) - Maximum (Reps >= 5) - Sum + Max Weight (Reps >= 1) + Max Weight (Reps >= 5) + Weight Sum + Reps Sum + Max Reps 1RM (Reps <= 10) + @string/maxRep1 @string/maxRep5d @string/sum + @string/sumReps + @string/maxReps @string/oneRepMax