Add date breaks

This commit is contained in:
nielsandriesse 2021-06-07 16:06:37 +10:00
parent 2b21f199ea
commit 7e6cd7c86f
3 changed files with 7 additions and 6 deletions

View File

@ -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)!!
}

View File

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

View File

@ -103,7 +103,7 @@
<dimen name="conversation_individual_left_gutter">@dimen/large_spacing</dimen>
<dimen name="conversation_group_left_gutter">60dp</dimen>
<dimen name="conversation_vertical_message_spacing_default">8dp</dimen>
<dimen name="conversation_vertical_message_spacing_collapse">1dp</dimen>
<dimen name="conversation_vertical_message_spacing_collapse">1px</dimen>
<dimen name="conversation_item_avatar_size">36dp</dimen>