From 49b164a8c52cdffa345eb252c35b88488912ebc0 Mon Sep 17 00:00:00 2001 From: Harris Date: Thu, 2 Sep 2021 09:27:23 +1000 Subject: [PATCH] feat: make date breaks more dynamic, spaced out in five minute clusters --- .../securesms/conversation/v2/messages/VisibleMessageView.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/VisibleMessageView.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/VisibleMessageView.kt index 5e5b1da220..e57ea8035b 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/VisibleMessageView.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/VisibleMessageView.kt @@ -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