diff --git a/android_app/app/src/main/java/com/health/openscale/gui/fragments/OverviewFragment.java b/android_app/app/src/main/java/com/health/openscale/gui/fragments/OverviewFragment.java index 6b4dc187..9cac71a3 100644 --- a/android_app/app/src/main/java/com/health/openscale/gui/fragments/OverviewFragment.java +++ b/android_app/app/src/main/java/com/health/openscale/gui/fragments/OverviewFragment.java @@ -54,7 +54,7 @@ import com.health.openscale.gui.views.WeightMeasurementView; import java.text.DateFormat; import java.util.ArrayList; -import java.util.Calendar; +import java.util.Date; import java.util.List; import lecho.lib.hellocharts.formatter.SimpleLineChartValueFormatter; @@ -255,12 +255,7 @@ public class OverviewFragment extends Fragment implements FragmentUpdateListener max_i = scaleDataList.size(); } - Calendar histDate = Calendar.getInstance(); - Calendar lastDate = Calendar.getInstance(); - - if (!scaleDataList.isEmpty()) { - lastDate.setTime(scaleDataList.get(0).getDateTime()); - } + Date now = new Date(); scaleDataLastDays = new ArrayList(); @@ -285,11 +280,9 @@ public class OverviewFragment extends Fragment implements FragmentUpdateListener if (histData.getBone() != 0.0f) valuesBone.add(new PointValue(i, histData.getBone())); - histDate.setTime(histData.getDateTime()); - - long days = 0 - daysBetween(lastDate, histDate); - - axisValues.add(new AxisValue(i, String.format("%d " + getResources().getString(R.string.label_days), days).toCharArray())); + int days = daysBetween(now, histData.getDateTime()); + String label = getResources().getQuantityString(R.plurals.label_days, Math.abs(days), days); + axisValues.add(new AxisValue(i, label.toCharArray())); } Line lineWeight = new Line(valuesWeight). @@ -428,8 +421,9 @@ public class OverviewFragment extends Fragment implements FragmentUpdateListener pieChartLast.setPieChartData(pieChartData); } - private long daysBetween(Calendar startDate, Calendar endDate) { - return startDate.get(Calendar.DAY_OF_YEAR) - endDate.get(Calendar.DAY_OF_YEAR); + private int daysBetween(Date startDate, Date endDate) { + final float msPerDay = 24 * 60 * 60 * 1000; + return Math.round((endDate.getTime() - startDate.getTime()) / msPerDay); } public void btnOnClickInsertData() diff --git a/android_app/app/src/main/java/com/health/openscale/gui/fragments/StatisticsFragment.java b/android_app/app/src/main/java/com/health/openscale/gui/fragments/StatisticsFragment.java index 276c2549..f4c6aad3 100644 --- a/android_app/app/src/main/java/com/health/openscale/gui/fragments/StatisticsFragment.java +++ b/android_app/app/src/main/java/com/health/openscale/gui/fragments/StatisticsFragment.java @@ -34,7 +34,7 @@ import com.health.openscale.core.datatypes.ScaleUser; import java.text.DateFormat; import java.util.ArrayList; import java.util.Calendar; -import java.util.concurrent.TimeUnit; +import java.util.Date; public class StatisticsFragment extends Fragment implements FragmentUpdateListener { @@ -99,7 +99,7 @@ public class StatisticsFragment extends Fragment implements FragmentUpdateListen txtTitleStatistics.setText(getResources().getString(R.string.label_title_statistics).toUpperCase()); prefs = PreferenceManager.getDefaultSharedPreferences(statisticsView.getContext()); - currentScaleUser = OpenScale.getInstance(getContext()).getSelectedScaleUser(); + currentScaleUser = OpenScale.getInstance(getContext()).getSelectedScaleUser(); updateStatistics(scaleDataList); updateGoal(scaleDataList); @@ -114,12 +114,8 @@ public class StatisticsFragment extends Fragment implements FragmentUpdateListen double weight_diff = goalScaleData.getConvertedWeight(currentScaleUser.scale_unit) - lastScaleData.getConvertedWeight(currentScaleUser.scale_unit); txtGoalDiff.setText(String.format("%.1f " + ScaleUser.UNIT_STRING[currentScaleUser.scale_unit], weight_diff)); - Calendar goalDate = Calendar.getInstance(); - Calendar curDate = Calendar.getInstance(); - goalDate.setTime(currentScaleUser.goal_date); - - long days = daysBetween(curDate, goalDate); - txtGoalDayLeft.setText(days + " " + getResources().getString(R.string.label_days)); + int days = Math.max(0, daysBetween(new Date(), currentScaleUser.goal_date)); + txtGoalDayLeft.setText(getResources().getQuantityString(R.plurals.label_days, days, days)); lastScaleData.setUserId(currentScaleUser.id); @@ -335,9 +331,8 @@ public class StatisticsFragment extends Fragment implements FragmentUpdateListen txtAvgMonth.setText(monthSize + " " + getResources().getString(R.string.label_measures)); } - private long daysBetween(Calendar startDate, Calendar endDate) { - long end = endDate.getTimeInMillis(); - long start = startDate.getTimeInMillis(); - return TimeUnit.MILLISECONDS.toDays(Math.abs(end - start)); + private int daysBetween(Date startDate, Date endDate) { + final float msPerDay = 24 * 60 * 60 * 1000; + return (int)Math.ceil((endDate.getTime() - startDate.getTime()) / msPerDay); } } diff --git a/android_app/app/src/main/res/values-de/strings.xml b/android_app/app/src/main/res/values-de/strings.xml index 69943f6a..1b8df397 100644 --- a/android_app/app/src/main/res/values-de/strings.xml +++ b/android_app/app/src/main/res/values-de/strings.xml @@ -36,7 +36,10 @@ Körpergröße Kommentar Datum - Tage + + %d Tag + %d Tage + Tage übrig Löschen Alles löschen diff --git a/android_app/app/src/main/res/values-es/strings.xml b/android_app/app/src/main/res/values-es/strings.xml index aa468726..81621e74 100644 --- a/android_app/app/src/main/res/values-es/strings.xml +++ b/android_app/app/src/main/res/values-es/strings.xml @@ -38,7 +38,10 @@ Masa ósea Asignación inteligente de usuario - días + + %d día + %d días + medidas Últimos 7 días Últimos 30 días diff --git a/android_app/app/src/main/res/values-fr/strings.xml b/android_app/app/src/main/res/values-fr/strings.xml index 35cd961f..8988b076 100644 --- a/android_app/app/src/main/res/values-fr/strings.xml +++ b/android_app/app/src/main/res/values-fr/strings.xml @@ -33,7 +33,10 @@ Rapport taille-hanches Affectation intelligente de l\'Utilisateur - jours + + %d jour + %d jours + mesures 7 derniers jours 30 derniers jours diff --git a/android_app/app/src/main/res/values-ja/strings.xml b/android_app/app/src/main/res/values-ja/strings.xml index fd95cb3f..829998e8 100644 --- a/android_app/app/src/main/res/values-ja/strings.xml +++ b/android_app/app/src/main/res/values-ja/strings.xml @@ -23,7 +23,9 @@ 身長 キャンセル コメント - + + %d 日 + 期日 デリート レコードのエクスポート diff --git a/android_app/app/src/main/res/values-pl/strings.xml b/android_app/app/src/main/res/values-pl/strings.xml index 56228709..6cbae2b5 100644 --- a/android_app/app/src/main/res/values-pl/strings.xml +++ b/android_app/app/src/main/res/values-pl/strings.xml @@ -36,7 +36,9 @@ Masa kostna Inteligente przypisywanie użytkowników - dni + + %d dni + pomiarów Ostatnie 7 dni Ostatnie 30 dni diff --git a/android_app/app/src/main/res/values-pt/strings.xml b/android_app/app/src/main/res/values-pt/strings.xml index 962d17b4..733f1acd 100644 --- a/android_app/app/src/main/res/values-pt/strings.xml +++ b/android_app/app/src/main/res/values-pt/strings.xml @@ -69,7 +69,9 @@ Cancelar Comentário Data - dias + + %d dias + Dias restantes Deletar Deletar tudo diff --git a/android_app/app/src/main/res/values-sk/strings.xml b/android_app/app/src/main/res/values-sk/strings.xml index 9a7b7292..c24f70cb 100644 --- a/android_app/app/src/main/res/values-sk/strings.xml +++ b/android_app/app/src/main/res/values-sk/strings.xml @@ -31,7 +31,9 @@ Pomer pásu a bokov Hmotnosť kostí Chytré priradenie používateľa - dni + + %d dni + merania Posledných 7 dní Posledných 30 dní diff --git a/android_app/app/src/main/res/values-sv/strings.xml b/android_app/app/src/main/res/values-sv/strings.xml index fc6c5c62..6e44683e 100644 --- a/android_app/app/src/main/res/values-sv/strings.xml +++ b/android_app/app/src/main/res/values-sv/strings.xml @@ -60,7 +60,10 @@ Dagar kvar Måldatum är Viktskillnad - dagar + + %d dag + %d dagar + mätningar Senast 7 dagarna Senast 30 dagarna diff --git a/android_app/app/src/main/res/values-tr/strings.xml b/android_app/app/src/main/res/values-tr/strings.xml index f7fea94b..efb1415b 100644 --- a/android_app/app/src/main/res/values-tr/strings.xml +++ b/android_app/app/src/main/res/values-tr/strings.xml @@ -37,7 +37,9 @@ Kemik kütlesi Akýllý kullanýcý atamasý - Günler + + %d Günler + Ölçüler Son 7 Gün Son 30 Gün diff --git a/android_app/app/src/main/res/values/strings.xml b/android_app/app/src/main/res/values/strings.xml index 5d2baf0d..d4177fa8 100644 --- a/android_app/app/src/main/res/values/strings.xml +++ b/android_app/app/src/main/res/values/strings.xml @@ -38,7 +38,10 @@ Bone mass Smart User assignment - days + + %d day + %d days + measures Last 7 days Last 30 days