Skip to content

Commit 94f1388

Browse files
jmartinespElementBot
andauthored
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 <[email protected]>
1 parent 941c762 commit 94f1388

File tree

4 files changed

+13
-8
lines changed

4 files changed

+13
-8
lines changed

libraries/textcomposer/impl/src/main/kotlin/io/element/android/libraries/textcomposer/mentions/MentionSpan.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,12 @@ class MentionSpan(
6161
backgroundColor = when (type) {
6262
Type.USER -> if (isCurrentUser) mentionSpanTheme.currentUserBackgroundColor else mentionSpanTheme.otherBackgroundColor
6363
Type.ROOM -> mentionSpanTheme.otherBackgroundColor
64-
Type.EVERYONE -> mentionSpanTheme.otherBackgroundColor
64+
Type.EVERYONE -> mentionSpanTheme.currentUserBackgroundColor
6565
}
6666
textColor = when (type) {
6767
Type.USER -> if (isCurrentUser) mentionSpanTheme.currentUserTextColor else mentionSpanTheme.otherTextColor
6868
Type.ROOM -> mentionSpanTheme.otherTextColor
69-
Type.EVERYONE -> mentionSpanTheme.otherTextColor
69+
Type.EVERYONE -> mentionSpanTheme.currentUserTextColor
7070
}
7171
backgroundPaint.color = backgroundColor
7272
val (startPaddingPx, endPaddingPx) = mentionSpanTheme.paddingValuesPx.value

libraries/textcomposer/impl/src/main/kotlin/io/element/android/libraries/textcomposer/mentions/MentionSpanTheme.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package io.element.android.libraries.textcomposer.mentions
1818

1919
import android.graphics.Color
2020
import android.graphics.Typeface
21+
import android.net.Uri
2122
import android.text.Spanned
2223
import android.view.ViewGroup
2324
import android.widget.TextView
@@ -129,6 +130,7 @@ val LocalMentionSpanTheme = staticCompositionLocalOf {
129130
eventId = null,
130131
viaParameters = persistentListOf(),
131132
)
133+
"@room" -> PermalinkData.FallbackLink(Uri.EMPTY, false)
132134
else -> throw AssertionError("Unexpected value $uriString")
133135
}
134136
}
@@ -139,7 +141,8 @@ val LocalMentionSpanTheme = staticCompositionLocalOf {
139141
val textColor = ElementTheme.colors.textPrimary.toArgb()
140142
fun mentionSpanMe() = provider.getMentionSpanFor("mention", "https://matrix.to/#/@me:matrix.org")
141143
fun mentionSpanOther() = provider.getMentionSpanFor("mention", "https://matrix.to/#/@other:matrix.org")
142-
fun mentionSpanRoom() = provider.getMentionSpanFor("room", "https://matrix.to/#/#room:matrix.org")
144+
fun mentionSpanRoom() = provider.getMentionSpanFor("room:matrix.org", "https://matrix.to/#/#room:matrix.org")
145+
fun mentionSpanEveryone() = provider.getMentionSpanFor("@room", "@room")
143146
mentionSpanTheme.updateStyles(currentUserId = UserId("@me:matrix.org"))
144147

145148
CompositionLocalProvider(
@@ -154,7 +157,9 @@ val LocalMentionSpanTheme = staticCompositionLocalOf {
154157
append("@mention", mentionSpanMe(), 0)
155158
append(" to the current user and this is a ")
156159
append("@mention", mentionSpanOther(), 0)
157-
append(" to other user. This one is for a room: ")
160+
append(" to other user. This is for everyone in the ")
161+
append("@room", mentionSpanEveryone(), 0)
162+
append(". This one is for a link to another room: ")
158163
append("#room:matrix.org", mentionSpanRoom(), 0)
159164
append("\n\n")
160165
append("This ")
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading

0 commit comments

Comments
 (0)