mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-25 09:17:44 +00:00
Add VisibleMessageContentView
This commit is contained in:
parent
a23cfbc11d
commit
7f3b714401
@ -0,0 +1,52 @@
|
||||
package org.thoughtcrime.securesms.conversation.v2.messages
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.util.Log
|
||||
import android.view.LayoutInflater
|
||||
import android.widget.LinearLayout
|
||||
import androidx.core.content.res.ResourcesCompat
|
||||
import androidx.core.graphics.BlendModeColorFilterCompat
|
||||
import androidx.core.graphics.BlendModeCompat
|
||||
import kotlinx.android.synthetic.main.view_visible_message_content.view.*
|
||||
import network.loki.messenger.R
|
||||
import org.session.libsession.utilities.ThemeUtil
|
||||
import org.thoughtcrime.securesms.database.model.MessageRecord
|
||||
|
||||
class VisibleMessageContentView : LinearLayout {
|
||||
|
||||
// region Lifecycle
|
||||
constructor(context: Context) : super(context) {
|
||||
setUpViewHierarchy()
|
||||
}
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
|
||||
setUpViewHierarchy()
|
||||
}
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {
|
||||
setUpViewHierarchy()
|
||||
}
|
||||
|
||||
private fun setUpViewHierarchy() {
|
||||
LayoutInflater.from(context).inflate(R.layout.view_visible_message_content, this)
|
||||
}
|
||||
// endregion
|
||||
|
||||
// region Updating
|
||||
fun bind(message: MessageRecord) {
|
||||
// Background
|
||||
// TODO: Set background to one of sent/received + top/middle/bottom + color
|
||||
val background = ResourcesCompat.getDrawable(resources, R.drawable.message_bubble_background, context.theme)!!
|
||||
val colorID = if (message.isOutgoing) R.attr.message_sent_background_color else R.attr.message_received_background_color
|
||||
val color = ThemeUtil.getThemedColor(context, colorID)
|
||||
val filter = BlendModeColorFilterCompat.createBlendModeColorFilterCompat(color, BlendModeCompat.SRC_IN)
|
||||
background.colorFilter = filter
|
||||
setBackground(background)
|
||||
// Body
|
||||
bodyTextView.text = message.body
|
||||
// TODO: All the other things that can show up in a visible message, such as link previews,
|
||||
// attachments (incl. multiple at once), open group invitations, voice messages, etc.
|
||||
}
|
||||
// endregion
|
||||
}
|
@ -53,7 +53,8 @@ class VisibleMessageView : LinearLayout {
|
||||
profilePictureContainer.visibility = View.GONE
|
||||
senderNameTextView.visibility = View.GONE
|
||||
}
|
||||
// TODO: Populate content view
|
||||
// Populate content view
|
||||
messageContentView.bind(message)
|
||||
}
|
||||
|
||||
fun recycle() {
|
||||
|
@ -60,12 +60,10 @@
|
||||
android:maxLines="1"
|
||||
android:ellipsize="end" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/messageContentContainer"
|
||||
<org.thoughtcrime.securesms.conversation.v2.messages.VisibleMessageContentView
|
||||
android:id="@+id/messageContentView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:background="@drawable/message_bubble_background" />
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
15
app/src/main/res/layout/view_visible_message_content.xml
Normal file
15
app/src/main/res/layout/view_visible_message_content.xml
Normal file
@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/bodyTextView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/text"
|
||||
android:textSize="@dimen/small_font_size" />
|
||||
|
||||
</LinearLayout>
|
Loading…
x
Reference in New Issue
Block a user