From 4a4a1e25df99941acc60332a4e5d8ac65a187540 Mon Sep 17 00:00:00 2001 From: cpfeiffer Date: Sat, 8 Apr 2017 23:16:33 +0200 Subject: [PATCH] Properly format the sleep goal as a duration, not as a time Also suppress trailing zeros, e.g. display 8h instead of 8h 0m --- .../gadgetbridge/activities/charts/WeekSleepChartFragment.java | 2 +- .../freeyourgadget/gadgetbridge/util/DateTimeUtils.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/WeekSleepChartFragment.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/WeekSleepChartFragment.java index 29ef5a969..f0ea551fe 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/WeekSleepChartFragment.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/WeekSleepChartFragment.java @@ -44,7 +44,7 @@ public class WeekSleepChartFragment extends AbstractWeekChartFragment { @Override String getPieDescription(int targetValue) { - return getString(R.string.weeksleepchart_today_sleep_description, DateTimeUtils.minutesToHHMM(targetValue)); + return getString(R.string.weeksleepchart_today_sleep_description, DateTimeUtils.formatDurationHoursMinutes(targetValue, TimeUnit.MINUTES)); } @Override diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/DateTimeUtils.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/DateTimeUtils.java index c0d6d8e19..068024b32 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/DateTimeUtils.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/DateTimeUtils.java @@ -54,7 +54,7 @@ public class DateTimeUtils { DurationFormatter df = DurationFormatter.Builder.SYMBOLS .maximum(TimeUnit.DAYS) .minimum(TimeUnit.MINUTES) - .suppressZeros(DurationFormatter.SuppressZeros.LEADING) + .suppressZeros(DurationFormatter.SuppressZeros.LEADING, DurationFormatter.SuppressZeros.TRAILING) .maximumAmountOfUnitsToShow(2) .build(); return df.format(duration, unit);