Show message timestamp on select

This commit is contained in:
nielsandriesse 2021-06-08 14:06:16 +10:00
parent 9568a907fe
commit 3820b07ad8
4 changed files with 24 additions and 11 deletions

View File

@ -4,7 +4,9 @@ import android.content.Context
import android.database.Cursor
import android.graphics.drawable.ColorDrawable
import android.view.ViewGroup
import androidx.core.view.isVisible
import androidx.recyclerview.widget.RecyclerView.ViewHolder
import kotlinx.android.synthetic.main.view_visible_message.view.*
import network.loki.messenger.R
import org.thoughtcrime.securesms.conversation.v2.messages.ControlMessageView
import org.thoughtcrime.securesms.conversation.v2.messages.VisibleMessageView
@ -62,11 +64,13 @@ class ConversationAdapter(context: Context, cursor: Cursor, private val onItemPr
when (viewHolder) {
is VisibleMessageViewHolder -> {
val view = viewHolder.view
view.background = if (selectedItems.contains(message)) {
val isSelected = selectedItems.contains(message)
view.background = if (isSelected) {
ColorDrawable(context.resources.getColorWithID(R.color.accent, context.theme))
} else {
null
}
view.messageTimestampTextView.isVisible = isSelected
val position = viewHolder.adapterPosition
view.bind(message, getMessageBefore(position, cursor), getMessageAfter(position, cursor))
view.setOnClickListener { onItemPress(message, viewHolder.adapterPosition) }

View File

@ -2,7 +2,6 @@ package org.thoughtcrime.securesms.conversation.v2.messages
import android.content.Context
import android.util.AttributeSet
import android.util.Log
import android.view.Gravity
import android.view.LayoutInflater
import android.view.View
@ -67,17 +66,19 @@ class VisibleMessageView : LinearLayout {
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 ""
// Timestamp
messageTimestampTextView.text = DateUtils.getExtendedRelativeTimeSpanString(context, Locale.getDefault(), message.timestamp)
// Margins
val messageContentViewLayoutParams = messageContentView.layoutParams as LinearLayout.LayoutParams
val messageContentContainerLayoutParams = messageContentContainer.layoutParams as LinearLayout.LayoutParams
if (isGroupThread) {
messageContentViewLayoutParams.leftMargin = if (message.isOutgoing) resources.getDimension(R.dimen.very_large_spacing).toInt() else 0
messageContentContainerLayoutParams.leftMargin = if (message.isOutgoing) resources.getDimension(R.dimen.very_large_spacing).toInt() else 0
} else {
messageContentViewLayoutParams.leftMargin = if (message.isOutgoing) resources.getDimension(R.dimen.very_large_spacing).toInt()
messageContentContainerLayoutParams.leftMargin = if (message.isOutgoing) resources.getDimension(R.dimen.very_large_spacing).toInt()
else resources.getDimension(R.dimen.medium_spacing).toInt()
}
messageContentViewLayoutParams.rightMargin = if (message.isOutgoing) resources.getDimension(R.dimen.medium_spacing).toInt()
messageContentContainerLayoutParams.rightMargin = if (message.isOutgoing) resources.getDimension(R.dimen.medium_spacing).toInt()
else resources.getDimension(R.dimen.very_large_spacing).toInt()
messageContentView.layoutParams = messageContentViewLayoutParams
messageContentContainer.layoutParams = messageContentContainerLayoutParams
// Set inter-message spacing
val isStartOfMessageCluster = isStartOfMessageCluster(message, previous, isGroupThread)
val isEndOfMessageCluster = isEndOfMessageCluster(message, next, isGroupThread)

View File

@ -57,6 +57,7 @@
</LinearLayout>
<LinearLayout
android:id="@+id/messageContentContainer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
@ -76,6 +77,13 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/messageTimestampTextView"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:maxLines="1"
android:textSize="@dimen/very_small_font_size" />
</LinearLayout>
</LinearLayout>

View File

@ -7,25 +7,25 @@
android:title="@string/conversation_context__menu_reply_to_message"
android:id="@+id/menu_context_reply"
android:icon="?menu_reply_icon"
app:showAsAction="ifRoom" />
app:showAsAction="always" />
<item
android:title="@string/conversation_context_image__save_attachment"
android:id="@+id/menu_context_save_attachment"
android:icon="?menu_save_icon"
app:showAsAction="ifRoom" />
app:showAsAction="always" />
<item
android:title="@string/conversation_context__menu_delete_message"
android:id="@+id/menu_context_delete_message"
android:icon="?menu_trash_icon"
app:showAsAction="ifRoom" />
app:showAsAction="always" />
<item
android:title="@string/conversation_context__menu_copy_text"
android:id="@+id/menu_context_copy"
android:icon="?menu_copy_icon"
app:showAsAction="ifRoom" />
app:showAsAction="always" />
<item
android:title="@string/conversation_context__menu_resend_message"