diff --git a/android_app/app/schemas/com.health.openscale.core.database.AppDatabase/2.json b/android_app/app/schemas/com.health.openscale.core.database.AppDatabase/2.json index 09425342..44f5adba 100644 --- a/android_app/app/schemas/com.health.openscale.core.database.AppDatabase/2.json +++ b/android_app/app/schemas/com.health.openscale.core.database.AppDatabase/2.json @@ -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\")" ] } } \ No newline at end of file diff --git a/android_app/app/schemas/com.health.openscale.core.database.AppDatabase/3.json b/android_app/app/schemas/com.health.openscale.core.database.AppDatabase/3.json index e752986f..b238f019 100644 --- a/android_app/app/schemas/com.health.openscale.core.database.AppDatabase/3.json +++ b/android_app/app/schemas/com.health.openscale.core.database.AppDatabase/3.json @@ -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\")" ] } } \ No newline at end of file diff --git a/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothDigooDGSO38H.java b/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothDigooDGSO38H.java index f6d3a17a..e0130cba 100644 --- a/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothDigooDGSO38H.java +++ b/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothDigooDGSO38H.java @@ -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); diff --git a/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothExcelvanCF369BLE.java b/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothExcelvanCF369BLE.java index 2a97074d..8ff48172 100644 --- a/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothExcelvanCF369BLE.java +++ b/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothExcelvanCF369BLE.java @@ -128,6 +128,7 @@ public class BluetoothExcelvanCF369BLE extends BluetoothCommunication { scaleBtData.setMuscle(muscle); scaleBtData.setWater(water); scaleBtData.setBone(bone); + scaleBtData.setVisceralFat(visceralFat); addScaleData(scaleBtData); } diff --git a/android_app/app/src/main/java/com/health/openscale/core/database/AppDatabase.java b/android_app/app/src/main/java/com/health/openscale/core/database/AppDatabase.java index f26cd23c..814dfc90 100644 --- a/android_app/app/src/main/java/com/health/openscale/core/database/AppDatabase.java +++ b/android_app/app/src/main/java/com/health/openscale/core/database/AppDatabase.java @@ -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"); diff --git a/android_app/app/src/main/java/com/health/openscale/core/datatypes/ScaleMeasurement.java b/android_app/app/src/main/java/com/health/openscale/core/datatypes/ScaleMeasurement.java index 2664fec9..7f0adc91 100644 --- a/android_app/app/src/main/java/com/health/openscale/core/datatypes/ScaleMeasurement.java +++ b/android_app/app/src/main/java/com/health/openscale/core/datatypes/ScaleMeasurement.java @@ -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; } diff --git a/android_app/app/src/main/java/com/health/openscale/gui/views/MeasurementView.java b/android_app/app/src/main/java/com/health/openscale/gui/views/MeasurementView.java index bca0785f..d61af4f8 100644 --- a/android_app/app/src/main/java/com/health/openscale/gui/views/MeasurementView.java +++ b/android_app/app/src/main/java/com/health/openscale/gui/views/MeasurementView.java @@ -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)); diff --git a/android_app/app/src/main/java/com/health/openscale/gui/views/MeasurementViewSettings.java b/android_app/app/src/main/java/com/health/openscale/gui/views/MeasurementViewSettings.java index 5db9c5ed..b209f52b 100644 --- a/android_app/app/src/main/java/com/health/openscale/gui/views/MeasurementViewSettings.java +++ b/android_app/app/src/main/java/com/health/openscale/gui/views/MeasurementViewSettings.java @@ -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: diff --git a/android_app/app/src/main/java/com/health/openscale/gui/views/VisceralFatMeasurementView.java b/android_app/app/src/main/java/com/health/openscale/gui/views/VisceralFatMeasurementView.java new file mode 100644 index 00000000..e42d65c3 --- /dev/null +++ b/android_app/app/src/main/java/com/health/openscale/gui/views/VisceralFatMeasurementView.java @@ -0,0 +1,77 @@ +/* Copyright (C) 2018 olie.xdev +* +* 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 +*/ +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; + } +} diff --git a/android_app/app/src/main/res/drawable-hdpi/ic_visceral_fat.png b/android_app/app/src/main/res/drawable-hdpi/ic_visceral_fat.png new file mode 100644 index 00000000..53727cdb Binary files /dev/null and b/android_app/app/src/main/res/drawable-hdpi/ic_visceral_fat.png differ diff --git a/android_app/app/src/main/res/drawable-ldpi/ic_visceral_fat.png b/android_app/app/src/main/res/drawable-ldpi/ic_visceral_fat.png new file mode 100644 index 00000000..767df8c2 Binary files /dev/null and b/android_app/app/src/main/res/drawable-ldpi/ic_visceral_fat.png differ diff --git a/android_app/app/src/main/res/drawable-mdpi/ic_visceral_fat.png b/android_app/app/src/main/res/drawable-mdpi/ic_visceral_fat.png new file mode 100644 index 00000000..c675fe8d Binary files /dev/null and b/android_app/app/src/main/res/drawable-mdpi/ic_visceral_fat.png differ diff --git a/android_app/app/src/main/res/drawable-xhdpi/ic_visceral_fat.png b/android_app/app/src/main/res/drawable-xhdpi/ic_visceral_fat.png new file mode 100644 index 00000000..204b525b Binary files /dev/null and b/android_app/app/src/main/res/drawable-xhdpi/ic_visceral_fat.png differ diff --git a/android_app/app/src/main/res/drawable-xxhdpi/ic_visceral_fat.png b/android_app/app/src/main/res/drawable-xxhdpi/ic_visceral_fat.png new file mode 100644 index 00000000..ce36fdb6 Binary files /dev/null and b/android_app/app/src/main/res/drawable-xxhdpi/ic_visceral_fat.png differ diff --git a/android_app/app/src/main/res/drawable-xxxhdpi/ic_visceral_fat.png b/android_app/app/src/main/res/drawable-xxxhdpi/ic_visceral_fat.png new file mode 100644 index 00000000..b6f72e25 Binary files /dev/null and b/android_app/app/src/main/res/drawable-xxxhdpi/ic_visceral_fat.png differ diff --git a/android_app/app/src/main/res/values/strings.xml b/android_app/app/src/main/res/values/strings.xml index 3b113cc3..5ee93625 100644 --- a/android_app/app/src/main/res/values/strings.xml +++ b/android_app/app/src/main/res/values/strings.xml @@ -223,6 +223,7 @@ Select measurement Select user Configure widget + Visceral fat Chest circumference Thigh circumference Biceps circumference