Fixed broken avatar generation for notifications & shortcuts

This commit is contained in:
Sylvain Berfini 2024-12-11 16:26:14 +01:00
parent b3da6ed347
commit d5ca4c29d3

View file

@ -45,11 +45,17 @@ class AvatarGenerator(private val context: Context) {
init {
val textTypedValue = TypedValue()
context.theme.resolveAttribute(R.attr.color_avatar_text, textTypedValue, true)
textColor = textTypedValue.data
// This will fail for notifications
if (textTypedValue.data != 0) {
textColor = textTypedValue.data
}
val backgroundTypedValue = TypedValue()
context.theme.resolveAttribute(R.attr.color_avatar_background, backgroundTypedValue, true)
backgroundColor = backgroundTypedValue.data
// This will fail for notifications
if (backgroundTypedValue.data != 0) {
backgroundColor = backgroundTypedValue.data
}
}
fun setTextSize(size: Float) = apply {