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:
@@ -2,11 +2,11 @@
|
|||||||
"formatVersion": 1,
|
"formatVersion": 1,
|
||||||
"database": {
|
"database": {
|
||||||
"version": 2,
|
"version": 2,
|
||||||
"identityHash": "41852b104c8d04f118c09bd1cd32725b",
|
"identityHash": "29790d4babbe129963d2c9282393c2d2",
|
||||||
"entities": [
|
"entities": [
|
||||||
{
|
{
|
||||||
"tableName": "scaleMeasurements",
|
"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": [
|
"fields": [
|
||||||
{
|
{
|
||||||
"fieldPath": "id",
|
"fieldPath": "id",
|
||||||
@@ -80,12 +80,6 @@
|
|||||||
"affinity": "REAL",
|
"affinity": "REAL",
|
||||||
"notNull": true
|
"notNull": true
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"fieldPath": "thigh",
|
|
||||||
"columnName": "thigh",
|
|
||||||
"affinity": "REAL",
|
|
||||||
"notNull": true
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"fieldPath": "comment",
|
"fieldPath": "comment",
|
||||||
"columnName": "comment",
|
"columnName": "comment",
|
||||||
@@ -195,7 +189,7 @@
|
|||||||
],
|
],
|
||||||
"setupQueries": [
|
"setupQueries": [
|
||||||
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
|
"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\")"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -2,11 +2,11 @@
|
|||||||
"formatVersion": 1,
|
"formatVersion": 1,
|
||||||
"database": {
|
"database": {
|
||||||
"version": 3,
|
"version": 3,
|
||||||
"identityHash": "fd4198e9af667e65ae56be8e9838d1ca",
|
"identityHash": "d64c7b69a0b7a1a0f93dd154a24b20f2",
|
||||||
"entities": [
|
"entities": [
|
||||||
{
|
{
|
||||||
"tableName": "scaleMeasurements",
|
"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": [
|
"fields": [
|
||||||
{
|
{
|
||||||
"fieldPath": "id",
|
"fieldPath": "id",
|
||||||
@@ -56,6 +56,12 @@
|
|||||||
"affinity": "REAL",
|
"affinity": "REAL",
|
||||||
"notNull": true
|
"notNull": true
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "visceralFat",
|
||||||
|
"columnName": "visceralFat",
|
||||||
|
"affinity": "REAL",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"fieldPath": "lbm",
|
"fieldPath": "lbm",
|
||||||
"columnName": "lbw",
|
"columnName": "lbw",
|
||||||
@@ -231,7 +237,7 @@
|
|||||||
],
|
],
|
||||||
"setupQueries": [
|
"setupQueries": [
|
||||||
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
|
"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\")"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -86,8 +86,8 @@ public class BluetoothDigooDGSO38H extends BluetoothCommunication {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void parseBytes(byte[] weightBytes) {
|
private void parseBytes(byte[] weightBytes) {
|
||||||
float weight, fat, water, muscle, boneWeight;
|
float weight, fat, water, muscle, boneWeight, visceralFat;
|
||||||
//float subcutaneousFat, visceralFat, metabolicBaseRate, biologicalAge, boneWeight;
|
//float subcutaneousFat, metabolicBaseRate, biologicalAge, boneWeight;
|
||||||
|
|
||||||
final byte ctrlByte = weightBytes[5];
|
final byte ctrlByte = weightBytes[5];
|
||||||
final boolean allValues = isBitSet(ctrlByte, 1);
|
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.");
|
"is done, but fat is still zero. Settling for just adding weight.");
|
||||||
} else {
|
} else {
|
||||||
//subcutaneousFat = (float) (((weightBytes[8] & 0xFF) << 8) | (weightBytes[9] & 0xFF)) / 10.0f;
|
//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;
|
water = (float) (((weightBytes[11] & 0xFF) << 8) | (weightBytes[12] & 0xFF)) / 10.0f;
|
||||||
//metabolicBaseRate = (float) (((weightBytes[13] & 0xFF) << 8) | (weightBytes[14] & 0xFF));
|
//metabolicBaseRate = (float) (((weightBytes[13] & 0xFF) << 8) | (weightBytes[14] & 0xFF));
|
||||||
//biologicalAge = (float) (weightBytes[15] & 0xFF) + 1;
|
//biologicalAge = (float) (weightBytes[15] & 0xFF) + 1;
|
||||||
muscle = (float) (((weightBytes[16] & 0xFF) << 8) | (weightBytes[17] & 0xFF)) / 10.0f;
|
muscle = (float) (((weightBytes[16] & 0xFF) << 8) | (weightBytes[17] & 0xFF)) / 10.0f;
|
||||||
boneWeight = (float) (weightBytes[18] & 0xFF) / 10.0f;
|
boneWeight = (float) (weightBytes[18] & 0xFF) / 10.0f;
|
||||||
|
|
||||||
//TODO: Add extra measurements?
|
|
||||||
scaleBtData.setDateTime(new Date());
|
scaleBtData.setDateTime(new Date());
|
||||||
scaleBtData.setFat(fat);
|
scaleBtData.setFat(fat);
|
||||||
scaleBtData.setMuscle(muscle);
|
scaleBtData.setMuscle(muscle);
|
||||||
scaleBtData.setWater(water);
|
scaleBtData.setWater(water);
|
||||||
scaleBtData.setBone(boneWeight);
|
scaleBtData.setBone(boneWeight);
|
||||||
|
scaleBtData.setVisceralFat(visceralFat);
|
||||||
}
|
}
|
||||||
scaleBtData.setWeight(weight);
|
scaleBtData.setWeight(weight);
|
||||||
addScaleData(scaleBtData);
|
addScaleData(scaleBtData);
|
||||||
|
@@ -128,6 +128,7 @@ public class BluetoothExcelvanCF369BLE extends BluetoothCommunication {
|
|||||||
scaleBtData.setMuscle(muscle);
|
scaleBtData.setMuscle(muscle);
|
||||||
scaleBtData.setWater(water);
|
scaleBtData.setWater(water);
|
||||||
scaleBtData.setBone(bone);
|
scaleBtData.setBone(bone);
|
||||||
|
scaleBtData.setVisceralFat(visceralFat);
|
||||||
|
|
||||||
addScaleData(scaleBtData);
|
addScaleData(scaleBtData);
|
||||||
}
|
}
|
||||||
|
@@ -81,6 +81,7 @@ public abstract class AppDatabase extends RoomDatabase {
|
|||||||
public void migrate(SupportSQLiteDatabase database) {
|
public void migrate(SupportSQLiteDatabase database) {
|
||||||
database.beginTransaction();
|
database.beginTransaction();
|
||||||
try {
|
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 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 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 biceps REAL NOT NULL DEFAULT 0");
|
||||||
|
@@ -62,6 +62,9 @@ public class ScaleMeasurement implements Cloneable {
|
|||||||
@ColumnInfo(name = "muscle")
|
@ColumnInfo(name = "muscle")
|
||||||
private float muscle;
|
private float muscle;
|
||||||
@CsvColumn
|
@CsvColumn
|
||||||
|
@ColumnInfo(name = "visceralFat")
|
||||||
|
private float visceralFat;
|
||||||
|
@CsvColumn
|
||||||
@ColumnInfo(name = "lbw")
|
@ColumnInfo(name = "lbw")
|
||||||
private float lbm;
|
private float lbm;
|
||||||
@CsvColumn
|
@CsvColumn
|
||||||
@@ -260,6 +263,14 @@ public class ScaleMeasurement implements Cloneable {
|
|||||||
this.muscle = muscle;
|
this.muscle = muscle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public float getVisceralFat() {
|
||||||
|
return visceralFat;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVisceralFat(float visceralFat) {
|
||||||
|
this.visceralFat = visceralFat;
|
||||||
|
}
|
||||||
|
|
||||||
public float getLbm() {
|
public float getLbm() {
|
||||||
return lbm;
|
return lbm;
|
||||||
}
|
}
|
||||||
|
@@ -112,6 +112,7 @@ public abstract class MeasurementView extends TableLayout {
|
|||||||
unsorted.add(new LBMMeasurementView(context));
|
unsorted.add(new LBMMeasurementView(context));
|
||||||
unsorted.add(new FatMeasurementView(context));
|
unsorted.add(new FatMeasurementView(context));
|
||||||
unsorted.add(new BoneMeasurementView(context));
|
unsorted.add(new BoneMeasurementView(context));
|
||||||
|
unsorted.add(new VisceralFatMeasurementView(context));
|
||||||
unsorted.add(new WaistMeasurementView(context));
|
unsorted.add(new WaistMeasurementView(context));
|
||||||
unsorted.add(new WHtRMeasurementView(context));
|
unsorted.add(new WHtRMeasurementView(context));
|
||||||
unsorted.add(new HipMeasurementView(context));
|
unsorted.add(new HipMeasurementView(context));
|
||||||
|
@@ -52,6 +52,7 @@ public class MeasurementViewSettings {
|
|||||||
case WeightMeasurementView.KEY:
|
case WeightMeasurementView.KEY:
|
||||||
// Weight can't be disabled
|
// Weight can't be disabled
|
||||||
return true;
|
return true;
|
||||||
|
case VisceralFatMeasurementView.KEY:
|
||||||
case LBMMeasurementView.KEY:
|
case LBMMeasurementView.KEY:
|
||||||
case BoneMeasurementView.KEY:
|
case BoneMeasurementView.KEY:
|
||||||
case WaistMeasurementView.KEY:
|
case WaistMeasurementView.KEY:
|
||||||
|
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
BIN
android_app/app/src/main/res/drawable-hdpi/ic_visceral_fat.png
Normal file
BIN
android_app/app/src/main/res/drawable-hdpi/ic_visceral_fat.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 795 B |
BIN
android_app/app/src/main/res/drawable-ldpi/ic_visceral_fat.png
Normal file
BIN
android_app/app/src/main/res/drawable-ldpi/ic_visceral_fat.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 405 B |
BIN
android_app/app/src/main/res/drawable-mdpi/ic_visceral_fat.png
Normal file
BIN
android_app/app/src/main/res/drawable-mdpi/ic_visceral_fat.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 524 B |
BIN
android_app/app/src/main/res/drawable-xhdpi/ic_visceral_fat.png
Normal file
BIN
android_app/app/src/main/res/drawable-xhdpi/ic_visceral_fat.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
BIN
android_app/app/src/main/res/drawable-xxhdpi/ic_visceral_fat.png
Normal file
BIN
android_app/app/src/main/res/drawable-xxhdpi/ic_visceral_fat.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
Binary file not shown.
After Width: | Height: | Size: 2.0 KiB |
@@ -223,6 +223,7 @@
|
|||||||
<string name="label_select_measurement">Select measurement</string>
|
<string name="label_select_measurement">Select measurement</string>
|
||||||
<string name="label_select_user">Select user</string>
|
<string name="label_select_user">Select user</string>
|
||||||
<string name="label_configure_widget">Configure widget</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_chest">Chest circumference</string>
|
||||||
<string name="label_thigh">Thigh circumference</string>
|
<string name="label_thigh">Thigh circumference</string>
|
||||||
<string name="label_biceps">Biceps circumference</string>
|
<string name="label_biceps">Biceps circumference</string>
|
||||||
|
Reference in New Issue
Block a user