diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/AutoCompleter.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/AutoCompleter.kt index daf401efc3..dd0024a15c 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/AutoCompleter.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/AutoCompleter.kt @@ -285,6 +285,7 @@ class AutoCompleter @AssistedInject constructor( // Add the span val span = PillImageSpan( + session, // TCHAP set pill background color when the user is mentioned glideRequests, avatarRenderer, editText.context, diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/composer/MessageComposerFragment.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/composer/MessageComposerFragment.kt index 68b8304fcb..3e09041f44 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/composer/MessageComposerFragment.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/composer/MessageComposerFragment.kt @@ -432,7 +432,8 @@ class MessageComposerFragment : VectorBaseFragment(), A getRoom = timelineViewModel::getRoom, getMember = timelineViewModel::getMember, ) { matrixItem: MatrixItem -> - PillImageSpan(glideRequests, avatarRenderer, requireContext(), matrixItem) + // TCHAP set pill background color when the user is mentioned + PillImageSpan(session, glideRequests, avatarRenderer, requireContext(), matrixItem) } } @@ -820,6 +821,7 @@ class MessageComposerFragment : VectorBaseFragment(), A append(displayName) setSpan( PillImageSpan( + session, // TCHAP set pill background color when the user is mentioned glideRequests, avatarRenderer, requireContext(), 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 79e8690c91..e3769281ca 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 @@ -116,7 +116,8 @@ class EventTextRenderer @AssistedInject constructor( } private fun createPillImageSpan(matrixItem: MatrixItem) = - PillImageSpan(GlideApp.with(context), avatarRenderer, context, matrixItem) + // TCHAP set pill background color when the user is mentioned + PillImageSpan(sessionHolder.getActiveSession(), GlideApp.with(context), avatarRenderer, context, matrixItem) private fun addPillSpan( renderedText: Spannable, 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 a1130bd251..76dbb94494 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 @@ -39,6 +39,7 @@ 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.extensions.orTrue +import org.matrix.android.sdk.api.session.Session import org.matrix.android.sdk.api.session.room.send.MatrixItemSpan import org.matrix.android.sdk.api.util.MatrixItem import java.lang.ref.WeakReference @@ -49,6 +50,7 @@ import java.lang.ref.WeakReference * Implements MatrixItemSpan so that it could be automatically transformed in matrix links and displayed as pills. */ class PillImageSpan( + private val session: Session, private val glideRequests: GlideRequests, private val avatarRenderer: AvatarRenderer, private val context: Context, @@ -156,10 +158,18 @@ class PillImageSpan( 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)) - // setTextColor API does not exist right now for ChipDrawable, use textAppearance - setTextAppearanceResource(R.style.TextAppearance_Vector_Body_OnError) + // TCHAP set pill background color when the user is mentioned + when { + matrixItem is MatrixItem.UserItem && matrixItem.id == session.myUserId-> { + chipBackgroundColor = ColorStateList.valueOf(ThemeUtils.getColor(context, R.attr.colorSecondary)) + setTextColor(ThemeUtils.getColor(context, R.attr.colorOnSecondary)) + setTextAppearanceResource(R.style.TextAppearance_Vector_Body_OnError) + } + matrixItem is MatrixItem.EveryoneInRoomItem -> { + chipBackgroundColor = ColorStateList.valueOf(ThemeUtils.getColor(context, R.attr.colorError)) + // setTextColor API does not exist right now for ChipDrawable, use textAppearance + setTextAppearanceResource(R.style.TextAppearance_Vector_Body_OnError) + } } setBounds(0, 0, intrinsicWidth, intrinsicHeight) } diff --git a/vector/src/main/java/im/vector/app/features/html/PillsPostProcessor.kt b/vector/src/main/java/im/vector/app/features/html/PillsPostProcessor.kt index 92d5b16998..5b8e4c85a8 100644 --- a/vector/src/main/java/im/vector/app/features/html/PillsPostProcessor.kt +++ b/vector/src/main/java/im/vector/app/features/html/PillsPostProcessor.kt @@ -104,7 +104,8 @@ class PillsPostProcessor @AssistedInject constructor( } private fun createPillImageSpan(matrixItem: MatrixItem) = - PillImageSpan(GlideApp.with(context), avatarRenderer, context, matrixItem) + // TCHAP set pill background color when the user is mentioned + PillImageSpan(sessionHolder.getActiveSession(), GlideApp.with(context), avatarRenderer, context, matrixItem) private fun LinkSpan.createPillSpan(): PillImageSpan? { val supportedHosts = context.resources.getStringArray(R.array.permalink_supported_hosts)