mirror of
https://github.com/vector-im/element-android.git
synced 2024-11-16 02:05:06 +08:00
Setting background color for chips
This commit is contained in:
parent
07a59e63a6
commit
24a92d5a1e
@ -29,7 +29,6 @@ import im.vector.app.features.home.AvatarRenderer
|
|||||||
import im.vector.app.features.html.PillImageSpan
|
import im.vector.app.features.html.PillImageSpan
|
||||||
import org.matrix.android.sdk.api.session.room.model.RoomSummary
|
import org.matrix.android.sdk.api.session.room.model.RoomSummary
|
||||||
import org.matrix.android.sdk.api.util.MatrixItem
|
import org.matrix.android.sdk.api.util.MatrixItem
|
||||||
import timber.log.Timber
|
|
||||||
|
|
||||||
class EventTextRenderer @AssistedInject constructor(@Assisted private val roomId: String?,
|
class EventTextRenderer @AssistedInject constructor(@Assisted private val roomId: String?,
|
||||||
private val context: Context,
|
private val context: Context,
|
||||||
@ -74,9 +73,7 @@ class EventTextRenderer @AssistedInject constructor(@Assisted private val roomId
|
|||||||
var foundIndex = text.indexOf(MatrixItem.NOTIFY_EVERYONE, 0)
|
var foundIndex = text.indexOf(MatrixItem.NOTIFY_EVERYONE, 0)
|
||||||
while (foundIndex >= 0) {
|
while (foundIndex >= 0) {
|
||||||
val endSpan = foundIndex + MatrixItem.NOTIFY_EVERYONE.length
|
val endSpan = foundIndex + MatrixItem.NOTIFY_EVERYONE.length
|
||||||
//text.setSpan(ForegroundColorSpan(Color.RED), foundIndex, endSpan, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
|
|
||||||
addPillSpan(text, createPillImageSpan(matrixItem), foundIndex, endSpan)
|
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)
|
foundIndex = text.indexOf(MatrixItem.NOTIFY_EVERYONE, endSpan)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
package im.vector.app.features.html
|
package im.vector.app.features.html
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.content.res.ColorStateList
|
||||||
import android.graphics.Canvas
|
import android.graphics.Canvas
|
||||||
import android.graphics.Paint
|
import android.graphics.Paint
|
||||||
import android.graphics.drawable.Drawable
|
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.core.glide.GlideRequests
|
||||||
import im.vector.app.features.displayname.getBestName
|
import im.vector.app.features.displayname.getBestName
|
||||||
import im.vector.app.features.home.AvatarRenderer
|
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.session.room.send.MatrixItemSpan
|
||||||
import org.matrix.android.sdk.api.util.MatrixItem
|
import org.matrix.android.sdk.api.util.MatrixItem
|
||||||
import java.lang.ref.WeakReference
|
import java.lang.ref.WeakReference
|
||||||
@ -117,6 +119,9 @@ class PillImageSpan(private val glideRequests: GlideRequests,
|
|||||||
setChipMinHeightResource(R.dimen.pill_min_height)
|
setChipMinHeightResource(R.dimen.pill_min_height)
|
||||||
setChipIconSizeResource(R.dimen.pill_avatar_size)
|
setChipIconSizeResource(R.dimen.pill_avatar_size)
|
||||||
chipIcon = icon
|
chipIcon = icon
|
||||||
|
if (matrixItem is MatrixItem.EveryoneInRoomItem) {
|
||||||
|
chipBackgroundColor = ColorStateList.valueOf(ThemeUtils.getColor(context, R.attr.colorError))
|
||||||
|
}
|
||||||
setBounds(0, 0, intrinsicWidth, intrinsicHeight)
|
setBounds(0, 0, intrinsicWidth, intrinsicHeight)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user