Skip to content
Snippets Groups Projects
Commit 2bf1a009 authored by Taras's avatar Taras
Browse files

Add room owner name to post header for circles

parent 1b9209b8
No related branches found
No related tags found
No related merge requests found
...@@ -45,7 +45,8 @@ class PostHeaderView( ...@@ -45,7 +45,8 @@ class PostHeaderView(
sender.avatarUrl, sender.avatarUrl,
data.postInfo.timestamp, data.postInfo.timestamp,
data.postInfo.isEncrypted, data.postInfo.isEncrypted,
data.timelineName data.timelineName,
data.timelineOwnerName
) )
} }
...@@ -55,7 +56,8 @@ class PostHeaderView( ...@@ -55,7 +56,8 @@ class PostHeaderView(
avatarUrl: String?, avatarUrl: String?,
timestamp: Long, timestamp: Long,
isEncrypted: Boolean, isEncrypted: Boolean,
roomName: String? = null roomName: String? = null,
timelineOwnerName: String? = null
) { ) {
with(binding) { with(binding) {
ivSenderImage.apply { ivSenderImage.apply {
...@@ -69,8 +71,10 @@ class PostHeaderView( ...@@ -69,8 +71,10 @@ class PostHeaderView(
tvUserId.text = UserUtils.removeDomainSuffix(userId) tvUserId.text = UserUtils.removeDomainSuffix(userId)
ivEncrypted.setIsEncryptedIcon(isEncrypted) ivEncrypted.setIsEncryptedIcon(isEncrypted)
tvMessageTime.text = DateFormat.format("MMM dd, h:mm a", Date(timestamp)) tvMessageTime.text = DateFormat.format("MMM dd, h:mm a", Date(timestamp))
roomName?.let { roomName?.let {
val nameFormat = "($it)" val nameFormat =
context.getString(R.string.in_timeline_format, timelineOwnerName ?: "", it)
tvRoomName.text = nameFormat tvRoomName.text = nameFormat
} }
} }
......
...@@ -215,6 +215,7 @@ ...@@ -215,6 +215,7 @@
<string name="rich_text_editor_code_block">Toggle code block</string> <string name="rich_text_editor_code_block">Toggle code block</string>
<string name="general">General</string> <string name="general">General</string>
<string name="empty_media_storage_info">0 MB used</string> <string name="empty_media_storage_info">0 MB used</string>
<string name="in_timeline_format">(in %1$s / %2$s)</string>
<string-array name="debug_domains"> <string-array name="debug_domains">
<item>nl.circles-dev.net</item> <item>nl.circles-dev.net</item>
......
package org.futo.circles.core.extensions package org.futo.circles.core.extensions
import org.futo.circles.core.utils.UserUtils import org.futo.circles.core.utils.UserUtils
import org.matrix.android.sdk.api.session.room.model.RoomMemberSummary
import org.matrix.android.sdk.api.session.room.sender.SenderInfo import org.matrix.android.sdk.api.session.room.sender.SenderInfo
import org.matrix.android.sdk.api.session.user.model.User import org.matrix.android.sdk.api.session.user.model.User
fun User.notEmptyDisplayName(): String = getName(userId, displayName) fun User.notEmptyDisplayName(): String = getName(userId, displayName)
fun RoomMemberSummary.notEmptyDisplayName(): String = getName(userId, displayName)
fun SenderInfo.notEmptyDisplayName(): String = getName(userId, displayName) fun SenderInfo.notEmptyDisplayName(): String = getName(userId, displayName)
private fun getName(userId: String, displayName: String?): String { private fun getName(userId: String, displayName: String?): String {
......
package org.futo.circles.core.feature.timeline.builder package org.futo.circles.core.feature.timeline.builder
import org.futo.circles.core.extensions.getRoomOwner
import org.futo.circles.core.extensions.notEmptyDisplayName
import org.futo.circles.core.mapping.nameOrId import org.futo.circles.core.mapping.nameOrId
import org.futo.circles.core.mapping.toPost import org.futo.circles.core.mapping.toPost
import org.futo.circles.core.model.Post import org.futo.circles.core.model.Post
...@@ -18,8 +20,9 @@ class MultiTimelineBuilder @Inject constructor() : BaseTimelineBuilder() { ...@@ -18,8 +20,9 @@ class MultiTimelineBuilder @Inject constructor() : BaseTimelineBuilder() {
val room = MatrixSessionProvider.currentSession?.getRoom(roomId) val room = MatrixSessionProvider.currentSession?.getRoom(roomId)
?: return getAllTimelinesPostsList() ?: return getAllTimelinesPostsList()
val roomName = room.roomSummary()?.nameOrId() val roomName = room.roomSummary()?.nameOrId()
val roomOwnerName = getRoomOwner(roomId)?.notEmptyDisplayName()
val receipts = getReadReceipts(room).also { readReceiptMap[roomId] = it } val receipts = getReadReceipts(room).also { readReceiptMap[roomId] = it }
currentSnapshotMap[roomId] = this.map { it.toPost(receipts, roomName) } currentSnapshotMap[roomId] = this.map { it.toPost(receipts, roomName, roomOwnerName) }
return sortList(getAllTimelinesPostsList(), isThread) return sortList(getAllTimelinesPostsList(), isThread)
} }
......
...@@ -12,7 +12,8 @@ import org.matrix.android.sdk.api.session.room.timeline.hasBeenEdited ...@@ -12,7 +12,8 @@ import org.matrix.android.sdk.api.session.room.timeline.hasBeenEdited
fun TimelineEvent.toPost( fun TimelineEvent.toPost(
readReceipts: List<Long> = emptyList(), readReceipts: List<Long> = emptyList(),
timelineName: String? = null timelineName: String? = null,
timelineOwnerName: String? = null
): Post = Post( ): Post = Post(
postInfo = toPostInfo(), postInfo = toPostInfo(),
content = toPostContent(), content = toPostContent(),
...@@ -22,7 +23,8 @@ fun TimelineEvent.toPost( ...@@ -22,7 +23,8 @@ fun TimelineEvent.toPost(
reactionsData = annotations?.reactionsSummary?.map { reactionsData = annotations?.reactionsSummary?.map {
ReactionsData(it.key, it.count, it.addedByMe) ReactionsData(it.key, it.count, it.addedByMe)
} ?: emptyList(), } ?: emptyList(),
timelineName = timelineName timelineName = timelineName,
timelineOwnerName = timelineOwnerName
) )
fun TimelineEvent.toPostInfo(): PostInfo = PostInfo( fun TimelineEvent.toPostInfo(): PostInfo = PostInfo(
......
...@@ -10,7 +10,8 @@ data class Post( ...@@ -10,7 +10,8 @@ data class Post(
val readByCount: Int, val readByCount: Int,
val repliesCount: Int, val repliesCount: Int,
val reactionsData: List<ReactionsData>, val reactionsData: List<ReactionsData>,
val timelineName: String? = null val timelineName: String? = null,
val timelineOwnerName: String? = null
) : IdEntity<String> { ) : IdEntity<String> {
override val id: String get() = postInfo.id override val id: String get() = postInfo.id
fun isMyPost(): Boolean = postInfo.isMyPost() fun isMyPost(): Boolean = postInfo.isMyPost()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment