From 7e6cd7c86f402b602f4b85f0e2c63a5e667074a5 Mon Sep 17 00:00:00 2001 From: nielsandriesse Date: Mon, 7 Jun 2021 16:06:37 +1000 Subject: [PATCH] Add date breaks --- .../v2/messages/VisibleMessageContentView.kt | 2 +- .../conversation/v2/messages/VisibleMessageView.kt | 9 +++++---- app/src/main/res/values/dimens.xml | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/VisibleMessageContentView.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/VisibleMessageContentView.kt index 2cf0f03b47..1c3f6f17ab 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/VisibleMessageContentView.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/VisibleMessageContentView.kt @@ -88,7 +88,7 @@ class VisibleMessageContentView : LinearLayout { } else if (isEndOfMessageCluster) { backgroundID = if (isOutgoing) R.drawable.message_bubble_background_sent_end else R.drawable.message_bubble_background_received_end } else { - backgroundID = if (isOutgoing) R.drawable.message_bubble_background_sent_middle else R.drawable.message_bubble_background_received_middle; + backgroundID = if (isOutgoing) R.drawable.message_bubble_background_sent_middle else R.drawable.message_bubble_background_received_middle } return ResourcesCompat.getDrawable(resources, backgroundID, context.theme)!! } 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 39e6c6731d..cac75f567f 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 @@ -7,15 +7,15 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.LinearLayout +import androidx.core.view.isVisible import kotlinx.android.synthetic.main.view_visible_message.view.* import network.loki.messenger.R -import nl.komponents.kovenant.combine.Tuple8 import org.session.libsession.messaging.contacts.Contact.ContactContext import org.session.libsession.utilities.ViewUtil -import org.session.libsignal.utilities.guava.Optional import org.thoughtcrime.securesms.database.DatabaseFactory import org.thoughtcrime.securesms.database.model.MessageRecord import org.thoughtcrime.securesms.util.DateUtils +import java.util.* import kotlin.math.roundToInt class VisibleMessageView : LinearLayout { @@ -63,8 +63,9 @@ class VisibleMessageView : LinearLayout { senderNameTextView.visibility = View.GONE } // Date break - dateBreakTextView.text = "The Ancient Past" - dateBreakTextView.visibility = View.GONE // TODO: Set this correctly + val showDateBreak = (previous == null || !DateUtils.isSameDay(message.timestamp, previous.timestamp)) + dateBreakTextView.isVisible = showDateBreak + dateBreakTextView.text = if (showDateBreak) DateUtils.getRelativeDate(context, Locale.getDefault(), message.timestamp) else "" // Margins val messageContentViewLayoutParams = messageContentView.layoutParams as LinearLayout.LayoutParams if (isGroupThread) { diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index 3d44675888..f614226d54 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -103,7 +103,7 @@ @dimen/large_spacing 60dp 8dp - 1dp + 1px 36dp