Use the right colors for @room mention pills (#3376)

* `@room` mentions the current user, so it should use the same colors as an explicit mention to them

* Update screenshots

---------

Co-authored-by: ElementBot <benoitm+elementbot@element.io>
This commit is contained in:
Jorge Martin Espinosa 2024-09-02 17:14:54 +02:00 committed by GitHub
parent 941c762cff
commit 94f1388402
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 13 additions and 8 deletions

View file

@ -61,12 +61,12 @@ class MentionSpan(
backgroundColor = when (type) {
Type.USER -> if (isCurrentUser) mentionSpanTheme.currentUserBackgroundColor else mentionSpanTheme.otherBackgroundColor
Type.ROOM -> mentionSpanTheme.otherBackgroundColor
Type.EVERYONE -> mentionSpanTheme.otherBackgroundColor
Type.EVERYONE -> mentionSpanTheme.currentUserBackgroundColor
}
textColor = when (type) {
Type.USER -> if (isCurrentUser) mentionSpanTheme.currentUserTextColor else mentionSpanTheme.otherTextColor
Type.ROOM -> mentionSpanTheme.otherTextColor
Type.EVERYONE -> mentionSpanTheme.otherTextColor
Type.EVERYONE -> mentionSpanTheme.currentUserTextColor
}
backgroundPaint.color = backgroundColor
val (startPaddingPx, endPaddingPx) = mentionSpanTheme.paddingValuesPx.value

View file

@ -18,6 +18,7 @@ package io.element.android.libraries.textcomposer.mentions
import android.graphics.Color
import android.graphics.Typeface
import android.net.Uri
import android.text.Spanned
import android.view.ViewGroup
import android.widget.TextView
@ -129,6 +130,7 @@ val LocalMentionSpanTheme = staticCompositionLocalOf {
eventId = null,
viaParameters = persistentListOf(),
)
"@room" -> PermalinkData.FallbackLink(Uri.EMPTY, false)
else -> throw AssertionError("Unexpected value $uriString")
}
}
@ -139,7 +141,8 @@ val LocalMentionSpanTheme = staticCompositionLocalOf {
val textColor = ElementTheme.colors.textPrimary.toArgb()
fun mentionSpanMe() = provider.getMentionSpanFor("mention", "https://matrix.to/#/@me:matrix.org")
fun mentionSpanOther() = provider.getMentionSpanFor("mention", "https://matrix.to/#/@other:matrix.org")
fun mentionSpanRoom() = provider.getMentionSpanFor("room", "https://matrix.to/#/#room:matrix.org")
fun mentionSpanRoom() = provider.getMentionSpanFor("room:matrix.org", "https://matrix.to/#/#room:matrix.org")
fun mentionSpanEveryone() = provider.getMentionSpanFor("@room", "@room")
mentionSpanTheme.updateStyles(currentUserId = UserId("@me:matrix.org"))
CompositionLocalProvider(
@ -154,7 +157,9 @@ val LocalMentionSpanTheme = staticCompositionLocalOf {
append("@mention", mentionSpanMe(), 0)
append(" to the current user and this is a ")
append("@mention", mentionSpanOther(), 0)
append(" to other user. This one is for a room: ")
append(" to other user. This is for everyone in the ")
append("@room", mentionSpanEveryone(), 0)
append(". This one is for a link to another room: ")
append("#room:matrix.org", mentionSpanRoom(), 0)
append("\n\n")
append("This ")

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:489ef02595ca267fa827c2cb2a66c609ec166efa2e047896392613195b5a1e1b
size 36967
oid sha256:f541f0a05b49272ef3e379a9a629c71458b37435928338a3a58ac852b38eb803
size 48802

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:24c72884be8a2e98f0e5c5cb3911bb1121c75c8b7641062c66f60cded6477c99
size 35107
oid sha256:a542b3be557dddc3aba16bda8bb7db1bf0078e6bb3abcc42a11c723e8dba3504
size 46683