diff --git a/library/ui-styles/src/main/res/values/attrs_sc.xml b/library/ui-styles/src/main/res/values/attrs_sc.xml
index c758752713..4a660c4422 100644
--- a/library/ui-styles/src/main/res/values/attrs_sc.xml
+++ b/library/ui-styles/src/main/res/values/attrs_sc.xml
@@ -28,6 +28,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/library/ui-styles/src/main/res/values/colors_sc.xml b/library/ui-styles/src/main/res/values/colors_sc.xml
index 605b4059df..506e16f894 100644
--- a/library/ui-styles/src/main/res/values/colors_sc.xml
+++ b/library/ui-styles/src/main/res/values/colors_sc.xml
@@ -75,6 +75,14 @@
#03A9F4
#8bc34a
-->
+ #4189c9
+ #aa43a7
+ #48a188
+ #b3526d
+ #be6a31
+ #299ea0
+ #5c57df
+ #69a011
#121212
diff --git a/library/ui-styles/src/main/res/values/theme_dark.xml b/library/ui-styles/src/main/res/values/theme_dark.xml
index da6b380673..8f52b2c284 100644
--- a/library/ui-styles/src/main/res/values/theme_dark.xml
+++ b/library/ui-styles/src/main/res/values/theme_dark.xml
@@ -138,6 +138,17 @@
- @color/element_background_light
- @color/palette_element_green
- @color/join_conference_animated_color
+ - @color/element_name_01
+ - @color/element_name_02
+ - @color/element_name_03
+ - @color/element_name_04
+ - @color/element_name_05
+ - @color/element_name_06
+ - @color/element_name_07
+ - @color/element_name_08
+ - @color/element_room_01
+ - @color/element_room_02
+ - @color/element_room_03
- @color/android_status_bar_background_dark
- @color/android_navigation_bar_background_dark
diff --git a/library/ui-styles/src/main/res/values/theme_light.xml b/library/ui-styles/src/main/res/values/theme_light.xml
index 0b7fa6b33b..d14a9571af 100644
--- a/library/ui-styles/src/main/res/values/theme_light.xml
+++ b/library/ui-styles/src/main/res/values/theme_light.xml
@@ -138,6 +138,17 @@
- @color/element_background_light
- @color/palette_element_green
- @color/join_conference_animated_color
+ - @color/element_name_01
+ - @color/element_name_02
+ - @color/element_name_03
+ - @color/element_name_04
+ - @color/element_name_05
+ - @color/element_name_06
+ - @color/element_name_07
+ - @color/element_name_08
+ - @color/element_room_01
+ - @color/element_room_02
+ - @color/element_room_03
- @color/android_status_bar_background_dark
diff --git a/library/ui-styles/src/main/res/values/theme_sc.xml b/library/ui-styles/src/main/res/values/theme_sc.xml
index 5dfaa8b597..9738b661db 100644
--- a/library/ui-styles/src/main/res/values/theme_sc.xml
+++ b/library/ui-styles/src/main/res/values/theme_sc.xml
@@ -100,6 +100,14 @@
- @color/background_sc_light
- ?colorAccent
- ?colorAccentPale
+ - @color/user_color_sc_mxid_1
+ - @color/user_color_sc_mxid_2
+ - @color/user_color_sc_mxid_3
+ - @color/user_color_sc_mxid_4
+ - @color/user_color_sc_mxid_5
+ - @color/user_color_sc_mxid_6
+ - @color/user_color_sc_mxid_7
+ - @color/user_color_sc_mxid_8
- @color/background_black_sc
- @color/background_black_sc
diff --git a/library/ui-styles/src/main/res/values/theme_sc_light.xml b/library/ui-styles/src/main/res/values/theme_sc_light.xml
index a146e593cb..c1ee827ecd 100644
--- a/library/ui-styles/src/main/res/values/theme_sc_light.xml
+++ b/library/ui-styles/src/main/res/values/theme_sc_light.xml
@@ -99,6 +99,14 @@
- @color/background_sc_light
- ?colorAccent
- ?colorAccentPale
+ - @color/user_color_sc_mxid_1
+ - @color/user_color_sc_mxid_2
+ - @color/user_color_sc_mxid_3
+ - @color/user_color_sc_mxid_4
+ - @color/user_color_sc_mxid_5
+ - @color/user_color_sc_mxid_6
+ - @color/user_color_sc_mxid_7
+ - @color/user_color_sc_mxid_8
- @color/background_black_sc
- @color/background_black_sc
diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/helper/MatrixItemColorProvider.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/helper/MatrixItemColorProvider.kt
index 98e3889587..e772251c9b 100644
--- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/helper/MatrixItemColorProvider.kt
+++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/helper/MatrixItemColorProvider.kt
@@ -16,13 +16,13 @@
package im.vector.app.features.home.room.detail.timeline.helper
+import androidx.annotation.AttrRes
import androidx.annotation.ColorInt
import androidx.annotation.ColorRes
import androidx.annotation.VisibleForTesting
import im.vector.app.R
import im.vector.app.core.resources.ColorProvider
import im.vector.app.features.settings.VectorPreferences
-import im.vector.app.features.themes.ThemeUtils
import org.matrix.android.sdk.api.util.MatrixItem
import javax.inject.Inject
import javax.inject.Singleton
@@ -55,10 +55,10 @@ class MatrixItemColorProvider @Inject constructor(
}
USER_COLORING_FROM_ID -> {
return cache.getOrPut(matrixItem.id) {
- colorProvider.getColor(
+ colorProvider.getColorFromAttribute(
when (matrixItem) {
- is MatrixItem.UserItem -> getColorFromUserId(matrixItem.id)
- else -> getColorFromRoomId(matrixItem.id)
+ is MatrixItem.UserItem -> getColorAttrFromUserId(matrixItem.id)
+ else -> getColorAttrFromRoomId(matrixItem.id)
}
)
}
@@ -69,9 +69,37 @@ class MatrixItemColorProvider @Inject constructor(
}
}
+ @AttrRes
+ fun getColorAttrFromUserId(userId: String?): Int {
+ var hash = 0
+
+ userId?.toList()?.map { chr -> hash = (hash shl 5) - hash + chr.code }
+
+ return when (abs(hash) % 8) {
+ 1 -> R.attr.user_color_hash_02
+ 2 -> R.attr.user_color_hash_03
+ 3 -> R.attr.user_color_hash_04
+ 4 -> R.attr.user_color_hash_05
+ 5 -> R.attr.user_color_hash_06
+ 6 -> R.attr.user_color_hash_07
+ 7 -> R.attr.user_color_hash_08
+ else -> R.attr.user_color_hash_01
+ }
+ }
+
+ @AttrRes
+ private fun getColorAttrFromRoomId(roomId: String?): Int {
+ return when ((roomId?.toList()?.sumOf { it.code } ?: 0) % 3) {
+ 1 -> R.attr.room_color_hash_02
+ 2 -> R.attr.room_color_hash_03
+ else -> R.attr.room_color_hash_01
+ }
+ }
+
companion object {
@ColorRes
@VisibleForTesting
+ @Deprecated("Use getColorAttrFromUserId")
fun getColorFromUserId(userId: String?): Int {
var hash = 0
@@ -90,6 +118,7 @@ class MatrixItemColorProvider @Inject constructor(
}
@ColorRes
+ @Deprecated("Use getColorAttrFromRoomId")
private fun getColorFromRoomId(roomId: String?): Int {
return when ((roomId?.toList()?.sumOf { it.code } ?: 0) % 3) {
1 -> R.color.element_room_02