From dbdd53c6c3f5146a44a5e8532ee2b1b8128a2450 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 2 Apr 2026 20:34:07 +0000 Subject: [PATCH] fix: load caller name and profile picture in call notification Both CallController and EventNotificationConsumer now load the caller's profile picture via Coil before showing the notification, so the large icon displays the caller's avatar instead of being empty. The caller name was already loaded from LocalCache but now the bitmap accompanies it. https://claude.ai/code/session_01Ak5tTkujpjNG1r5ASuPipZ --- .../amethyst/service/call/CallController.kt | 20 ++++++++++++++++-- .../EventNotificationConsumer.kt | 21 +++++++++++++++++-- 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/call/CallController.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/call/CallController.kt index 488500434..bca75e0aa 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/call/CallController.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/call/CallController.kt @@ -22,6 +22,9 @@ package com.vitorpamplona.amethyst.service.call import android.content.Context import android.content.Intent +import coil3.ImageLoader +import coil3.asDrawable +import coil3.request.ImageRequest import com.vitorpamplona.amethyst.commons.call.CallManager import com.vitorpamplona.amethyst.commons.call.CallState import com.vitorpamplona.amethyst.model.LocalCache @@ -462,14 +465,27 @@ class CallController( } } - private fun showIncomingCallNotification(callerPubKey: String) { + private suspend fun showIncomingCallNotification(callerPubKey: String) { val callerUser = LocalCache.getUserIfExists(callerPubKey) val callerName = callerUser?.toBestDisplayName() ?: callerPubKey.take(8) + "..." val uri = "nostr:${callerPubKey.hexToByteArray().toNpub()}" + val callerBitmap = + callerUser?.profilePicture()?.let { pictureUrl -> + withContext(Dispatchers.IO) { + try { + val request = ImageRequest.Builder(context).data(pictureUrl).build() + val result = ImageLoader(context).execute(request) + (result.image?.asDrawable(context.resources) as? android.graphics.drawable.BitmapDrawable)?.bitmap + } catch (_: Exception) { + null + } + } + } + NotificationUtils.sendCallNotification( callerName = callerName, - callerBitmap = null, + callerBitmap = callerBitmap, uri = uri, applicationContext = context, ) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/notifications/EventNotificationConsumer.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/notifications/EventNotificationConsumer.kt index d47e1058c..356f65c40 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/notifications/EventNotificationConsumer.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/notifications/EventNotificationConsumer.kt @@ -22,7 +22,11 @@ package com.vitorpamplona.amethyst.service.notifications import android.app.NotificationManager import android.content.Context +import android.graphics.drawable.BitmapDrawable import androidx.core.content.ContextCompat +import coil3.ImageLoader +import coil3.asDrawable +import coil3.request.ImageRequest import com.vitorpamplona.amethyst.Amethyst import com.vitorpamplona.amethyst.LocalPreferences import com.vitorpamplona.amethyst.R @@ -625,7 +629,7 @@ class EventNotificationConsumer( } } - private fun notifyIncomingCall( + private suspend fun notifyIncomingCall( event: CallOfferEvent, account: Account, ) { @@ -636,10 +640,23 @@ class EventNotificationConsumer( val callerUser = LocalCache.getUserIfExists(event.pubKey) val callerName = callerUser?.toBestDisplayName() ?: event.pubKey.take(8) + "..." + val callerBitmap = + callerUser?.profilePicture()?.let { pictureUrl -> + kotlinx.coroutines.withContext(kotlinx.coroutines.Dispatchers.IO) { + try { + val request = ImageRequest.Builder(applicationContext).data(pictureUrl).build() + val result = ImageLoader(applicationContext).execute(request) + (result.image?.asDrawable(applicationContext.resources) as? BitmapDrawable)?.bitmap + } catch (_: Exception) { + null + } + } + } + NotificationUtils .sendCallNotification( callerName = callerName, - callerBitmap = null, + callerBitmap = callerBitmap, uri = "nostr:${event.pubKey.hexToByteArray().toNpub()}", applicationContext = applicationContext, )