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 fc59df878f
commit 19f2e0e8c9
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(),
)
}

View File

@@ -8,6 +8,7 @@
package io.element.android.libraries.designsystem.background
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
@@ -32,13 +33,17 @@ import io.element.android.libraries.designsystem.preview.PreviewsDayNight
@Suppress("ModifierMissing")
@Composable
fun OnboardingBackground() {
Box(modifier = Modifier.fillMaxSize()) {
Box(
modifier = Modifier
.fillMaxSize()
.background(ElementTheme.colors.bgCanvasDefault)
) {
val isLightTheme = ElementTheme.isLightTheme
Canvas(
modifier = Modifier
.fillMaxWidth()
.height(220.dp)
.align(Alignment.BottomCenter)
.fillMaxWidth()
.height(220.dp)
.align(Alignment.BottomCenter)
) {
val gradientBrush = ShaderBrush(
LinearGradientShader(