mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-26 09:47:43 +00:00
Implement parts of the visible message view
This commit is contained in:
parent
d20f81bd2e
commit
a23cfbc11d
@ -4,7 +4,7 @@ import android.content.Context
|
|||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.widget.LinearLayout
|
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 network.loki.messenger.R
|
||||||
import org.thoughtcrime.securesms.database.model.MessageRecord
|
import org.thoughtcrime.securesms.database.model.MessageRecord
|
||||||
|
|
||||||
@ -30,7 +30,11 @@ class ControlMessageView : LinearLayout {
|
|||||||
|
|
||||||
// region Updating
|
// region Updating
|
||||||
fun bind(message: MessageRecord) {
|
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() {
|
fun recycle() {
|
||||||
|
@ -3,9 +3,12 @@ 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.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
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
|
||||||
|
import org.session.libsession.messaging.contacts.Contact.ContactContext
|
||||||
|
import org.thoughtcrime.securesms.database.DatabaseFactory
|
||||||
import org.thoughtcrime.securesms.database.model.MessageRecord
|
import org.thoughtcrime.securesms.database.model.MessageRecord
|
||||||
|
|
||||||
class VisibleMessageView : LinearLayout {
|
class VisibleMessageView : LinearLayout {
|
||||||
@ -30,11 +33,31 @@ class VisibleMessageView : LinearLayout {
|
|||||||
|
|
||||||
// region Updating
|
// region Updating
|
||||||
fun bind(message: MessageRecord) {
|
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() {
|
fun recycle() {
|
||||||
// TODO: Implement
|
profilePictureView.recycle()
|
||||||
}
|
}
|
||||||
// endregion
|
// endregion
|
||||||
}
|
}
|
@ -4,7 +4,6 @@
|
|||||||
<item
|
<item
|
||||||
android:top="2px"
|
android:top="2px"
|
||||||
android:bottom="2px">
|
android:bottom="2px">
|
||||||
|
|
||||||
<shape android:shape="rectangle">
|
<shape android:shape="rectangle">
|
||||||
<corners android:radius="@dimen/message_corner_radius"/>
|
<corners android:radius="@dimen/message_corner_radius"/>
|
||||||
<solid android:color="@color/white" />
|
<solid android:color="@color/white" />
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
<item
|
<item
|
||||||
android:top="2px"
|
android:top="2px"
|
||||||
android:bottom="2px">
|
android:bottom="2px">
|
||||||
|
|
||||||
<shape android:shape="rectangle">
|
<shape android:shape="rectangle">
|
||||||
<corners android:radius="@dimen/message_corner_radius"/>
|
<corners android:radius="@dimen/message_corner_radius"/>
|
||||||
<solid android:color="@color/white" />
|
<solid android:color="@color/white" />
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
<item
|
<item
|
||||||
android:top="2px"
|
android:top="2px"
|
||||||
android:bottom="2px">
|
android:bottom="2px">
|
||||||
|
|
||||||
<shape android:shape="rectangle">
|
<shape android:shape="rectangle">
|
||||||
<corners
|
<corners
|
||||||
android:topLeftRadius="@dimen/message_corner_collapse_radius"
|
android:topLeftRadius="@dimen/message_corner_collapse_radius"
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
<item
|
<item
|
||||||
android:top="2px"
|
android:top="2px"
|
||||||
android:bottom="2px">
|
android:bottom="2px">
|
||||||
|
|
||||||
<shape android:shape="rectangle">
|
<shape android:shape="rectangle">
|
||||||
<corners
|
<corners
|
||||||
android:topLeftRadius="@dimen/message_corner_collapse_radius"
|
android:topLeftRadius="@dimen/message_corner_collapse_radius"
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
<item
|
<item
|
||||||
android:top="2px"
|
android:top="2px"
|
||||||
android:bottom="2px">
|
android:bottom="2px">
|
||||||
|
|
||||||
<shape android:shape="rectangle">
|
<shape android:shape="rectangle">
|
||||||
<corners
|
<corners
|
||||||
android:topLeftRadius="@dimen/message_corner_radius"
|
android:topLeftRadius="@dimen/message_corner_radius"
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
<item
|
<item
|
||||||
android:top="2px"
|
android:top="2px"
|
||||||
android:bottom="2px">
|
android:bottom="2px">
|
||||||
|
|
||||||
<shape android:shape="rectangle">
|
<shape android:shape="rectangle">
|
||||||
<corners android:radius="@dimen/message_corner_radius"/>
|
<corners android:radius="@dimen/message_corner_radius"/>
|
||||||
<solid android:color="@color/white" />
|
<solid android:color="@color/white" />
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
<item
|
<item
|
||||||
android:top="2px"
|
android:top="2px"
|
||||||
android:bottom="2px">
|
android:bottom="2px">
|
||||||
|
|
||||||
<shape android:shape="rectangle">
|
<shape android:shape="rectangle">
|
||||||
<corners
|
<corners
|
||||||
android:topLeftRadius="@dimen/message_corner_radius"
|
android:topLeftRadius="@dimen/message_corner_radius"
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
<item
|
<item
|
||||||
android:top="2px"
|
android:top="2px"
|
||||||
android:bottom="2px">
|
android:bottom="2px">
|
||||||
|
|
||||||
<shape android:shape="rectangle">
|
<shape android:shape="rectangle">
|
||||||
<corners
|
<corners
|
||||||
android:topLeftRadius="@dimen/message_corner_radius"
|
android:topLeftRadius="@dimen/message_corner_radius"
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
<item
|
<item
|
||||||
android:top="2px"
|
android:top="2px"
|
||||||
android:bottom="2px">
|
android:bottom="2px">
|
||||||
|
|
||||||
<shape android:shape="rectangle">
|
<shape android:shape="rectangle">
|
||||||
<corners
|
<corners
|
||||||
android:topLeftRadius="@dimen/message_corner_radius"
|
android:topLeftRadius="@dimen/message_corner_radius"
|
||||||
|
@ -1,14 +1,13 @@
|
|||||||
<?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"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
android:orientation="horizontal"
|
||||||
android:orientation="horizontal">
|
android:gravity="center">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/testTextView"
|
android:id="@+id/textView"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textSize="@dimen/medium_font_size"
|
android:textSize="@dimen/medium_font_size"
|
||||||
|
@ -1,17 +1,72 @@
|
|||||||
<?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"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
android:orientation="horizontal"
|
||||||
android:orientation="horizontal">
|
android:gravity="bottom">
|
||||||
|
|
||||||
<TextView
|
<!-- The linear layout below is marked as "useless", but this isn't the case. It's
|
||||||
android:id="@+id/testTextView"
|
convenient because it allows you to show or hide the profile picture plus the spacers
|
||||||
android:layout_width="match_parent"
|
before and behind it in one go. -->
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/profilePictureContainer"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textSize="@dimen/medium_font_size"
|
android:orientation="horizontal">
|
||||||
android:textColor="@color/text" />
|
|
||||||
|
<View
|
||||||
|
android:layout_width="12dp"
|
||||||
|
android:layout_height="0dp" />
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content" >
|
||||||
|
|
||||||
|
<org.thoughtcrime.securesms.loki.views.ProfilePictureView
|
||||||
|
android:id="@+id/profilePictureView"
|
||||||
|
android:layout_width="@dimen/very_small_profile_picture_size"
|
||||||
|
android:layout_height="@dimen/very_small_profile_picture_size" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/moderatorIconImageView"
|
||||||
|
android:layout_width="20dp"
|
||||||
|
android:layout_height="20dp"
|
||||||
|
android:src="@drawable/ic_crown"
|
||||||
|
android:layout_alignParentEnd="true"
|
||||||
|
android:layout_alignParentBottom="true" />
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="12dp"
|
||||||
|
android:layout_height="0dp" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/senderNameTextView"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="4dp"
|
||||||
|
android:textColor="@color/text"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:ellipsize="end" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/messageContentContainer"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:background="@drawable/message_bubble_background" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
Loading…
x
Reference in New Issue
Block a user