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:
parent
9c21a96d3d
commit
9b27547196
4 changed files with 13 additions and 8 deletions
|
|
@ -61,12 +61,12 @@ class MentionSpan(
|
||||||
backgroundColor = when (type) {
|
backgroundColor = when (type) {
|
||||||
Type.USER -> if (isCurrentUser) mentionSpanTheme.currentUserBackgroundColor else mentionSpanTheme.otherBackgroundColor
|
Type.USER -> if (isCurrentUser) mentionSpanTheme.currentUserBackgroundColor else mentionSpanTheme.otherBackgroundColor
|
||||||
Type.ROOM -> mentionSpanTheme.otherBackgroundColor
|
Type.ROOM -> mentionSpanTheme.otherBackgroundColor
|
||||||
Type.EVERYONE -> mentionSpanTheme.otherBackgroundColor
|
Type.EVERYONE -> mentionSpanTheme.currentUserBackgroundColor
|
||||||
}
|
}
|
||||||
textColor = when (type) {
|
textColor = when (type) {
|
||||||
Type.USER -> if (isCurrentUser) mentionSpanTheme.currentUserTextColor else mentionSpanTheme.otherTextColor
|
Type.USER -> if (isCurrentUser) mentionSpanTheme.currentUserTextColor else mentionSpanTheme.otherTextColor
|
||||||
Type.ROOM -> mentionSpanTheme.otherTextColor
|
Type.ROOM -> mentionSpanTheme.otherTextColor
|
||||||
Type.EVERYONE -> mentionSpanTheme.otherTextColor
|
Type.EVERYONE -> mentionSpanTheme.currentUserTextColor
|
||||||
}
|
}
|
||||||
backgroundPaint.color = backgroundColor
|
backgroundPaint.color = backgroundColor
|
||||||
val (startPaddingPx, endPaddingPx) = mentionSpanTheme.paddingValuesPx.value
|
val (startPaddingPx, endPaddingPx) = mentionSpanTheme.paddingValuesPx.value
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ package io.element.android.libraries.textcomposer.mentions
|
||||||
|
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import android.graphics.Typeface
|
import android.graphics.Typeface
|
||||||
|
import android.net.Uri
|
||||||
import android.text.Spanned
|
import android.text.Spanned
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
|
|
@ -129,6 +130,7 @@ val LocalMentionSpanTheme = staticCompositionLocalOf {
|
||||||
eventId = null,
|
eventId = null,
|
||||||
viaParameters = persistentListOf(),
|
viaParameters = persistentListOf(),
|
||||||
)
|
)
|
||||||
|
"@room" -> PermalinkData.FallbackLink(Uri.EMPTY, false)
|
||||||
else -> throw AssertionError("Unexpected value $uriString")
|
else -> throw AssertionError("Unexpected value $uriString")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -139,7 +141,8 @@ val LocalMentionSpanTheme = staticCompositionLocalOf {
|
||||||
val textColor = ElementTheme.colors.textPrimary.toArgb()
|
val textColor = ElementTheme.colors.textPrimary.toArgb()
|
||||||
fun mentionSpanMe() = provider.getMentionSpanFor("mention", "https://matrix.to/#/@me:matrix.org")
|
fun mentionSpanMe() = provider.getMentionSpanFor("mention", "https://matrix.to/#/@me:matrix.org")
|
||||||
fun mentionSpanOther() = provider.getMentionSpanFor("mention", "https://matrix.to/#/@other: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"))
|
mentionSpanTheme.updateStyles(currentUserId = UserId("@me:matrix.org"))
|
||||||
|
|
||||||
CompositionLocalProvider(
|
CompositionLocalProvider(
|
||||||
|
|
@ -154,7 +157,9 @@ val LocalMentionSpanTheme = staticCompositionLocalOf {
|
||||||
append("@mention", mentionSpanMe(), 0)
|
append("@mention", mentionSpanMe(), 0)
|
||||||
append(" to the current user and this is a ")
|
append(" to the current user and this is a ")
|
||||||
append("@mention", mentionSpanOther(), 0)
|
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("#room:matrix.org", mentionSpanRoom(), 0)
|
||||||
append("\n\n")
|
append("\n\n")
|
||||||
append("This ")
|
append("This ")
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:489ef02595ca267fa827c2cb2a66c609ec166efa2e047896392613195b5a1e1b
|
oid sha256:f541f0a05b49272ef3e379a9a629c71458b37435928338a3a58ac852b38eb803
|
||||||
size 36967
|
size 48802
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:24c72884be8a2e98f0e5c5cb3911bb1121c75c8b7641062c66f60cded6477c99
|
oid sha256:a542b3be557dddc3aba16bda8bb7db1bf0078e6bb3abcc42a11c723e8dba3504
|
||||||
size 35107
|
size 46683
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue