diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/AbstractChartFragment.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/AbstractChartFragment.java index 9c1aae219..3b30e7d27 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/AbstractChartFragment.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/AbstractChartFragment.java @@ -24,6 +24,7 @@ import android.content.Intent; import android.content.IntentFilter; import android.os.AsyncTask; import android.os.Bundle; +import android.text.format.DateUtils; import android.view.View; import androidx.fragment.app.FragmentActivity; @@ -381,10 +382,11 @@ public abstract class AbstractChartFragment extends Abstra } private void updateDateInfo(final Date from, final Date to) { + int dateFlags = DateUtils.FORMAT_SHOW_WEEKDAY; if (from.equals(to)) { - getChartsHost().setDateInfo(DateTimeUtils.formatDate(from)); + getChartsHost().setDateInfo(DateTimeUtils.formatDate(from, dateFlags)); } else { - getChartsHost().setDateInfo(DateTimeUtils.formatDateRange(from, to)); + getChartsHost().setDateInfo(DateTimeUtils.formatDateRange(from, to, dateFlags)); } } } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/ActivityListingChartFragment.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/ActivityListingChartFragment.java index 8e1845d98..411d7f359 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/ActivityListingChartFragment.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/ActivityListingChartFragment.java @@ -151,7 +151,7 @@ public class ActivityListingChartFragment extends AbstractActivityChartFragment< } Date activityDate = new Date(tsDateTo * 1000L); - stepsDateView.setText(DateTimeUtils.formatDate(activityDate)); + stepsDateView.setText(DateTimeUtils.formatDate(activityDate, DateUtils.FORMAT_SHOW_WEEKDAY)); if (GBApplication.getPrefs().getBoolean("charts_show_ongoing_activity", true)) { if (mcd.getOngoingSession() != null && DateUtils.isToday(activityDate.getTime())) { 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 ef9a69a54..387bbec41 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/DateTimeUtils.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/DateTimeUtils.java @@ -86,15 +86,11 @@ public class DateTimeUtils { } public static String formatDate(Date date) { - return DateUtils.formatDateTime(GBApplication.getContext(), date.getTime(), DateUtils.FORMAT_SHOW_DATE); -// long dateMillis = date.getTime(); -// if (isToday(dateMillis)) { -// return "Today"; -// } -// if (isYesterday(dateMillis)) { -// return "Yesterday"; -// } -// DateFormat.getDateInstance(DateFormat.SHORT).format(date); + return DateUtils.formatDateTime(GBApplication.getContext(), date.getTime(), DateUtils.FORMAT_SHOW_DATE|DateUtils.FORMAT_ABBREV_ALL); + } + + public static String formatDate(Date date, int extraFlags) { + return DateUtils.formatDateTime(GBApplication.getContext(), date.getTime(), DateUtils.FORMAT_SHOW_DATE|DateUtils.FORMAT_ABBREV_ALL|extraFlags); } public static String formatDurationHoursMinutes(long duration, TimeUnit unit) { @@ -108,7 +104,11 @@ public class DateTimeUtils { } public static String formatDateRange(Date from, Date to) { - return DateUtils.formatDateRange(GBApplication.getContext(), from.getTime(), to.getTime(), DateUtils.FORMAT_SHOW_DATE); + return DateUtils.formatDateRange(GBApplication.getContext(), from.getTime(), to.getTime(), DateUtils.FORMAT_SHOW_DATE|DateUtils.FORMAT_ABBREV_ALL); + } + + public static String formatDateRange(Date from, Date to, int extraFlags) { + return DateUtils.formatDateRange(GBApplication.getContext(), from.getTime(), to.getTime(), DateUtils.FORMAT_SHOW_DATE|DateUtils.FORMAT_ABBREV_ALL|extraFlags); } public static Date shiftByDays(Date date, int offset) {