From a966623db2db1febd35819ac327296fbac8d3fe5 Mon Sep 17 00:00:00 2001 From: ceokot Date: Mon, 6 Dec 2021 06:07:46 +0200 Subject: [PATCH] Add conversation constants file --- .../securesms/conversation/v2/ConversationConstants.kt | 5 +++++ .../securesms/conversation/v2/messages/ControlMessageView.kt | 3 ++- .../securesms/conversation/v2/messages/VisibleMessageView.kt | 4 ++-- 3 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationConstants.kt diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationConstants.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationConstants.kt new file mode 100644 index 0000000000..9e893ef89f --- /dev/null +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationConstants.kt @@ -0,0 +1,5 @@ +package org.thoughtcrime.securesms.conversation.v2 + +object ConversationConstants { + const val MAX_TIME_BETWEEN_BREAKS = 5 * 60 * 1000L // 5 minutes +} \ No newline at end of file diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/ControlMessageView.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/ControlMessageView.kt index 75f5af85f6..76215040d2 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/ControlMessageView.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/ControlMessageView.kt @@ -10,6 +10,7 @@ import androidx.core.view.isVisible import androidx.recyclerview.widget.RecyclerView import kotlinx.android.synthetic.main.view_control_message.view.* import network.loki.messenger.R +import org.thoughtcrime.securesms.conversation.v2.ConversationConstants.MAX_TIME_BETWEEN_BREAKS import org.thoughtcrime.securesms.database.model.MessageRecord import org.thoughtcrime.securesms.util.DateUtils import java.util.Locale @@ -29,7 +30,7 @@ class ControlMessageView : LinearLayout { // region Updating fun bind(message: MessageRecord, previous: MessageRecord?) { - val showDateBreak = (previous == null || message.timestamp - previous.timestamp > VisibleMessageView.maxTimeBetweenBreaks) + val showDateBreak = (previous == null || message.timestamp - previous.timestamp > MAX_TIME_BETWEEN_BREAKS) dateBreakTextView.isVisible = showDateBreak dateBreakTextView.text = if (showDateBreak) DateUtils.getDisplayFormattedTimeSpanString(context, Locale.getDefault(), message.timestamp) else "" iconImageView.visibility = View.GONE 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 521a249e06..64db47c5f5 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 @@ -25,6 +25,7 @@ import org.session.libsession.messaging.open_groups.OpenGroupAPIV2 import org.session.libsession.utilities.ViewUtil import org.session.libsignal.utilities.ThreadUtils import org.thoughtcrime.securesms.ApplicationContext +import org.thoughtcrime.securesms.conversation.v2.ConversationConstants.MAX_TIME_BETWEEN_BREAKS import org.thoughtcrime.securesms.database.* import org.thoughtcrime.securesms.database.model.MessageRecord import org.thoughtcrime.securesms.home.UserDetailsBottomSheet @@ -69,7 +70,6 @@ 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 @@ -120,7 +120,7 @@ class VisibleMessageView : LinearLayout { senderNameTextView.visibility = View.GONE } // Date break - val showDateBreak = (previous == null || message.timestamp - previous.timestamp > maxTimeBetweenBreaks) + val showDateBreak = (previous == null || message.timestamp - previous.timestamp > MAX_TIME_BETWEEN_BREAKS) dateBreakTextView.isVisible = showDateBreak dateBreakTextView.text = if (showDateBreak) DateUtils.getDisplayFormattedTimeSpanString(context, Locale.getDefault(), message.timestamp) else "" // Timestamp