1
0
mirror of https://github.com/oliexdev/openScale.git synced 2025-09-02 12:54:10 +02:00

added fat caliper measurement

This commit is contained in:
OliE
2018-05-13 14:56:22 +02:00
parent a9f79637e0
commit d20a824f51
35 changed files with 400 additions and 6 deletions

View File

@@ -2,11 +2,11 @@
"formatVersion": 1,
"database": {
"version": 3,
"identityHash": "dcde328ede1fdeacf08edfb4d8b834ae",
"identityHash": "fd4198e9af667e65ae56be8e9838d1ca",
"entities": [
{
"tableName": "scaleMeasurements",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `userId` INTEGER NOT NULL, `enabled` INTEGER NOT NULL, `datetime` INTEGER, `weight` REAL NOT NULL, `fat` REAL NOT NULL, `water` REAL NOT NULL, `muscle` REAL NOT NULL, `lbw` REAL NOT NULL, `waist` REAL NOT NULL, `hip` REAL NOT NULL, `bone` REAL NOT NULL, `chest` REAL NOT NULL, `thigh` REAL NOT NULL, `biceps` REAL NOT NULL, `neck` REAL NOT NULL, `comment` TEXT, FOREIGN KEY(`userId`) REFERENCES `scaleUsers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `userId` INTEGER NOT NULL, `enabled` INTEGER NOT NULL, `datetime` INTEGER, `weight` REAL NOT NULL, `fat` REAL NOT NULL, `water` REAL NOT NULL, `muscle` REAL NOT NULL, `lbw` REAL NOT NULL, `waist` REAL NOT NULL, `hip` REAL NOT NULL, `bone` REAL NOT NULL, `chest` REAL NOT NULL, `thigh` REAL NOT NULL, `biceps` REAL NOT NULL, `neck` REAL NOT NULL, `caliper1` REAL NOT NULL, `caliper2` REAL NOT NULL, `caliper3` REAL NOT NULL, `comment` TEXT, FOREIGN KEY(`userId`) REFERENCES `scaleUsers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
"fields": [
{
"fieldPath": "id",
@@ -104,6 +104,24 @@
"affinity": "REAL",
"notNull": true
},
{
"fieldPath": "caliper1",
"columnName": "caliper1",
"affinity": "REAL",
"notNull": true
},
{
"fieldPath": "caliper2",
"columnName": "caliper2",
"affinity": "REAL",
"notNull": true
},
{
"fieldPath": "caliper3",
"columnName": "caliper3",
"affinity": "REAL",
"notNull": true
},
{
"fieldPath": "comment",
"columnName": "comment",
@@ -213,7 +231,7 @@
],
"setupQueries": [
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, \"dcde328ede1fdeacf08edfb4d8b834ae\")"
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, \"fd4198e9af667e65ae56be8e9838d1ca\")"
]
}
}

View File

@@ -85,6 +85,9 @@ public abstract class AppDatabase extends RoomDatabase {
database.execSQL("ALTER TABLE scaleMeasurements ADD COLUMN thigh REAL NOT NULL DEFAULT 0");
database.execSQL("ALTER TABLE scaleMeasurements ADD COLUMN biceps REAL NOT NULL DEFAULT 0");
database.execSQL("ALTER TABLE scaleMeasurements ADD COLUMN neck REAL NOT NULL DEFAULT 0");
database.execSQL("ALTER TABLE scaleMeasurements ADD COLUMN caliper1 REAL NOT NULL DEFAULT 0");
database.execSQL("ALTER TABLE scaleMeasurements ADD COLUMN caliper2 REAL NOT NULL DEFAULT 0");
database.execSQL("ALTER TABLE scaleMeasurements ADD COLUMN caliper3 REAL NOT NULL DEFAULT 0");
database.setTransactionSuccessful();
}

View File

@@ -86,6 +86,15 @@ public class ScaleMeasurement implements Cloneable {
@ColumnInfo(name = "neck")
private float neck;
@CsvColumn
@ColumnInfo(name = "caliper1")
private float caliper1;
@CsvColumn
@ColumnInfo(name = "caliper2")
private float caliper2;
@CsvColumn
@ColumnInfo(name = "caliper3")
private float caliper3;
@CsvColumn
@ColumnInfo(name = "comment")
private String comment;
@@ -308,6 +317,30 @@ public class ScaleMeasurement implements Cloneable {
this.neck = neck;
}
public float getCaliper1() {
return caliper1;
}
public void setCaliper1(float caliper1) {
this.caliper1 = caliper1;
}
public float getCaliper2() {
return caliper2;
}
public void setCaliper2(float caliper2) {
this.caliper2 = caliper2;
}
public float getCaliper3() {
return caliper3;
}
public void setCaliper3(float caliper3) {
this.caliper3 = caliper3;
}
public String getComment() {
return comment;
}
@@ -345,14 +378,39 @@ public class ScaleMeasurement implements Cloneable {
return waist / hip;
}
public float getFatCaliper(ScaleUser scaleUser) {
float fat_caliper;
float k0, k1, k2, ka;
float s = caliper1 + caliper2 + caliper3;
if (scaleUser.getGender().isMale()) {
k0 = 1.10938f;
k1 = 0.0008267f;
k2 = 0.0000016f;
ka = 0.0002574f;
} else {
k0 = 1.0994921f;
k1 = 0.0009929f;
k2 = 0.0000023f;
ka = 0.0001392f;
}
// calipometrie formula by Jackson, Pollock: Generalized equations for predicting body density of women. In: British Journal of Nutrition. Nr.40, Oktober 1978, S.497504
fat_caliper = ((4.95f / (k0 - (k1*s) + (k2 * s*s) - (ka*scaleUser.getAge()))) - 4.5f) * 100.0f;
return fat_caliper;
}
@Override
public String toString()
{
return String.format(
"ID: %d, USER_ID: %d, DATE_TIME: %s, WEIGHT: %.2f, FAT: %.2f, WATER: %.2f, " +
"MUSCLE: %.2f, LBM: %.2f, WAIST: %.2f, HIP: %.2f, BONE: %.2f, CHEST: %.2f, " +
"THIGH: %.2f, ARM: %.2f, NECK: %.2f, COMMENT: %s",
"THIGH: %.2f, ARM: %.2f, NECK: %.2f, CALIPER1: %2.f, CALIPER2: %2.f, CALIPER3: %2.f, COMMENT: %s",
id, userId, dateTime.toString(), weight, fat, water,
muscle, lbm, waist, hip, bone, chest, thigh, biceps, neck, comment);
muscle, lbm, waist, hip, bone, chest, thigh, biceps, neck, caliper1, caliper2, caliper3, comment);
}
}

View File

@@ -0,0 +1,72 @@
/* Copyright (C) 2018 olie.xdev <olie.xdev@googlemail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.health.openscale.gui.views;
import android.content.Context;
import android.graphics.Color;
import com.health.openscale.R;
import com.health.openscale.core.datatypes.ScaleMeasurement;
import com.health.openscale.core.evaluation.EvaluationResult;
import com.health.openscale.core.evaluation.EvaluationSheet;
public class Caliper1MeasurementView extends FloatMeasurementView {
// Don't change key value, it may be stored persistent in preferences
public static final String KEY = "caliper1";
public Caliper1MeasurementView(Context context) {
super(context, R.string.label_caliper1_female, R.drawable.ic_caliper1);
if (getScaleUser().getGender().isMale()) {
setNameView(getResources().getText(R.string.label_caliper1_male));
}
}
@Override
public String getKey() {
return KEY;
}
@Override
protected float getMeasurementValue(ScaleMeasurement measurement) {
return measurement.getCaliper1();
}
@Override
protected void setMeasurementValue(float value, ScaleMeasurement measurement) {
measurement.setCaliper1(value);
}
@Override
public String getUnit() {
return "mm";
}
@Override
protected float getMaxValue() {
return 500;
}
@Override
public int getColor() {
return Color.parseColor("#ba68c8");
}
@Override
protected EvaluationResult evaluateSheet(EvaluationSheet evalSheet, float value) {
return null;
}
}

View File

@@ -0,0 +1,72 @@
/* Copyright (C) 2018 olie.xdev <olie.xdev@googlemail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.health.openscale.gui.views;
import android.content.Context;
import android.graphics.Color;
import com.health.openscale.R;
import com.health.openscale.core.datatypes.ScaleMeasurement;
import com.health.openscale.core.evaluation.EvaluationResult;
import com.health.openscale.core.evaluation.EvaluationSheet;
public class Caliper2MeasurementView extends FloatMeasurementView {
// Don't change key value, it may be stored persistent in preferences
public static final String KEY = "caliper2";
public Caliper2MeasurementView(Context context) {
super(context, R.string.label_caliper2_female, R.drawable.ic_caliper2);
if (getScaleUser().getGender().isMale()) {
setNameView(getResources().getText(R.string.label_caliper2_male));
}
}
@Override
public String getKey() {
return KEY;
}
@Override
protected float getMeasurementValue(ScaleMeasurement measurement) {
return measurement.getCaliper2();
}
@Override
protected void setMeasurementValue(float value, ScaleMeasurement measurement) {
measurement.setCaliper2(value);
}
@Override
public String getUnit() {
return "mm";
}
@Override
protected float getMaxValue() {
return 500;
}
@Override
public int getColor() {
return Color.parseColor("#ce93d8");
}
@Override
protected EvaluationResult evaluateSheet(EvaluationSheet evalSheet, float value) {
return null;
}
}

View File

@@ -0,0 +1,72 @@
/* Copyright (C) 2018 olie.xdev <olie.xdev@googlemail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.health.openscale.gui.views;
import android.content.Context;
import android.graphics.Color;
import com.health.openscale.R;
import com.health.openscale.core.datatypes.ScaleMeasurement;
import com.health.openscale.core.evaluation.EvaluationResult;
import com.health.openscale.core.evaluation.EvaluationSheet;
public class Caliper3MeasurementView extends FloatMeasurementView {
// Don't change key value, it may be stored persistent in preferences
public static final String KEY = "caliper3";
public Caliper3MeasurementView(Context context) {
super(context, R.string.label_caliper3_female, R.drawable.ic_caliper3);
if (getScaleUser().getGender().isMale()) {
setNameView(getResources().getText(R.string.label_caliper3_male));
}
}
@Override
public String getKey() {
return KEY;
}
@Override
protected float getMeasurementValue(ScaleMeasurement measurement) {
return measurement.getCaliper3();
}
@Override
protected void setMeasurementValue(float value, ScaleMeasurement measurement) {
measurement.setCaliper3(value);
}
@Override
public String getUnit() {
return "mm";
}
@Override
protected float getMaxValue() {
return 500;
}
@Override
public int getColor() {
return Color.parseColor("#e1bee7");
}
@Override
protected EvaluationResult evaluateSheet(EvaluationSheet evalSheet, float value) {
return null;
}
}

View File

@@ -0,0 +1,73 @@
/* Copyright (C) 2018 olie.xdev <olie.xdev@googlemail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.health.openscale.gui.views;
import android.content.Context;
import android.graphics.Color;
import com.health.openscale.R;
import com.health.openscale.core.datatypes.ScaleMeasurement;
import com.health.openscale.core.evaluation.EvaluationResult;
import com.health.openscale.core.evaluation.EvaluationSheet;
public class FatCaliperMeasurementView extends FloatMeasurementView {
// Don't change key value, it may be stored persistent in preferences
public static final String KEY = "fat_caliper";
public FatCaliperMeasurementView(Context context) {
super(context, R.string.label_fat_caliper, R.drawable.ic_fat_caliper);
}
@Override
public String getKey() {
return KEY;
}
@Override
public boolean isEditable() {
return false;
}
@Override
protected float getMeasurementValue(ScaleMeasurement measurement) {
return measurement.getFatCaliper(getScaleUser());
}
@Override
protected void setMeasurementValue(float value, ScaleMeasurement measurement) {
}
@Override
public String getUnit() {
return "%";
}
@Override
protected float getMaxValue() {
return 80;
}
@Override
public int getColor() {
return Color.parseColor("#f3e5f5");
}
@Override
protected EvaluationResult evaluateSheet(EvaluationSheet evalSheet, float value) {
return null;
}
}

View File

@@ -68,7 +68,7 @@ public abstract class FloatMeasurementView extends MeasurementView {
private float userConvertedWeight;
private EvaluationResult evaluationResult;
private final String nameText;
private String nameText;
private Button incButton;
private Button decButton;
@@ -465,6 +465,13 @@ public abstract class FloatMeasurementView extends MeasurementView {
}
}
@Override
protected void setNameView(CharSequence text) {
super.setNameView(text);
nameText = text.toString();
}
@Override
public void setExpand(boolean state) {
final boolean show = state && isVisible() && evaluationResult != null;

View File

@@ -120,6 +120,10 @@ public abstract class MeasurementView extends TableLayout {
unsorted.add(new ThighMeasurementView(context));
unsorted.add(new BicepsMeasurementView(context));
unsorted.add(new NeckMeasurementView(context));
unsorted.add(new FatCaliperMeasurementView(context));
unsorted.add(new Caliper1MeasurementView(context));
unsorted.add(new Caliper2MeasurementView(context));
unsorted.add(new Caliper3MeasurementView(context));
unsorted.add(new BMRMeasurementView(context));
unsorted.add(new CommentMeasurementView(context));

View File

@@ -60,6 +60,9 @@ public class MeasurementViewSettings {
case BicepsMeasurementView.KEY:
case ThighMeasurementView.KEY:
case NeckMeasurementView.KEY:
case Caliper1MeasurementView.KEY:
case Caliper2MeasurementView.KEY:
case Caliper3MeasurementView.KEY:
defaultValue = false;
break;
default:
@@ -80,6 +83,11 @@ public class MeasurementViewSettings {
public boolean areDependenciesEnabled() {
switch (key) {
case FatCaliperMeasurementView.KEY:
return isDependencyEnabled(Caliper1MeasurementView.KEY)
&& isDependencyEnabled(Caliper2MeasurementView.KEY)
&& isDependencyEnabled(Caliper3MeasurementView.KEY);
case BMIMeasurementView.KEY:
case BMRMeasurementView.KEY:
return isDependencyEnabled(WeightMeasurementView.KEY);

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 891 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 481 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 489 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 494 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 431 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 661 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 674 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 693 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 580 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

@@ -227,4 +227,11 @@
<string name="label_thigh">Thigh circumference</string>
<string name="label_biceps">Biceps circumference</string>
<string name="label_neck">Neck circumference</string>
<string name="label_fat_caliper">Body fat caliper</string>
<string name="label_caliper1_male">Chest skinfold</string>
<string name="label_caliper2_male">Abdominal skinfold</string>
<string name="label_caliper3_male">Thigh skinfold</string>
<string name="label_caliper1_female">Triceps skinfold</string>
<string name="label_caliper2_female">Abdominal skinfold</string>
<string name="label_caliper3_female">Hip skinfold</string>
</resources>