Fixed generated avatar size sometimes small

This commit is contained in:
Sylvain Berfini 2026-01-12 16:44:25 +01:00
parent 4039da9c8a
commit 3df3c8d741
2 changed files with 6 additions and 10 deletions

View file

@ -500,7 +500,7 @@ private fun getErrorImageLoader(
R.drawable.inset_user_circle
}
} else {
ImageUtils.generatedAvatarIfNeededAndReturnPath(context, size, textSize, initials)
ImageUtils.generatedAvatarIfNeededAndReturnPath(context, initials)
}
}

View file

@ -35,13 +35,14 @@ import org.linphone.contacts.AvatarGenerator
import org.linphone.core.tools.Log
import androidx.core.net.toUri
import androidx.core.graphics.createBitmap
import org.linphone.R
class ImageUtils {
companion object {
private const val TAG = "[Image Utils]"
@AnyThread
fun generatedAvatarIfNeededAndReturnPath(context: Context, size: Int = 0, textSize: Int = 0, initials: String): String {
fun generatedAvatarIfNeededAndReturnPath(context: Context, initials: String): String {
val darkMode = context.resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK == Configuration.UI_MODE_NIGHT_YES
val suffix = if (darkMode) "_dark" else "_light"
@ -53,14 +54,9 @@ class ImageUtils {
val builder = AvatarGenerator(context)
builder.setInitials(initials)
if (size > 0) {
builder.setAvatarSize(
AppUtils.getDimension(size).toInt()
)
}
if (textSize > 0) {
builder.setTextSize(AppUtils.getDimension(textSize))
}
builder.setAvatarSize(AppUtils.getDimension(R.dimen.avatar_big_size).toInt())
builder.setTextSize(AppUtils.getDimension(R.dimen.avatar_initials_call_text_size))
val bitmap = builder.buildBitmap(false)
val path = FileUtils.storeBitmap(bitmap, generatedAvatarPath)
return path