mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-28 04:25:18 +00:00
Fix outgoing message layout
This commit is contained in:
parent
7f3b714401
commit
e177fc4689
@ -30,11 +30,8 @@ class ControlMessageView : LinearLayout {
|
|||||||
|
|
||||||
// region Updating
|
// region Updating
|
||||||
fun bind(message: MessageRecord) {
|
fun bind(message: MessageRecord) {
|
||||||
// TODO: Localize strings, make the view look better, handle closed group control messages
|
// TODO: Make view look better
|
||||||
if (message.isExpirationTimerUpdate) { textView.text = "Expiration timer update" }
|
textView.text = message.getDisplayBody(context)
|
||||||
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" }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun recycle() {
|
fun recycle() {
|
||||||
|
@ -2,8 +2,10 @@ package org.thoughtcrime.securesms.conversation.v2.messages
|
|||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
|
import android.view.Gravity
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import kotlinx.android.synthetic.main.view_visible_message.view.*
|
import kotlinx.android.synthetic.main.view_visible_message.view.*
|
||||||
import network.loki.messenger.R
|
import network.loki.messenger.R
|
||||||
@ -28,6 +30,7 @@ class VisibleMessageView : LinearLayout {
|
|||||||
|
|
||||||
private fun setUpViewHierarchy() {
|
private fun setUpViewHierarchy() {
|
||||||
LayoutInflater.from(context).inflate(R.layout.view_visible_message, this)
|
LayoutInflater.from(context).inflate(R.layout.view_visible_message, this)
|
||||||
|
layoutParams = ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
|
||||||
}
|
}
|
||||||
// endregion
|
// endregion
|
||||||
|
|
||||||
@ -40,8 +43,9 @@ class VisibleMessageView : LinearLayout {
|
|||||||
val thread = threadDB.getRecipientForThreadId(threadID)
|
val thread = threadDB.getRecipientForThreadId(threadID)
|
||||||
val contactDB = DatabaseFactory.getSessionContactDatabase(context)
|
val contactDB = DatabaseFactory.getSessionContactDatabase(context)
|
||||||
val isGroupThread = (thread?.isGroupRecipient == true)
|
val isGroupThread = (thread?.isGroupRecipient == true)
|
||||||
// Show profile picture and sender name if this is a group thread
|
// Show profile picture and sender name if this is a group thread AND
|
||||||
if (isGroupThread) {
|
// the message is incoming
|
||||||
|
if (isGroupThread && !message.isOutgoing) {
|
||||||
profilePictureContainer.visibility = View.VISIBLE
|
profilePictureContainer.visibility = View.VISIBLE
|
||||||
profilePictureView.publicKey = senderSessionID
|
profilePictureView.publicKey = senderSessionID
|
||||||
// TODO: Set glide on the profile picture view and update it
|
// TODO: Set glide on the profile picture view and update it
|
||||||
@ -53,6 +57,13 @@ class VisibleMessageView : LinearLayout {
|
|||||||
profilePictureContainer.visibility = View.GONE
|
profilePictureContainer.visibility = View.GONE
|
||||||
senderNameTextView.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
|
// Populate content view
|
||||||
messageContentView.bind(message)
|
messageContentView.bind(message)
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
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:layout_height="wrap_content"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:gravity="bottom">
|
android:gravity="bottom">
|
||||||
|
Loading…
Reference in New Issue
Block a user