diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/VisibleMessageContentView.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/VisibleMessageContentView.kt new file mode 100644 index 0000000000..227cebbbb4 --- /dev/null +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/VisibleMessageContentView.kt @@ -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 +} \ No newline at end of file diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/VisibleMessageView.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/VisibleMessageView.kt index 2b87668f93..07ec78dbe0 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/VisibleMessageView.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/VisibleMessageView.kt @@ -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() { diff --git a/app/src/main/res/layout/view_visible_message.xml b/app/src/main/res/layout/view_visible_message.xml index 9c7b492fa4..a638cee67b 100644 --- a/app/src/main/res/layout/view_visible_message.xml +++ b/app/src/main/res/layout/view_visible_message.xml @@ -60,12 +60,10 @@ android:maxLines="1" android:ellipsize="end" /> - + android:layout_height="wrap_content" /> diff --git a/app/src/main/res/layout/view_visible_message_content.xml b/app/src/main/res/layout/view_visible_message_content.xml new file mode 100644 index 0000000000..b829043b42 --- /dev/null +++ b/app/src/main/res/layout/view_visible_message_content.xml @@ -0,0 +1,15 @@ + + + + + + \ No newline at end of file