1
0
mirror of https://github.com/oliexdev/openScale.git synced 2025-08-20 07:21:40 +02:00

Rename LBW (lean body weight) to LBM (... mass)

As suggested in #243.

Except for the database column and some strings that are stored
persistent in preferences.
This commit is contained in:
Erik Johansson
2018-04-16 22:53:56 +02:00
parent f5692637c8
commit 8ad10370c8
31 changed files with 98 additions and 72 deletions

View File

@@ -57,7 +57,7 @@
"notNull": true
},
{
"fieldPath": "lbw",
"fieldPath": "lbm",
"columnName": "lbw",
"affinity": "REAL",
"notNull": true

View File

@@ -141,7 +141,7 @@ public class ScreenshotRecorder {
private List<ScaleMeasurement> getTestMeasurements() {
List<ScaleMeasurement> scaleMeasurementList = new ArrayList<>();
String data = "\"dateTime\",\"weight\",\"fat\",\"water\",\"muscle\",\"lbw\",\"bone\",\"waist\",\"hip\",\"comment\"\n" +
String data = "\"dateTime\",\"weight\",\"fat\",\"water\",\"muscle\",\"lbm\",\"bone\",\"waist\",\"hip\",\"comment\"\n" +
"04.08.2015 08:08,89.7,21.2,58.0,41.5\n" +
"03.08.2015 05:17,89.0,26.4,54.6,41.6\n" +
"02.08.2015 07:32,88.8,25.0,55.6,41.7\n" +

View File

@@ -36,7 +36,7 @@ import com.health.openscale.core.alarm.AlarmHandler;
import com.health.openscale.core.bluetooth.BluetoothCommunication;
import com.health.openscale.core.bluetooth.BluetoothFactory;
import com.health.openscale.core.bodymetric.EstimatedFatMetric;
import com.health.openscale.core.bodymetric.EstimatedLBWMetric;
import com.health.openscale.core.bodymetric.EstimatedLBMMetric;
import com.health.openscale.core.bodymetric.EstimatedWaterMetric;
import com.health.openscale.core.database.AppDatabase;
import com.health.openscale.core.database.ScaleDatabase;
@@ -49,7 +49,7 @@ import com.health.openscale.core.utils.Converters;
import com.health.openscale.core.utils.CsvHelper;
import com.health.openscale.gui.fragments.FragmentUpdateListener;
import com.health.openscale.gui.views.FatMeasurementView;
import com.health.openscale.gui.views.LBWMeasurementView;
import com.health.openscale.gui.views.LBMMeasurementView;
import com.health.openscale.gui.views.MeasurementViewSettings;
import com.health.openscale.gui.views.WaterMeasurementView;
@@ -271,11 +271,11 @@ public class OpenScale {
scaleMeasurement.setWater(waterMetric.getWater(getScaleUser(scaleMeasurement.getUserId()), scaleMeasurement));
}
settings = new MeasurementViewSettings(prefs, LBWMeasurementView.KEY);
settings = new MeasurementViewSettings(prefs, LBMMeasurementView.KEY);
if (settings.isEnabled() && settings.isEstimationEnabled()) {
EstimatedLBWMetric lbwMetric = EstimatedLBWMetric.getEstimatedMetric(
EstimatedLBWMetric.FORMULA.valueOf(settings.getEstimationFormula()));
scaleMeasurement.setLbw(lbwMetric.getLBW(getScaleUser(scaleMeasurement.getUserId()), scaleMeasurement));
EstimatedLBMMetric lbmMetric = EstimatedLBMMetric.getEstimatedMetric(
EstimatedLBMMetric.FORMULA.valueOf(settings.getEstimationFormula()));
scaleMeasurement.setLbm(lbmMetric.getLBM(getScaleUser(scaleMeasurement.getUserId()), scaleMeasurement));
}
settings = new MeasurementViewSettings(prefs, FatMeasurementView.KEY);

View File

@@ -18,20 +18,21 @@ package com.health.openscale.core.bodymetric;
import com.health.openscale.core.datatypes.ScaleMeasurement;
import com.health.openscale.core.datatypes.ScaleUser;
public abstract class EstimatedLBWMetric {
public abstract class EstimatedLBMMetric {
// Don't change enum names, they are stored persistent in preferences
public enum FORMULA { LBW_HUME, LBW_BOER }
public static EstimatedLBWMetric getEstimatedMetric(FORMULA metric) {
public static EstimatedLBMMetric getEstimatedMetric(FORMULA metric) {
switch (metric) {
case LBW_HUME:
return new LBWHume();
return new LBMHume();
case LBW_BOER:
return new LBWBoer();
return new LBMBoer();
}
return null;
}
public abstract String getName();
public abstract float getLBW(ScaleUser user, ScaleMeasurement data);
public abstract float getLBM(ScaleUser user, ScaleMeasurement data);
}

View File

@@ -19,14 +19,14 @@ package com.health.openscale.core.bodymetric;
import com.health.openscale.core.datatypes.ScaleMeasurement;
import com.health.openscale.core.datatypes.ScaleUser;
public class LBWBoer extends EstimatedLBWMetric {
public class LBMBoer extends EstimatedLBMMetric {
@Override
public String getName() {
return "Boer (1984)";
}
@Override
public float getLBW(ScaleUser user, ScaleMeasurement data) {
public float getLBM(ScaleUser user, ScaleMeasurement data) {
if (user.getGender().isMale()) {
return (0.4071f * data.getWeight()) + (0.267f * user.getBodyHeight()) - 19.2f;
}

View File

@@ -19,14 +19,14 @@ package com.health.openscale.core.bodymetric;
import com.health.openscale.core.datatypes.ScaleMeasurement;
import com.health.openscale.core.datatypes.ScaleUser;
public class LBWHume extends EstimatedLBWMetric {
public class LBMHume extends EstimatedLBMMetric {
@Override
public String getName() {
return "Hume (1966)";
}
@Override
public float getLBW(ScaleUser user, ScaleMeasurement data) {
public float getLBM(ScaleUser user, ScaleMeasurement data) {
if (user.getGender().isMale()) {
return (0.32810f * data.getWeight()) + (0.33929f * user.getBodyHeight()) - 29.5336f;
}

View File

@@ -32,6 +32,9 @@ public abstract class AppDatabase extends RoomDatabase {
public abstract ScaleMeasurementDAO measurementDAO();
public abstract ScaleUserDAO userDAO();
// For the next database version:
// - rename lbw column to lbm
public static final Migration MIGRATION_1_2 = new Migration(1, 2) {
@Override
public void migrate(SupportSQLiteDatabase database) {

View File

@@ -161,7 +161,7 @@ public class ScaleDatabase extends SQLiteOpenHelper {
scaleMeasurement.setFat(cur.getFloat(cur.getColumnIndexOrThrow(COLUMN_NAME_FAT)));
scaleMeasurement.setWater(cur.getFloat(cur.getColumnIndexOrThrow(COLUMN_NAME_WATER)));
scaleMeasurement.setMuscle(cur.getFloat(cur.getColumnIndexOrThrow(COLUMN_NAME_MUSCLE)));
scaleMeasurement.setLbw(cur.getFloat(cur.getColumnIndexOrThrow(COLUMN_NAME_LBW)));
scaleMeasurement.setLbm(cur.getFloat(cur.getColumnIndexOrThrow(COLUMN_NAME_LBW)));
scaleMeasurement.setBone(cur.getFloat(cur.getColumnIndexOrThrow(COLUMN_NAME_BONE)));
scaleMeasurement.setWaist(cur.getFloat(cur.getColumnIndexOrThrow(COLUMN_NAME_WAIST)));
scaleMeasurement.setHip(cur.getFloat(cur.getColumnIndexOrThrow(COLUMN_NAME_HIP)));

View File

@@ -62,7 +62,7 @@ public class ScaleMeasurement implements Cloneable {
private float muscle;
@CsvColumn
@ColumnInfo(name = "lbw")
private float lbw;
private float lbm;
@CsvColumn
@ColumnInfo(name = "waist")
private float waist;
@@ -85,7 +85,7 @@ public class ScaleMeasurement implements Cloneable {
fat = 0.0f;
water = 0.0f;
muscle = 0.0f;
lbw = 0.0f;
lbm = 0.0f;
bone = 0.0f;
waist = 0.0f;
hip = 0.0f;
@@ -231,12 +231,12 @@ public class ScaleMeasurement implements Cloneable {
this.muscle = muscle;
}
public float getLbw() {
return lbw;
public float getLbm() {
return lbm;
}
public void setLbw(float lbw) {
this.lbw = lbw;
public void setLbm(float lbm) {
this.lbm = lbm;
}
public float getWaist() {
@@ -301,8 +301,8 @@ public class ScaleMeasurement implements Cloneable {
{
return String.format(
"ID: %d, USER_ID: %d, DATE_TIME: %s, WEIGHT: %.2f, FAT: %.2f, WATER: %.2f, " +
"MUSCLE: %.2f, LBW: %.2f, WAIST: %.2f, HIP: %.2f, BONE: %.2f, COMMENT: %s",
"MUSCLE: %.2f, LBM: %.2f, WAIST: %.2f, HIP: %.2f, BONE: %.2f, COMMENT: %s",
id, userId, dateTime.toString(), weight, fat, water,
muscle, lbw, waist, hip, bone, comment);
muscle, lbm, waist, hip, bone, comment);
}
}

View File

@@ -17,6 +17,7 @@
package com.health.openscale.core.utils;
import com.health.openscale.core.datatypes.ScaleMeasurement;
import com.j256.simplecsv.processor.ColumnNameMatcher;
import com.j256.simplecsv.processor.CsvProcessor;
import java.io.BufferedReader;
@@ -44,31 +45,31 @@ public class CsvHelper {
if (fields.length == 10) {
// From version 1.6 up to 1.7
return new String[]{
"dateTime", "weight", "fat", "water", "muscle", "lbw", "bone", "waist", "hip", "comment"};
"dateTime", "weight", "fat", "water", "muscle", "lbm", "bone", "waist", "hip", "comment"};
}
else if (fields.length == 9) {
// From version 1.5.5 (lbw unused)
// From version 1.5.5 (lbm unused)
return new String[]{
"dateTime", "weight", "fat", "water", "muscle", "bone", "waist", "hip", "comment",
"lbw"};
"lbm"};
}
else if (fields.length == 8) {
// From version 1.3 (lbw and bone unused)
// From version 1.3 (lbm and bone unused)
return new String[]{
"dateTime", "weight", "fat", "water", "muscle", "waist", "hip", "comment",
"lbw", "bone"};
"lbm", "bone"};
}
else if (fields.length == 6) {
// From version 1.2 (lbw, bone, waist and hip unused)
// From version 1.2 (lbm, bone, waist and hip unused)
return new String[]{
"dateTime", "weight", "fat", "water", "muscle", "comment",
"lbw", "bone", "waist", "hip"};
"lbm", "bone", "waist", "hip"};
}
else if (fields.length == 5) {
// From version 1.0 (lbw, bone, waist, hip and muscle unused)
// From version 1.0 (lbm, bone, waist, hip and muscle unused)
return new String[]{
"dateTime", "weight", "fat", "water", "comment",
"lbw", "bone", "waist", "hip", "muscle"};
"lbm", "bone", "waist", "hip", "muscle"};
}
// Unknown input data format
@@ -84,6 +85,14 @@ public class CsvHelper {
.withAlwaysTrimInput(true)
.withAllowPartialLines(true);
csvProcessor.setColumnNameMatcher(new ColumnNameMatcher() {
@Override
public boolean matchesColumnName(String definitionName, String csvName) {
return definitionName.equals(csvName)
|| (definitionName.equals("lbm") && csvName.equals("lbw"));
}
});
reader.mark(1000);
try {
csvProcessor.readHeader(reader, null);

View File

@@ -36,7 +36,7 @@ import com.health.openscale.core.utils.DateTimeHelpers;
import com.health.openscale.gui.views.BoneMeasurementView;
import com.health.openscale.gui.views.FatMeasurementView;
import com.health.openscale.gui.views.HipMeasurementView;
import com.health.openscale.gui.views.LBWMeasurementView;
import com.health.openscale.gui.views.LBMMeasurementView;
import com.health.openscale.gui.views.MeasurementView;
import com.health.openscale.gui.views.MuscleMeasurementView;
import com.health.openscale.gui.views.WaistMeasurementView;
@@ -98,7 +98,7 @@ public class StatisticsFragment extends Fragment implements FragmentUpdateListen
viewMeasurementsListWeek.add(new WeightMeasurementView(statisticsView.getContext()));
viewMeasurementsListWeek.add(new WaterMeasurementView(statisticsView.getContext()));
viewMeasurementsListWeek.add(new MuscleMeasurementView(statisticsView.getContext()));
viewMeasurementsListWeek.add(new LBWMeasurementView(statisticsView.getContext()));
viewMeasurementsListWeek.add(new LBMMeasurementView(statisticsView.getContext()));
viewMeasurementsListWeek.add(new FatMeasurementView(statisticsView.getContext()));
viewMeasurementsListWeek.add(new BoneMeasurementView(statisticsView.getContext()));
viewMeasurementsListWeek.add(new WaistMeasurementView(statisticsView.getContext()));
@@ -128,7 +128,7 @@ public class StatisticsFragment extends Fragment implements FragmentUpdateListen
viewMeasurementsListMonth.add(new WeightMeasurementView(statisticsView.getContext()));
viewMeasurementsListMonth.add(new WaterMeasurementView(statisticsView.getContext()));
viewMeasurementsListMonth.add(new MuscleMeasurementView(statisticsView.getContext()));
viewMeasurementsListMonth.add(new LBWMeasurementView(statisticsView.getContext()));
viewMeasurementsListMonth.add(new LBMMeasurementView(statisticsView.getContext()));
viewMeasurementsListMonth.add(new FatMeasurementView(statisticsView.getContext()));
viewMeasurementsListMonth.add(new BoneMeasurementView(statisticsView.getContext()));
viewMeasurementsListMonth.add(new WaistMeasurementView(statisticsView.getContext()));

View File

@@ -21,16 +21,17 @@ import android.preference.ListPreference;
import android.support.v4.content.ContextCompat;
import com.health.openscale.R;
import com.health.openscale.core.bodymetric.EstimatedLBWMetric;
import com.health.openscale.core.bodymetric.EstimatedLBMMetric;
import com.health.openscale.core.datatypes.ScaleMeasurement;
import com.health.openscale.core.evaluation.EvaluationResult;
import com.health.openscale.core.evaluation.EvaluationSheet;
public class LBWMeasurementView extends FloatMeasurementView {
public class LBMMeasurementView extends FloatMeasurementView {
// Don't change key value, it may be stored persistent in preferences
public static final String KEY = "lbw";
public LBWMeasurementView(Context context) {
super(context, context.getResources().getString(R.string.label_lbw), ContextCompat.getDrawable(context, R.drawable.ic_lbw));
public LBMMeasurementView(Context context) {
super(context, context.getResources().getString(R.string.label_lbm), ContextCompat.getDrawable(context, R.drawable.ic_lbm));
}
@Override
@@ -40,12 +41,12 @@ public class LBWMeasurementView extends FloatMeasurementView {
@Override
protected float getMeasurementValue(ScaleMeasurement measurement) {
return measurement.getLbw();
return measurement.getLbm();
}
@Override
protected void setMeasurementValue(float value, ScaleMeasurement measurement) {
measurement.setLbw(value);
measurement.setLbm(value);
}
@Override
@@ -68,12 +69,12 @@ public class LBWMeasurementView extends FloatMeasurementView {
@Override
protected void prepareEstimationFormulaPreference(ListPreference preference) {
String[] entries = new String[EstimatedLBWMetric.FORMULA.values().length];
String[] entries = new String[EstimatedLBMMetric.FORMULA.values().length];
String[] values = new String[entries.length];
int idx = 0;
for (EstimatedLBWMetric.FORMULA formula : EstimatedLBWMetric.FORMULA.values()) {
entries[idx] = EstimatedLBWMetric.getEstimatedMetric(formula).getName();
for (EstimatedLBMMetric.FORMULA formula : EstimatedLBMMetric.FORMULA.values()) {
entries[idx] = EstimatedLBMMetric.getEstimatedMetric(formula).getName();
values[idx] = formula.name();
++idx;
}

View File

@@ -106,7 +106,7 @@ public abstract class MeasurementView extends TableLayout {
unsorted.add(new BMIMeasurementView(context));
unsorted.add(new WaterMeasurementView(context));
unsorted.add(new MuscleMeasurementView(context));
unsorted.add(new LBWMeasurementView(context));
unsorted.add(new LBMMeasurementView(context));
unsorted.add(new FatMeasurementView(context));
unsorted.add(new BoneMeasurementView(context));
unsorted.add(new WaistMeasurementView(context));

View File

@@ -19,7 +19,7 @@ package com.health.openscale.gui.views;
import android.content.SharedPreferences;
import com.health.openscale.core.bodymetric.EstimatedFatMetric;
import com.health.openscale.core.bodymetric.EstimatedLBWMetric;
import com.health.openscale.core.bodymetric.EstimatedLBMMetric;
import com.health.openscale.core.bodymetric.EstimatedWaterMetric;
public class MeasurementViewSettings {
@@ -52,7 +52,7 @@ public class MeasurementViewSettings {
case WeightMeasurementView.KEY:
// Weight can't be disabled
return true;
case LBWMeasurementView.KEY:
case LBMMeasurementView.KEY:
case BoneMeasurementView.KEY:
case WaistMeasurementView.KEY:
case HipMeasurementView.KEY:
@@ -137,7 +137,7 @@ public class MeasurementViewSettings {
switch (key) {
case FatMeasurementView.KEY:
return "estimateFatEnable";
case LBWMeasurementView.KEY:
case LBMMeasurementView.KEY:
return "estimateLBWEnable";
case WaterMeasurementView.KEY:
return "estimateWaterEnable";
@@ -153,7 +153,7 @@ public class MeasurementViewSettings {
switch (key) {
case FatMeasurementView.KEY:
return "estimateFatFormula";
case LBWMeasurementView.KEY:
case LBMMeasurementView.KEY:
return "estimateLBWFormula";
case WaterMeasurementView.KEY:
return "estimateWaterFormula";
@@ -167,8 +167,8 @@ public class MeasurementViewSettings {
case FatMeasurementView.KEY:
defaultValue = EstimatedFatMetric.FORMULA.BF_GALLAGHER.name();
break;
case LBWMeasurementView.KEY:
defaultValue = EstimatedLBWMetric.FORMULA.LBW_HUME.name();
case LBMMeasurementView.KEY:
defaultValue = EstimatedLBMMetric.FORMULA.LBW_HUME.name();
break;
case WaterMeasurementView.KEY:
defaultValue = EstimatedWaterMetric.FORMULA.TBW_LEESONGKIM.name();

View File

Before

Width:  |  Height:  |  Size: 954 B

After

Width:  |  Height:  |  Size: 954 B

View File

Before

Width:  |  Height:  |  Size: 367 B

After

Width:  |  Height:  |  Size: 367 B

View File

Before

Width:  |  Height:  |  Size: 548 B

After

Width:  |  Height:  |  Size: 548 B

View File

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

@@ -25,7 +25,7 @@
<string name="label_fat">Percentatge de greix corporal</string>
<string name="label_water">Percentatge d\'aigua</string>
<string name="label_muscle">Percentatge muscular</string>
<string name="label_lbw">Massa corporal magra</string>
<string name="label_lbm">Massa corporal magra</string>
<string name="label_waist">Circumferència de la cintura</string>
<string name="label_hip">Circumferència del maluc</string>
<string name="label_comment">Comentari</string>

View File

@@ -121,7 +121,7 @@
<string name="info_step_on_scale">Bitte steigen Sie barfuß auf die Waage zur Referenzmessung</string>
<string name="label_automatic">auto</string>
<string name="label_category_measurement_database">Messwertedatenbank</string>
<string name="label_lbw">Fettfreie Körpermasse</string>
<string name="label_lbm">Fettfreie Körpermasse</string>
<string name="label_license">Lizenz</string>
<string name="label_maintainer">Hauptentwickler</string>
<string name="label_website">Webseite</string>

View File

@@ -25,7 +25,7 @@
<string name="label_fat">Porcentaje de grasa corporal</string>
<string name="label_water">Porcentaje de agua</string>
<string name="label_muscle">Porcentaje muscular</string>
<string name="label_lbw">Masa corporal magra</string>
<string name="label_lbm">Masa corporal magra</string>
<string name="label_waist">Circunferencia de la cintura</string>
<string name="label_hip">Circunferencia de la cadera</string>
<string name="label_comment">Comentario</string>

View File

@@ -33,15 +33,15 @@
<string name="label_comment">Kommentar</string>
<string name="label_bone">Beinmasse</string>
<string name="label_estimate_measurement_summary">Basert på vekt, høyde, alder, kjønn, etc.</string>
<string name="label_lbw">Fettfri kroppsvekt</string>
<string name="label_lbm">Fettfri kroppsvekt</string>
<string name="label_whtr">Midje-til-høyde -forhold</string>
<string name="label_whr">Midje-til-hofte -forhold</string>
<string name="label_smartUserAssign">Smart brukertildeling</string>
<plurals name="label_days">
<item quantity="one">%d dag</item>
<item quantity="other">%d dager</item>
</plurals>
<item quantity="one">%d dag</item>
<item quantity="other">%d dager</item>
</plurals>
<string name="label_last_week">De siste 7 dagene</string>
<string name="label_last_month">De siste 30 dagene</string>
<string name="label_weight_difference">Vektforskjell</string>

View File

@@ -27,7 +27,7 @@
<string name="label_fat">Lichaamsvet</string>
<string name="label_water">Lichaamsvocht</string>
<string name="label_muscle">Spieren</string>
<string name="label_lbw">Vetvrije massa</string>
<string name="label_lbm">Vetvrije massa</string>
<string name="label_waist">Taille-omtrek</string>
<string name="label_hip">Heup-omtrek</string>
<string name="label_comment">Commentaar</string>
@@ -153,7 +153,7 @@
<string name="info_step_on_scale">Stap alsjeblieft met blote voeten op de weegschaal voor een meting</string>
<string name="info_measuring">Gewicht meten: %.2f</string>
<string name="title_general">Algemeen</string>
<string name="title_general">Algemeen</string>
<string name="label_share">Delen</string>
<string name="label_share_subject">openScale CSV data exporteren (%s)</string>

View File

@@ -30,7 +30,7 @@
<string name="label_fat">Procent tkanki tłuszczowej</string>
<string name="label_water">Procent wody w organizmie</string>
<string name="label_muscle">Procent masy mięśniowej</string>
<string name="label_lbw">Beztłuszczowa masa ciała</string>
<string name="label_lbm">Beztłuszczowa masa ciała</string>
<string name="label_waist">Obwód talii</string>
<string name="label_hip">Obwód bioder</string>
<string name="label_comment">Komentarz</string>

View File

@@ -124,7 +124,7 @@
<string name="label_share_subject">Exportar dados openScale para CSV (%s)</string>
<string name="label_bmr">Taxa Metabólica Basal (TMB)</string>
<string name="label_lbw">Massa Magra</string>
<string name="label_lbm">Massa Magra</string>
<string name="label_bone">Massa óssea</string>
<string name="info_bluetooth_no_device_set">Sem dispositivo Bluetooth selecionado</string>
<string name="info_new_data_added">%1$.2f%2$s [%3$s] para %4$s adicionado</string>

View File

@@ -58,7 +58,7 @@
<string name="label_last_week">Senast 7 dagarna</string>
<string name="label_last_month">Senast 30 dagarna</string>
<string name="label_muscle">Muskler</string>
<string name="label_lbw">Fettfri kroppsvikt</string>
<string name="label_lbm">Fettfri kroppsvikt</string>
<string name="label_waist">Midjemått</string>
<string name="label_hip">Höftomkrets</string>
<string name="label_comment">Kommentar</string>

View File

@@ -24,7 +24,7 @@
<string name="label_fat">Vücüt Yað Yüzdesi</string>
<string name="label_water">Su Yüzdesi</string>
<string name="label_muscle">Kas Yüzdesi</string>
<string name="label_lbw">Yaðsýz vücüt aðýrlýðý</string>
<string name="label_lbm">Yaðsýz vücüt aðýrlýðý</string>
<string name="label_waist">Bel çevresi</string>
<string name="label_hip">Kalça çevresi</string>
<string name="label_comment">Yorum</string>

View File

@@ -31,7 +31,7 @@
<string name="label_fat">Body fat</string>
<string name="label_water">Body water</string>
<string name="label_muscle">Muscle</string>
<string name="label_lbw">Lean body weight</string>
<string name="label_lbm">Lean body mass</string>
<string name="label_waist">Waist circumference</string>
<string name="label_hip">Hip circumference</string>
<string name="label_comment">Comment</string>

View File

@@ -33,7 +33,7 @@ import static junit.framework.Assert.assertEquals;
public class CsvHelperTest {
private static final String HEADERS =
"\"bone\",\"comment\",\"dateTime\",\"fat\",\"hip\",\"lbw\","
"\"bone\",\"comment\",\"dateTime\",\"fat\",\"hip\",\"lbm\","
+ "\"muscle\",\"waist\",\"water\",\"weight\"\n";
private void validateEntry(ScaleMeasurement m, int version) throws Exception {
@@ -63,10 +63,10 @@ public class CsvHelperTest {
assertEquals(0.0, m.getBone(), 0.001);
}
if (version > 3) {
assertEquals(4.0, m.getLbw(), 0.001);
assertEquals(4.0, m.getLbm(), 0.001);
}
else {
assertEquals(0.0, m.getLbw(), 0.001);
assertEquals(0.0, m.getLbm(), 0.001);
}
assertEquals("some text", m.getComment());
@@ -89,6 +89,18 @@ public class CsvHelperTest {
validateEntry(list.get(0), 5);
}
@Test
public void newStyleOldLbwHeaderNameSingleEntry() throws Exception {
final String data = HEADERS.replace("lbm", "lbw")
+ "1.0,\"some text\",\"01.03.2018 12:45\",2.0,3.0,4.0,5.0,6.0,7.0,8.0\n";
List<ScaleMeasurement> list = CsvHelper.importFrom(
new BufferedReader(new StringReader(data)));
assertEquals(1, list.size());
validateEntry(list.get(0), 5);
}
@Test
public void exportImport() throws Exception {
ScaleMeasurement m = new ScaleMeasurement();
@@ -96,7 +108,7 @@ public class CsvHelperTest {
m.setFat(2.0f);
m.setWater(7.0f);
m.setMuscle(5.0f);
m.setLbw(4.0f);
m.setLbm(4.0f);
m.setBone(1.0f);
m.setWaist(6.0f);
m.setHip(3.0f);