show full date in message list, fixed #328

This commit is contained in:
iNPUTmice 2014-09-21 23:16:23 +02:00
parent 98a8fd4d05
commit 1f91ed11fa
2 changed files with 20 additions and 4 deletions

View File

@ -168,7 +168,7 @@ public class MessageAdapter extends ArrayAdapter<Message> {
viewHolder.indicator.setVisibility(View.VISIBLE); viewHolder.indicator.setVisibility(View.VISIBLE);
} }
String formatedTime = UIHelper.readableTimeDifference(getContext(), String formatedTime = UIHelper.readableTimeDifferenceFull(getContext(),
message.getMergedTimeSent()); message.getMergedTimeSent());
if (message.getStatus() <= Message.STATUS_RECEIVED) { if (message.getStatus() <= Message.STATUS_RECEIVED) {
if ((filesize != null) && (info != null)) { if ((filesize != null) && (info != null)) {

View File

@ -51,10 +51,21 @@ public class UIHelper {
private static final int BG_COLOR = 0xFF181818; private static final int BG_COLOR = 0xFF181818;
private static final int FG_COLOR = 0xFFFAFAFA; private static final int FG_COLOR = 0xFFFAFAFA;
private static final int TRANSPARENT = 0x00000000; private static final int TRANSPARENT = 0x00000000;
private static final int DATE_NO_YEAR_FLAGS = DateUtils.FORMAT_SHOW_DATE private static final int SHORT_DATE_FLAGS = DateUtils.FORMAT_SHOW_DATE
| DateUtils.FORMAT_NO_YEAR | DateUtils.FORMAT_ABBREV_ALL; | DateUtils.FORMAT_NO_YEAR | DateUtils.FORMAT_ABBREV_ALL;
private static final int FULL_DATE_FLAGS = DateUtils.FORMAT_SHOW_TIME
| DateUtils.FORMAT_ABBREV_ALL | DateUtils.FORMAT_SHOW_DATE;
public static String readableTimeDifference(Context context, long time) { public static String readableTimeDifference(Context context, long time) {
return readableTimeDifference(context, time, false);
}
public static String readableTimeDifferenceFull(Context context, long time) {
return readableTimeDifference(context, time, true);
}
private static String readableTimeDifference(Context context, long time,
boolean fullDate) {
if (time == 0) { if (time == 0) {
return context.getString(R.string.just_now); return context.getString(R.string.just_now);
} }
@ -71,8 +82,13 @@ public class UIHelper {
java.text.DateFormat df = DateFormat.getTimeFormat(context); java.text.DateFormat df = DateFormat.getTimeFormat(context);
return df.format(date); return df.format(date);
} else { } else {
return DateUtils.formatDateTime(context, date.getTime(), if (fullDate) {
DATE_NO_YEAR_FLAGS); return DateUtils.formatDateTime(context, date.getTime(),
FULL_DATE_FLAGS);
} else {
return DateUtils.formatDateTime(context, date.getTime(),
SHORT_DATE_FLAGS);
}
} }
} }