Fixed date with previous year in chat
This commit is contained in:
parent
62547b8c02
commit
867183fd28
4 changed files with 6 additions and 5 deletions
|
@ -135,7 +135,7 @@ class CallLogsListAdapter(
|
||||||
} else if (TimestampUtils.isYesterday(date)) {
|
} else if (TimestampUtils.isYesterday(date)) {
|
||||||
return context.getString(R.string.yesterday)
|
return context.getString(R.string.yesterday)
|
||||||
}
|
}
|
||||||
return TimestampUtils.toString(date, onlyDate = true, shortDate = false)
|
return TimestampUtils.toString(date, onlyDate = true, shortDate = false, hideYear = false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -93,7 +93,7 @@ class CallLogViewModel(val callLog: CallLog) : GenericContactViewModel(callLog.r
|
||||||
}
|
}
|
||||||
|
|
||||||
val date: String by lazy {
|
val date: String by lazy {
|
||||||
TimestampUtils.toString(callLog.startDate, shortDate = false)
|
TimestampUtils.toString(callLog.startDate, shortDate = false, hideYear = false)
|
||||||
}
|
}
|
||||||
|
|
||||||
val startCallEvent: MutableLiveData<Event<Address>> by lazy {
|
val startCallEvent: MutableLiveData<Event<Address>> by lazy {
|
||||||
|
|
|
@ -131,7 +131,7 @@ class RecordingsListAdapter(
|
||||||
} else if (TimestampUtils.isYesterday(date, false)) {
|
} else if (TimestampUtils.isYesterday(date, false)) {
|
||||||
return context.getString(R.string.yesterday)
|
return context.getString(R.string.yesterday)
|
||||||
}
|
}
|
||||||
return TimestampUtils.toString(date, onlyDate = true, timestampInSecs = false, shortDate = false)
|
return TimestampUtils.toString(date, onlyDate = true, timestampInSecs = false, shortDate = false, hideYear = false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,8 @@ class TimestampUtils {
|
||||||
timestamp: Long,
|
timestamp: Long,
|
||||||
onlyDate: Boolean = false,
|
onlyDate: Boolean = false,
|
||||||
timestampInSecs: Boolean = true,
|
timestampInSecs: Boolean = true,
|
||||||
shortDate: Boolean = true
|
shortDate: Boolean = true,
|
||||||
|
hideYear: Boolean = true
|
||||||
): String {
|
): String {
|
||||||
val dateFormat = if (isToday(timestamp, timestampInSecs)) {
|
val dateFormat = if (isToday(timestamp, timestampInSecs)) {
|
||||||
DateFormat.getTimeInstance(DateFormat.SHORT)
|
DateFormat.getTimeInstance(DateFormat.SHORT)
|
||||||
|
@ -76,7 +77,7 @@ class TimestampUtils {
|
||||||
}
|
}
|
||||||
} as SimpleDateFormat
|
} as SimpleDateFormat
|
||||||
|
|
||||||
if (isSameYear(timestamp, timestampInSecs)) {
|
if (hideYear || isSameYear(timestamp, timestampInSecs)) {
|
||||||
// Remove the year part of the format
|
// Remove the year part of the format
|
||||||
dateFormat.applyPattern(
|
dateFormat.applyPattern(
|
||||||
dateFormat.toPattern().replace("/?y+/?|,?\\s?y+\\s?".toRegex(), if (shortDate) "" else " ")
|
dateFormat.toPattern().replace("/?y+/?|,?\\s?y+\\s?".toRegex(), if (shortDate) "" else " ")
|
||||||
|
|
Loading…
Reference in a new issue