Skip to content

Commit

Permalink
Merge remote-tracking branch 'oliexdev/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
wolkenschieber committed Dec 25, 2017
2 parents 9c4f6f8 + 7283bd1 commit 14e7dbb
Show file tree
Hide file tree
Showing 10 changed files with 645 additions and 37 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ Install [openScale-dev-build.apk](https://github.com/oliexdev/openScale/releases
- Import or export your data from/into a CSV file
- Estimates body metrics (body fat, body water and lean body mass) based on scientic publications
- Support for multiple users
- Partially or full support for custom made Bluetooth scale, Xiaomi Mi scale v1, Sanitas SBF70, Medisana BS444, Digoo DG-S038H, Yunmai Mini, Excelvan CF369BLE, Yunmai SE, MGB, Xiaomi Mi scale v2 (see [openScale wiki](https://github.com/oliexdev/openScale/wiki/Supported-scales-in-openScale) for details)
- Partially or full translated into English, German, Japanese, French, Polish, Brazilian portuguese, Slovak
- Partially or full support for custom made Bluetooth scale, Xiaomi Mi scale v1/v2, Sanitas SBF70, Medisana BS444, Digoo DG-S038H, Yunmai Mini, Excelvan CF369BLE, Yunmai SE, MGB, Exingtech Y1, Beurer BF700/800 (see [openScale wiki](https://github.com/oliexdev/openScale/wiki/Supported-scales-in-openScale) for details)
- Partially or full translated into English, German, Japanese, French, Polish, Brazilian portuguese, Slovak, Turkish, Swedish, Spanish
- No advertising and for free
- All data belongs to you (no cloud service)

# Supported Bluetooth scales
Expand Down
4 changes: 2 additions & 2 deletions android_app/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ android {
applicationId "com.health.openscale"
minSdkVersion 18
targetSdkVersion 22 // don't set target sdk > 22 otherwise bluetooth le discovery need permission to ACCESS_COARSE_LOCATION
versionCode 19
versionName "1.6"
versionCode 21
versionName "1.6.1"
}

lintOptions {
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public enum BT_STATUS_CODE {BT_RETRIEVE_SCALE_DATA, BT_INIT_PROCESS, BT_CONNECTI
BT_CONNECTION_LOST, BT_NO_DEVICE_FOUND, BT_UNEXPECTED_ERROR, BT_SCALE_MESSAGE
};
public enum BT_MACHINE_STATE {BT_INIT_STATE, BT_CMD_STATE, BT_CLEANUP_STATE}
public enum BT_DEVICE_ID {CUSTOM_OPENSCALE, MI_SCALE_V1, MI_SCALE_V2, SANITAS_SBF70, MEDISANA_BS444, DIGOO_DGS038H, EXCELVANT_CF369BLE, YUNMAI_MINI, YUNMAI_SE, MGB, EXINGTECH_Y1}
public enum BT_DEVICE_ID {CUSTOM_OPENSCALE, MI_SCALE_V1, MI_SCALE_V2, SANITAS_SBF70, MEDISANA_BS444, DIGOO_DGS038H, EXCELVANT_CF369BLE, YUNMAI_MINI, YUNMAI_SE, MGB, EXINGTECH_Y1, BEURER_BF700_800}

protected Context context;

Expand Down Expand Up @@ -99,6 +99,8 @@ public static BluetoothCommunication getBtDevice(Context context, BT_DEVICE_ID b
return new BluetoothMGB(context);
case EXINGTECH_Y1:
return new BluetoothExingtechY1(context);
case BEURER_BF700_800:
return new BluetoothBeurerBF700_800(context);
}

return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ private void updateOnView()
id = getIntent().getExtras().getLong("id");
}

ScaleData scaleData;

if (id > 0) {
// keep edit mode state if we are moving to left or right
if (prefs.getBoolean(String.valueOf(switchEditMode.getId()), false)) {
Expand All @@ -202,40 +204,40 @@ private void updateOnView()

ScaleData[] tupleScaleData = openScale.getTupleScaleData(id);
ScaleData prevScaleData = tupleScaleData[0];
ScaleData selectedScaleData = tupleScaleData[1];
scaleData = tupleScaleData[1];

if (prevScaleData == null) {
prevScaleData = new ScaleData();
}

txtDataNr.setText(DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.SHORT).format(selectedScaleData.getDateTime()));

// show selected scale data
for (MeasurementView measurement : dataEntryMeasurements) {
measurement.updateValue(selectedScaleData);
measurement.updateDiff(selectedScaleData, prevScaleData);
measurement.updateValue(scaleData);
measurement.updateDiff(scaleData, prevScaleData);
measurement.setExpand(doExpand);
}
} else if (!OpenScale.getInstance(getApplicationContext()).getScaleDataList().isEmpty()) {
} else {
setViewMode(MeasurementView.MeasurementViewMode.ADD);
txtDataNr.setText(DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.SHORT).format(new Date()));
ScaleData lastScaleData = OpenScale.getInstance(getApplicationContext()).getScaleDataList().get(0);

// show as default last scale data
lastScaleData.setDateTime(new Date());
lastScaleData.setComment("");
for (MeasurementView measurement : dataEntryMeasurements) {
measurement.updateValue(lastScaleData);
if (OpenScale.getInstance(getApplicationContext()).getScaleDataList().isEmpty()) {
// Show default values
scaleData = new ScaleData();
}
} else {
setViewMode(MeasurementView.MeasurementViewMode.ADD);
// show default values
ScaleData newScaleData = new ScaleData();
else {
// Show the last scale data as default
scaleData = OpenScale.getInstance(getApplicationContext()).getScaleDataList().get(0);
scaleData.setDateTime(new Date());
scaleData.setComment("");
}

for (MeasurementView measurement : dataEntryMeasurements) {
measurement.updateValue(newScaleData);
measurement.updateValue(scaleData);
}
}

txtDataNr.setText(DateFormat.getDateTimeInstance(
DateFormat.LONG, DateFormat.SHORT).format(scaleData.getDateTime()));

onMeasurementViewUpdateListener updateListener = new onMeasurementViewUpdateListener();
for (MeasurementView measurement : dataEntryMeasurements) {
measurement.setOnUpdateListener(updateListener);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,6 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
measurementsList.add(new BMRMeasurementView(tableView.getContext()));
measurementsList.add(new CommentMeasurementView(tableView.getContext()));

for (MeasurementView measurement : measurementsList) {
measurement.setEditMode(MeasurementView.MeasurementViewMode.EDIT);
}

prefs = PreferenceManager.getDefaultSharedPreferences(tableView.getContext());

OpenScale.getInstance(getContext()).registerFragment(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ public void onCreate(Bundle savedInstanceState) {

addPreferencesFromResource(R.xml.about_preferences);

findPreference(KEY_APP_VERSION).setSummary("v" + BuildConfig.VERSION_NAME);
findPreference(KEY_APP_VERSION).setSummary("v" + BuildConfig.VERSION_NAME + " (" + BuildConfig.VERSION_CODE + ")");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,20 @@ protected void onDraw(Canvas canvas) {

final boolean hasFirstLimit = firstLimit >= 0;

// Calculate the size of the "normal" span with a fallback if there is no such span
float span = hasFirstLimit ? secondLimit - firstLimit : 0.3f * secondLimit;
// Calculate how much bar to show to the left and right of the "normal" span
// (or just the second limit if there is no first limit).
float span = hasFirstLimit ? (secondLimit - firstLimit) / 2.0f : 0.3f * secondLimit;

// Add some extra margin to avoid having the indicator too far towards an edge
final float margin = 0.05f * span;

// Adjust the span if needed to make the value fit inside of it
if (hasFirstLimit && value < firstLimit - span) {
span = firstLimit - value;
} else if (!hasFirstLimit && value < secondLimit - span) {
span = secondLimit - value;
} else if (value > secondLimit + span) {
span = value - secondLimit;
if (hasFirstLimit && value - margin < firstLimit - span) {
span = firstLimit - value + margin;
} else if (!hasFirstLimit && value - margin < secondLimit - span) {
span = secondLimit - value + margin;
} else if (value + margin > secondLimit + span) {
span = value - secondLimit + margin;
}

// Round span to some nice value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ protected void setDiffOnView(float value, float prevValue) {
}

public void setExpand(boolean state) {
if (state && measurementRow.getVisibility() == View.VISIBLE && evaluateSheet(new EvaluationSheet(getScaleUser(), dateTime), 0.0f) != null) {
if (state && isVisible() && evaluateSheet(new EvaluationSheet(getScaleUser(), dateTime), 0.0f) != null) {
evaluatorRow.setVisibility(View.VISIBLE);
} else {
evaluatorRow.setVisibility(View.GONE);
Expand Down
Binary file added doc/scales/beurer_bf700.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 14e7dbb

Please sign in to comment.