|
13 | 13 | import android.widget.LinearLayout; |
14 | 14 | import android.widget.TextView; |
15 | 15 |
|
| 16 | +import com.eveningoutpost.dexdrip.models.JoH; |
16 | 17 | import com.eveningoutpost.dexdrip.utilitymodels.PersistentStore; |
17 | 18 | import com.eveningoutpost.dexdrip.utilitymodels.Pref; |
18 | 19 | import com.eveningoutpost.dexdrip.insulin.Insulin; |
@@ -370,29 +371,32 @@ private void submitAll() { |
370 | 371 |
|
371 | 372 | // The green tick is clickable even when it's hidden, so we might get here |
372 | 373 | // without valid data. Ignore the click if input is incomplete |
373 | | - if(!nonzeroBloodValue && !nonzeroCarbsValue && !nonzeroInsulin1Value && !nonzeroInsulin2Value && !nonzeroInsulin3Value) { |
| 374 | + if (!nonzeroBloodValue && !nonzeroCarbsValue && !nonzeroInsulin1Value && !nonzeroInsulin2Value && !nonzeroInsulin3Value) { |
374 | 375 | Log.d(TAG, "All zero values in tabs - not processing button click"); |
375 | 376 | return; |
376 | 377 | } |
377 | 378 |
|
378 | 379 | if (isInvalidTime()) { |
379 | | - Log.d(TAG,"Time value is invalid - not processing button click"); |
| 380 | + Log.d(TAG, "Time value is invalid - not processing button click"); |
380 | 381 | return; |
381 | 382 | } |
382 | 383 |
|
383 | 384 |
|
384 | 385 | // Add the dot to the time if it is missing |
385 | 386 | String timeValue = getValue("time"); |
386 | 387 | if (timeValue.length() > 2 && !timeValue.contains(".")) { |
387 | | - timeValue = timeValue.substring(0, timeValue.length()-2) + "." + timeValue.substring(timeValue.length()-2); |
| 388 | + timeValue = timeValue.substring(0, timeValue.length() - 2) + "." + timeValue.substring(timeValue.length() - 2); |
388 | 389 | } |
389 | 390 |
|
390 | 391 | String mystring = ""; |
391 | 392 | double units = 0; |
392 | 393 | final DecimalFormat df = new DecimalFormat("0.0#", new DecimalFormatSymbols(Locale.ENGLISH)); |
393 | 394 | if (timeValue.length() > 0) mystring += timeValue + " time "; |
394 | 395 | if (nonzeroBloodValue) mystring += getValue("bloodtest") + " blood "; |
395 | | - if (nonzeroCarbsValue) mystring += getValue("carbs") + " g carbs "; |
| 396 | + if (nonzeroCarbsValue) { |
| 397 | + String carbValue = String.valueOf(JoH.roundDouble(JoH.tolerantParseDouble(getValue("carbs")), 2)); // Let's round the entered carb value to 2 decimal points |
| 398 | + mystring += carbValue + " g carbs "; |
| 399 | + } |
396 | 400 | if (nonzeroInsulin1Value && (insulinProfile1 != null)) |
397 | 401 | { |
398 | 402 | double d = Double.parseDouble(getValue("insulin-1")); |
|
0 commit comments