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

renamed ScaleData class to ScaleMeasurement class for consistent naming

saved generated Room database shema
This commit is contained in:
OliE
2018-01-01 11:18:06 +01:00
parent 1ec1ae577b
commit bd187962d4
60 changed files with 632 additions and 451 deletions

View File

@@ -9,6 +9,14 @@ android {
targetSdkVersion 22 // don't set target sdk > 22 otherwise bluetooth le discovery need permission to ACCESS_COARSE_LOCATION
versionCode 21
versionName "1.6.1"
javaCompileOptions {
annotationProcessorOptions { arguments = ["room.schemaLocation":"$projectDir/schemas".toString()] }
}
}
sourceSets {
androidTest.assets.srcDirs += files("$projectDir/schemas".toString())
}
lintOptions {

View File

@@ -0,0 +1,173 @@
{
"formatVersion": 1,
"database": {
"version": 1,
"identityHash": "410f7d8b5658d42485fff50486fde7f5",
"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, `comment` TEXT)",
"fields": [
{
"fieldPath": "id",
"columnName": "id",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "userId",
"columnName": "userId",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "enabled",
"columnName": "enabled",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "dateTime",
"columnName": "datetime",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "weight",
"columnName": "weight",
"affinity": "REAL",
"notNull": true
},
{
"fieldPath": "fat",
"columnName": "fat",
"affinity": "REAL",
"notNull": true
},
{
"fieldPath": "water",
"columnName": "water",
"affinity": "REAL",
"notNull": true
},
{
"fieldPath": "muscle",
"columnName": "muscle",
"affinity": "REAL",
"notNull": true
},
{
"fieldPath": "lbw",
"columnName": "lbw",
"affinity": "REAL",
"notNull": true
},
{
"fieldPath": "waist",
"columnName": "waist",
"affinity": "REAL",
"notNull": true
},
{
"fieldPath": "hip",
"columnName": "hip",
"affinity": "REAL",
"notNull": true
},
{
"fieldPath": "bone",
"columnName": "bone",
"affinity": "REAL",
"notNull": true
},
{
"fieldPath": "comment",
"columnName": "comment",
"affinity": "TEXT",
"notNull": false
}
],
"primaryKey": {
"columnNames": [
"id"
],
"autoGenerate": true
},
"indices": [],
"foreignKeys": []
},
{
"tableName": "scaleUsers",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `username` TEXT, `birthday` INTEGER, `bodyHeight` INTEGER NOT NULL, `scaleUnit` INTEGER NOT NULL, `gender` INTEGER NOT NULL, `initialWeight` REAL NOT NULL, `goalWeight` REAL NOT NULL, `goalDate` INTEGER)",
"fields": [
{
"fieldPath": "id",
"columnName": "id",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "userName",
"columnName": "username",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "birthday",
"columnName": "birthday",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "bodyHeight",
"columnName": "bodyHeight",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "scaleUnit",
"columnName": "scaleUnit",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "gender",
"columnName": "gender",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "initialWeight",
"columnName": "initialWeight",
"affinity": "REAL",
"notNull": true
},
{
"fieldPath": "goalWeight",
"columnName": "goalWeight",
"affinity": "REAL",
"notNull": true
},
{
"fieldPath": "goalDate",
"columnName": "goalDate",
"affinity": "INTEGER",
"notNull": false
}
],
"primaryKey": {
"columnNames": [
"id"
],
"autoGenerate": true
},
"indices": [],
"foreignKeys": []
}
],
"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, \"410f7d8b5658d42485fff50486fde7f5\")"
]
}
}

View File

@@ -37,7 +37,7 @@ import com.health.openscale.core.database.ScaleDatabase;
import com.health.openscale.core.database.ScaleMeasurementDAO;
import com.health.openscale.core.database.ScaleUserDAO;
import com.health.openscale.core.database.ScaleUserDatabase;
import com.health.openscale.core.datatypes.ScaleData;
import com.health.openscale.core.datatypes.ScaleMeasurement;
import com.health.openscale.core.datatypes.ScaleUser;
import com.health.openscale.gui.fragments.FragmentUpdateListener;
@@ -65,7 +65,7 @@ public class OpenScale {
private ScaleUserDAO userDAO;
private ScaleDatabase scaleDB;
private ScaleUserDatabase scaleUserDB;
private List<ScaleData> scaleDataList;
private List<ScaleMeasurement> scaleMeasurementList;
private BluetoothCommunication btCom;
private String btDeviceName;
@@ -108,8 +108,8 @@ public class OpenScale {
userDAO.insertAll(scaleUserList);
for (ScaleUser user : scaleUserList) {
List<ScaleData> scaleDataList = scaleDB.getScaleDataList(user.getId());
measurementDAO.insertAll(scaleDataList);
List<ScaleMeasurement> scaleMeasurementList = scaleDB.getScaleDataList(user.getId());
measurementDAO.insertAll(scaleMeasurementList);
}
}
}
@@ -164,14 +164,14 @@ public class OpenScale {
userDAO.update(user);
}
public List<ScaleData> getScaleDataList() {
return scaleDataList;
public List<ScaleMeasurement> getScaleMeasurementList() {
return scaleMeasurementList;
}
public ScaleData[] getTupleScaleData(int id)
public ScaleMeasurement[] getTupleScaleData(int id)
{
ScaleData[] tupleScaleData = new ScaleData[3];
ScaleMeasurement[] tupleScaleData = new ScaleMeasurement[3];
tupleScaleData[0] = measurementDAO.getPrevious(id, getSelectedScaleUser().getId());
tupleScaleData[1] = measurementDAO.get(id);
@@ -180,18 +180,18 @@ public class OpenScale {
return tupleScaleData;
}
public int addScaleData(final ScaleData scaleData) {
public int addScaleData(final ScaleMeasurement scaleMeasurement) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
if (scaleData.getUserId() == -1) {
if (scaleMeasurement.getUserId() == -1) {
if (prefs.getBoolean("smartUserAssign", false)) {
scaleData.setUserId(getSmartUserAssignment(scaleData.getWeight(), 15.0f));
scaleMeasurement.setUserId(getSmartUserAssignment(scaleMeasurement.getWeight(), 15.0f));
} else {
scaleData.setUserId(getSelectedScaleUser().getId());
scaleMeasurement.setUserId(getSelectedScaleUser().getId());
}
// don't add scale data if no user is selected
if (scaleData.getUserId() == -1) {
if (scaleMeasurement.getUserId() == -1) {
return -1;
}
}
@@ -199,32 +199,32 @@ public class OpenScale {
if (prefs.getBoolean("estimateWaterEnable", false)) {
EstimatedWaterMetric waterMetric = EstimatedWaterMetric.getEstimatedMetric(EstimatedWaterMetric.FORMULA.valueOf(prefs.getString("estimateWaterFormula", "TBW_LEESONGKIM")));
scaleData.setWater(waterMetric.getWater(getScaleUser(scaleData.getUserId()), scaleData));
scaleMeasurement.setWater(waterMetric.getWater(getScaleUser(scaleMeasurement.getUserId()), scaleMeasurement));
}
if (prefs.getBoolean("estimateLBWEnable", false)) {
EstimatedLBWMetric lbwMetric = EstimatedLBWMetric.getEstimatedMetric(EstimatedLBWMetric.FORMULA.valueOf(prefs.getString("estimateLBWFormula", "LBW_HUME")));
scaleData.setLbw(lbwMetric.getLBW(getScaleUser(scaleData.getUserId()), scaleData));
scaleMeasurement.setLbw(lbwMetric.getLBW(getScaleUser(scaleMeasurement.getUserId()), scaleMeasurement));
}
if (prefs.getBoolean("estimateFatEnable", false)) {
EstimatedFatMetric fatMetric = EstimatedFatMetric.getEstimatedMetric(EstimatedFatMetric.FORMULA.valueOf(prefs.getString("estimateFatFormula", "BF_GALLAGHER")));
scaleData.setFat(fatMetric.getFat(getScaleUser(scaleData.getUserId()), scaleData));
scaleMeasurement.setFat(fatMetric.getFat(getScaleUser(scaleMeasurement.getUserId()), scaleMeasurement));
}
if (measurementDAO.get(scaleData.getDateTime(), scaleData.getUserId()) == null) {
measurementDAO.insert(scaleData);
ScaleUser scaleUser = getScaleUser(scaleData.getUserId());
if (measurementDAO.get(scaleMeasurement.getDateTime(), scaleMeasurement.getUserId()) == null) {
measurementDAO.insert(scaleMeasurement);
ScaleUser scaleUser = getScaleUser(scaleMeasurement.getUserId());
String infoText = String.format(context.getString(R.string.info_new_data_added), scaleData.getConvertedWeight(scaleUser.getScaleUnit()), scaleUser.UNIT_STRING[scaleUser.getScaleUnit()], dateTimeFormat.format(scaleData.getDateTime()), scaleUser.getUserName());
String infoText = String.format(context.getString(R.string.info_new_data_added), scaleMeasurement.getConvertedWeight(scaleUser.getScaleUnit()), scaleUser.UNIT_STRING[scaleUser.getScaleUnit()], dateTimeFormat.format(scaleMeasurement.getDateTime()), scaleUser.getUserName());
Toast.makeText(context, infoText, Toast.LENGTH_LONG).show();
alarmHandler.entryChanged(context, scaleData);
alarmHandler.entryChanged(context, scaleMeasurement);
updateScaleData();
}
return scaleData.getUserId();
return scaleMeasurement.getUserId();
}
private int getSmartUserAssignment(float weight, float range) {
@@ -232,7 +232,7 @@ public class OpenScale {
Map<Float, Integer> inRangeWeights = new TreeMap<>();
for (int i = 0; i < scaleUsers.size(); i++) {
List<ScaleData> scaleUserData = measurementDAO.getAll(scaleUsers.get(i).getId());
List<ScaleMeasurement> scaleUserData = measurementDAO.getAll(scaleUsers.get(i).getId());
float lastWeight = 0;
@@ -263,9 +263,9 @@ public class OpenScale {
return getSelectedScaleUser().getId();
}
public void updateScaleData(ScaleData scaleData) {
measurementDAO.update(scaleData);
alarmHandler.entryChanged(context, scaleData);
public void updateScaleData(ScaleMeasurement scaleMeasurement) {
measurementDAO.update(scaleMeasurement);
alarmHandler.entryChanged(context, scaleMeasurement);
updateScaleData();
}
@@ -295,22 +295,22 @@ public class OpenScale {
throw new IOException("Can't parse CSV file. Field length is wrong.");
}
ScaleData newScaleData = new ScaleData();
ScaleMeasurement newScaleMeasurement = new ScaleMeasurement();
newScaleData.setDateTime(dateTimeFormat.parse(csvField[0]));
newScaleData.setWeight(Float.parseFloat(csvField[1]));
newScaleData.setFat(Float.parseFloat(csvField[2]));
newScaleData.setWater(Float.parseFloat(csvField[3]));
newScaleData.setMuscle(Float.parseFloat(csvField[4]));
newScaleData.setLbw(Float.parseFloat(csvField[5]));
newScaleData.setBone(Float.parseFloat(csvField[6]));
newScaleData.setWaist(Float.parseFloat(csvField[7]));
newScaleData.setHip(Float.parseFloat(csvField[8]));
newScaleData.setComment(csvField[9]);
newScaleMeasurement.setDateTime(dateTimeFormat.parse(csvField[0]));
newScaleMeasurement.setWeight(Float.parseFloat(csvField[1]));
newScaleMeasurement.setFat(Float.parseFloat(csvField[2]));
newScaleMeasurement.setWater(Float.parseFloat(csvField[3]));
newScaleMeasurement.setMuscle(Float.parseFloat(csvField[4]));
newScaleMeasurement.setLbw(Float.parseFloat(csvField[5]));
newScaleMeasurement.setBone(Float.parseFloat(csvField[6]));
newScaleMeasurement.setWaist(Float.parseFloat(csvField[7]));
newScaleMeasurement.setHip(Float.parseFloat(csvField[8]));
newScaleMeasurement.setComment(csvField[9]);
newScaleData.setUserId(getSelectedScaleUser().getId());
newScaleMeasurement.setUserId(getSelectedScaleUser().getId());
measurementDAO.insert(newScaleData);
measurementDAO.insert(newScaleMeasurement);
line = csvReader.readLine();
}
@@ -337,18 +337,18 @@ public class OpenScale {
OutputStreamWriter csvWriter = new OutputStreamWriter(outputStream);
for (ScaleData scaleData : scaleDataList) {
csvWriter.append(dateTimeFormat.format(scaleData.getDateTime()) + ",");
csvWriter.append(Float.toString(scaleData.getWeight()) + ",");
csvWriter.append(Float.toString(scaleData.getFat()) + ",");
csvWriter.append(Float.toString(scaleData.getWater()) + ",");
csvWriter.append(Float.toString(scaleData.getMuscle()) + ",");
csvWriter.append(Float.toString(scaleData.getLbw()) + ",");
csvWriter.append(Float.toString(scaleData.getBone()) + ",");
csvWriter.append(Float.toString(scaleData.getWaist()) + ",");
csvWriter.append(Float.toString(scaleData.getHip()) + ",");
if (!scaleData.getComment().isEmpty()) {
csvWriter.append(scaleData.getComment());
for (ScaleMeasurement scaleMeasurement : scaleMeasurementList) {
csvWriter.append(dateTimeFormat.format(scaleMeasurement.getDateTime()) + ",");
csvWriter.append(Float.toString(scaleMeasurement.getWeight()) + ",");
csvWriter.append(Float.toString(scaleMeasurement.getFat()) + ",");
csvWriter.append(Float.toString(scaleMeasurement.getWater()) + ",");
csvWriter.append(Float.toString(scaleMeasurement.getMuscle()) + ",");
csvWriter.append(Float.toString(scaleMeasurement.getLbw()) + ",");
csvWriter.append(Float.toString(scaleMeasurement.getBone()) + ",");
csvWriter.append(Float.toString(scaleMeasurement.getWaist()) + ",");
csvWriter.append(Float.toString(scaleMeasurement.getHip()) + ",");
if (!scaleMeasurement.getComment().isEmpty()) {
csvWriter.append(scaleMeasurement.getComment());
}
csvWriter.append("\n");
@@ -386,7 +386,7 @@ public class OpenScale {
return numOfMonth;
}
public List<ScaleData> getScaleDataOfMonth(int year, int month) {
public List<ScaleMeasurement> getScaleDataOfMonth(int year, int month) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
int selectedUserId = prefs.getInt("selectedUserId", -1);
@@ -400,7 +400,7 @@ public class OpenScale {
return measurementDAO.getAllInRange(startCalender.getTime(), endCalender.getTime(), selectedUserId);
}
public List<ScaleData> getScaleDataOfYear(int year) {
public List<ScaleMeasurement> getScaleDataOfYear(int year) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
int selectedUserId = prefs.getInt("selectedUserId", -1);
@@ -445,9 +445,9 @@ public class OpenScale {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
int selectedUserId = prefs.getInt("selectedUserId", -1);
scaleDataList = measurementDAO.getAll(selectedUserId);
scaleMeasurementList = measurementDAO.getAll(selectedUserId);
fragment.updateOnView(scaleDataList);
fragment.updateOnView(scaleMeasurementList);
}
public void updateScaleData()
@@ -455,12 +455,12 @@ public class OpenScale {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
int selectedUserId = prefs.getInt("selectedUserId", -1);
scaleDataList = measurementDAO.getAll(selectedUserId);
scaleMeasurementList = measurementDAO.getAll(selectedUserId);
for (FragmentUpdateListener fragment : fragmentList) {
if (fragment != null) {
if (((Fragment)fragment).isAdded()) {
fragment.updateOnView(scaleDataList);
fragment.updateOnView(scaleMeasurementList);
}
}
}

View File

@@ -27,7 +27,7 @@ import android.support.v4.app.NotificationCompat;
import android.util.Log;
import com.health.openscale.R;
import com.health.openscale.core.datatypes.ScaleData;
import com.health.openscale.core.datatypes.ScaleMeasurement;
import com.health.openscale.gui.MainActivity;
import java.util.Calendar;
@@ -52,7 +52,7 @@ public class AlarmHandler
enableAlarms(context, alarmEntries);
}
public void entryChanged(Context context, ScaleData data)
public void entryChanged(Context context, ScaleMeasurement data)
{
long dataMillis = data.getDateTime().getTime();

View File

@@ -24,7 +24,7 @@ import android.util.Log;
import com.health.openscale.R;
import com.health.openscale.core.OpenScale;
import com.health.openscale.core.datatypes.ScaleData;
import com.health.openscale.core.datatypes.ScaleMeasurement;
import com.health.openscale.core.datatypes.ScaleUser;
import java.io.ByteArrayOutputStream;
@@ -427,7 +427,7 @@ public class BluetoothBeurerBF700_800 extends BluetoothCommunication {
if (current_item % 2 == 0) {
try {
ScaleData parsedData = parseScaleData(receivedScaleData.toByteArray());
ScaleMeasurement parsedData = parseScaleData(receivedScaleData.toByteArray());
addScaleData(parsedData);
} catch (ParseException e) {
Log.d(TAG, "Could not parse byte array: " + byteInHex(receivedScaleData.toByteArray()));
@@ -500,7 +500,7 @@ public class BluetoothBeurerBF700_800 extends BluetoothCommunication {
if (current_item == max_items) {
// received all parts
ScaleData parsedData = null;
ScaleMeasurement parsedData = null;
try {
parsedData = parseScaleData(receivedScaleData.toByteArray());
addScaleData(parsedData);
@@ -530,11 +530,11 @@ public class BluetoothBeurerBF700_800 extends BluetoothCommunication {
});
}
private ScaleData parseScaleData(byte[] data) throws ParseException {
private ScaleMeasurement parseScaleData(byte[] data) throws ParseException {
if (data.length != 11 + 11)
throw new ParseException("Parse scala data: unexpected length", 0);
ScaleData receivedMeasurement = new ScaleData();
ScaleMeasurement receivedMeasurement = new ScaleMeasurement();
// Parse timestamp
long timestamp = ByteBuffer.wrap(data, 0, 4).getInt() * 1000L;

View File

@@ -27,7 +27,7 @@ import android.content.Context;
import android.os.Handler;
import android.util.Log;
import com.health.openscale.core.datatypes.ScaleData;
import com.health.openscale.core.datatypes.ScaleMeasurement;
import java.util.LinkedList;
import java.util.Queue;
@@ -137,10 +137,10 @@ public abstract class BluetoothCommunication {
/**
* Add a new scale data to openScale
*
* @param scaleData the scale data that should be added to openScale
* @param scaleMeasurement the scale data that should be added to openScale
*/
protected void addScaleData(ScaleData scaleData) {
callbackBtHandler.obtainMessage(BT_STATUS_CODE.BT_RETRIEVE_SCALE_DATA.ordinal(), scaleData).sendToTarget();
protected void addScaleData(ScaleMeasurement scaleMeasurement) {
callbackBtHandler.obtainMessage(BT_STATUS_CODE.BT_RETRIEVE_SCALE_DATA.ordinal(), scaleMeasurement).sendToTarget();
}
/**

View File

@@ -20,7 +20,7 @@ import android.bluetooth.BluetoothSocket;
import android.content.Context;
import android.util.Log;
import com.health.openscale.core.datatypes.ScaleData;
import com.health.openscale.core.datatypes.ScaleMeasurement;
import java.io.IOException;
import java.io.InputStream;
@@ -190,10 +190,10 @@ public class BluetoothCustomOpenScale extends BluetoothCommunication {
btLine.append(btChar);
if (btLine.charAt(btLine.length() - 1) == '\n') {
ScaleData scaleData = parseBtString(btLine.toString());
ScaleMeasurement scaleMeasurement = parseBtString(btLine.toString());
if (scaleData != null) {
addScaleData(scaleData);
if (scaleMeasurement != null) {
addScaleData(scaleMeasurement);
}
btLine.setLength(0);
@@ -206,8 +206,8 @@ public class BluetoothCustomOpenScale extends BluetoothCommunication {
}
}
private ScaleData parseBtString(String btString) throws IOException {
ScaleData scaleBtData = new ScaleData();
private ScaleMeasurement parseBtString(String btString) throws IOException {
ScaleMeasurement scaleBtData = new ScaleMeasurement();
btString = btString.substring(0, btString.length() - 1); // delete newline '\n' of the string
if (btString.charAt(0) != '$' && btString.charAt(2) != '$') {

View File

@@ -22,7 +22,7 @@ import android.content.Context;
import android.util.Log;
import com.health.openscale.core.OpenScale;
import com.health.openscale.core.datatypes.ScaleData;
import com.health.openscale.core.datatypes.ScaleMeasurement;
import com.health.openscale.core.datatypes.ScaleUser;
import java.util.Date;
@@ -130,7 +130,7 @@ public class BluetoothDigooDGSO38H extends BluetoothCommunication {
configBytes[15] = (byte)(checksum & 0xFF);
writeBytes(WEIGHT_MEASUREMENT_SERVICE, EXTRA_MEASUREMENT_CHARACTERISTIC, configBytes);
} else if (allValues) {
ScaleData scaleBtData = new ScaleData();
ScaleMeasurement scaleBtData = new ScaleMeasurement();
weight = (float) (((weightBytes[3] & 0xFF) << 8) | (weightBytes[4] & 0xFF)) / 100.0f;
fat = (float) (((weightBytes[6] & 0xFF) << 8) | (weightBytes[7] & 0xFF)) / 10.0f;
if (Math.abs(fat - 0.0) < 0.00001) {

View File

@@ -21,7 +21,7 @@ import android.bluetooth.BluetoothGattCharacteristic;
import android.content.Context;
import com.health.openscale.core.OpenScale;
import com.health.openscale.core.datatypes.ScaleData;
import com.health.openscale.core.datatypes.ScaleMeasurement;
import com.health.openscale.core.datatypes.ScaleUser;
import java.util.Arrays;
@@ -126,7 +126,7 @@ public class BluetoothExcelvanCF369BLE extends BluetoothCommunication {
float water = (float)(((weightBytes[12] & 0xFF) << 8) | (weightBytes[13] & 0xFF)) / 10.0f;
float bmr = (float)(((weightBytes[14] & 0xFF) << 8) | (weightBytes[15] & 0xFF));
ScaleData scaleBtData = new ScaleData();
ScaleMeasurement scaleBtData = new ScaleMeasurement();
final ScaleUser selectedUser = OpenScale.getInstance(context).getSelectedScaleUser();

View File

@@ -23,7 +23,7 @@ import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import com.health.openscale.core.OpenScale;
import com.health.openscale.core.datatypes.ScaleData;
import com.health.openscale.core.datatypes.ScaleMeasurement;
import com.health.openscale.core.datatypes.ScaleUser;
import java.util.Date;
@@ -112,7 +112,7 @@ public class BluetoothExingtechY1 extends BluetoothCommunication {
float calorie = (float)(((weightBytes[15] & 0xFF) << 8) | (weightBytes[16] & 0xFF));
float bmi = (float)(((weightBytes[17] & 0xFF) << 8) | (weightBytes[18] & 0xFF)) / 10.0f;
ScaleData scaleBtData = new ScaleData();
ScaleMeasurement scaleBtData = new ScaleMeasurement();
final ScaleUser selectedUser = OpenScale.getInstance(context).getSelectedScaleUser();

View File

@@ -22,7 +22,7 @@ import android.bluetooth.BluetoothGattCharacteristic;
import android.content.Context;
import com.health.openscale.core.OpenScale;
import com.health.openscale.core.datatypes.ScaleData;
import com.health.openscale.core.datatypes.ScaleMeasurement;
import com.health.openscale.core.datatypes.ScaleUser;
import java.util.Calendar;
@@ -41,7 +41,7 @@ public class BluetoothMGB extends BluetoothCommunication {
private Calendar now;
private ScaleUser user;
private ScaleData measurement;
private ScaleMeasurement measurement;
private byte[] packet_buf;
private int packet_pos;
@@ -170,7 +170,7 @@ public class BluetoothMGB extends BluetoothCommunication {
int hdr_3 = popInt();
if (hdr_1 == 0xAC && hdr_2 == 0x02 && hdr_3 == 0xFF) {
measurement = new ScaleData();
measurement = new ScaleMeasurement();
popInt(); //unknown =00
popInt(); //unknown =02

View File

@@ -19,7 +19,7 @@ import android.bluetooth.BluetoothGatt;
import android.bluetooth.BluetoothGattCharacteristic;
import android.content.Context;
import com.health.openscale.core.datatypes.ScaleData;
import com.health.openscale.core.datatypes.ScaleMeasurement;
import java.util.Date;
import java.util.UUID;
@@ -33,11 +33,11 @@ public class BluetoothMedisanaBS444 extends BluetoothCommunication {
private final UUID CUSTOM5_MEASUREMENT_CHARACTERISTIC = UUID.fromString("00008a82-0000-1000-8000-00805f9b34fb"); // indication, read-only
private final UUID WEIGHT_MEASUREMENT_CONFIG = UUID.fromString("00002902-0000-1000-8000-00805f9b34fb");
private ScaleData btScaleData;
private ScaleMeasurement btScaleMeasurement;
public BluetoothMedisanaBS444(Context context) {
super(context);
btScaleData = new ScaleData();
btScaleMeasurement = new ScaleMeasurement();
}
@Override
@@ -119,7 +119,7 @@ public class BluetoothMedisanaBS444 extends BluetoothCommunication {
if (gattCharacteristic.getUuid().equals(FEATURE_MEASUREMENT_CHARACTERISTIC)) {
parseFeatureData(data);
addScaleData(btScaleData);
addScaleData(btScaleMeasurement);
}
}
@@ -131,16 +131,16 @@ public class BluetoothMedisanaBS444 extends BluetoothCommunication {
unix_timestamp += 1262304000; // +40 years because unix time starts in year 1970
btDate.setTime(unix_timestamp*1000); // multiply with 1000 to get milliseconds
btScaleData.setDateTime(btDate);
btScaleData.setWeight(weight);
btScaleMeasurement.setDateTime(btDate);
btScaleMeasurement.setWeight(weight);
}
private void parseFeatureData(byte[] featureData) {
//btScaleData.setKCal(((featureData[7] & 0xFF) << 8) | (featureData[6] & 0xFF));
btScaleData.setFat(decodeFeature(featureData[8], featureData[9]));
btScaleData.setWater(decodeFeature(featureData[10], featureData[11]));
btScaleData.setMuscle(decodeFeature(featureData[12], featureData[13]));
btScaleData.setBone(decodeFeature(featureData[14], featureData[15]));
btScaleMeasurement.setFat(decodeFeature(featureData[8], featureData[9]));
btScaleMeasurement.setWater(decodeFeature(featureData[10], featureData[11]));
btScaleMeasurement.setMuscle(decodeFeature(featureData[12], featureData[13]));
btScaleMeasurement.setBone(decodeFeature(featureData[14], featureData[15]));
}
private float decodeFeature(byte highByte, byte lowByte) {

View File

@@ -23,7 +23,7 @@ import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.util.Log;
import com.health.openscale.core.datatypes.ScaleData;
import com.health.openscale.core.datatypes.ScaleMeasurement;
import java.text.ParseException;
import java.text.SimpleDateFormat;
@@ -238,7 +238,7 @@ public class BluetoothMiScale extends BluetoothCommunication {
// Is the year plausible? Check if the year is in the range of 20 years...
if (validateDate(date_time, 20)) {
ScaleData scaleBtData = new ScaleData();
ScaleMeasurement scaleBtData = new ScaleMeasurement();
scaleBtData.setWeight(weight);
scaleBtData.setDateTime(date_time);

View File

@@ -24,7 +24,7 @@ import android.preference.PreferenceManager;
import android.util.Log;
import com.health.openscale.core.OpenScale;
import com.health.openscale.core.datatypes.ScaleData;
import com.health.openscale.core.datatypes.ScaleMeasurement;
import com.health.openscale.core.datatypes.ScaleUser;
import java.text.ParseException;
@@ -211,7 +211,7 @@ public class BluetoothMiScale2 extends BluetoothCommunication {
// Is the year plausible? Check if the year is in the range of 20 years...
if (validateDate(date_time, 20)) {
ScaleData scaleBtData = new ScaleData();
ScaleMeasurement scaleBtData = new ScaleMeasurement();
scaleBtData.setWeight(weight);
scaleBtData.setDateTime(date_time);

View File

@@ -24,7 +24,7 @@ import android.util.Log;
import com.health.openscale.R;
import com.health.openscale.core.OpenScale;
import com.health.openscale.core.datatypes.ScaleData;
import com.health.openscale.core.datatypes.ScaleMeasurement;
import com.health.openscale.core.datatypes.ScaleUser;
import java.io.ByteArrayOutputStream;
@@ -424,7 +424,7 @@ public class BluetoothSanitasSbf70 extends BluetoothCommunication {
if (current_item % 2 == 0) {
try {
ScaleData parsedData = parseScaleData(receivedScaleData.toByteArray());
ScaleMeasurement parsedData = parseScaleData(receivedScaleData.toByteArray());
addScaleData(parsedData);
} catch (ParseException e) {
Log.d(TAG, "Could not parse byte array: " + byteInHex(receivedScaleData.toByteArray()));
@@ -497,7 +497,7 @@ public class BluetoothSanitasSbf70 extends BluetoothCommunication {
if (current_item == max_items) {
// received all parts
ScaleData parsedData = null;
ScaleMeasurement parsedData = null;
try {
parsedData = parseScaleData(receivedScaleData.toByteArray());
addScaleData(parsedData);
@@ -527,11 +527,11 @@ public class BluetoothSanitasSbf70 extends BluetoothCommunication {
});
}
private ScaleData parseScaleData(byte[] data) throws ParseException {
private ScaleMeasurement parseScaleData(byte[] data) throws ParseException {
if (data.length != 11 + 11)
throw new ParseException("Parse scala data: unexpected length", 0);
ScaleData receivedMeasurement = new ScaleData();
ScaleMeasurement receivedMeasurement = new ScaleMeasurement();
// Parse timestamp
long timestamp = ByteBuffer.wrap(data, 0, 4).getInt() * 1000L;

View File

@@ -23,7 +23,7 @@ import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import com.health.openscale.core.OpenScale;
import com.health.openscale.core.datatypes.ScaleData;
import com.health.openscale.core.datatypes.ScaleMeasurement;
import com.health.openscale.core.datatypes.ScaleUser;
import java.util.Date;
@@ -128,7 +128,7 @@ public class BluetoothYunmaiMini extends BluetoothCommunication {
float weight = (float) (((weightBytes[13] & 0xFF) << 8) | (weightBytes[14] & 0xFF)) / 100.0f;
float fat = (float)(((weightBytes[17] & 0xFF) << 8) | (weightBytes[18] & 0xFF)) / 100.0f;
ScaleData scaleBtData = new ScaleData();
ScaleMeasurement scaleBtData = new ScaleMeasurement();
final ScaleUser selectedUser = OpenScale.getInstance(context).getSelectedScaleUser();

View File

@@ -23,7 +23,7 @@ import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import com.health.openscale.core.OpenScale;
import com.health.openscale.core.datatypes.ScaleData;
import com.health.openscale.core.datatypes.ScaleMeasurement;
import com.health.openscale.core.datatypes.ScaleUser;
import java.util.Date;
@@ -127,7 +127,7 @@ public class BluetoothYunmaiSE extends BluetoothCommunication {
float weight = (float) (((weightBytes[13] & 0xFF) << 8) | (weightBytes[14] & 0xFF)) / 100.0f;
ScaleData scaleBtData = new ScaleData();
ScaleMeasurement scaleBtData = new ScaleMeasurement();
final ScaleUser selectedUser = OpenScale.getInstance(context).getSelectedScaleUser();

View File

@@ -15,7 +15,7 @@
*/
package com.health.openscale.core.bodymetric;
import com.health.openscale.core.datatypes.ScaleData;
import com.health.openscale.core.datatypes.ScaleMeasurement;
import com.health.openscale.core.datatypes.ScaleUser;
public class BFDeurenberg extends EstimatedFatMetric {
@@ -25,7 +25,7 @@ public class BFDeurenberg extends EstimatedFatMetric {
}
@Override
public float getFat(ScaleUser user, ScaleData data) {
public float getFat(ScaleUser user, ScaleMeasurement data) {
if (user.getAge(data.getDateTime()) >= 16) {
return (1.2f * data.getBMI(user.getBodyHeight())) + (0.23f*user.getAge(data.getDateTime())) - (10.8f*(1-user.getGender())) - 5.4f;
}

View File

@@ -15,7 +15,7 @@
*/
package com.health.openscale.core.bodymetric;
import com.health.openscale.core.datatypes.ScaleData;
import com.health.openscale.core.datatypes.ScaleMeasurement;
import com.health.openscale.core.datatypes.ScaleUser;
public class BFDeurenbergII extends EstimatedFatMetric {
@@ -25,7 +25,7 @@ public class BFDeurenbergII extends EstimatedFatMetric {
}
@Override
public float getFat(ScaleUser user, ScaleData data) {
public float getFat(ScaleUser user, ScaleMeasurement data) {
if (user.isMale()) {
return (data.getBMI(user.getBodyHeight()) * 1.2f) + (user.getAge(data.getDateTime()) * 0.23f) - 16.2f;
}

View File

@@ -15,7 +15,7 @@
*/
package com.health.openscale.core.bodymetric;
import com.health.openscale.core.datatypes.ScaleData;
import com.health.openscale.core.datatypes.ScaleMeasurement;
import com.health.openscale.core.datatypes.ScaleUser;
public class BFEddy extends EstimatedFatMetric {
@@ -25,7 +25,7 @@ public class BFEddy extends EstimatedFatMetric {
}
@Override
public float getFat(ScaleUser user, ScaleData data) {
public float getFat(ScaleUser user, ScaleMeasurement data) {
if (user.isMale()) {
return (1.281f* data.getBMI(user.getBodyHeight())) - 10.13f;
}

View File

@@ -15,7 +15,7 @@
*/
package com.health.openscale.core.bodymetric;
import com.health.openscale.core.datatypes.ScaleData;
import com.health.openscale.core.datatypes.ScaleMeasurement;
import com.health.openscale.core.datatypes.ScaleUser;
public class BFGallagher extends EstimatedFatMetric {
@@ -25,7 +25,7 @@ public class BFGallagher extends EstimatedFatMetric {
}
@Override
public float getFat(ScaleUser user, ScaleData data) {
public float getFat(ScaleUser user, ScaleMeasurement data) {
if (user.isMale()) {
// non-asian male
return 64.5f - 848.0f * (1.0f / data.getBMI(user.getBodyHeight())) + 0.079f * user.getAge(data.getDateTime()) - 16.4f + 0.05f * user.getAge(data.getDateTime()) + 39.0f * (1.0f / data.getBMI(user.getBodyHeight()));

View File

@@ -15,7 +15,7 @@
*/
package com.health.openscale.core.bodymetric;
import com.health.openscale.core.datatypes.ScaleData;
import com.health.openscale.core.datatypes.ScaleMeasurement;
import com.health.openscale.core.datatypes.ScaleUser;
public class BFGallagherAsian extends EstimatedFatMetric {
@@ -25,7 +25,7 @@ public class BFGallagherAsian extends EstimatedFatMetric {
}
@Override
public float getFat(ScaleUser user, ScaleData data) {
public float getFat(ScaleUser user, ScaleMeasurement data) {
if (user.isMale()) {
// asian male
return 51.9f - 740.0f * (1.0f / data.getBMI(user.getBodyHeight())) + 0.029f * user.getAge(data.getDateTime());

View File

@@ -15,7 +15,7 @@
*/
package com.health.openscale.core.bodymetric;
import com.health.openscale.core.datatypes.ScaleData;
import com.health.openscale.core.datatypes.ScaleMeasurement;
import com.health.openscale.core.datatypes.ScaleUser;
public abstract class EstimatedFatMetric {
@@ -39,5 +39,5 @@ public abstract class EstimatedFatMetric {
}
public abstract String getName();
public abstract float getFat(ScaleUser user, ScaleData data);
public abstract float getFat(ScaleUser user, ScaleMeasurement data);
}

View File

@@ -15,7 +15,7 @@
*/
package com.health.openscale.core.bodymetric;
import com.health.openscale.core.datatypes.ScaleData;
import com.health.openscale.core.datatypes.ScaleMeasurement;
import com.health.openscale.core.datatypes.ScaleUser;
public abstract class EstimatedLBWMetric {
@@ -33,5 +33,5 @@ public abstract class EstimatedLBWMetric {
}
public abstract String getName();
public abstract float getLBW(ScaleUser user, ScaleData data);
public abstract float getLBW(ScaleUser user, ScaleMeasurement data);
}

View File

@@ -15,7 +15,7 @@
*/
package com.health.openscale.core.bodymetric;
import com.health.openscale.core.datatypes.ScaleData;
import com.health.openscale.core.datatypes.ScaleMeasurement;
import com.health.openscale.core.datatypes.ScaleUser;
public abstract class EstimatedWaterMetric {
@@ -37,5 +37,5 @@ public abstract class EstimatedWaterMetric {
}
public abstract String getName();
public abstract float getWater(ScaleUser user, ScaleData data);
public abstract float getWater(ScaleUser user, ScaleMeasurement data);
}

View File

@@ -16,7 +16,7 @@
package com.health.openscale.core.bodymetric;
import com.health.openscale.core.datatypes.ScaleData;
import com.health.openscale.core.datatypes.ScaleMeasurement;
import com.health.openscale.core.datatypes.ScaleUser;
public class LBWBoer extends EstimatedLBWMetric {
@@ -26,7 +26,7 @@ public class LBWBoer extends EstimatedLBWMetric {
}
@Override
public float getLBW(ScaleUser user, ScaleData data) {
public float getLBW(ScaleUser user, ScaleMeasurement data) {
if (user.isMale()) {
return (0.4071f * data.getWeight()) + (0.267f * user.getBodyHeight()) - 19.2f;
}

View File

@@ -16,7 +16,7 @@
package com.health.openscale.core.bodymetric;
import com.health.openscale.core.datatypes.ScaleData;
import com.health.openscale.core.datatypes.ScaleMeasurement;
import com.health.openscale.core.datatypes.ScaleUser;
public class LBWHume extends EstimatedLBWMetric {
@@ -26,7 +26,7 @@ public class LBWHume extends EstimatedLBWMetric {
}
@Override
public float getLBW(ScaleUser user, ScaleData data) {
public float getLBW(ScaleUser user, ScaleMeasurement data) {
if (user.isMale()) {
return (0.32810f * data.getWeight()) + (0.33929f * user.getBodyHeight()) - 29.5336f;
}

View File

@@ -15,7 +15,7 @@
*/
package com.health.openscale.core.bodymetric;
import com.health.openscale.core.datatypes.ScaleData;
import com.health.openscale.core.datatypes.ScaleMeasurement;
import com.health.openscale.core.datatypes.ScaleUser;
public class TBWBehnke extends EstimatedWaterMetric {
@@ -25,7 +25,7 @@ public class TBWBehnke extends EstimatedWaterMetric {
}
@Override
public float getWater(ScaleUser user, ScaleData data) {
public float getWater(ScaleUser user, ScaleMeasurement data) {
if (user.isMale()) {
return 0.72f * (0.204f * user.getBodyHeight() * user.getBodyHeight()) / 100.0f;
}

View File

@@ -15,7 +15,7 @@
*/
package com.health.openscale.core.bodymetric;
import com.health.openscale.core.datatypes.ScaleData;
import com.health.openscale.core.datatypes.ScaleMeasurement;
import com.health.openscale.core.datatypes.ScaleUser;
public class TBWDelwaideCrenier extends EstimatedWaterMetric {
@@ -25,7 +25,7 @@ public class TBWDelwaideCrenier extends EstimatedWaterMetric {
}
@Override
public float getWater(ScaleUser user, ScaleData data) {
public float getWater(ScaleUser user, ScaleMeasurement data) {
return 0.72f * (-1.976f + 0.907f * data.getWeight());
}
}

View File

@@ -15,7 +15,7 @@
*/
package com.health.openscale.core.bodymetric;
import com.health.openscale.core.datatypes.ScaleData;
import com.health.openscale.core.datatypes.ScaleMeasurement;
import com.health.openscale.core.datatypes.ScaleUser;
public class TBWHumeWeyers extends EstimatedWaterMetric {
@@ -25,7 +25,7 @@ public class TBWHumeWeyers extends EstimatedWaterMetric {
}
@Override
public float getWater(ScaleUser user, ScaleData data) {
public float getWater(ScaleUser user, ScaleMeasurement data) {
if (user.isMale()) {
return (0.194786f * user.getBodyHeight()) + (0.296785f * data.getWeight()) - 14.012934f;
}

View File

@@ -15,7 +15,7 @@
*/
package com.health.openscale.core.bodymetric;
import com.health.openscale.core.datatypes.ScaleData;
import com.health.openscale.core.datatypes.ScaleMeasurement;
import com.health.openscale.core.datatypes.ScaleUser;
public class TBWLeeSongKim extends EstimatedWaterMetric {
@@ -25,7 +25,7 @@ public class TBWLeeSongKim extends EstimatedWaterMetric {
}
@Override
public float getWater(ScaleUser user, ScaleData data) {
public float getWater(ScaleUser user, ScaleMeasurement data) {
if (user.isMale()) {
return -28.3497f + (0.243057f * user.getBodyHeight()) + (0.366248f * data.getWeight());
}

View File

@@ -20,11 +20,11 @@ import android.arch.persistence.room.Database;
import android.arch.persistence.room.RoomDatabase;
import android.arch.persistence.room.TypeConverters;
import com.health.openscale.core.datatypes.ScaleData;
import com.health.openscale.core.datatypes.ScaleMeasurement;
import com.health.openscale.core.datatypes.ScaleUser;
import com.health.openscale.core.utils.Converters;
@Database(entities = {ScaleData.class, ScaleUser.class}, version = 1)
@Database(entities = {ScaleMeasurement.class, ScaleUser.class}, version = 1)
@TypeConverters({Converters.class})
public abstract class AppDatabase extends RoomDatabase {
public abstract ScaleMeasurementDAO measurementDAO();

View File

@@ -24,7 +24,7 @@ import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;
import com.health.openscale.core.datatypes.ScaleData;
import com.health.openscale.core.datatypes.ScaleMeasurement;
import java.text.ParseException;
import java.text.SimpleDateFormat;
@@ -130,11 +130,11 @@ public class ScaleDatabase extends SQLiteOpenHelper {
dbWrite.delete(TABLE_NAME, COLUMN_NAME_USER_ID + "=" + Integer.toString(userId), null);
}
public boolean insertEntry(ScaleData scaleData) {
public boolean insertEntry(ScaleMeasurement scaleMeasurement) {
SQLiteDatabase db = getWritableDatabase();
Cursor cursorScaleDB = db.query(TABLE_NAME, new String[] {COLUMN_NAME_DATE_TIME}, COLUMN_NAME_DATE_TIME + "=? AND " + COLUMN_NAME_USER_ID + "=?",
new String[] {formatDateTime.format(scaleData.getDateTime()), Integer.toString(scaleData.getUserId())}, null, null, null);
new String[] {formatDateTime.format(scaleMeasurement.getDateTime()), Integer.toString(scaleMeasurement.getUserId())}, null, null, null);
// we don't want double entries
if (cursorScaleDB.getCount() > 0) {
@@ -142,17 +142,17 @@ public class ScaleDatabase extends SQLiteOpenHelper {
return false;
} else {
ContentValues values = new ContentValues();
values.put(COLUMN_NAME_USER_ID, scaleData.getUserId());
values.put(COLUMN_NAME_DATE_TIME, formatDateTime.format(scaleData.getDateTime()));
values.put(COLUMN_NAME_WEIGHT, scaleData.getWeight());
values.put(COLUMN_NAME_FAT, scaleData.getFat());
values.put(COLUMN_NAME_WATER, scaleData.getWater());
values.put(COLUMN_NAME_MUSCLE, scaleData.getMuscle());
values.put(COLUMN_NAME_LBW, scaleData.getLbw());
values.put(COLUMN_NAME_BONE, scaleData.getBone());
values.put(COLUMN_NAME_WAIST, scaleData.getWaist());
values.put(COLUMN_NAME_HIP, scaleData.getHip());
values.put(COLUMN_NAME_COMMENT, scaleData.getComment());
values.put(COLUMN_NAME_USER_ID, scaleMeasurement.getUserId());
values.put(COLUMN_NAME_DATE_TIME, formatDateTime.format(scaleMeasurement.getDateTime()));
values.put(COLUMN_NAME_WEIGHT, scaleMeasurement.getWeight());
values.put(COLUMN_NAME_FAT, scaleMeasurement.getFat());
values.put(COLUMN_NAME_WATER, scaleMeasurement.getWater());
values.put(COLUMN_NAME_MUSCLE, scaleMeasurement.getMuscle());
values.put(COLUMN_NAME_LBW, scaleMeasurement.getLbw());
values.put(COLUMN_NAME_BONE, scaleMeasurement.getBone());
values.put(COLUMN_NAME_WAIST, scaleMeasurement.getWaist());
values.put(COLUMN_NAME_HIP, scaleMeasurement.getHip());
values.put(COLUMN_NAME_COMMENT, scaleMeasurement.getComment());
values.put(COLUMN_NAME_ENABLE, 1);
try
@@ -172,29 +172,29 @@ public class ScaleDatabase extends SQLiteOpenHelper {
return true;
}
public void updateEntry(long id, ScaleData scaleData) {
public void updateEntry(long id, ScaleMeasurement scaleMeasurement) {
ContentValues values = new ContentValues();
values.put(COLUMN_NAME_DATE_TIME, formatDateTime.format(scaleData.getDateTime()));
values.put(COLUMN_NAME_WEIGHT, scaleData.getWeight());
values.put(COLUMN_NAME_FAT, scaleData.getFat());
values.put(COLUMN_NAME_WATER, scaleData.getWater());
values.put(COLUMN_NAME_MUSCLE, scaleData.getMuscle());
values.put(COLUMN_NAME_LBW, scaleData.getLbw());
values.put(COLUMN_NAME_BONE, scaleData.getBone());
values.put(COLUMN_NAME_WAIST, scaleData.getWaist());
values.put(COLUMN_NAME_HIP, scaleData.getHip());
values.put(COLUMN_NAME_COMMENT, scaleData.getComment());
values.put(COLUMN_NAME_DATE_TIME, formatDateTime.format(scaleMeasurement.getDateTime()));
values.put(COLUMN_NAME_WEIGHT, scaleMeasurement.getWeight());
values.put(COLUMN_NAME_FAT, scaleMeasurement.getFat());
values.put(COLUMN_NAME_WATER, scaleMeasurement.getWater());
values.put(COLUMN_NAME_MUSCLE, scaleMeasurement.getMuscle());
values.put(COLUMN_NAME_LBW, scaleMeasurement.getLbw());
values.put(COLUMN_NAME_BONE, scaleMeasurement.getBone());
values.put(COLUMN_NAME_WAIST, scaleMeasurement.getWaist());
values.put(COLUMN_NAME_HIP, scaleMeasurement.getHip());
values.put(COLUMN_NAME_COMMENT, scaleMeasurement.getComment());
values.put(COLUMN_NAME_ENABLE, 1);
dbWrite.update(TABLE_NAME, values, COLUMN_NAME_ID + "=" + id, null);
}
public ScaleData[] getTupleDataEntry(int userId, long id)
public ScaleMeasurement[] getTupleDataEntry(int userId, long id)
{
Cursor cursorScaleDB;
ScaleData[] tupleScaleData = new ScaleData[3];
ScaleMeasurement[] tupleScaleData = new ScaleMeasurement[3];
// selected scale data entry
cursorScaleDB = dbRead.query(
@@ -212,7 +212,7 @@ public class ScaleDatabase extends SQLiteOpenHelper {
cursorScaleDB.moveToFirst();
tupleScaleData[1] = readAtCursor(cursorScaleDB);
} else {
tupleScaleData[1] = new ScaleData();
tupleScaleData[1] = new ScaleMeasurement();
}
// previous scale entry
@@ -298,8 +298,8 @@ public class ScaleDatabase extends SQLiteOpenHelper {
return numOfMonth;
}
public ArrayList<ScaleData> getScaleDataOfMonth(int userId, int year, int month) {
ArrayList<ScaleData> scaleDataList = new ArrayList<ScaleData>();
public ArrayList<ScaleMeasurement> getScaleDataOfMonth(int userId, int year, int month) {
ArrayList<ScaleMeasurement> scaleMeasurementList = new ArrayList<ScaleMeasurement>();
String sortOrder = COLUMN_NAME_DATE_TIME + " DESC";
@@ -323,18 +323,18 @@ public class ScaleDatabase extends SQLiteOpenHelper {
cursorScaleDB.moveToFirst();
while (!cursorScaleDB.isAfterLast()) {
scaleDataList.add(readAtCursor(cursorScaleDB));
scaleMeasurementList.add(readAtCursor(cursorScaleDB));
cursorScaleDB.moveToNext();
}
cursorScaleDB.close();
return scaleDataList;
return scaleMeasurementList;
}
public ArrayList<ScaleData> getScaleDataOfYear(int userId, int year) {
ArrayList<ScaleData> scaleDataList = new ArrayList<ScaleData>();
public ArrayList<ScaleMeasurement> getScaleDataOfYear(int userId, int year) {
ArrayList<ScaleMeasurement> scaleMeasurementList = new ArrayList<ScaleMeasurement>();
String sortOrder = COLUMN_NAME_DATE_TIME + " DESC";
@@ -357,18 +357,18 @@ public class ScaleDatabase extends SQLiteOpenHelper {
cursorScaleDB.moveToFirst();
while (!cursorScaleDB.isAfterLast()) {
scaleDataList.add(readAtCursor(cursorScaleDB));
scaleMeasurementList.add(readAtCursor(cursorScaleDB));
cursorScaleDB.moveToNext();
}
cursorScaleDB.close();
return scaleDataList;
return scaleMeasurementList;
}
public ArrayList<ScaleData> getScaleDataList(int userId) {
ArrayList<ScaleData> scaleDataList = new ArrayList<ScaleData>();
public ArrayList<ScaleMeasurement> getScaleDataList(int userId) {
ArrayList<ScaleMeasurement> scaleMeasurementList = new ArrayList<ScaleMeasurement>();
try {
String sortOrder = COLUMN_NAME_DATE_TIME + " DESC";
@@ -386,7 +386,7 @@ public class ScaleDatabase extends SQLiteOpenHelper {
cursorScaleDB.moveToFirst();
while (!cursorScaleDB.isAfterLast()) {
scaleDataList.add(readAtCursor(cursorScaleDB));
scaleMeasurementList.add(readAtCursor(cursorScaleDB));
cursorScaleDB.moveToNext();
}
@@ -396,28 +396,28 @@ public class ScaleDatabase extends SQLiteOpenHelper {
Log.e("ScaleDatabase", "SQL exception occured while getting scale data list: " + ex.getMessage());
}
return scaleDataList;
return scaleMeasurementList;
}
private ScaleData readAtCursor (Cursor cur) {
ScaleData scaleData = new ScaleData();
private ScaleMeasurement readAtCursor (Cursor cur) {
ScaleMeasurement scaleMeasurement = new ScaleMeasurement();
try {
scaleData.setId(cur.getInt(cur.getColumnIndexOrThrow(COLUMN_NAME_ID)));
scaleData.setUserId(cur.getInt(cur.getColumnIndexOrThrow(COLUMN_NAME_USER_ID)));
scaleMeasurement.setId(cur.getInt(cur.getColumnIndexOrThrow(COLUMN_NAME_ID)));
scaleMeasurement.setUserId(cur.getInt(cur.getColumnIndexOrThrow(COLUMN_NAME_USER_ID)));
String date_time = cur.getString(cur.getColumnIndexOrThrow(COLUMN_NAME_DATE_TIME));
scaleData.setWeight(cur.getFloat(cur.getColumnIndexOrThrow(COLUMN_NAME_WEIGHT)));
scaleData.setFat(cur.getFloat(cur.getColumnIndexOrThrow(COLUMN_NAME_FAT)));
scaleData.setWater(cur.getFloat(cur.getColumnIndexOrThrow(COLUMN_NAME_WATER)));
scaleData.setMuscle(cur.getFloat(cur.getColumnIndexOrThrow(COLUMN_NAME_MUSCLE)));
scaleData.setLbw(cur.getFloat(cur.getColumnIndexOrThrow(COLUMN_NAME_LBW)));
scaleData.setBone(cur.getFloat(cur.getColumnIndexOrThrow(COLUMN_NAME_BONE)));
scaleData.setWaist(cur.getFloat(cur.getColumnIndexOrThrow(COLUMN_NAME_WAIST)));
scaleData.setHip(cur.getFloat(cur.getColumnIndexOrThrow(COLUMN_NAME_HIP)));
scaleData.setComment(cur.getString(cur.getColumnIndexOrThrow(COLUMN_NAME_COMMENT)));
scaleMeasurement.setWeight(cur.getFloat(cur.getColumnIndexOrThrow(COLUMN_NAME_WEIGHT)));
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.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)));
scaleMeasurement.setComment(cur.getString(cur.getColumnIndexOrThrow(COLUMN_NAME_COMMENT)));
scaleData.setDateTime(formatDateTime.parse(date_time));
scaleMeasurement.setDateTime(formatDateTime.parse(date_time));
} catch (ParseException ex) {
Log.e("ScaleDatabase", "Can't parse the date time string: " + ex.getMessage());
}
@@ -425,6 +425,6 @@ public class ScaleDatabase extends SQLiteOpenHelper {
Log.e("ScaleDatabase", "Illegal argument while reading from scale database: " + ex.getMessage());
}
return scaleData;
return scaleMeasurement;
}
}

View File

@@ -21,43 +21,43 @@ import android.arch.persistence.room.Insert;
import android.arch.persistence.room.Query;
import android.arch.persistence.room.Update;
import com.health.openscale.core.datatypes.ScaleData;
import com.health.openscale.core.datatypes.ScaleMeasurement;
import java.util.Date;
import java.util.List;
@Dao
public interface ScaleMeasurementDAO {
@Query("SELECT * FROM scaledata WHERE datetime = :datetime AND userId = :userId AND enabled = 1")
ScaleData get(Date datetime, int userId);
@Query("SELECT * FROM scaleMeasurements WHERE datetime = :datetime AND userId = :userId AND enabled = 1")
ScaleMeasurement get(Date datetime, int userId);
@Query("SELECT * FROM scaledata WHERE id = :id AND enabled = 1")
ScaleData get(int id);
@Query("SELECT * FROM scaleMeasurements WHERE id = :id AND enabled = 1")
ScaleMeasurement get(int id);
@Query("SELECT * FROM scaledata WHERE datetime < (SELECT datetime FROM scaledata WHERE id = :id) AND userId = :userId AND enabled = 1 ORDER BY datetime DESC LIMIT 0,1")
ScaleData getPrevious(int id, int userId);
@Query("SELECT * FROM scaleMeasurements WHERE datetime < (SELECT datetime FROM scaleMeasurements WHERE id = :id) AND userId = :userId AND enabled = 1 ORDER BY datetime DESC LIMIT 0,1")
ScaleMeasurement getPrevious(int id, int userId);
@Query("SELECT * FROM scaledata WHERE datetime > (SELECT datetime FROM scaledata WHERE id = :id) AND userId = :userId AND enabled = 1 LIMIT 0,1")
ScaleData getNext(int id, int userId);
@Query("SELECT * FROM scaleMeasurements WHERE datetime > (SELECT datetime FROM scaleMeasurements WHERE id = :id) AND userId = :userId AND enabled = 1 LIMIT 0,1")
ScaleMeasurement getNext(int id, int userId);
@Query("SELECT * FROM scaledata WHERE userId = :userId AND enabled = 1 ORDER BY datetime DESC")
List<ScaleData> getAll(int userId);
@Query("SELECT * FROM scaleMeasurements WHERE userId = :userId AND enabled = 1 ORDER BY datetime DESC")
List<ScaleMeasurement> getAll(int userId);
@Query("SELECT * FROM scaledata WHERE datetime >= :startYear AND datetime < :endYear AND userId = :userId AND enabled = 1 ORDER BY datetime DESC")
List<ScaleData> getAllInRange(Date startYear, Date endYear, int userId);
@Query("SELECT * FROM scaleMeasurements WHERE datetime >= :startYear AND datetime < :endYear AND userId = :userId AND enabled = 1 ORDER BY datetime DESC")
List<ScaleMeasurement> getAllInRange(Date startYear, Date endYear, int userId);
@Insert
void insert(ScaleData measurement);
void insert(ScaleMeasurement measurement);
@Insert
void insertAll(List<ScaleData> measurementList);
void insertAll(List<ScaleMeasurement> measurementList);
@Update
void update(ScaleData measurement);
void update(ScaleMeasurement measurement);
@Query("UPDATE scaledata SET enabled = 0 WHERE id = :id")
@Query("UPDATE scaleMeasurements SET enabled = 0 WHERE id = :id")
void delete(int id);
@Query("DELETE FROM scaledata WHERE userId = :userId")
@Query("DELETE FROM scaleMeasurements WHERE userId = :userId")
void deleteAll(int userId);
}

View File

@@ -28,10 +28,10 @@ import java.util.List;
@Dao
public interface ScaleUserDAO {
@Query("SELECT * FROM scaleuser")
@Query("SELECT * FROM scaleUsers")
List<ScaleUser> getAll();
@Query("SELECT * FROM scaleuser WHERE id = :id")
@Query("SELECT * FROM scaleUsers WHERE id = :id")
ScaleUser get(int id);
@Insert

View File

@@ -22,8 +22,8 @@ import android.arch.persistence.room.PrimaryKey;
import java.util.Date;
@Entity
public class ScaleData {
@Entity(tableName = "scaleMeasurements")
public class ScaleMeasurement {
private static float KG_LB = 2.20462f;
private static float KG_ST = 0.157473f;
@@ -55,7 +55,7 @@ public class ScaleData {
@ColumnInfo(name = "comment")
private String comment;
public ScaleData()
public ScaleMeasurement()
{
userId = -1;
enabled = true;

View File

@@ -23,7 +23,7 @@ import android.arch.persistence.room.PrimaryKey;
import java.util.Calendar;
import java.util.Date;
@Entity
@Entity(tableName = "scaleUsers")
public class ScaleUser {
public static final String[] UNIT_STRING = new String[] {"kg", "lb", "st"};
private static float KG_LB = 2.20462f;

View File

@@ -44,7 +44,7 @@ import android.widget.Toast;
import com.health.openscale.R;
import com.health.openscale.core.OpenScale;
import com.health.openscale.core.bluetooth.BluetoothCommunication;
import com.health.openscale.core.datatypes.ScaleData;
import com.health.openscale.core.datatypes.ScaleMeasurement;
import com.health.openscale.gui.activities.SettingsActivity;
import com.health.openscale.gui.activities.UserSettingsActivity;
import com.health.openscale.gui.fragments.GraphFragment;
@@ -274,7 +274,7 @@ public class MainActivity extends AppCompatActivity {
switch (btStatusCode) {
case BT_RETRIEVE_SCALE_DATA:
setBluetoothStatusIcon(R.drawable.ic_bluetooth_connection_success);
ScaleData scaleBtData = (ScaleData) msg.obj;
ScaleMeasurement scaleBtData = (ScaleMeasurement) msg.obj;
scaleBtData.setConvertedWeight(scaleBtData.getWeight(), OpenScale.getInstance(getApplicationContext()).getSelectedScaleUser().getScaleUnit());

View File

@@ -33,7 +33,7 @@ import android.widget.Toast;
import com.health.openscale.R;
import com.health.openscale.core.OpenScale;
import com.health.openscale.core.datatypes.ScaleData;
import com.health.openscale.core.datatypes.ScaleMeasurement;
import com.health.openscale.core.datatypes.ScaleUser;
import com.health.openscale.gui.views.BMIMeasurementView;
import com.health.openscale.gui.views.BMRMeasurementView;
@@ -181,7 +181,7 @@ public class DataEntryActivity extends Activity {
id = getIntent().getExtras().getInt("id");
}
ScaleData scaleData;
ScaleMeasurement scaleMeasurement;
if (id > 0) {
// keep edit mode state if we are moving to left or right
@@ -202,41 +202,41 @@ public class DataEntryActivity extends Activity {
OpenScale openScale = OpenScale.getInstance(context);
ScaleData[] tupleScaleData = openScale.getTupleScaleData(id);
ScaleData prevScaleData = tupleScaleData[0];
scaleData = tupleScaleData[1];
ScaleMeasurement[] tupleScaleData = openScale.getTupleScaleData(id);
ScaleMeasurement prevScaleMeasurement = tupleScaleData[0];
scaleMeasurement = tupleScaleData[1];
if (prevScaleData == null) {
prevScaleData = new ScaleData();
if (prevScaleMeasurement == null) {
prevScaleMeasurement = new ScaleMeasurement();
}
// show selected scale data
for (MeasurementView measurement : dataEntryMeasurements) {
measurement.updateValue(scaleData);
measurement.updateDiff(scaleData, prevScaleData);
measurement.updateValue(scaleMeasurement);
measurement.updateDiff(scaleMeasurement, prevScaleMeasurement);
measurement.setExpand(doExpand);
}
} else {
setViewMode(MeasurementView.MeasurementViewMode.ADD);
if (OpenScale.getInstance(getApplicationContext()).getScaleDataList().isEmpty()) {
if (OpenScale.getInstance(getApplicationContext()).getScaleMeasurementList().isEmpty()) {
// Show default values
scaleData = new ScaleData();
scaleMeasurement = new ScaleMeasurement();
}
else {
// Show the last scale data as default
scaleData = OpenScale.getInstance(getApplicationContext()).getScaleDataList().get(0);
scaleData.setDateTime(new Date());
scaleData.setComment("");
scaleMeasurement = OpenScale.getInstance(getApplicationContext()).getScaleMeasurementList().get(0);
scaleMeasurement.setDateTime(new Date());
scaleMeasurement.setComment("");
}
for (MeasurementView measurement : dataEntryMeasurements) {
measurement.updateValue(scaleData);
measurement.updateValue(scaleMeasurement);
}
}
txtDataNr.setText(DateFormat.getDateTimeInstance(
DateFormat.LONG, DateFormat.SHORT).format(scaleData.getDateTime()));
DateFormat.LONG, DateFormat.SHORT).format(scaleMeasurement.getDateTime()));
onMeasurementViewUpdateListener updateListener = new onMeasurementViewUpdateListener();
for (MeasurementView measurement : dataEntryMeasurements) {
@@ -287,7 +287,7 @@ public class DataEntryActivity extends Activity {
}
}
private ScaleData createScaleDataFromMeasurement() {
private ScaleMeasurement createScaleDataFromMeasurement() {
OpenScale openScale = OpenScale.getInstance(getApplicationContext());
ScaleUser user = openScale.getSelectedScaleUser();
@@ -300,39 +300,39 @@ public class DataEntryActivity extends Activity {
cal.set(Calendar.MINUTE, time.get(Calendar.MINUTE));
cal.set(Calendar.SECOND, time.get(Calendar.SECOND));
ScaleData scaleData = new ScaleData();
ScaleMeasurement scaleMeasurement = new ScaleMeasurement();
scaleData.setUserId(user.getId());
scaleData.setDateTime(cal.getTime());
scaleData.setConvertedWeight(weightMeasurement.getValue(), user.getScaleUnit());
scaleData.setFat(fatMeasurement.getValue());
scaleData.setWater(waterMeasurement.getValue());
scaleData.setMuscle(muscleMeasurement.getValue());
scaleData.setLbw(lbwMeasurement.getValue());
scaleData.setWaist(waistMeasurement.getValue());
scaleData.setHip(hipMeasurement.getValue());
scaleData.setBone(boneMeasurementView.getValue());
scaleData.setComment(commentMeasurement.getValueAsString());
scaleMeasurement.setUserId(user.getId());
scaleMeasurement.setDateTime(cal.getTime());
scaleMeasurement.setConvertedWeight(weightMeasurement.getValue(), user.getScaleUnit());
scaleMeasurement.setFat(fatMeasurement.getValue());
scaleMeasurement.setWater(waterMeasurement.getValue());
scaleMeasurement.setMuscle(muscleMeasurement.getValue());
scaleMeasurement.setLbw(lbwMeasurement.getValue());
scaleMeasurement.setWaist(waistMeasurement.getValue());
scaleMeasurement.setHip(hipMeasurement.getValue());
scaleMeasurement.setBone(boneMeasurementView.getValue());
scaleMeasurement.setComment(commentMeasurement.getValueAsString());
return scaleData;
return scaleMeasurement;
}
private void saveScaleData() {
ScaleData scaleData = createScaleDataFromMeasurement();
ScaleMeasurement scaleMeasurement = createScaleDataFromMeasurement();
scaleData.setId(id);
scaleMeasurement.setId(id);
OpenScale openScale = OpenScale.getInstance(getApplicationContext());
openScale.updateScaleData(scaleData);
openScale.updateScaleData(scaleMeasurement);
}
private boolean moveLeft() {
ScaleData[] tupleScaleData = OpenScale.getInstance(getApplicationContext()).getTupleScaleData(id);
ScaleData prevScaleData = tupleScaleData[0];
ScaleMeasurement[] tupleScaleData = OpenScale.getInstance(getApplicationContext()).getTupleScaleData(id);
ScaleMeasurement prevScaleMeasurement = tupleScaleData[0];
if (prevScaleData != null) {
if (prevScaleMeasurement != null) {
saveScaleData();
getIntent().putExtra("id", prevScaleData.getId());
getIntent().putExtra("id", prevScaleMeasurement.getId());
updateOnView();
return true;
}
@@ -342,12 +342,12 @@ public class DataEntryActivity extends Activity {
private boolean moveRight()
{
ScaleData[] tupleScaleData = OpenScale.getInstance(getApplicationContext()).getTupleScaleData(id);
ScaleData nextScaleData = tupleScaleData[2];
ScaleMeasurement[] tupleScaleData = OpenScale.getInstance(getApplicationContext()).getTupleScaleData(id);
ScaleMeasurement nextScaleMeasurement = tupleScaleData[2];
if (nextScaleData != null) {
if (nextScaleMeasurement != null) {
saveScaleData();
getIntent().putExtra("id", nextScaleData.getId());
getIntent().putExtra("id", nextScaleMeasurement.getId());
updateOnView();
return true;
}
@@ -372,9 +372,9 @@ public class DataEntryActivity extends Activity {
}
if (!viewsToUpdate.isEmpty()) {
ScaleData scaleData = createScaleDataFromMeasurement();
ScaleMeasurement scaleMeasurement = createScaleDataFromMeasurement();
for (MeasurementView measurement : viewsToUpdate) {
measurement.updateValue(scaleData);
measurement.updateValue(scaleMeasurement);
}
}
}
@@ -395,10 +395,10 @@ public class DataEntryActivity extends Activity {
infoDialog.show();
} else {
ScaleData scaleData = createScaleDataFromMeasurement();
ScaleMeasurement scaleMeasurement = createScaleDataFromMeasurement();
OpenScale openScale = OpenScale.getInstance(getApplicationContext());
openScale.addScaleData(scaleData);
openScale.addScaleData(scaleMeasurement);
finish();
}

View File

@@ -16,10 +16,10 @@
package com.health.openscale.gui.fragments;
import com.health.openscale.core.datatypes.ScaleData;
import com.health.openscale.core.datatypes.ScaleMeasurement;
import java.util.List;
public interface FragmentUpdateListener {
public void updateOnView(List<ScaleData> scaleDataList);
public void updateOnView(List<ScaleMeasurement> scaleMeasurementList);
}

View File

@@ -35,7 +35,7 @@ import android.widget.TextView;
import com.health.openscale.R;
import com.health.openscale.core.OpenScale;
import com.health.openscale.core.datatypes.ScaleData;
import com.health.openscale.core.datatypes.ScaleMeasurement;
import com.health.openscale.core.utils.PolynomialFitter;
import com.health.openscale.gui.activities.DataEntryActivity;
@@ -85,8 +85,8 @@ public class GraphFragment extends Fragment implements FragmentUpdateListener {
private Calendar calYears;
private Calendar calLastSelected;
private List<ScaleData> scaleDataList;
private List<ScaleData> pointIndexScaleDataList;
private List<ScaleMeasurement> scaleMeasurementList;
private List<ScaleMeasurement> pointIndexScaleMeasurementList;
public GraphFragment() {
calYears = Calendar.getInstance();
@@ -186,7 +186,7 @@ public class GraphFragment extends Fragment implements FragmentUpdateListener {
}
@Override
public void updateOnView(List<ScaleData> scaleDataList)
public void updateOnView(List<ScaleMeasurement> scaleMeasurementList)
{
generateGraphs();
}
@@ -256,13 +256,13 @@ public class GraphFragment extends Fragment implements FragmentUpdateListener {
Calendar calDB = Calendar.getInstance();
pointIndexScaleDataList = new ArrayList<>();
pointIndexScaleMeasurementList = new ArrayList<>();
for (ScaleData scaleEntry: scaleDataList) {
for (ScaleMeasurement scaleEntry: scaleMeasurementList) {
calDB.setTime(scaleEntry.getDateTime());
if (addPointValue(valuesWeight, calDB.get(field), scaleEntry.getConvertedWeight(openScale.getSelectedScaleUser().getScaleUnit()))) {
pointIndexScaleDataList.add(scaleEntry); // if new point was added, add this point to pointIndexScaleDataList to get the correct point index after selecting an point
pointIndexScaleMeasurementList.add(scaleEntry); // if new point was added, add this point to pointIndexScaleDataList to get the correct point index after selecting an point
}
addPointValue(valuesFat, calDB.get(field), scaleEntry.getFat());
@@ -482,7 +482,7 @@ public class GraphFragment extends Fragment implements FragmentUpdateListener {
chartBottom.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 0, 0.7f));
generateColumnData();
scaleDataList = openScale.getScaleDataOfMonth(calYears.get(Calendar.YEAR), calLastSelected.get(Calendar.MONTH));
scaleMeasurementList = openScale.getScaleDataOfMonth(calYears.get(Calendar.YEAR), calLastSelected.get(Calendar.MONTH));
generateLineData(Calendar.DAY_OF_MONTH);
// show only yearly diagram and hide monthly diagram
@@ -490,7 +490,7 @@ public class GraphFragment extends Fragment implements FragmentUpdateListener {
chartTop.setVisibility(View.GONE);
chartBottom.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));
scaleDataList = openScale.getScaleDataOfYear(calYears.get(Calendar.YEAR));
scaleMeasurementList = openScale.getScaleDataOfYear(calYears.get(Calendar.YEAR));
generateLineData(Calendar.DAY_OF_YEAR);
}
@@ -505,7 +505,7 @@ public class GraphFragment extends Fragment implements FragmentUpdateListener {
calLastSelected = cal;
scaleDataList = openScale.getScaleDataOfMonth(calYears.get(Calendar.YEAR), calLastSelected.get(Calendar.MONTH));
scaleMeasurementList = openScale.getScaleDataOfMonth(calYears.get(Calendar.YEAR), calLastSelected.get(Calendar.MONTH));
generateLineData(Calendar.DAY_OF_MONTH);
}
@@ -531,9 +531,9 @@ public class GraphFragment extends Fragment implements FragmentUpdateListener {
private class chartBottomValueTouchListener implements LineChartOnValueSelectListener {
@Override
public void onValueSelected(int lineIndex, int pointIndex, PointValue pointValue) {
ScaleData scaleData = pointIndexScaleDataList.get(pointIndex);
ScaleMeasurement scaleMeasurement = pointIndexScaleMeasurementList.get(pointIndex);
int id = scaleData.getId();
int id = scaleMeasurement.getId();
Intent intent = new Intent(graphView.getContext(), DataEntryActivity.class);
intent.putExtra("id", id);

View File

@@ -35,7 +35,7 @@ import android.widget.Toast;
import com.health.openscale.R;
import com.health.openscale.core.OpenScale;
import com.health.openscale.core.datatypes.ScaleData;
import com.health.openscale.core.datatypes.ScaleMeasurement;
import com.health.openscale.core.datatypes.ScaleUser;
import com.health.openscale.core.utils.DateTimeHelpers;
import com.health.openscale.gui.activities.DataEntryActivity;
@@ -91,11 +91,11 @@ public class OverviewFragment extends Fragment implements FragmentUpdateListener
private SharedPreferences prefs;
private ScaleData lastScaleData;
private ScaleData userSelectedData;
private ScaleMeasurement lastScaleMeasurement;
private ScaleMeasurement userSelectedData;
private ScaleUser currentScaleUser;
private List<ScaleData> scaleDataLastDays;
private List<ScaleMeasurement> scaleMeasurementLastDays;
private ArrayAdapter<String> spinUserAdapter;
@@ -174,14 +174,14 @@ public class OverviewFragment extends Fragment implements FragmentUpdateListener
}
@Override
public void updateOnView(List<ScaleData> scaleDataList) {
if (scaleDataList.isEmpty()) {
lastScaleData = new ScaleData();
public void updateOnView(List<ScaleMeasurement> scaleMeasurementList) {
if (scaleMeasurementList.isEmpty()) {
lastScaleMeasurement = new ScaleMeasurement();
} else if (userSelectedData != null) {
lastScaleData = userSelectedData;
lastScaleMeasurement = userSelectedData;
}
else {
lastScaleData = scaleDataList.get(0);
lastScaleMeasurement = scaleMeasurementList.get(0);
}
@@ -192,19 +192,19 @@ public class OverviewFragment extends Fragment implements FragmentUpdateListener
updateUserSelection();
updateLastPieChart();
updateLastLineChart(scaleDataList);
updateLastLineChart(scaleMeasurementList);
ScaleData[] tupleScaleData = OpenScale.getInstance(context).getTupleScaleData(lastScaleData.getId());
ScaleData prevScaleData = tupleScaleData[0];
ScaleMeasurement[] tupleScaleData = OpenScale.getInstance(context).getTupleScaleData(lastScaleMeasurement.getId());
ScaleMeasurement prevScaleMeasurement = tupleScaleData[0];
if (prevScaleData == null) {
prevScaleData = new ScaleData();
if (prevScaleMeasurement == null) {
prevScaleMeasurement = new ScaleMeasurement();
}
for (MeasurementView measurement : overviewMeasurements) {
measurement.updatePreferences(prefs);
measurement.updateValue(lastScaleData);
measurement.updateDiff(lastScaleData, prevScaleData);
measurement.updateValue(lastScaleMeasurement);
measurement.updateDiff(lastScaleMeasurement, prevScaleMeasurement);
}
}
@@ -237,7 +237,7 @@ public class OverviewFragment extends Fragment implements FragmentUpdateListener
}
private void updateLastLineChart(List<ScaleData> scaleDataList) {
private void updateLastLineChart(List<ScaleMeasurement> scaleMeasurementList) {
List<AxisValue> axisValues = new ArrayList<AxisValue>();
List<PointValue> valuesWeight = new ArrayList<PointValue>();
@@ -252,19 +252,19 @@ public class OverviewFragment extends Fragment implements FragmentUpdateListener
int max_i = 7;
if (scaleDataList.size() < 7) {
max_i = scaleDataList.size();
if (scaleMeasurementList.size() < 7) {
max_i = scaleMeasurementList.size();
}
final Calendar now = Calendar.getInstance();
Calendar histCalendar = Calendar.getInstance();
scaleDataLastDays = new ArrayList<ScaleData>();
scaleMeasurementLastDays = new ArrayList<ScaleMeasurement>();
for (int i=0; i<max_i; i++) {
ScaleData histData = scaleDataList.get(max_i - i - 1);
ScaleMeasurement histData = scaleMeasurementList.get(max_i - i - 1);
scaleDataLastDays.add(histData);
scaleMeasurementLastDays.add(histData);
valuesWeight.add(new PointValue(i, histData.getConvertedWeight(currentScaleUser.getScaleUnit())));
if (histData.getFat() != 0.0f)
@@ -383,32 +383,32 @@ public class OverviewFragment extends Fragment implements FragmentUpdateListener
List<SliceValue> arcValuesLast = new ArrayList<SliceValue>();
if (lastScaleData.getFat() == 0) {
if (lastScaleMeasurement.getFat() == 0) {
arcValuesLast.add(new SliceValue(1, ChartUtils.COLOR_ORANGE));
}
else {
arcValuesLast.add(new SliceValue(lastScaleData.getFat(), ChartUtils.COLOR_ORANGE));
arcValuesLast.add(new SliceValue(lastScaleMeasurement.getFat(), ChartUtils.COLOR_ORANGE));
}
if (lastScaleData.getWater() == 0) {
if (lastScaleMeasurement.getWater() == 0) {
arcValuesLast.add(new SliceValue(1, ChartUtils.COLOR_BLUE));
}
else {
arcValuesLast.add(new SliceValue(lastScaleData.getWater(), ChartUtils.COLOR_BLUE));
arcValuesLast.add(new SliceValue(lastScaleMeasurement.getWater(), ChartUtils.COLOR_BLUE));
}
if (lastScaleData.getMuscle() == 0) {
if (lastScaleMeasurement.getMuscle() == 0) {
arcValuesLast.add(new SliceValue(1, ChartUtils.COLOR_GREEN));
}
else {
arcValuesLast.add(new SliceValue(lastScaleData.getMuscle(), ChartUtils.COLOR_GREEN));
arcValuesLast.add(new SliceValue(lastScaleMeasurement.getMuscle(), ChartUtils.COLOR_GREEN));
}
PieChartData pieChartData = new PieChartData(arcValuesLast);
pieChartData.setHasLabels(false);
pieChartData.setHasCenterCircle(true);
pieChartData.setCenterText1(String.format("%.2f %s", lastScaleData.getConvertedWeight(currentScaleUser.getScaleUnit()), ScaleUser.UNIT_STRING[currentScaleUser.getScaleUnit()]));
pieChartData.setCenterText2(DateFormat.getDateInstance(DateFormat.MEDIUM).format(lastScaleData.getDateTime()));
pieChartData.setCenterText1(String.format("%.2f %s", lastScaleMeasurement.getConvertedWeight(currentScaleUser.getScaleUnit()), ScaleUser.UNIT_STRING[currentScaleUser.getScaleUnit()]));
pieChartData.setCenterText2(DateFormat.getDateInstance(DateFormat.MEDIUM).format(lastScaleMeasurement.getDateTime()));
if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE ||
@@ -434,21 +434,21 @@ public class OverviewFragment extends Fragment implements FragmentUpdateListener
{
@Override
public void onValueSelected(int i, SliceValue arcValue) {
if (lastScaleData == null) {
if (lastScaleMeasurement == null) {
return;
}
String date_time = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.SHORT).format(lastScaleData.getDateTime());
String date_time = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.SHORT).format(lastScaleMeasurement.getDateTime());
switch (i) {
case 0:
Toast.makeText(getActivity(), getResources().getString(R.string.info_your_fat) + " " + lastScaleData.getFat() + "% " + getResources().getString(R.string.info_on_date) + " " + date_time, Toast.LENGTH_SHORT).show();
Toast.makeText(getActivity(), getResources().getString(R.string.info_your_fat) + " " + lastScaleMeasurement.getFat() + "% " + getResources().getString(R.string.info_on_date) + " " + date_time, Toast.LENGTH_SHORT).show();
break;
case 1:
Toast.makeText(getActivity(), getResources().getString(R.string.info_your_water) + " " + lastScaleData.getWater() + "% " + getResources().getString(R.string.info_on_date) + " " + date_time, Toast.LENGTH_SHORT).show();
Toast.makeText(getActivity(), getResources().getString(R.string.info_your_water) + " " + lastScaleMeasurement.getWater() + "% " + getResources().getString(R.string.info_on_date) + " " + date_time, Toast.LENGTH_SHORT).show();
break;
case 2:
Toast.makeText(getActivity(), getResources().getString(R.string.info_your_muscle) + " " + lastScaleData.getMuscle() + "% " + getResources().getString(R.string.info_on_date) + " " + date_time, Toast.LENGTH_SHORT).show();
Toast.makeText(getActivity(), getResources().getString(R.string.info_your_muscle) + " " + lastScaleMeasurement.getMuscle() + "% " + getResources().getString(R.string.info_on_date) + " " + date_time, Toast.LENGTH_SHORT).show();
break;
}
}
@@ -462,9 +462,9 @@ public class OverviewFragment extends Fragment implements FragmentUpdateListener
private class LineChartTouchListener implements LineChartOnValueSelectListener {
@Override
public void onValueSelected(int lineIndex, int pointIndex, PointValue pointValue) {
userSelectedData = scaleDataLastDays.get(pointIndex);
userSelectedData = scaleMeasurementLastDays.get(pointIndex);
updateOnView(OpenScale.getInstance(getContext()).getScaleDataList());
updateOnView(OpenScale.getInstance(getContext()).getScaleMeasurementList());
}
@Override

View File

@@ -28,7 +28,7 @@ import android.widget.TextView;
import com.health.openscale.R;
import com.health.openscale.core.OpenScale;
import com.health.openscale.core.datatypes.ScaleData;
import com.health.openscale.core.datatypes.ScaleMeasurement;
import com.health.openscale.core.datatypes.ScaleUser;
import com.health.openscale.core.utils.DateTimeHelpers;
@@ -59,7 +59,7 @@ public class StatisticsFragment extends Fragment implements FragmentUpdateListen
private SharedPreferences prefs;
private ScaleUser currentScaleUser;
private ScaleData lastScaleData;
private ScaleMeasurement lastScaleMeasurement;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
@@ -88,11 +88,11 @@ public class StatisticsFragment extends Fragment implements FragmentUpdateListen
}
@Override
public void updateOnView(List<ScaleData> scaleDataList) {
if (scaleDataList.isEmpty()) {
lastScaleData = new ScaleData();
public void updateOnView(List<ScaleMeasurement> scaleMeasurementList) {
if (scaleMeasurementList.isEmpty()) {
lastScaleMeasurement = new ScaleMeasurement();
} else {
lastScaleData = scaleDataList.get(0);
lastScaleMeasurement = scaleMeasurementList.get(0);
}
txtTitleGoal.setText(getResources().getString(R.string.label_title_goal).toUpperCase());
@@ -101,17 +101,17 @@ public class StatisticsFragment extends Fragment implements FragmentUpdateListen
prefs = PreferenceManager.getDefaultSharedPreferences(statisticsView.getContext());
currentScaleUser = OpenScale.getInstance(getContext()).getSelectedScaleUser();
updateStatistics(scaleDataList);
updateGoal(scaleDataList);
updateStatistics(scaleMeasurementList);
updateGoal(scaleMeasurementList);
}
private void updateGoal(List<ScaleData> scaleDataList) {
ScaleData goalScaleData = new ScaleData();
goalScaleData.setConvertedWeight(currentScaleUser.getGoalWeight(), currentScaleUser.getScaleUnit());
private void updateGoal(List<ScaleMeasurement> scaleMeasurementList) {
ScaleMeasurement goalScaleMeasurement = new ScaleMeasurement();
goalScaleMeasurement.setConvertedWeight(currentScaleUser.getGoalWeight(), currentScaleUser.getScaleUnit());
txtGoalWeight.setText(goalScaleData.getConvertedWeight(currentScaleUser.getScaleUnit()) + " " + ScaleUser.UNIT_STRING[currentScaleUser.getScaleUnit()]);
txtGoalWeight.setText(goalScaleMeasurement.getConvertedWeight(currentScaleUser.getScaleUnit()) + " " + ScaleUser.UNIT_STRING[currentScaleUser.getScaleUnit()]);
double weight_diff = goalScaleData.getConvertedWeight(currentScaleUser.getScaleUnit()) - lastScaleData.getConvertedWeight(currentScaleUser.getScaleUnit());
double weight_diff = goalScaleMeasurement.getConvertedWeight(currentScaleUser.getScaleUnit()) - lastScaleMeasurement.getConvertedWeight(currentScaleUser.getScaleUnit());
txtGoalDiff.setText(String.format("%.1f " + ScaleUser.UNIT_STRING[currentScaleUser.getScaleUnit()], weight_diff));
Calendar goalCalendar = Calendar.getInstance();
@@ -119,9 +119,9 @@ public class StatisticsFragment extends Fragment implements FragmentUpdateListen
int days = Math.max(0, DateTimeHelpers.daysBetween(Calendar.getInstance(), goalCalendar));
txtGoalDayLeft.setText(getResources().getQuantityString(R.plurals.label_days, days, days));
lastScaleData.setUserId(currentScaleUser.getId());
lastScaleMeasurement.setUserId(currentScaleUser.getId());
ScaleData goalData = new ScaleData();
ScaleMeasurement goalData = new ScaleMeasurement();
goalData.setConvertedWeight(currentScaleUser.getGoalWeight(), currentScaleUser.getScaleUnit());
goalData.setUserId(currentScaleUser.getId());
@@ -141,7 +141,7 @@ public class StatisticsFragment extends Fragment implements FragmentUpdateListen
" <br> <font color='grey'><small>" +
getResources().getString(R.string.label_bmi) +
": " +
String.format("%.1f", lastScaleData.getBMI(currentScaleUser.getBodyHeight()) - goalData.getBMI(currentScaleUser.getBodyHeight())) +
String.format("%.1f", lastScaleMeasurement.getBMI(currentScaleUser.getBodyHeight()) - goalData.getBMI(currentScaleUser.getBodyHeight())) +
" </small></font>"
)
);
@@ -157,15 +157,15 @@ public class StatisticsFragment extends Fragment implements FragmentUpdateListen
); // currentScaleUser.goalDate
}
private void updateStatistics(List<ScaleData> scaleDataList) {
private void updateStatistics(List<ScaleMeasurement> scaleMeasurementList) {
Calendar histDate = Calendar.getInstance();
Calendar weekPastDate = Calendar.getInstance();
Calendar monthPastDate = Calendar.getInstance();
weekPastDate.setTime(lastScaleData.getDateTime());
weekPastDate.setTime(lastScaleMeasurement.getDateTime());
weekPastDate.add(Calendar.DATE, -7);
monthPastDate.setTime(lastScaleData.getDateTime());
monthPastDate.setTime(lastScaleMeasurement.getDateTime());
monthPastDate.add(Calendar.DATE, -30);
int weekSize = 0;
@@ -194,40 +194,40 @@ public class StatisticsFragment extends Fragment implements FragmentUpdateListen
float monthAvgHip = 0;
float monthAvgWHR = 0;
for (ScaleData scaleData : scaleDataList)
for (ScaleMeasurement scaleMeasurement : scaleMeasurementList)
{
histDate.setTime(scaleData.getDateTime());
histDate.setTime(scaleMeasurement.getDateTime());
if (weekPastDate.before(histDate)) {
weekSize++;
weekAvgWeight += scaleData.getConvertedWeight(currentScaleUser.getScaleUnit());
weekAvgBMI += scaleData.getBMI(currentScaleUser.getBodyHeight());
weekAvgFat += scaleData.getFat();
weekAvgWater += scaleData.getWater();
weekAvgMuscle += scaleData.getMuscle();
weekAvgLBW += scaleData.getLbw();
weekAvgBone += scaleData.getBone();
weekAvgWaist += scaleData.getWaist();
weekAvgHip += scaleData.getHip();
weekAvgWHtR += scaleData.getWHtR(currentScaleUser.getBodyHeight());
weekAvgWHR += scaleData.getWHR();
weekAvgWeight += scaleMeasurement.getConvertedWeight(currentScaleUser.getScaleUnit());
weekAvgBMI += scaleMeasurement.getBMI(currentScaleUser.getBodyHeight());
weekAvgFat += scaleMeasurement.getFat();
weekAvgWater += scaleMeasurement.getWater();
weekAvgMuscle += scaleMeasurement.getMuscle();
weekAvgLBW += scaleMeasurement.getLbw();
weekAvgBone += scaleMeasurement.getBone();
weekAvgWaist += scaleMeasurement.getWaist();
weekAvgHip += scaleMeasurement.getHip();
weekAvgWHtR += scaleMeasurement.getWHtR(currentScaleUser.getBodyHeight());
weekAvgWHR += scaleMeasurement.getWHR();
}
if (monthPastDate.before(histDate)) {
monthSize++;
monthAvgWeight += scaleData.getConvertedWeight(currentScaleUser.getScaleUnit());
monthAvgBMI += scaleData.getBMI(currentScaleUser.getBodyHeight());
monthAvgFat += scaleData.getFat();
monthAvgWater += scaleData.getWater();
monthAvgMuscle += scaleData.getMuscle();
monthAvgLBW += scaleData.getLbw();
monthAvgBone += scaleData.getBone();
monthAvgWaist += scaleData.getWaist();
monthAvgHip += scaleData.getHip();
monthAvgWHtR += scaleData.getWHtR(currentScaleUser.getBodyHeight());
monthAvgWHR += scaleData.getWHR();
monthAvgWeight += scaleMeasurement.getConvertedWeight(currentScaleUser.getScaleUnit());
monthAvgBMI += scaleMeasurement.getBMI(currentScaleUser.getBodyHeight());
monthAvgFat += scaleMeasurement.getFat();
monthAvgWater += scaleMeasurement.getWater();
monthAvgMuscle += scaleMeasurement.getMuscle();
monthAvgLBW += scaleMeasurement.getLbw();
monthAvgBone += scaleMeasurement.getBone();
monthAvgWaist += scaleMeasurement.getWaist();
monthAvgHip += scaleMeasurement.getHip();
monthAvgWHtR += scaleMeasurement.getWHtR(currentScaleUser.getBodyHeight());
monthAvgWHR += scaleMeasurement.getWHR();
} else {
break;
}

View File

@@ -46,7 +46,7 @@ import android.widget.Toast;
import com.health.openscale.R;
import com.health.openscale.core.OpenScale;
import com.health.openscale.core.datatypes.ScaleData;
import com.health.openscale.core.datatypes.ScaleMeasurement;
import com.health.openscale.gui.activities.DataEntryActivity;
import com.health.openscale.gui.views.BMIMeasurementView;
import com.health.openscale.gui.views.BMRMeasurementView;
@@ -130,17 +130,17 @@ public class TableFragment extends Fragment implements FragmentUpdateListener {
}
@Override
public void updateOnView(List<ScaleData> scaleDataList)
public void updateOnView(List<ScaleMeasurement> scaleMeasurementList)
{
tableDataView.setAdapter(new ListViewAdapter(new ArrayList<HashMap<Integer, String>>())); // delete all data in the table with an empty adapter array list
if (scaleDataList.isEmpty()) {
if (scaleMeasurementList.isEmpty()) {
return;
}
final int maxSize = 20;
int subpageCount = (int)Math.ceil(scaleDataList.size() / (double)maxSize);
int subpageCount = (int)Math.ceil(scaleMeasurementList.size() / (double)maxSize);
subpageView.removeAllViews();
@@ -203,27 +203,27 @@ public class TableFragment extends Fragment implements FragmentUpdateListener {
int displayCount = 0;
for (int i = (maxSize * selectedSubpageNr); i<scaleDataList.size(); i++) {
ScaleData scaleData = scaleDataList.get(i);
for (int i = (maxSize * selectedSubpageNr); i< scaleMeasurementList.size(); i++) {
ScaleMeasurement scaleMeasurement = scaleMeasurementList.get(i);
ScaleData prevScaleData;
ScaleMeasurement prevScaleMeasurement;
if (i >= scaleDataList.size()-1) {
prevScaleData = new ScaleData();
if (i >= scaleMeasurementList.size()-1) {
prevScaleMeasurement = new ScaleMeasurement();
} else {
prevScaleData = scaleDataList.get(i+1);
prevScaleMeasurement = scaleMeasurementList.get(i+1);
}
HashMap<Integer,String> dataRow = new HashMap<>();
int columnNr = 0;
dataRow.put(columnNr, Long.toString(scaleData.getId()));
dataRow.put(columnNr, Long.toString(scaleMeasurement.getId()));
for (int j=0; j< measurementsList.size(); j++) {
MeasurementView measurement = measurementsList.get(j);
measurement.updateValue(scaleData);
measurement.updateDiff(scaleData, prevScaleData);
measurement.updateValue(scaleMeasurement);
measurement.updateDiff(scaleMeasurement, prevScaleMeasurement);
if (measurement.isVisible()) {
columnNr++;
@@ -301,7 +301,7 @@ public class TableFragment extends Fragment implements FragmentUpdateListener {
if (!isError) {
Toast.makeText(tableView.getContext(), getResources().getString(R.string.info_data_imported) + " /sdcard" + txtFilename.getText().toString(), Toast.LENGTH_SHORT).show();
updateOnView(OpenScale.getInstance(getContext()).getScaleDataList());
updateOnView(OpenScale.getInstance(getContext()).getScaleMeasurementList());
}
}
});
@@ -363,7 +363,7 @@ public class TableFragment extends Fragment implements FragmentUpdateListener {
public void onClick(View v) {
if (selectedSubpageNr > 0) {
selectedSubpageNr--;
updateOnView(OpenScale.getInstance(getContext()).getScaleDataList());
updateOnView(OpenScale.getInstance(getContext()).getScaleMeasurementList());
}
}
}
@@ -373,7 +373,7 @@ public class TableFragment extends Fragment implements FragmentUpdateListener {
public void onClick(View v) {
if (selectedSubpageNr < (subpageView.getChildCount() - 3)) {
selectedSubpageNr++;
updateOnView(OpenScale.getInstance(getContext()).getScaleDataList());
updateOnView(OpenScale.getInstance(getContext()).getScaleMeasurementList());
}
}
}
@@ -384,7 +384,7 @@ public class TableFragment extends Fragment implements FragmentUpdateListener {
TextView nrView = (TextView)v;
selectedSubpageNr = Integer.parseInt(nrView.getText().toString())-1;
updateOnView(OpenScale.getInstance(getContext()).getScaleDataList());
updateOnView(OpenScale.getInstance(getContext()).getScaleMeasurementList());
}
}

View File

@@ -20,7 +20,7 @@ import android.content.SharedPreferences;
import android.support.v4.content.ContextCompat;
import com.health.openscale.R;
import com.health.openscale.core.datatypes.ScaleData;
import com.health.openscale.core.datatypes.ScaleMeasurement;
import com.health.openscale.core.evaluation.EvaluationResult;
import com.health.openscale.core.evaluation.EvaluationSheet;
@@ -36,13 +36,13 @@ public class BMIMeasurementView extends MeasurementView {
}
@Override
public void updateValue(ScaleData updateData) {
setValueOnView(updateData.getDateTime(), updateData.getBMI(getScaleUser().getBodyHeight()));
public void updateValue(ScaleMeasurement newMeasurement) {
setValueOnView(newMeasurement.getDateTime(), newMeasurement.getBMI(getScaleUser().getBodyHeight()));
}
@Override
public void updateDiff(ScaleData updateData, ScaleData lastData) {
setDiffOnView(updateData.getBMI(getScaleUser().getBodyHeight()), lastData.getBMI(getScaleUser().getBodyHeight()));
public void updateDiff(ScaleMeasurement newMeasurement, ScaleMeasurement lastMeasurement) {
setDiffOnView(newMeasurement.getBMI(getScaleUser().getBodyHeight()), lastMeasurement.getBMI(getScaleUser().getBodyHeight()));
}
@Override

View File

@@ -20,7 +20,7 @@ import android.content.SharedPreferences;
import android.support.v4.content.ContextCompat;
import com.health.openscale.R;
import com.health.openscale.core.datatypes.ScaleData;
import com.health.openscale.core.datatypes.ScaleMeasurement;
import com.health.openscale.core.evaluation.EvaluationResult;
import com.health.openscale.core.evaluation.EvaluationSheet;
@@ -36,13 +36,13 @@ public class BMRMeasurementView extends MeasurementView {
}
@Override
public void updateValue(ScaleData updateData) {
setValueOnView(updateData.getDateTime(), updateData.getBMR(getScaleUser()));
public void updateValue(ScaleMeasurement newMeasurement) {
setValueOnView(newMeasurement.getDateTime(), newMeasurement.getBMR(getScaleUser()));
}
@Override
public void updateDiff(ScaleData updateData, ScaleData lastData) {
setDiffOnView(updateData.getBMR(getScaleUser()), lastData.getBMR(getScaleUser()));
public void updateDiff(ScaleMeasurement newMeasurement, ScaleMeasurement lastMeasurement) {
setDiffOnView(newMeasurement.getBMR(getScaleUser()), lastMeasurement.getBMR(getScaleUser()));
}
@Override

View File

@@ -20,7 +20,7 @@ import android.content.SharedPreferences;
import android.support.v4.content.ContextCompat;
import com.health.openscale.R;
import com.health.openscale.core.datatypes.ScaleData;
import com.health.openscale.core.datatypes.ScaleMeasurement;
import com.health.openscale.core.evaluation.EvaluationResult;
import com.health.openscale.core.evaluation.EvaluationSheet;
@@ -31,13 +31,13 @@ public class BoneMeasurementView extends MeasurementView {
}
@Override
public void updateValue(ScaleData updateData) {
setValueOnView(updateData.getDateTime(), updateData.getBone());
public void updateValue(ScaleMeasurement newMeasurement) {
setValueOnView(newMeasurement.getDateTime(), newMeasurement.getBone());
}
@Override
public void updateDiff(ScaleData updateData, ScaleData lastData) {
setDiffOnView(updateData.getBone(), lastData.getBone());
public void updateDiff(ScaleMeasurement newMeasurement, ScaleMeasurement lastMeasurement) {
setDiffOnView(newMeasurement.getBone(), lastMeasurement.getBone());
}
@Override

View File

@@ -22,7 +22,7 @@ import android.text.InputType;
import android.widget.EditText;
import com.health.openscale.R;
import com.health.openscale.core.datatypes.ScaleData;
import com.health.openscale.core.datatypes.ScaleMeasurement;
import com.health.openscale.core.evaluation.EvaluationResult;
import com.health.openscale.core.evaluation.EvaluationSheet;
@@ -47,12 +47,12 @@ public class CommentMeasurementView extends MeasurementView {
}
@Override
public void updateValue(ScaleData updateData) {
setValueOnView(updateData.getDateTime(), updateData.getComment());
public void updateValue(ScaleMeasurement newMeasurement) {
setValueOnView(newMeasurement.getDateTime(), newMeasurement.getComment());
}
@Override
public void updateDiff(ScaleData updateData, ScaleData lastData) {
public void updateDiff(ScaleMeasurement newMeasurement, ScaleMeasurement lastMeasurement) {
}

View File

@@ -23,7 +23,7 @@ import android.support.v4.content.ContextCompat;
import android.widget.DatePicker;
import com.health.openscale.R;
import com.health.openscale.core.datatypes.ScaleData;
import com.health.openscale.core.datatypes.ScaleMeasurement;
import com.health.openscale.core.evaluation.EvaluationResult;
import com.health.openscale.core.evaluation.EvaluationSheet;
@@ -61,12 +61,12 @@ public class DateMeasurementView extends MeasurementView {
}
@Override
public void updateValue(ScaleData updateData) {
setValueOnView(updateData.getDateTime(), dateFormat.format(updateData.getDateTime()));
public void updateValue(ScaleMeasurement newMeasurement) {
setValueOnView(newMeasurement.getDateTime(), dateFormat.format(newMeasurement.getDateTime()));
}
@Override
public void updateDiff(ScaleData updateData, ScaleData lastData) {
public void updateDiff(ScaleMeasurement newMeasurement, ScaleMeasurement lastMeasurement) {
}

View File

@@ -20,7 +20,7 @@ import android.content.SharedPreferences;
import android.support.v4.content.ContextCompat;
import com.health.openscale.R;
import com.health.openscale.core.datatypes.ScaleData;
import com.health.openscale.core.datatypes.ScaleMeasurement;
import com.health.openscale.core.evaluation.EvaluationResult;
import com.health.openscale.core.evaluation.EvaluationSheet;
@@ -41,17 +41,17 @@ public class FatMeasurementView extends MeasurementView {
}
@Override
public void updateValue(ScaleData updateData) {
public void updateValue(ScaleMeasurement newMeasurement) {
if (estimateFatEnable && getMeasurementMode() == MeasurementViewMode.ADD) {
setValueOnView(updateData.getDateTime(), (getContext().getString(R.string.label_automatic)));
setValueOnView(newMeasurement.getDateTime(), (getContext().getString(R.string.label_automatic)));
} else {
setValueOnView(updateData.getDateTime(), updateData.getFat());
setValueOnView(newMeasurement.getDateTime(), newMeasurement.getFat());
}
}
@Override
public void updateDiff(ScaleData updateData, ScaleData lastData) {
setDiffOnView(updateData.getFat(), lastData.getFat());
public void updateDiff(ScaleMeasurement newMeasurement, ScaleMeasurement lastMeasurement) {
setDiffOnView(newMeasurement.getFat(), lastMeasurement.getFat());
}
@Override

View File

@@ -20,7 +20,7 @@ import android.content.SharedPreferences;
import android.support.v4.content.ContextCompat;
import com.health.openscale.R;
import com.health.openscale.core.datatypes.ScaleData;
import com.health.openscale.core.datatypes.ScaleMeasurement;
import com.health.openscale.core.evaluation.EvaluationResult;
import com.health.openscale.core.evaluation.EvaluationSheet;
@@ -31,13 +31,13 @@ public class HipMeasurementView extends MeasurementView {
}
@Override
public void updateValue(ScaleData updateData) {
setValueOnView(updateData.getDateTime(), updateData.getHip());
public void updateValue(ScaleMeasurement newMeasurement) {
setValueOnView(newMeasurement.getDateTime(), newMeasurement.getHip());
}
@Override
public void updateDiff(ScaleData updateData, ScaleData lastData) {
setDiffOnView(updateData.getHip(), lastData.getHip());
public void updateDiff(ScaleMeasurement newMeasurement, ScaleMeasurement lastMeasurement) {
setDiffOnView(newMeasurement.getHip(), lastMeasurement.getHip());
}
@Override

View File

@@ -20,7 +20,7 @@ import android.content.SharedPreferences;
import android.support.v4.content.ContextCompat;
import com.health.openscale.R;
import com.health.openscale.core.datatypes.ScaleData;
import com.health.openscale.core.datatypes.ScaleMeasurement;
import com.health.openscale.core.evaluation.EvaluationResult;
import com.health.openscale.core.evaluation.EvaluationSheet;
@@ -41,17 +41,17 @@ public class LBWMeasurementView extends MeasurementView {
}
@Override
public void updateValue(ScaleData updateData) {
public void updateValue(ScaleMeasurement newMeasurement) {
if (estimateLBWEnable && getMeasurementMode() == MeasurementViewMode.ADD) {
setValueOnView(updateData.getDateTime(), (getContext().getString(R.string.label_automatic)));
setValueOnView(newMeasurement.getDateTime(), (getContext().getString(R.string.label_automatic)));
} else {
setValueOnView(updateData.getDateTime(), updateData.getLbw());
setValueOnView(newMeasurement.getDateTime(), newMeasurement.getLbw());
}
}
@Override
public void updateDiff(ScaleData updateData, ScaleData lastData) {
setDiffOnView(updateData.getLbw(), lastData.getLbw());
public void updateDiff(ScaleMeasurement newMeasurement, ScaleMeasurement lastMeasurement) {
setDiffOnView(newMeasurement.getLbw(), lastMeasurement.getLbw());
}
@Override

View File

@@ -41,7 +41,7 @@ import android.widget.TextView;
import com.health.openscale.R;
import com.health.openscale.core.OpenScale;
import com.health.openscale.core.datatypes.ScaleData;
import com.health.openscale.core.datatypes.ScaleMeasurement;
import com.health.openscale.core.datatypes.ScaleUser;
import com.health.openscale.core.evaluation.EvaluationResult;
import com.health.openscale.core.evaluation.EvaluationSheet;
@@ -208,8 +208,8 @@ public abstract class MeasurementView extends TableLayout {
updateListener = listener;
}
public abstract void updateValue(ScaleData updateData);
public abstract void updateDiff(ScaleData updateData, ScaleData lastData);
public abstract void updateValue(ScaleMeasurement newMeasurement);
public abstract void updateDiff(ScaleMeasurement newMeasurement, ScaleMeasurement lastMeasurement);
public abstract void updatePreferences(SharedPreferences preferences);
public abstract String getUnit();
public abstract EvaluationResult evaluateSheet(EvaluationSheet evalSheet, float value);

View File

@@ -20,7 +20,7 @@ import android.content.SharedPreferences;
import android.support.v4.content.ContextCompat;
import com.health.openscale.R;
import com.health.openscale.core.datatypes.ScaleData;
import com.health.openscale.core.datatypes.ScaleMeasurement;
import com.health.openscale.core.evaluation.EvaluationResult;
import com.health.openscale.core.evaluation.EvaluationSheet;
@@ -36,13 +36,13 @@ public class MuscleMeasurementView extends MeasurementView {
}
@Override
public void updateValue(ScaleData updateData) {
setValueOnView(updateData.getDateTime(), updateData.getMuscle());
public void updateValue(ScaleMeasurement newMeasurement) {
setValueOnView(newMeasurement.getDateTime(), newMeasurement.getMuscle());
}
@Override
public void updateDiff(ScaleData updateData, ScaleData lastData) {
setDiffOnView(updateData.getMuscle(), lastData.getMuscle());
public void updateDiff(ScaleMeasurement newMeasurement, ScaleMeasurement lastMeasurement) {
setDiffOnView(newMeasurement.getMuscle(), lastMeasurement.getMuscle());
}
@Override

View File

@@ -23,7 +23,7 @@ import android.support.v4.content.ContextCompat;
import android.widget.TimePicker;
import com.health.openscale.R;
import com.health.openscale.core.datatypes.ScaleData;
import com.health.openscale.core.datatypes.ScaleMeasurement;
import com.health.openscale.core.evaluation.EvaluationResult;
import com.health.openscale.core.evaluation.EvaluationSheet;
@@ -65,12 +65,12 @@ public class TimeMeasurementView extends MeasurementView {
}
@Override
public void updateValue(ScaleData updateData) {
setValueOnView(updateData.getDateTime(), timeFormat.format(updateData.getDateTime()));
public void updateValue(ScaleMeasurement newMeasurement) {
setValueOnView(newMeasurement.getDateTime(), timeFormat.format(newMeasurement.getDateTime()));
}
@Override
public void updateDiff(ScaleData updateData, ScaleData lastData) {
public void updateDiff(ScaleMeasurement newMeasurement, ScaleMeasurement lastMeasurement) {
}

View File

@@ -20,7 +20,7 @@ import android.content.SharedPreferences;
import android.support.v4.content.ContextCompat;
import com.health.openscale.R;
import com.health.openscale.core.datatypes.ScaleData;
import com.health.openscale.core.datatypes.ScaleMeasurement;
import com.health.openscale.core.evaluation.EvaluationResult;
import com.health.openscale.core.evaluation.EvaluationSheet;
@@ -36,13 +36,13 @@ public class WHRMeasurementView extends MeasurementView {
}
@Override
public void updateValue(ScaleData updateData) {
setValueOnView(updateData.getDateTime(), updateData.getWHR());
public void updateValue(ScaleMeasurement newMeasurement) {
setValueOnView(newMeasurement.getDateTime(), newMeasurement.getWHR());
}
@Override
public void updateDiff(ScaleData updateData, ScaleData lastData) {
setDiffOnView(updateData.getWHR(), lastData.getWHR());
public void updateDiff(ScaleMeasurement newMeasurement, ScaleMeasurement lastMeasurement) {
setDiffOnView(newMeasurement.getWHR(), lastMeasurement.getWHR());
}
@Override

View File

@@ -20,7 +20,7 @@ import android.content.SharedPreferences;
import android.support.v4.content.ContextCompat;
import com.health.openscale.R;
import com.health.openscale.core.datatypes.ScaleData;
import com.health.openscale.core.datatypes.ScaleMeasurement;
import com.health.openscale.core.evaluation.EvaluationResult;
import com.health.openscale.core.evaluation.EvaluationSheet;
@@ -36,13 +36,13 @@ public class WHtRMeasurementView extends MeasurementView {
}
@Override
public void updateValue(ScaleData updateData) {
setValueOnView(updateData.getDateTime(), updateData.getWHtR(getScaleUser().getBodyHeight()));
public void updateValue(ScaleMeasurement newMeasurement) {
setValueOnView(newMeasurement.getDateTime(), newMeasurement.getWHtR(getScaleUser().getBodyHeight()));
}
@Override
public void updateDiff(ScaleData updateData, ScaleData lastData) {
setDiffOnView(updateData.getWHtR(getScaleUser().getBodyHeight()), lastData.getWHtR(getScaleUser().getBodyHeight()));
public void updateDiff(ScaleMeasurement newMeasurement, ScaleMeasurement lastMeasurement) {
setDiffOnView(newMeasurement.getWHtR(getScaleUser().getBodyHeight()), lastMeasurement.getWHtR(getScaleUser().getBodyHeight()));
}
@Override

View File

@@ -20,7 +20,7 @@ import android.content.SharedPreferences;
import android.support.v4.content.ContextCompat;
import com.health.openscale.R;
import com.health.openscale.core.datatypes.ScaleData;
import com.health.openscale.core.datatypes.ScaleMeasurement;
import com.health.openscale.core.evaluation.EvaluationResult;
import com.health.openscale.core.evaluation.EvaluationSheet;
@@ -31,13 +31,13 @@ public class WaistMeasurementView extends MeasurementView {
}
@Override
public void updateValue(ScaleData updateData) {
setValueOnView(updateData.getDateTime(), updateData.getWaist());
public void updateValue(ScaleMeasurement newMeasurement) {
setValueOnView(newMeasurement.getDateTime(), newMeasurement.getWaist());
}
@Override
public void updateDiff(ScaleData updateData, ScaleData lastData) {
setDiffOnView(updateData.getWaist(), lastData.getWaist());
public void updateDiff(ScaleMeasurement newMeasurement, ScaleMeasurement lastMeasurement) {
setDiffOnView(newMeasurement.getWaist(), lastMeasurement.getWaist());
}
@Override

View File

@@ -20,7 +20,7 @@ import android.content.SharedPreferences;
import android.support.v4.content.ContextCompat;
import com.health.openscale.R;
import com.health.openscale.core.datatypes.ScaleData;
import com.health.openscale.core.datatypes.ScaleMeasurement;
import com.health.openscale.core.evaluation.EvaluationResult;
import com.health.openscale.core.evaluation.EvaluationSheet;
@@ -41,17 +41,17 @@ public class WaterMeasurementView extends MeasurementView {
}
@Override
public void updateValue(ScaleData updateData) {
public void updateValue(ScaleMeasurement newMeasurement) {
if (estimateWaterEnable && getMeasurementMode() == MeasurementViewMode.ADD) {
setValueOnView(updateData.getDateTime(), (getContext().getString(R.string.label_automatic)));
setValueOnView(newMeasurement.getDateTime(), (getContext().getString(R.string.label_automatic)));
} else {
setValueOnView(updateData.getDateTime(), updateData.getWater());
setValueOnView(newMeasurement.getDateTime(), newMeasurement.getWater());
}
}
@Override
public void updateDiff(ScaleData updateData, ScaleData lastData) {
setDiffOnView(updateData.getWater(), lastData.getWater());
public void updateDiff(ScaleMeasurement newMeasurement, ScaleMeasurement lastMeasurement) {
setDiffOnView(newMeasurement.getWater(), lastMeasurement.getWater());
}
@Override

View File

@@ -20,7 +20,7 @@ import android.content.SharedPreferences;
import android.support.v4.content.ContextCompat;
import com.health.openscale.R;
import com.health.openscale.core.datatypes.ScaleData;
import com.health.openscale.core.datatypes.ScaleMeasurement;
import com.health.openscale.core.datatypes.ScaleUser;
import com.health.openscale.core.evaluation.EvaluationResult;
import com.health.openscale.core.evaluation.EvaluationSheet;
@@ -32,13 +32,13 @@ public class WeightMeasurementView extends MeasurementView {
}
@Override
public void updateValue(ScaleData updateData) {
setValueOnView(updateData.getDateTime(), updateData.getConvertedWeight(getScaleUser().getScaleUnit()));
public void updateValue(ScaleMeasurement newMeasurement) {
setValueOnView(newMeasurement.getDateTime(), newMeasurement.getConvertedWeight(getScaleUser().getScaleUnit()));
}
@Override
public void updateDiff(ScaleData updateData, ScaleData lastData) {
setDiffOnView(updateData.getConvertedWeight(getScaleUser().getScaleUnit()), lastData.getConvertedWeight(getScaleUser().getScaleUnit()));
public void updateDiff(ScaleMeasurement newMeasurement, ScaleMeasurement lastMeasurement) {
setDiffOnView(newMeasurement.getConvertedWeight(getScaleUser().getScaleUnit()), lastMeasurement.getConvertedWeight(getScaleUser().getScaleUnit()));
}
@Override