diff --git a/app/src/main/java/openfoodfacts/github/scrachx/openfood/models/Nutriments.java b/app/src/main/java/openfoodfacts/github/scrachx/openfood/models/Nutriments.java index 053c5b78200d..f1b3e572cbb6 100644 --- a/app/src/main/java/openfoodfacts/github/scrachx/openfood/models/Nutriments.java +++ b/app/src/main/java/openfoodfacts/github/scrachx/openfood/models/Nutriments.java @@ -332,6 +332,12 @@ private static String getValueInUnits(String stringValue, String unit) { } else if (unit.equals("µg")) { float value = Float.valueOf(stringValue); return getRoundNumber(value * 1000000); + } else if (unit.equals("l")) { + float value = Float.valueOf(stringValue); + return getRoundNumber(value / 1000); + } else if (unit.equals("cl")) { + float value = Float.valueOf(stringValue); + return getRoundNumber(value / 10); } else { return stringValue; @@ -363,7 +369,15 @@ public String getForAnyValue(float userSetServing, String unit) { float value = Float.valueOf(strValue); value = (userSetServing / 100000) * value; return getRoundNumber(value); - } else { + } else if (unit.equals("l")) { + float value = Float.valueOf(strValue); + value = (userSetServing * 10) * value; + return getRoundNumber(value); + } else if (unit.equals("cl")) { + float value = Float.valueOf(strValue); + value = (userSetServing / 10) * value; + return getRoundNumber(value); + }else { return strValue; } } diff --git a/app/src/main/java/openfoodfacts/github/scrachx/openfood/views/product/CalculateDetails.java b/app/src/main/java/openfoodfacts/github/scrachx/openfood/views/product/CalculateDetails.java index 45c939ec4b64..2e1c68297dd8 100644 --- a/app/src/main/java/openfoodfacts/github/scrachx/openfood/views/product/CalculateDetails.java +++ b/app/src/main/java/openfoodfacts/github/scrachx/openfood/views/product/CalculateDetails.java @@ -191,6 +191,12 @@ private String calculateCalories(float weight, String unit) { case "kg": weightInG = weight * 1000; break; + case "l": + weightInG = weight * 1000; + break; + case "cl": + weightInG = weight * 10; + break; default: weightInG = weight; break; diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 4f26aba226b2..aee7a949b0c1 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -67,6 +67,8 @@ g mg kg + l + cl