From 1cb91ca5dfb16f586fdc2062b9bd633294882fc6 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Fri, 31 Dec 2021 15:13:01 +0100 Subject: [PATCH] Use color parser --- .../room/detail/timeline/helper/MatrixItemColorProvider.kt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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 4c99894bf3..1c64082f65 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,6 +16,7 @@ package im.vector.app.features.home.room.detail.timeline.helper +import android.graphics.Color import androidx.annotation.ColorInt import androidx.annotation.ColorRes import androidx.annotation.VisibleForTesting @@ -69,10 +70,10 @@ class MatrixItemColorProvider @Inject constructor( null } else { try { - if (colorText.first() == '#') { - (colorText.substring(1).toLong(radix = 16) or 0xff000000L).toInt() - } else { + if (colorText.length == 1) { colorProvider.getColor(getUserColorByIndex(colorText.toInt())) + } else { + Color.parseColor(colorText) } } catch (e: Throwable) { Timber.e(e, "Unable to parse color $colorText")