From 94f138840273b6a98ceb935b940c87dd9af4c13a Mon Sep 17 00:00:00 2001 From: Jorge Martin Espinosa Date: Mon, 2 Sep 2024 17:14:54 +0200 Subject: [PATCH] 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 --- .../libraries/textcomposer/mentions/MentionSpan.kt | 4 ++-- .../libraries/textcomposer/mentions/MentionSpanTheme.kt | 9 +++++++-- ...s.textcomposer.mentions_MentionSpanTheme_Day_0_en.png | 4 ++-- ...textcomposer.mentions_MentionSpanTheme_Night_0_en.png | 4 ++-- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/libraries/textcomposer/impl/src/main/kotlin/io/element/android/libraries/textcomposer/mentions/MentionSpan.kt b/libraries/textcomposer/impl/src/main/kotlin/io/element/android/libraries/textcomposer/mentions/MentionSpan.kt index a095320e0a..78f66d5220 100644 --- a/libraries/textcomposer/impl/src/main/kotlin/io/element/android/libraries/textcomposer/mentions/MentionSpan.kt +++ b/libraries/textcomposer/impl/src/main/kotlin/io/element/android/libraries/textcomposer/mentions/MentionSpan.kt @@ -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 diff --git a/libraries/textcomposer/impl/src/main/kotlin/io/element/android/libraries/textcomposer/mentions/MentionSpanTheme.kt b/libraries/textcomposer/impl/src/main/kotlin/io/element/android/libraries/textcomposer/mentions/MentionSpanTheme.kt index f3befe34cb..fbbe96fa99 100644 --- a/libraries/textcomposer/impl/src/main/kotlin/io/element/android/libraries/textcomposer/mentions/MentionSpanTheme.kt +++ b/libraries/textcomposer/impl/src/main/kotlin/io/element/android/libraries/textcomposer/mentions/MentionSpanTheme.kt @@ -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 ") diff --git a/tests/uitests/src/test/snapshots/images/libraries.textcomposer.mentions_MentionSpanTheme_Day_0_en.png b/tests/uitests/src/test/snapshots/images/libraries.textcomposer.mentions_MentionSpanTheme_Day_0_en.png index 58a71dd0cd..5f6cb5caad 100644 --- a/tests/uitests/src/test/snapshots/images/libraries.textcomposer.mentions_MentionSpanTheme_Day_0_en.png +++ b/tests/uitests/src/test/snapshots/images/libraries.textcomposer.mentions_MentionSpanTheme_Day_0_en.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:489ef02595ca267fa827c2cb2a66c609ec166efa2e047896392613195b5a1e1b -size 36967 +oid sha256:f541f0a05b49272ef3e379a9a629c71458b37435928338a3a58ac852b38eb803 +size 48802 diff --git a/tests/uitests/src/test/snapshots/images/libraries.textcomposer.mentions_MentionSpanTheme_Night_0_en.png b/tests/uitests/src/test/snapshots/images/libraries.textcomposer.mentions_MentionSpanTheme_Night_0_en.png index d42c2b1372..81f4997ffc 100644 --- a/tests/uitests/src/test/snapshots/images/libraries.textcomposer.mentions_MentionSpanTheme_Night_0_en.png +++ b/tests/uitests/src/test/snapshots/images/libraries.textcomposer.mentions_MentionSpanTheme_Night_0_en.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:24c72884be8a2e98f0e5c5cb3911bb1121c75c8b7641062c66f60cded6477c99 -size 35107 +oid sha256:a542b3be557dddc3aba16bda8bb7db1bf0078e6bb3abcc42a11c723e8dba3504 +size 46683