mirror of
https://github.com/oxen-io/session-android.git
synced 2025-12-14 06:45:38 +00:00
Implement parts of the visible message view
This commit is contained in:
@@ -4,7 +4,7 @@ import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.widget.LinearLayout
|
||||
import kotlinx.android.synthetic.main.view_visible_message.view.*
|
||||
import kotlinx.android.synthetic.main.view_control_message.view.*
|
||||
import network.loki.messenger.R
|
||||
import org.thoughtcrime.securesms.database.model.MessageRecord
|
||||
|
||||
@@ -30,7 +30,11 @@ class ControlMessageView : LinearLayout {
|
||||
|
||||
// region Updating
|
||||
fun bind(message: MessageRecord) {
|
||||
testTextView.text = "Control message: ${message.body}"
|
||||
// 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" }
|
||||
}
|
||||
|
||||
fun recycle() {
|
||||
|
||||
@@ -3,9 +3,12 @@ package org.thoughtcrime.securesms.conversation.v2.messages
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.widget.LinearLayout
|
||||
import kotlinx.android.synthetic.main.view_visible_message.view.*
|
||||
import network.loki.messenger.R
|
||||
import org.session.libsession.messaging.contacts.Contact.ContactContext
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory
|
||||
import org.thoughtcrime.securesms.database.model.MessageRecord
|
||||
|
||||
class VisibleMessageView : LinearLayout {
|
||||
@@ -30,11 +33,31 @@ class VisibleMessageView : LinearLayout {
|
||||
|
||||
// region Updating
|
||||
fun bind(message: MessageRecord) {
|
||||
testTextView.text = "Visible message: ${message.body}"
|
||||
val sender = message.individualRecipient
|
||||
val senderSessionID = sender.address.serialize()
|
||||
val threadID = message.threadId
|
||||
val threadDB = DatabaseFactory.getThreadDatabase(context)
|
||||
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) {
|
||||
profilePictureContainer.visibility = View.VISIBLE
|
||||
profilePictureView.publicKey = senderSessionID
|
||||
// TODO: Set glide on the profile picture view and update it
|
||||
// TODO: Show crown if this is an open group and the user is a moderator; otherwise hide it
|
||||
senderNameTextView.visibility = View.VISIBLE
|
||||
val context = if (thread?.isOpenGroupRecipient == true) ContactContext.OPEN_GROUP else ContactContext.REGULAR
|
||||
senderNameTextView.text = contactDB.getContactWithSessionID(senderSessionID)?.displayName(context) ?: senderSessionID
|
||||
} else {
|
||||
profilePictureContainer.visibility = View.GONE
|
||||
senderNameTextView.visibility = View.GONE
|
||||
}
|
||||
// TODO: Populate content view
|
||||
}
|
||||
|
||||
fun recycle() {
|
||||
// TODO: Implement
|
||||
profilePictureView.recycle()
|
||||
}
|
||||
// endregion
|
||||
}
|
||||
Reference in New Issue
Block a user