Fix outgoing message layout

This commit is contained in:
nielsandriesse 2021-06-01 14:28:14 +10:00
parent 7f3b714401
commit e177fc4689
3 changed files with 16 additions and 8 deletions

View File

@ -30,11 +30,8 @@ class ControlMessageView : LinearLayout {
// region Updating
fun bind(message: MessageRecord) {
// TODO: Localize strings, make the view look better, handle closed group control messages
if (message.isExpirationTimerUpdate) { textView.text = "Expiration timer update" }
else if (message.isScreenshotNotification) { textView.text = "Screenshot notification" }
else if (message.isMediaSavedNotification) { textView.text = "Media saved notification" }
else { textView.text = "Control message not yet handled" }
// TODO: Make view look better
textView.text = message.getDisplayBody(context)
}
fun recycle() {

View File

@ -2,8 +2,10 @@ package org.thoughtcrime.securesms.conversation.v2.messages
import android.content.Context
import android.util.AttributeSet
import android.view.Gravity
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.LinearLayout
import kotlinx.android.synthetic.main.view_visible_message.view.*
import network.loki.messenger.R
@ -28,6 +30,7 @@ class VisibleMessageView : LinearLayout {
private fun setUpViewHierarchy() {
LayoutInflater.from(context).inflate(R.layout.view_visible_message, this)
layoutParams = ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
}
// endregion
@ -40,8 +43,9 @@ class VisibleMessageView : LinearLayout {
val thread = threadDB.getRecipientForThreadId(threadID)
val contactDB = DatabaseFactory.getSessionContactDatabase(context)
val isGroupThread = (thread?.isGroupRecipient == true)
// Show profile picture and sender name if this is a group thread
if (isGroupThread) {
// Show profile picture and sender name if this is a group thread AND
// the message is incoming
if (isGroupThread && !message.isOutgoing) {
profilePictureContainer.visibility = View.VISIBLE
profilePictureView.publicKey = senderSessionID
// TODO: Set glide on the profile picture view and update it
@ -53,6 +57,13 @@ class VisibleMessageView : LinearLayout {
profilePictureContainer.visibility = View.GONE
senderNameTextView.visibility = View.GONE
}
// Margins
val messageContentViewLayoutParams = messageContentView.layoutParams as LinearLayout.LayoutParams
messageContentViewLayoutParams.leftMargin = if (message.isOutgoing) resources.getDimension(R.dimen.very_large_spacing).toInt() else 0
messageContentViewLayoutParams.rightMargin = if (message.isOutgoing) 0 else resources.getDimension(R.dimen.very_large_spacing).toInt()
messageContentView.layoutParams = messageContentViewLayoutParams
// Gravity
gravity = if (message.isOutgoing) Gravity.RIGHT else Gravity.LEFT
// Populate content view
messageContentView.bind(message)
}

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="bottom">