Render caller avatar on Incoming call screen (#4635)

* Ensure that the image loader is set, else the IncomingCallActivity will not be able to render the avatar.

Fixes #4633

* Add background color to OnboardingBackground

Fixes #4629

* Trigger CI
This commit is contained in:
Benoit Marty 2025-04-24 23:32:46 +02:00 committed by GitHub
parent 2ca541936f
commit add03ab33a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 23 additions and 4 deletions

View file

@ -13,6 +13,8 @@ import android.os.PowerManager
import androidx.annotation.VisibleForTesting
import androidx.core.app.NotificationManagerCompat
import androidx.core.content.getSystemService
import coil3.SingletonImageLoader
import coil3.annotation.DelicateCoilApi
import com.squareup.anvil.annotations.ContributesBinding
import io.element.android.appconfig.ElementCallConfig
import io.element.android.features.call.api.CallType
@ -23,6 +25,8 @@ import io.element.android.libraries.di.AppScope
import io.element.android.libraries.di.ApplicationContext
import io.element.android.libraries.di.SingleIn
import io.element.android.libraries.matrix.api.MatrixClientProvider
import io.element.android.libraries.matrix.api.core.SessionId
import io.element.android.libraries.matrix.ui.media.ImageLoaderHolder
import io.element.android.libraries.push.api.notifications.ForegroundServiceType
import io.element.android.libraries.push.api.notifications.NotificationIdProvider
import io.element.android.libraries.push.api.notifications.OnMissedCallNotificationHandler
@ -89,6 +93,7 @@ class DefaultActiveCallManager @Inject constructor(
private val matrixClientProvider: MatrixClientProvider,
private val defaultCurrentCallService: DefaultCurrentCallService,
private val appForegroundStateService: AppForegroundStateService,
private val imageLoaderHolder: ImageLoaderHolder,
) : ActiveCallManager {
private val tag = "DefaultActiveCallManager"
private var timedOutCallJob: Job? = null
@ -125,6 +130,7 @@ class DefaultActiveCallManager @Inject constructor(
)
timedOutCallJob = coroutineScope.launch {
setUpCoil(notificationData.sessionId)
showIncomingCallNotification(notificationData)
// Wait for the ringing call to time out
@ -140,6 +146,13 @@ class DefaultActiveCallManager @Inject constructor(
}
}
@OptIn(DelicateCoilApi::class)
private suspend fun setUpCoil(sessionId: SessionId) {
val matrixClient = matrixClientProvider.getOrRestore(sessionId).getOrNull() ?: return
// Ensure that the image loader is set, else the IncomingCallActivity will not be able to render the caller avatar
SingletonImageLoader.setUnsafe(imageLoaderHolder.get(matrixClient))
}
/**
* Called when the incoming call timed out. It will remove the active call and remove any associated UI, adding a 'missed call' notification.
*/

View file

@ -325,5 +325,6 @@ class DefaultActiveCallManagerTest {
matrixClientProvider = matrixClientProvider,
defaultCurrentCallService = DefaultCurrentCallService(),
appForegroundStateService = FakeAppForegroundStateService(),
imageLoaderHolder = FakeImageLoaderHolder(),
)
}