Overview: display the year instead of the weekday for old chats
i.e. chats that are older than one year Change-Id: I439e78df1425eb57cf597449f09ef5549e90f9b8
This commit is contained in:
parent
c20a6b8001
commit
5e4d9c18be
|
@ -51,6 +51,10 @@ class VectorDateFormatter @Inject constructor(private val context: Context,
|
||||||
DateTimeFormatter.ofPattern(DateFormat.getBestDateTimePattern(localeProvider.current(), "EEE d MMM"))
|
DateTimeFormatter.ofPattern(DateFormat.getBestDateTimePattern(localeProvider.current(), "EEE d MMM"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val messageDayWithYearFormatter by lazy {
|
||||||
|
DateTimeFormatter.ofPattern(DateFormat.getBestDateTimePattern(localeProvider.current(), "d MMM YYYY"))
|
||||||
|
}
|
||||||
|
|
||||||
fun formatMessageHour(localDateTime: LocalDateTime): String {
|
fun formatMessageHour(localDateTime: LocalDateTime): String {
|
||||||
return messageHourFormatter.format(localDateTime)
|
return messageHourFormatter.format(localDateTime)
|
||||||
}
|
}
|
||||||
|
@ -59,6 +63,10 @@ class VectorDateFormatter @Inject constructor(private val context: Context,
|
||||||
return messageDayFormatter.format(localDateTime)
|
return messageDayFormatter.format(localDateTime)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun formatMessageDayWithYear(localDateTime: LocalDateTime): String {
|
||||||
|
return messageDayWithYearFormatter.format(localDateTime)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Formats a localized relative date time for the last 2 days, e.g, "Today, HH:MM", "Yesterday, HH:MM" or
|
* Formats a localized relative date time for the last 2 days, e.g, "Today, HH:MM", "Yesterday, HH:MM" or
|
||||||
* "2 days ago, HH:MM".
|
* "2 days ago, HH:MM".
|
||||||
|
|
|
@ -92,11 +92,14 @@ class RoomSummaryItemFactory @Inject constructor(private val displayableEventFor
|
||||||
val date = latestEvent.root.localDateTime()
|
val date = latestEvent.root.localDateTime()
|
||||||
val currentDate = DateProvider.currentLocalDateTime()
|
val currentDate = DateProvider.currentLocalDateTime()
|
||||||
val isSameDay = date.toLocalDate() == currentDate.toLocalDate()
|
val isSameDay = date.toLocalDate() == currentDate.toLocalDate()
|
||||||
|
val withinOneYear = currentDate.minusYears(1).isBefore(date)
|
||||||
latestFormattedEvent = displayableEventFormatter.format(latestEvent, roomSummary.isDirect.not())
|
latestFormattedEvent = displayableEventFormatter.format(latestEvent, roomSummary.isDirect.not())
|
||||||
latestEventTime = if (isSameDay) {
|
latestEventTime = if (isSameDay) {
|
||||||
dateFormatter.formatMessageHour(date)
|
dateFormatter.formatMessageHour(date)
|
||||||
} else {
|
} else if (withinOneYear) {
|
||||||
dateFormatter.formatMessageDay(date)
|
dateFormatter.formatMessageDay(date)
|
||||||
|
} else {
|
||||||
|
dateFormatter.formatMessageDayWithYear(date)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val typingMessage = typingHelper.getTypingMessage(roomSummary.typingUsers)
|
val typingMessage = typingHelper.getTypingMessage(roomSummary.typingUsers)
|
||||||
|
|
Loading…
Reference in New Issue