mirror of
https://github.com/permissionlesstech/bitchat-android.git
synced 2026-08-15 06:56:30 +00:00
timestamp no seconds
This commit is contained in:
parent
a85ba40637
commit
7cef3f329e
@ -21,6 +21,9 @@ import java.util.*
|
||||
/** Opacity applied to the `#abcd` disambiguation suffix so the readable name dominates. */
|
||||
internal const val SUFFIX_ALPHA = ChatVisualTokens.SenderSuffixAlpha
|
||||
|
||||
/** Compact transcript timestamp; seconds add noise without helping conversation scanning. */
|
||||
internal const val CHAT_TIMESTAMP_PATTERN = "HH:mm"
|
||||
|
||||
/** Background opacity for a mention chip referring to somebody else. */
|
||||
internal const val MENTION_CHIP_ALPHA = ChatVisualTokens.HighlightAlpha
|
||||
|
||||
@ -102,7 +105,7 @@ fun formatTextMessageSender(
|
||||
*/
|
||||
fun formatTextMessageMetadata(
|
||||
message: BitchatMessage,
|
||||
timeFormatter: SimpleDateFormat = SimpleDateFormat("HH:mm:ss", Locale.getDefault())
|
||||
timeFormatter: SimpleDateFormat = SimpleDateFormat(CHAT_TIMESTAMP_PATTERN, Locale.getDefault())
|
||||
): AnnotatedString {
|
||||
val builder = AnnotatedString.Builder()
|
||||
builder.pushStyle(
|
||||
@ -183,7 +186,7 @@ fun formatTextMessageBody(
|
||||
message: BitchatMessage,
|
||||
currentUserNickname: String,
|
||||
palette: BitchatPalette,
|
||||
timeFormatter: SimpleDateFormat = SimpleDateFormat("HH:mm:ss", Locale.getDefault()),
|
||||
timeFormatter: SimpleDateFormat = SimpleDateFormat(CHAT_TIMESTAMP_PATTERN, Locale.getDefault()),
|
||||
includeTimestamp: Boolean = true
|
||||
): AnnotatedString {
|
||||
val builder = AnnotatedString.Builder()
|
||||
@ -210,7 +213,7 @@ fun formatTextMessageBody(
|
||||
fun formatSystemMessage(
|
||||
message: BitchatMessage,
|
||||
palette: BitchatPalette,
|
||||
timeFormatter: SimpleDateFormat = SimpleDateFormat("HH:mm:ss", Locale.getDefault())
|
||||
timeFormatter: SimpleDateFormat = SimpleDateFormat(CHAT_TIMESTAMP_PATTERN, Locale.getDefault())
|
||||
): AnnotatedString {
|
||||
val builder = AnnotatedString.Builder()
|
||||
builder.pushStyle(
|
||||
@ -240,7 +243,7 @@ fun formatMessageHeaderAnnotatedString(
|
||||
currentUserNickname: String,
|
||||
myPeerID: String,
|
||||
palette: BitchatPalette,
|
||||
timeFormatter: SimpleDateFormat = SimpleDateFormat("HH:mm:ss", Locale.getDefault()),
|
||||
timeFormatter: SimpleDateFormat = SimpleDateFormat(CHAT_TIMESTAMP_PATTERN, Locale.getDefault()),
|
||||
includeSender: Boolean = true
|
||||
): AnnotatedString {
|
||||
val builder = AnnotatedString.Builder()
|
||||
|
||||
@ -372,7 +372,7 @@ fun MessageItem(
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
val colorScheme = MaterialTheme.colorScheme
|
||||
val timeFormatter = remember { SimpleDateFormat("HH:mm:ss", Locale.getDefault()) }
|
||||
val timeFormatter = remember { SimpleDateFormat(CHAT_TIMESTAMP_PATTERN, Locale.getDefault()) }
|
||||
|
||||
Column(
|
||||
modifier = modifier
|
||||
|
||||
@ -28,7 +28,7 @@ import org.robolectric.RobolectricTestRunner
|
||||
*/
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
class ChatUIUtilsTest {
|
||||
private val timeFormatter = SimpleDateFormat("HH:mm:ss", Locale.ROOT).apply {
|
||||
private val timeFormatter = SimpleDateFormat(CHAT_TIMESTAMP_PATTERN, Locale.ROOT).apply {
|
||||
timeZone = java.util.TimeZone.getTimeZone("UTC")
|
||||
}
|
||||
|
||||
@ -50,7 +50,7 @@ class ChatUIUtilsTest {
|
||||
@Test
|
||||
fun `text message metadata separates PoW badge with one space`() {
|
||||
assertEquals(
|
||||
"00:00:00 ⛨12b",
|
||||
"00:00 ⛨12b",
|
||||
formatTextMessageMetadata(message("hello", powDifficulty = 12), timeFormatter).text,
|
||||
)
|
||||
}
|
||||
@ -58,7 +58,7 @@ class ChatUIUtilsTest {
|
||||
@Test
|
||||
fun `text message metadata omits non-positive PoW difficulty`() {
|
||||
assertEquals(
|
||||
"00:00:00",
|
||||
"00:00",
|
||||
formatTextMessageMetadata(message("hello", powDifficulty = 0), timeFormatter).text,
|
||||
)
|
||||
}
|
||||
@ -74,9 +74,9 @@ class ChatUIUtilsTest {
|
||||
timeFormatter = timeFormatter,
|
||||
)
|
||||
|
||||
assertEquals("hello there 00:00:00", body.text)
|
||||
assertEquals("hello there 00:00", body.text)
|
||||
val timestamp = body.spanStyles.first {
|
||||
body.text.substring(it.start, it.end) == " 00:00:00"
|
||||
body.text.substring(it.start, it.end) == " 00:00"
|
||||
}.item
|
||||
assertEquals(10.sp, timestamp.fontSize)
|
||||
assertEquals(FontWeight.Normal, timestamp.fontWeight)
|
||||
@ -92,9 +92,9 @@ class ChatUIUtilsTest {
|
||||
timeFormatter = timeFormatter,
|
||||
)
|
||||
|
||||
assertEquals("mined 00:00:00 ⛨8b", body.text)
|
||||
assertEquals("mined 00:00 ⛨8b", body.text)
|
||||
val timestampAndPow = body.spanStyles.first {
|
||||
body.text.substring(it.start, it.end) == " 00:00:00 ⛨8b"
|
||||
body.text.substring(it.start, it.end) == " 00:00 ⛨8b"
|
||||
}.item
|
||||
assertEquals(10.sp, timestampAndPow.fontSize)
|
||||
assertEquals(palette.textTertiary, timestampAndPow.color)
|
||||
@ -240,7 +240,7 @@ class ChatUIUtilsTest {
|
||||
timeFormatter = timeFormatter,
|
||||
).text
|
||||
|
||||
assertEquals("// Tor started. Routing all chats via Tor 00:00:00", text)
|
||||
assertEquals("// Tor started. Routing all chats via Tor 00:00", text)
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -268,7 +268,7 @@ class ChatUIUtilsTest {
|
||||
annotated.text.substring(it.start, it.end) == "// tor restarting"
|
||||
}.item
|
||||
val time = annotated.spanStyles.first {
|
||||
annotated.text.substring(it.start, it.end) == " 00:00:00"
|
||||
annotated.text.substring(it.start, it.end) == " 00:00"
|
||||
}.item
|
||||
|
||||
assertEquals(12.sp, action.fontSize)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user