Add conversation constants file

This commit is contained in:
ceokot 2021-12-06 06:07:46 +02:00
parent bfe91427ab
commit a966623db2
3 changed files with 9 additions and 3 deletions

View File

@ -0,0 +1,5 @@
package org.thoughtcrime.securesms.conversation.v2
object ConversationConstants {
const val MAX_TIME_BETWEEN_BREAKS = 5 * 60 * 1000L // 5 minutes
}

View File

@ -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

View File

@ -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