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:
parent
fc59df878f
commit
19f2e0e8c9
3 changed files with 23 additions and 4 deletions
|
|
@ -13,6 +13,8 @@ import android.os.PowerManager
|
||||||
import androidx.annotation.VisibleForTesting
|
import androidx.annotation.VisibleForTesting
|
||||||
import androidx.core.app.NotificationManagerCompat
|
import androidx.core.app.NotificationManagerCompat
|
||||||
import androidx.core.content.getSystemService
|
import androidx.core.content.getSystemService
|
||||||
|
import coil3.SingletonImageLoader
|
||||||
|
import coil3.annotation.DelicateCoilApi
|
||||||
import com.squareup.anvil.annotations.ContributesBinding
|
import com.squareup.anvil.annotations.ContributesBinding
|
||||||
import io.element.android.appconfig.ElementCallConfig
|
import io.element.android.appconfig.ElementCallConfig
|
||||||
import io.element.android.features.call.api.CallType
|
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.ApplicationContext
|
||||||
import io.element.android.libraries.di.SingleIn
|
import io.element.android.libraries.di.SingleIn
|
||||||
import io.element.android.libraries.matrix.api.MatrixClientProvider
|
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.ForegroundServiceType
|
||||||
import io.element.android.libraries.push.api.notifications.NotificationIdProvider
|
import io.element.android.libraries.push.api.notifications.NotificationIdProvider
|
||||||
import io.element.android.libraries.push.api.notifications.OnMissedCallNotificationHandler
|
import io.element.android.libraries.push.api.notifications.OnMissedCallNotificationHandler
|
||||||
|
|
@ -89,6 +93,7 @@ class DefaultActiveCallManager @Inject constructor(
|
||||||
private val matrixClientProvider: MatrixClientProvider,
|
private val matrixClientProvider: MatrixClientProvider,
|
||||||
private val defaultCurrentCallService: DefaultCurrentCallService,
|
private val defaultCurrentCallService: DefaultCurrentCallService,
|
||||||
private val appForegroundStateService: AppForegroundStateService,
|
private val appForegroundStateService: AppForegroundStateService,
|
||||||
|
private val imageLoaderHolder: ImageLoaderHolder,
|
||||||
) : ActiveCallManager {
|
) : ActiveCallManager {
|
||||||
private val tag = "DefaultActiveCallManager"
|
private val tag = "DefaultActiveCallManager"
|
||||||
private var timedOutCallJob: Job? = null
|
private var timedOutCallJob: Job? = null
|
||||||
|
|
@ -125,6 +130,7 @@ class DefaultActiveCallManager @Inject constructor(
|
||||||
)
|
)
|
||||||
|
|
||||||
timedOutCallJob = coroutineScope.launch {
|
timedOutCallJob = coroutineScope.launch {
|
||||||
|
setUpCoil(notificationData.sessionId)
|
||||||
showIncomingCallNotification(notificationData)
|
showIncomingCallNotification(notificationData)
|
||||||
|
|
||||||
// Wait for the ringing call to time out
|
// 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.
|
* Called when the incoming call timed out. It will remove the active call and remove any associated UI, adding a 'missed call' notification.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -325,5 +325,6 @@ class DefaultActiveCallManagerTest {
|
||||||
matrixClientProvider = matrixClientProvider,
|
matrixClientProvider = matrixClientProvider,
|
||||||
defaultCurrentCallService = DefaultCurrentCallService(),
|
defaultCurrentCallService = DefaultCurrentCallService(),
|
||||||
appForegroundStateService = FakeAppForegroundStateService(),
|
appForegroundStateService = FakeAppForegroundStateService(),
|
||||||
|
imageLoaderHolder = FakeImageLoaderHolder(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@
|
||||||
package io.element.android.libraries.designsystem.background
|
package io.element.android.libraries.designsystem.background
|
||||||
|
|
||||||
import androidx.compose.foundation.Canvas
|
import androidx.compose.foundation.Canvas
|
||||||
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
import androidx.compose.foundation.layout.fillMaxSize
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
|
|
@ -32,13 +33,17 @@ import io.element.android.libraries.designsystem.preview.PreviewsDayNight
|
||||||
@Suppress("ModifierMissing")
|
@Suppress("ModifierMissing")
|
||||||
@Composable
|
@Composable
|
||||||
fun OnboardingBackground() {
|
fun OnboardingBackground() {
|
||||||
Box(modifier = Modifier.fillMaxSize()) {
|
Box(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxSize()
|
||||||
|
.background(ElementTheme.colors.bgCanvasDefault)
|
||||||
|
) {
|
||||||
val isLightTheme = ElementTheme.isLightTheme
|
val isLightTheme = ElementTheme.isLightTheme
|
||||||
Canvas(
|
Canvas(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.height(220.dp)
|
.height(220.dp)
|
||||||
.align(Alignment.BottomCenter)
|
.align(Alignment.BottomCenter)
|
||||||
) {
|
) {
|
||||||
val gradientBrush = ShaderBrush(
|
val gradientBrush = ShaderBrush(
|
||||||
LinearGradientShader(
|
LinearGradientShader(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue