mirror of
https://github.com/nextcloud/talk-android
synced 2025-07-29 15:45:12 +01:00
show last activity in threads overview
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
2639a22c78
commit
4a05a082d2
@ -9,6 +9,7 @@ package com.nextcloud.talk.threadsoverview
|
|||||||
|
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.text.format.DateUtils
|
||||||
import androidx.activity.compose.setContent
|
import androidx.activity.compose.setContent
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.clickable
|
import androidx.compose.foundation.clickable
|
||||||
@ -219,6 +220,7 @@ fun ThreadsList(
|
|||||||
threadName = threadInfo.first?.actorDisplayName.orEmpty(),
|
threadName = threadInfo.first?.actorDisplayName.orEmpty(),
|
||||||
threadMessage = threadInfo.first?.message.toString(),
|
threadMessage = threadInfo.first?.message.toString(),
|
||||||
numReplies = threadInfo.thread?.numReplies ?: 0,
|
numReplies = threadInfo.thread?.numReplies ?: 0,
|
||||||
|
lastActivityDate = getLastActivityDate(threadInfo),
|
||||||
imageRequest = imageRequest,
|
imageRequest = imageRequest,
|
||||||
roomToken = roomToken,
|
roomToken = roomToken,
|
||||||
onThreadClick = onThreadClick
|
onThreadClick = onThreadClick
|
||||||
@ -227,11 +229,28 @@ fun ThreadsList(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun getLastActivityDate(threadInfo: ThreadInfo): String {
|
||||||
|
val MILLIES = 1000L
|
||||||
|
|
||||||
|
val lastActivityTimestamp = threadInfo.last?.timestamp
|
||||||
|
?: threadInfo.first?.timestamp
|
||||||
|
?: 0
|
||||||
|
|
||||||
|
val lastActivityDate = DateUtils.getRelativeTimeSpanString(
|
||||||
|
lastActivityTimestamp.times(MILLIES),
|
||||||
|
System.currentTimeMillis(),
|
||||||
|
0,
|
||||||
|
DateUtils.FORMAT_ABBREV_RELATIVE
|
||||||
|
).toString()
|
||||||
|
return lastActivityDate
|
||||||
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun ThreadRow(
|
fun ThreadRow(
|
||||||
threadId: Int,
|
threadId: Int,
|
||||||
threadName: String,
|
threadName: String,
|
||||||
threadMessage: String,
|
threadMessage: String,
|
||||||
|
lastActivityDate: String,
|
||||||
numReplies: Int,
|
numReplies: Int,
|
||||||
imageRequest: ImageRequest?,
|
imageRequest: ImageRequest?,
|
||||||
roomToken: String,
|
roomToken: String,
|
||||||
@ -275,11 +294,21 @@ fun ThreadRow(
|
|||||||
|
|
||||||
Spacer(modifier = Modifier.width(8.dp))
|
Spacer(modifier = Modifier.width(8.dp))
|
||||||
|
|
||||||
Text(
|
Column(
|
||||||
text = numReplies.toString(),
|
horizontalAlignment = Alignment.End
|
||||||
style = MaterialTheme.typography.bodyMedium,
|
) {
|
||||||
color = MaterialTheme.colorScheme.onSurfaceVariant
|
Text(
|
||||||
)
|
text = lastActivityDate,
|
||||||
|
style = MaterialTheme.typography.bodyMedium,
|
||||||
|
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||||
|
)
|
||||||
|
Spacer(modifier = Modifier.height(2.dp))
|
||||||
|
Text(
|
||||||
|
text = numReplies.toString(),
|
||||||
|
style = MaterialTheme.typography.bodyMedium,
|
||||||
|
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
Spacer(modifier = Modifier.width(16.dp))
|
Spacer(modifier = Modifier.width(16.dp))
|
||||||
}
|
}
|
||||||
@ -315,6 +344,7 @@ fun ThreadRowPreview() {
|
|||||||
threadName = "actor name aka. thread name",
|
threadName = "actor name aka. thread name",
|
||||||
threadMessage = "The message of the first message of the thread...",
|
threadMessage = "The message of the first message of the thread...",
|
||||||
numReplies = 3,
|
numReplies = 3,
|
||||||
|
lastActivityDate = "14 sec ago",
|
||||||
roomToken = "1234",
|
roomToken = "1234",
|
||||||
onThreadClick = null,
|
onThreadClick = null,
|
||||||
imageRequest = null
|
imageRequest = null
|
||||||
|
Loading…
Reference in New Issue
Block a user