ActivityStackGraph now only displays Month Day without clock.

This commit is contained in:
Rsl1122 2018-02-01 20:20:10 +02:00
parent 4d92e67caa
commit 673e0a2790
2 changed files with 15 additions and 2 deletions

View File

@ -47,6 +47,16 @@ public class FormatUtils {
return formatMilliseconds(Math.abs(after - before)); return formatMilliseconds(Math.abs(after - before));
} }
public static String formatTimeStampDay(long epochMs) {
String format = "MMMMM d";
if (Settings.FORMAT_DATE_RECENT_DAYS.isTrue()) {
format = replaceRecentDays(epochMs, format, "MMMMM");
}
return format(epochMs, format);
}
public static String formatTimeStampClock(long epochMs) { public static String formatTimeStampClock(long epochMs) {
String format = Settings.FORMAT_DATE_CLOCK.toString(); String format = Settings.FORMAT_DATE_CLOCK.toString();
@ -71,9 +81,12 @@ public class FormatUtils {
} }
private static String replaceRecentDays(long epochMs, String format) { private static String replaceRecentDays(long epochMs, String format) {
return replaceRecentDays(epochMs, format, Settings.FORMAT_DATE_RECENT_DAYS_PATTERN.toString());
}
private static String replaceRecentDays(long epochMs, String format, String pattern) {
long now = MiscUtils.getTime(); long now = MiscUtils.getTime();
String pattern = Settings.FORMAT_DATE_RECENT_DAYS_PATTERN.toString();
long fromStartOfDay = now % TimeAmount.DAY.ms(); long fromStartOfDay = now % TimeAmount.DAY.ms();
if (epochMs > now - fromStartOfDay) { if (epochMs > now - fromStartOfDay) {
format = format.replace(pattern, "'Today'"); format = format.replace(pattern, "'Today'");

View File

@ -28,7 +28,7 @@ public class ActivityStackGraph extends AbstractStackGraph {
private static String[] getLabels(NavigableSet<Long> dates) { private static String[] getLabels(NavigableSet<Long> dates) {
return dates.stream() return dates.stream()
.map(FormatUtils::formatTimeStampYear) .map(FormatUtils::formatTimeStampDay)
.toArray(String[]::new); .toArray(String[]::new);
} }