mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-01-10 17:11:56 +01:00
Make charts' date format more consistent
Sleep and Steps charts already have the day/way/month sub-charts that already use the "Mon, Sep 7" format. This commit attempts to make the rest of the date formatting more consistent with that format in the activity list and the base navigation bar at the bottom of all charts. Closes #2412 Signed-off-by: Linos Giannopoulos <linosgian00@gmail.com>
This commit is contained in:
parent
f6f196847b
commit
e1c245cdbd
@ -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<D extends ChartsData> 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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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())) {
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user