diff --git a/app/src/main/java/chat/revolt/components/chat/InReplyTo.kt b/app/src/main/java/chat/revolt/components/chat/InReplyTo.kt
index cc06dfb8..f0d74a08 100644
--- a/app/src/main/java/chat/revolt/components/chat/InReplyTo.kt
+++ b/app/src/main/java/chat/revolt/components/chat/InReplyTo.kt
@@ -66,14 +66,15 @@ fun InReplyTo(
modifier = Modifier.padding(horizontal = 4.dp)
)
- if (message.masquerade != null && author?.bot != null) {
- InlineBadge(
- badge = InlineBadge.Masquerade,
- colour = MaterialTheme.colorScheme.onBackground.copy(alpha = 0.5f),
- modifier = Modifier.size(8.dp)
- )
- Spacer(modifier = Modifier.width(4.dp))
- }
+ InlineBadges(
+ bot = message.masquerade == null && author?.bot != null,
+ masquerade = message.masquerade != null && author?.bot != null,
+ colour = MaterialTheme.colorScheme.onBackground.copy(alpha = 0.5f),
+ modifier = Modifier.size(8.dp),
+ followingIfAny = {
+ Spacer(modifier = Modifier.width(4.dp))
+ }
+ )
Text(
text = message.content ?: "",
diff --git a/app/src/main/java/chat/revolt/components/chat/InlineBadge.kt b/app/src/main/java/chat/revolt/components/chat/InlineBadge.kt
index 99b6ee0a..a5f8d7fc 100644
--- a/app/src/main/java/chat/revolt/components/chat/InlineBadge.kt
+++ b/app/src/main/java/chat/revolt/components/chat/InlineBadge.kt
@@ -1,5 +1,6 @@
package chat.revolt.components.chat
+import androidx.compose.foundation.layout.Row
import androidx.compose.material3.Icon
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
@@ -37,4 +38,55 @@ fun InlineBadge(
InlineBadge.PlatformModeration -> TODO()
InlineBadge.Developer -> TODO()
}
+}
+
+@Composable
+fun InlineBadges(
+ modifier: Modifier = Modifier,
+ bot: Boolean = false,
+ masquerade: Boolean = false,
+ platformModeration: Boolean = false,
+ developer: Boolean = false,
+ colour: Color = Color.Unspecified,
+ precedingIfAny: @Composable () -> Unit = {},
+ followingIfAny: @Composable () -> Unit = {},
+) {
+ if (bot || masquerade || platformModeration || developer) {
+ precedingIfAny()
+ }
+
+ Row {
+ if (bot) {
+ InlineBadge(
+ badge = InlineBadge.Bot,
+ modifier = modifier,
+ colour = colour
+ )
+ }
+ if (masquerade) {
+ InlineBadge(
+ badge = InlineBadge.Masquerade,
+ modifier = modifier,
+ colour = colour
+ )
+ }
+ if (platformModeration) {
+ InlineBadge(
+ badge = InlineBadge.PlatformModeration,
+ modifier = modifier,
+ colour = colour
+ )
+ }
+ if (developer) {
+ InlineBadge(
+ badge = InlineBadge.Developer,
+ modifier = modifier,
+ colour = colour
+ )
+ }
+ }
+
+ if (bot || masquerade || platformModeration || developer) {
+ followingIfAny()
+ }
}
\ No newline at end of file
diff --git a/app/src/main/java/chat/revolt/components/chat/Message.kt b/app/src/main/java/chat/revolt/components/chat/Message.kt
index 1edeac16..049fe8d7 100644
--- a/app/src/main/java/chat/revolt/components/chat/Message.kt
+++ b/app/src/main/java/chat/revolt/components/chat/Message.kt
@@ -107,15 +107,15 @@ fun Message(
overflow = TextOverflow.Ellipsis
)
- if (message.masquerade != null && author.bot != null) {
- Spacer(modifier = Modifier.width(5.dp))
-
- InlineBadge(
- badge = InlineBadge.Masquerade,
- colour = MaterialTheme.colorScheme.onBackground.copy(alpha = 0.5f),
- modifier = Modifier.size(16.dp)
- )
- }
+ InlineBadges(
+ bot = author.bot != null && message.masquerade == null,
+ masquerade = message.masquerade != null && author.bot != null,
+ colour = MaterialTheme.colorScheme.onBackground.copy(alpha = 0.5f),
+ modifier = Modifier.size(16.dp),
+ precedingIfAny = {
+ Spacer(modifier = Modifier.width(5.dp))
+ }
+ )
Spacer(modifier = Modifier.width(5.dp))
diff --git a/app/src/main/java/chat/revolt/components/screens/chat/ReplyManager.kt b/app/src/main/java/chat/revolt/components/screens/chat/ReplyManager.kt
index bb115d62..7111e57d 100644
--- a/app/src/main/java/chat/revolt/components/screens/chat/ReplyManager.kt
+++ b/app/src/main/java/chat/revolt/components/screens/chat/ReplyManager.kt
@@ -3,21 +3,26 @@ package chat.revolt.components.screens.chat
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.horizontalScroll
-import androidx.compose.foundation.layout.Column
-import androidx.compose.foundation.layout.Row
-import androidx.compose.foundation.layout.fillMaxWidth
-import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.layout.*
import androidx.compose.foundation.rememberScrollState
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Close
-import androidx.compose.material3.Icon
-import androidx.compose.material3.MaterialTheme
-import androidx.compose.material3.surfaceColorAtElevation
+import androidx.compose.material3.*
import androidx.compose.runtime.Composable
+import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
+import androidx.compose.ui.draw.clip
+import androidx.compose.ui.res.stringResource
+import androidx.compose.ui.text.font.FontWeight
+import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
+import androidx.compose.ui.unit.sp
+import chat.revolt.R
+import chat.revolt.api.RevoltAPI
+import chat.revolt.api.asJanuaryProxyUrl
+import chat.revolt.api.internals.WebCompat
import chat.revolt.api.routes.channel.SendMessageReply
-import chat.revolt.components.chat.InReplyTo
+import chat.revolt.components.generic.UserAvatar
@Composable
fun ManageableReply(
@@ -25,29 +30,93 @@ fun ManageableReply(
onToggleMention: () -> Unit,
onRemove: () -> Unit,
) {
- // TODO Revamp this. Placeholder design ("functional" but extremely ugly)
+ val replyMessage = RevoltAPI.messageCache[reply.id] ?: return onRemove()
+ val replyAuthor = RevoltAPI.userCache[replyMessage.author] ?: return onRemove()
+
Row(
modifier = Modifier
.fillMaxWidth()
.background(MaterialTheme.colorScheme.surfaceColorAtElevation(1.dp))
.horizontalScroll(rememberScrollState())
- .padding(horizontal = 8.dp, vertical = 4.dp)
+ .padding(horizontal = 8.dp, vertical = 4.dp),
+ verticalAlignment = Alignment.CenterVertically,
) {
Icon(
imageVector = Icons.Default.Close,
- contentDescription = "Remove reply",
+ contentDescription = stringResource(id = R.string.remove_reply_alt),
modifier = Modifier
+ .clip(MaterialTheme.shapes.small)
.clickable {
onRemove()
}
+ .padding(4.dp)
+ .size(16.dp),
+ )
+
+ Spacer(modifier = Modifier.width(8.dp))
+
+ UserAvatar(
+ username = replyAuthor.username!!,
+ userId = replyAuthor.id!!,
+ avatar = replyAuthor.avatar,
+ rawUrl = replyMessage.masquerade?.avatar?.let { asJanuaryProxyUrl(it) },
+ size = 16.dp
+ )
+
+ Spacer(modifier = Modifier.width(4.dp))
+
+ Text(
+ text = replyMessage.masquerade?.name ?: replyAuthor.username,
+ fontSize = 12.sp,
+ modifier = Modifier
+ .clickable {
+ onToggleMention()
+ }
+ .padding(4.dp),
+ color = if (replyMessage.masquerade?.colour != null) {
+ WebCompat.parseColour(replyMessage.masquerade.colour)
+ } else LocalContentColor.current,
+ fontWeight = FontWeight.Bold,
+ )
+
+ Text(
+ text = if (replyMessage.content?.trim().isNullOrEmpty()) {
+ stringResource(id = R.string.reply_message_empty_has_attachments)
+ } else {
+ replyMessage.content!!
+ },
+ fontSize = 12.sp,
+ maxLines = 1,
+ overflow = TextOverflow.Ellipsis,
+ modifier = Modifier
+ .clickable {
+ onToggleMention()
+ }
+ .padding(4.dp)
+ .weight(1f)
+ )
+
+ Spacer(modifier = Modifier.width(4.dp))
+
+ Text(
+ text = if (reply.mention) {
+ stringResource(id = R.string.reply_mention_on)
+ } else {
+ stringResource(id = R.string.reply_mention_off)
+ },
+ modifier = Modifier
+ .clip(MaterialTheme.shapes.small)
+ .clickable {
+ onToggleMention()
+ }
+ .padding(4.dp),
+ color = if (reply.mention) {
+ MaterialTheme.colorScheme.primary
+ } else {
+ MaterialTheme.colorScheme.onBackground.copy(alpha = 0.7f)
+ },
+ fontWeight = FontWeight.Bold,
)
- InReplyTo(
- messageId = reply.id,
- withMention = reply.mention,
- modifier = Modifier.weight(1f)
- ) {
- onToggleMention()
- }
}
}
diff --git a/app/src/main/java/chat/revolt/ui/theme/Theme.kt b/app/src/main/java/chat/revolt/ui/theme/Theme.kt
index e924fc5e..5790f111 100644
--- a/app/src/main/java/chat/revolt/ui/theme/Theme.kt
+++ b/app/src/main/java/chat/revolt/ui/theme/Theme.kt
@@ -84,13 +84,24 @@ fun RevoltTheme(
else -> RevoltColorScheme
}
+ val colorSchemeIsDark = when {
+ m3Supported && requestedTheme == Theme.M3Dynamic -> isSystemInDarkTheme()
+ requestedTheme == Theme.Revolt -> true
+ requestedTheme == Theme.Light -> false
+ requestedTheme == Theme.Amoled -> true
+ requestedTheme == Theme.None && systemInDarkTheme -> true
+ requestedTheme == Theme.None && !systemInDarkTheme -> false
+ else -> true
+ }
+
val view = LocalView.current
if (!view.isInEditMode) {
SideEffect {
val window = (view.context as Activity).window
window.statusBarColor = colorScheme.background.toArgb()
@Suppress("DEPRECATION")
- ViewCompat.getWindowInsetsController(view)?.isAppearanceLightStatusBars = false
+ ViewCompat.getWindowInsetsController(view)?.isAppearanceLightStatusBars =
+ !colorSchemeIsDark
}
}
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index c4a4e659..72b25e97 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -71,6 +71,9 @@
Send
Add attachment
Remove attachment
+ Remove reply
+ \@ on
+ \@ off
Bot
From linked channel
@@ -98,6 +101,7 @@
Add a note
Unknown message, tap to jump
+ Sent attachments
Disconnected
Tap to reconnect