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

added visceral fat measurement and revert AppDatabase version 2 json file

This commit is contained in:
OliE
2018-05-13 19:37:33 +02:00
parent a3f642d395
commit 69a652ef51
16 changed files with 109 additions and 16 deletions

View File

@@ -2,11 +2,11 @@
"formatVersion": 1,
"database": {
"version": 2,
"identityHash": "41852b104c8d04f118c09bd1cd32725b",
"identityHash": "29790d4babbe129963d2c9282393c2d2",
"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, `thigh` 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, `comment` TEXT, FOREIGN KEY(`userId`) REFERENCES `scaleUsers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
"fields": [
{
"fieldPath": "id",
@@ -80,12 +80,6 @@
"affinity": "REAL",
"notNull": true
},
{
"fieldPath": "thigh",
"columnName": "thigh",
"affinity": "REAL",
"notNull": true
},
{
"fieldPath": "comment",
"columnName": "comment",
@@ -195,7 +189,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, \"41852b104c8d04f118c09bd1cd32725b\")"
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, \"29790d4babbe129963d2c9282393c2d2\")"
]
}
}

View File

@@ -2,11 +2,11 @@
"formatVersion": 1,
"database": {
"version": 3,
"identityHash": "fd4198e9af667e65ae56be8e9838d1ca",
"identityHash": "d64c7b69a0b7a1a0f93dd154a24b20f2",
"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, `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 )",
"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, `visceralFat` 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",
@@ -56,6 +56,12 @@
"affinity": "REAL",
"notNull": true
},
{
"fieldPath": "visceralFat",
"columnName": "visceralFat",
"affinity": "REAL",
"notNull": true
},
{
"fieldPath": "lbm",
"columnName": "lbw",
@@ -231,7 +237,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, \"fd4198e9af667e65ae56be8e9838d1ca\")"
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, \"d64c7b69a0b7a1a0f93dd154a24b20f2\")"
]
}
}

View File

@@ -86,8 +86,8 @@ public class BluetoothDigooDGSO38H extends BluetoothCommunication {
}
private void parseBytes(byte[] weightBytes) {
float weight, fat, water, muscle, boneWeight;
//float subcutaneousFat, visceralFat, metabolicBaseRate, biologicalAge, boneWeight;
float weight, fat, water, muscle, boneWeight, visceralFat;
//float subcutaneousFat, metabolicBaseRate, biologicalAge, boneWeight;
final byte ctrlByte = weightBytes[5];
final boolean allValues = isBitSet(ctrlByte, 1);
@@ -125,19 +125,19 @@ public class BluetoothDigooDGSO38H extends BluetoothCommunication {
"is done, but fat is still zero. Settling for just adding weight.");
} else {
//subcutaneousFat = (float) (((weightBytes[8] & 0xFF) << 8) | (weightBytes[9] & 0xFF)) / 10.0f;
//visceralFat = (float) (weightBytes[10] & 0xFF) / 10.0f;
visceralFat = (float) (weightBytes[10] & 0xFF) / 10.0f;
water = (float) (((weightBytes[11] & 0xFF) << 8) | (weightBytes[12] & 0xFF)) / 10.0f;
//metabolicBaseRate = (float) (((weightBytes[13] & 0xFF) << 8) | (weightBytes[14] & 0xFF));
//biologicalAge = (float) (weightBytes[15] & 0xFF) + 1;
muscle = (float) (((weightBytes[16] & 0xFF) << 8) | (weightBytes[17] & 0xFF)) / 10.0f;
boneWeight = (float) (weightBytes[18] & 0xFF) / 10.0f;
//TODO: Add extra measurements?
scaleBtData.setDateTime(new Date());
scaleBtData.setFat(fat);
scaleBtData.setMuscle(muscle);
scaleBtData.setWater(water);
scaleBtData.setBone(boneWeight);
scaleBtData.setVisceralFat(visceralFat);
}
scaleBtData.setWeight(weight);
addScaleData(scaleBtData);

View File

@@ -128,6 +128,7 @@ public class BluetoothExcelvanCF369BLE extends BluetoothCommunication {
scaleBtData.setMuscle(muscle);
scaleBtData.setWater(water);
scaleBtData.setBone(bone);
scaleBtData.setVisceralFat(visceralFat);
addScaleData(scaleBtData);
}

View File

@@ -81,6 +81,7 @@ public abstract class AppDatabase extends RoomDatabase {
public void migrate(SupportSQLiteDatabase database) {
database.beginTransaction();
try {
database.execSQL("ALTER TABLE scaleMeasurements ADD COLUMN visceralFat REAL NOT NULL DEFAULT 0");
database.execSQL("ALTER TABLE scaleMeasurements ADD COLUMN chest REAL NOT NULL DEFAULT 0");
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");

View File

@@ -62,6 +62,9 @@ public class ScaleMeasurement implements Cloneable {
@ColumnInfo(name = "muscle")
private float muscle;
@CsvColumn
@ColumnInfo(name = "visceralFat")
private float visceralFat;
@CsvColumn
@ColumnInfo(name = "lbw")
private float lbm;
@CsvColumn
@@ -260,6 +263,14 @@ public class ScaleMeasurement implements Cloneable {
this.muscle = muscle;
}
public float getVisceralFat() {
return visceralFat;
}
public void setVisceralFat(float visceralFat) {
this.visceralFat = visceralFat;
}
public float getLbm() {
return lbm;
}

View File

@@ -112,6 +112,7 @@ public abstract class MeasurementView extends TableLayout {
unsorted.add(new LBMMeasurementView(context));
unsorted.add(new FatMeasurementView(context));
unsorted.add(new BoneMeasurementView(context));
unsorted.add(new VisceralFatMeasurementView(context));
unsorted.add(new WaistMeasurementView(context));
unsorted.add(new WHtRMeasurementView(context));
unsorted.add(new HipMeasurementView(context));

View File

@@ -52,6 +52,7 @@ public class MeasurementViewSettings {
case WeightMeasurementView.KEY:
// Weight can't be disabled
return true;
case VisceralFatMeasurementView.KEY:
case LBMMeasurementView.KEY:
case BoneMeasurementView.KEY:
case WaistMeasurementView.KEY:

View File

@@ -0,0 +1,77 @@
/* 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 VisceralFatMeasurementView extends FloatMeasurementView {
// Don't change key value, it may be stored persistent in preferences
public static final String KEY = "visceralFat";
public VisceralFatMeasurementView(Context context) {
super(context, R.string.label_visceral_fat, R.drawable.ic_visceral_fat);
}
@Override
public String getKey() {
return KEY;
}
@Override
protected boolean supportsPercentageToAbsoluteWeightConversion() {
return true;
}
@Override
protected float getMeasurementValue(ScaleMeasurement measurement) {
return measurement.getVisceralFat();
}
@Override
protected void setMeasurementValue(float value, ScaleMeasurement measurement) {
measurement.setVisceralFat(value);
}
@Override
public String getUnit() {
if (shouldConvertPercentageToAbsoluteWeight()) {
return getScaleUser().getScaleUnit().toString();
}
return "%";
}
@Override
protected float getMaxValue() {
return maybeConvertPercentageToAbsoluteWeight(80);
}
@Override
public int getColor() {
return Color.parseColor("#8d6e63");
}
@Override
protected EvaluationResult evaluateSheet(EvaluationSheet evalSheet, float value) {
return null;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 795 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 405 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 524 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@@ -223,6 +223,7 @@
<string name="label_select_measurement">Select measurement</string>
<string name="label_select_user">Select user</string>
<string name="label_configure_widget">Configure widget</string>
<string name="label_visceral_fat">Visceral fat</string>
<string name="label_chest">Chest circumference</string>
<string name="label_thigh">Thigh circumference</string>
<string name="label_biceps">Biceps circumference</string>