File tree Expand file tree Collapse file tree 2 files changed +7
-21
lines changed
app/src/main/kotlin/com/wire/android Expand file tree Collapse file tree 2 files changed +7
-21
lines changed Original file line number Diff line number Diff line change @@ -27,7 +27,6 @@ private const val ONE_MINUTE_FROM_MILLIS = 60 * 1000
2727private const val THIRTY_MINUTES = 30
2828private const val ONE_WEEK_IN_DAYS = 7
2929private const val ONE_DAY = 1
30- private const val FORTY_FIVE_MINUTES_DIFFERENCE = 45
3130private const val MINIMUM_DAYS_DIFFERENCE = 1
3231
3332fun String.shouldDisplayDatesDifferenceDivider (previousDate : String ): Boolean {
@@ -36,17 +35,12 @@ fun String.shouldDisplayDatesDifferenceDivider(previousDate: String): Boolean {
3635 val currentLocalDateTime = currentDate.serverDate()?.toInstant()?.atZone(ZoneId .systemDefault())?.toLocalDateTime()
3736 val previousLocalDateTime = previousDate.serverDate()?.toInstant()?.atZone(ZoneId .systemDefault())?.toLocalDateTime()
3837
39- val differenceInMinutes = ChronoUnit .MINUTES .between(
40- currentLocalDateTime,
41- previousLocalDateTime
42- )
43-
4438 val differenceInDays = ChronoUnit .DAYS .between(
4539 currentLocalDateTime,
4640 previousLocalDateTime
4741 )
4842
49- return differenceInMinutes > FORTY_FIVE_MINUTES_DIFFERENCE || differenceInDays >= MINIMUM_DAYS_DIFFERENCE
43+ return differenceInDays >= MINIMUM_DAYS_DIFFERENCE
5044}
5145
5246fun String.groupedUIMessageDateTime (now : Long ): MessageDateTimeGroup ? = this
Original file line number Diff line number Diff line change @@ -1342,39 +1342,31 @@ private fun MessageGroupDateTime(
13421342
13431343 is MessageDateTimeGroup .Daily -> {
13441344 when (messageDateTimeGroup.type) {
1345- MessageDateTimeGroup .Daily .Type .Today -> DateUtils .getRelativeDateTimeString(
1346- context,
1347- messageDateTime.time,
1348- DateUtils .DAY_IN_MILLIS ,
1349- DateUtils .DAY_IN_MILLIS ,
1350- 0
1351- ).toString()
1352-
1345+ MessageDateTimeGroup .Daily .Type .Today ,
13531346 MessageDateTimeGroup .Daily .Type .Yesterday ->
1354- DateUtils .getRelativeDateTimeString(
1355- context,
1347+ DateUtils .getRelativeTimeSpanString(
13561348 messageDateTime.time,
1349+ now,
13571350 DateUtils .DAY_IN_MILLIS ,
1358- DateUtils .DAY_IN_MILLIS * 2 ,
13591351 0
13601352 ).toString()
13611353
13621354 MessageDateTimeGroup .Daily .Type .WithinWeek -> DateUtils .formatDateTime(
13631355 context,
13641356 messageDateTime.time,
1365- DateUtils .FORMAT_SHOW_WEEKDAY or DateUtils .FORMAT_SHOW_DATE or DateUtils . FORMAT_SHOW_TIME
1357+ DateUtils .FORMAT_SHOW_WEEKDAY or DateUtils .FORMAT_SHOW_DATE
13661358 )
13671359
13681360 MessageDateTimeGroup .Daily .Type .NotWithinWeekButSameYear -> DateUtils .formatDateTime(
13691361 context,
13701362 messageDateTime.time,
1371- DateUtils .FORMAT_SHOW_DATE or DateUtils .FORMAT_SHOW_TIME
1363+ DateUtils .FORMAT_SHOW_WEEKDAY or DateUtils .FORMAT_SHOW_DATE
13721364 )
13731365
13741366 MessageDateTimeGroup .Daily .Type .Other -> DateUtils .formatDateTime(
13751367 context,
13761368 messageDateTime.time,
1377- DateUtils .FORMAT_SHOW_DATE or DateUtils .FORMAT_SHOW_YEAR or DateUtils .FORMAT_SHOW_TIME
1369+ DateUtils .FORMAT_SHOW_DATE or DateUtils .FORMAT_SHOW_DATE or DateUtils .FORMAT_SHOW_YEAR
13781370 )
13791371 }
13801372 }
You can’t perform that action at this time.
0 commit comments