From 24a92d5a1eb6ae3f6497a05382bd8fa54391d246 Mon Sep 17 00:00:00 2001 From: Maxime Naturel Date: Mon, 14 Feb 2022 14:10:41 +0100 Subject: [PATCH] Setting background color for chips --- .../home/room/detail/timeline/render/EventTextRenderer.kt | 3 --- .../main/java/im/vector/app/features/html/PillImageSpan.kt | 5 +++++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/render/EventTextRenderer.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/render/EventTextRenderer.kt index 29761e0d68..dab3f41570 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/render/EventTextRenderer.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/render/EventTextRenderer.kt @@ -29,7 +29,6 @@ import im.vector.app.features.home.AvatarRenderer import im.vector.app.features.html.PillImageSpan import org.matrix.android.sdk.api.session.room.model.RoomSummary import org.matrix.android.sdk.api.util.MatrixItem -import timber.log.Timber class EventTextRenderer @AssistedInject constructor(@Assisted private val roomId: String?, private val context: Context, @@ -74,9 +73,7 @@ class EventTextRenderer @AssistedInject constructor(@Assisted private val roomId var foundIndex = text.indexOf(MatrixItem.NOTIFY_EVERYONE, 0) while (foundIndex >= 0) { val endSpan = foundIndex + MatrixItem.NOTIFY_EVERYONE.length - //text.setSpan(ForegroundColorSpan(Color.RED), foundIndex, endSpan, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE) addPillSpan(text, createPillImageSpan(matrixItem), foundIndex, endSpan) - Timber.e("set span for text $text from index $foundIndex to $endSpan") foundIndex = text.indexOf(MatrixItem.NOTIFY_EVERYONE, endSpan) } } diff --git a/vector/src/main/java/im/vector/app/features/html/PillImageSpan.kt b/vector/src/main/java/im/vector/app/features/html/PillImageSpan.kt index ff2e2a9cdb..3a388cfc69 100644 --- a/vector/src/main/java/im/vector/app/features/html/PillImageSpan.kt +++ b/vector/src/main/java/im/vector/app/features/html/PillImageSpan.kt @@ -19,6 +19,7 @@ package im.vector.app.features.html import android.content.Context +import android.content.res.ColorStateList import android.graphics.Canvas import android.graphics.Paint import android.graphics.drawable.Drawable @@ -32,6 +33,7 @@ import im.vector.app.R import im.vector.app.core.glide.GlideRequests import im.vector.app.features.displayname.getBestName import im.vector.app.features.home.AvatarRenderer +import im.vector.app.features.themes.ThemeUtils import org.matrix.android.sdk.api.session.room.send.MatrixItemSpan import org.matrix.android.sdk.api.util.MatrixItem import java.lang.ref.WeakReference @@ -117,6 +119,9 @@ class PillImageSpan(private val glideRequests: GlideRequests, setChipMinHeightResource(R.dimen.pill_min_height) setChipIconSizeResource(R.dimen.pill_avatar_size) chipIcon = icon + if (matrixItem is MatrixItem.EveryoneInRoomItem) { + chipBackgroundColor = ColorStateList.valueOf(ThemeUtils.getColor(context, R.attr.colorError)) + } setBounds(0, 0, intrinsicWidth, intrinsicHeight) } }