Add lowercase relative dates

pull/996/head
Alex Baker 5 years ago
parent ebadd01e9b
commit 974f101108

@ -90,7 +90,12 @@ public class DateUtilities {
public static String getRelativeDateTime(
Context context, long date, java.util.Locale locale, FormatStyle style) {
String day = getRelativeDay(context, date, locale, isAbbreviated(style));
return getRelativeDateTime(context, date, locale, style, false);
}
public static String getRelativeDateTime(
Context context, long date, java.util.Locale locale, FormatStyle style, boolean lowercase) {
String day = getRelativeDay(context, date, locale, isAbbreviated(style), lowercase);
if (!isNullOrEmpty(day)) {
if (Task.hasDueTime(date)) {
String time = getTimeString(context, newDateTime(date));
@ -113,7 +118,16 @@ public class DateUtilities {
long date,
java.util.Locale locale,
FormatStyle style) {
String relativeDay = getRelativeDay(context, date, locale, isAbbreviated(style));
return getRelativeDay(context, date, locale, style, false);
}
public static String getRelativeDay(
Context context,
long date,
java.util.Locale locale,
FormatStyle style,
boolean lowercase) {
String relativeDay = getRelativeDay(context, date, locale, isAbbreviated(style), lowercase);
return isNullOrEmpty(relativeDay)
? getFullDate(newDateTime(date), locale, style)
: relativeDay;
@ -139,20 +153,26 @@ public class DateUtilities {
return date.replaceAll("(?: de |, |/| )?" + year + "(?:年|년 | г\\.)?", "");
}
private static @Nullable String getRelativeDay(Context context, long date, java.util.Locale locale, boolean abbreviated) {
private static @Nullable String getRelativeDay(Context context, long date, java.util.Locale locale, boolean abbreviated, boolean lowercase) {
DateTime startOfToday = newDateTime().startOfDay();
DateTime startOfDate = newDateTime(date).startOfDay();
if (startOfToday.equals(startOfDate)) {
return context.getString(R.string.today);
return context.getString(lowercase ? R.string.today_lowercase : R.string.today);
}
if (startOfToday.plusDays(1).equals(startOfDate)) {
return context.getString(abbreviated ? R.string.tmrw : R.string.tomorrow);
return context.getString(
abbreviated
? R.string.tmrw
: lowercase ? R.string.tomorrow_lowercase : R.string.tomorrow);
}
if (startOfDate.plusDays(1).equals(startOfToday)) {
return context.getString(abbreviated ? R.string.yest : R.string.yesterday);
return context.getString(
abbreviated
? R.string.yest
: lowercase ? R.string.yesterday_lowercase : R.string.yesterday);
}
if (Math.abs(startOfToday.getMillis() - startOfDate.getMillis()) <= DateUtilities.ONE_DAY * 6) {

@ -67,7 +67,7 @@ public class RepeatConfirmationReceiver extends BroadcastReceiver {
final long newDueDate) {
String dueDateString =
DateUtilities.getRelativeDateTime(
activity, newDueDate, locale.getLocale(), FormatStyle.LONG);
activity, newDueDate, locale.getLocale(), FormatStyle.LONG, true);
taskListFragment
.makeSnackbar(R.string.repeat_snackbar, task.getTitle(), dueDateString)
.setAction(

@ -519,7 +519,7 @@ public class CustomRecurrenceDialog extends InjectingDialogFragment {
getString(
R.string.repeat_until,
DateUtilities.getRelativeDateTime(
context, repeatUntil, locale.getLocale(), FormatStyle.MEDIUM)));
context, repeatUntil, locale.getLocale(), FormatStyle.MEDIUM, true)));
repeatTimes.setVisibility(View.GONE);
repeatTimesText.setVisibility(View.GONE);
} else if (count > 0) {

@ -294,9 +294,12 @@ File %1$s contained %2$s.\n\n
<item quantity="other">%d tasks</item>
</plurals>
<string name="today">Today</string>
<string name="today_lowercase">today</string>
<string name="tomorrow">Tomorrow</string>
<string name="tomorrow_lowercase">tomorrow</string>
<string name="next">Next %s</string>
<string name="yesterday">Yesterday</string>
<string name="yesterday_lowercase">yesterday</string>
<string name="tmrw">Tmrw</string>
<string name="yest">Yest</string>
<string name="sync_SPr_interval_title">Background sync</string>

Loading…
Cancel
Save