Merge pull request #719 from hjubb/date_break_improvement

Improve date breaks in messages
This commit is contained in:
Harris 2021-09-08 04:51:30 +00:00 committed by GitHub
commit ef3d2bb28f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -59,6 +59,7 @@ class VisibleMessageView : LinearLayout {
const val longPressMovementTreshold = 10.0f // dp
const val longPressDurationThreshold = 250L // ms
const val maxDoubleTapInterval = 200L
const val maxTimeBetweenBreaks = 5 * 60 * 1000L // 5 minutes
}
// region Lifecycle
@ -111,7 +112,7 @@ class VisibleMessageView : LinearLayout {
senderNameTextView.visibility = View.GONE
}
// Date break
val showDateBreak = (previous == null || !DateUtils.isSameHour(message.timestamp, previous.timestamp))
val showDateBreak = (previous == null || message.timestamp - previous.timestamp > maxTimeBetweenBreaks)
dateBreakTextView.isVisible = showDateBreak
dateBreakTextView.text = if (showDateBreak) DateUtils.getDisplayFormattedTimeSpanString(context, Locale.getDefault(), message.timestamp) else ""
// Timestamp