Condensed date/time format

pull/214/head
M66B 2 years ago
parent 73752804a3
commit 5eb1e7902c

@ -1462,8 +1462,11 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
message.totalSize != null && ("size".equals(sort) || "attachments".equals(sort)) message.totalSize != null && ("size".equals(sort) || "attachments".equals(sort))
? View.VISIBLE : View.GONE); ? View.VISIBLE : View.GONE);
SpannableStringBuilder time; SpannableStringBuilder time;
if (date_time) if (EntityMessage.PRIORITIY_HIGH.equals(message.importance) ||
time = new SpannableStringBuilderEx(Helper.getRelativeDateTimeSpanString(context, message.received)); EntityMessage.PRIORITIY_LOW.equals(message.importance))
time = new SpannableStringBuilderEx(Helper.getRelativeDateTimeSpanString(context, message.received, true));
else if (date_time)
time = new SpannableStringBuilderEx(Helper.getRelativeDateTimeSpanString(context, message.received, false));
else if (date_week) else if (date_week)
time = new SpannableStringBuilderEx(Helper.getRelativeDateSpanString(context, message.received)); time = new SpannableStringBuilderEx(Helper.getRelativeDateSpanString(context, message.received));
else else

@ -2256,18 +2256,18 @@ public class Helper {
} }
static CharSequence getRelativeDateSpanString(Context context, long millis) { static CharSequence getRelativeDateSpanString(Context context, long millis) {
return getRelativeTimeSpanString(context, millis, false, true); return getRelativeTimeSpanString(context, millis, false, true, false);
} }
static CharSequence getRelativeTimeSpanString(Context context, long millis) { static CharSequence getRelativeTimeSpanString(Context context, long millis) {
return getRelativeTimeSpanString(context, millis, true, false); return getRelativeTimeSpanString(context, millis, true, false, false);
} }
static CharSequence getRelativeDateTimeSpanString(Context context, long millis) { static CharSequence getRelativeDateTimeSpanString(Context context, long millis, boolean condensed) {
return getRelativeTimeSpanString(context, millis, true, true); return getRelativeTimeSpanString(context, millis, true, true, condensed);
} }
private static CharSequence getRelativeTimeSpanString(Context context, long millis, boolean withTime, boolean withDate) { private static CharSequence getRelativeTimeSpanString(Context context, long millis, boolean withTime, boolean withDate, boolean condensed) {
Calendar cal0 = Calendar.getInstance(); Calendar cal0 = Calendar.getInstance();
Calendar cal1 = Calendar.getInstance(); Calendar cal1 = Calendar.getInstance();
cal0.setTimeInMillis(millis); cal0.setTimeInMillis(millis);
@ -2277,7 +2277,9 @@ public class Helper {
boolean thisDay = (cal0.get(Calendar.DAY_OF_MONTH) == cal1.get(Calendar.DAY_OF_MONTH)); boolean thisDay = (cal0.get(Calendar.DAY_OF_MONTH) == cal1.get(Calendar.DAY_OF_MONTH));
if (withDate) { if (withDate) {
try { try {
String skeleton = (thisMonth && thisYear ? "MMM-d" : "yyyy-M-d"); if (condensed && thisYear && thisMonth && thisDay)
return getTimeInstance(context, SimpleDateFormat.SHORT).format(millis);
String skeleton = (thisYear ? "MMM-d" : "yyyy-M-d");
if (withTime) { if (withTime) {
boolean is24Hour = android.text.format.DateFormat.is24HourFormat(context); boolean is24Hour = android.text.format.DateFormat.is24HourFormat(context);
skeleton += (is24Hour ? " Hm" : " hm"); skeleton += (is24Hour ? " Hm" : " hm");

Loading…
Cancel
Save