Rename CurrentCallObserver to CurrentCallService

This commit is contained in:
Benoit Marty
2024-11-06 17:24:26 +01:00
parent 1e44eb3538
commit 04274b8384
7 changed files with 23 additions and 23 deletions

View File

@@ -9,7 +9,7 @@ package io.element.android.features.call.api
import kotlinx.coroutines.flow.StateFlow
interface CurrentCallObserver {
interface CurrentCallService {
/**
* The current call state flow, which will be updated when the active call changes.
* This value reflect the local state of the call. It is not updated if the user answers

View File

@@ -83,7 +83,7 @@ class DefaultActiveCallManager @Inject constructor(
private val ringingCallNotificationCreator: RingingCallNotificationCreator,
private val notificationManagerCompat: NotificationManagerCompat,
private val matrixClientProvider: MatrixClientProvider,
private val defaultCurrentCallObserver: DefaultCurrentCallObserver,
private val defaultCurrentCallService: DefaultCurrentCallService,
) : ActiveCallManager {
private var timedOutCallJob: Job? = null
@@ -217,7 +217,7 @@ class DefaultActiveCallManager @Inject constructor(
activeCall
.onEach { value ->
if (value == null) {
defaultCurrentCallObserver.onCallEnded()
defaultCurrentCallService.onCallEnded()
} else {
when (value.callState) {
is CallState.Ringing -> {
@@ -225,8 +225,8 @@ class DefaultActiveCallManager @Inject constructor(
}
is CallState.InCall -> {
when (val callType = value.callType) {
is CallType.ExternalUrl -> defaultCurrentCallObserver.onCallStarted(CurrentCall.ExternalUrl(callType.url))
is CallType.RoomCall -> defaultCurrentCallObserver.onCallStarted(CurrentCall.RoomCall(callType.roomId))
is CallType.ExternalUrl -> defaultCurrentCallService.onCallStarted(CurrentCall.ExternalUrl(callType.url))
is CallType.RoomCall -> defaultCurrentCallService.onCallStarted(CurrentCall.RoomCall(callType.roomId))
}
}
}

View File

@@ -9,7 +9,7 @@ package io.element.android.features.call.impl.utils
import com.squareup.anvil.annotations.ContributesBinding
import io.element.android.features.call.api.CurrentCall
import io.element.android.features.call.api.CurrentCallObserver
import io.element.android.features.call.api.CurrentCallService
import io.element.android.libraries.di.AppScope
import io.element.android.libraries.di.SingleIn
import kotlinx.coroutines.flow.MutableStateFlow
@@ -17,7 +17,7 @@ import javax.inject.Inject
@SingleIn(AppScope::class)
@ContributesBinding(AppScope::class)
class DefaultCurrentCallObserver @Inject constructor() : CurrentCallObserver {
class DefaultCurrentCallService @Inject constructor() : CurrentCallService {
override val currentCall = MutableStateFlow<CurrentCall>(CurrentCall.None)
fun onCallStarted(call: CurrentCall) {

View File

@@ -15,7 +15,7 @@ import io.element.android.features.call.impl.notifications.RingingCallNotificati
import io.element.android.features.call.impl.utils.ActiveCall
import io.element.android.features.call.impl.utils.CallState
import io.element.android.features.call.impl.utils.DefaultActiveCallManager
import io.element.android.features.call.impl.utils.DefaultCurrentCallObserver
import io.element.android.features.call.impl.utils.DefaultCurrentCallService
import io.element.android.features.call.test.aCallNotificationData
import io.element.android.libraries.matrix.api.core.EventId
import io.element.android.libraries.matrix.api.core.RoomId
@@ -300,6 +300,6 @@ class DefaultActiveCallManagerTest {
),
notificationManagerCompat = notificationManagerCompat,
matrixClientProvider = matrixClientProvider,
defaultCurrentCallObserver = DefaultCurrentCallObserver(),
defaultCurrentCallService = DefaultCurrentCallService(),
)
}

View File

@@ -8,12 +8,12 @@
package io.element.android.features.call.test
import io.element.android.features.call.api.CurrentCall
import io.element.android.features.call.api.CurrentCallObserver
import io.element.android.features.call.api.CurrentCallService
import kotlinx.coroutines.flow.MutableStateFlow
class FakeCurrentCallObserver(
class FakeCurrentCallService(
initialValue: CurrentCall = CurrentCall.None,
) : CurrentCallObserver {
) : CurrentCallService {
override val currentCall = MutableStateFlow(initialValue)
fun setCurrentCall(value: CurrentCall) {

View File

@@ -13,7 +13,7 @@ import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import io.element.android.features.call.api.CurrentCall
import io.element.android.features.call.api.CurrentCallObserver
import io.element.android.features.call.api.CurrentCallService
import io.element.android.features.roomcall.api.RoomCallState
import io.element.android.libraries.architecture.Presenter
import io.element.android.libraries.matrix.api.room.MatrixRoom
@@ -22,7 +22,7 @@ import javax.inject.Inject
class RoomCallStatePresenter @Inject constructor(
private val room: MatrixRoom,
private val currentCallObserver: CurrentCallObserver,
private val currentCallService: CurrentCallService,
) : Presenter<RoomCallState> {
@Composable
override fun present(): RoomCallState {
@@ -34,7 +34,7 @@ class RoomCallStatePresenter @Inject constructor(
room.sessionId in roomInfo?.activeRoomCallParticipants.orEmpty()
}
}
val currentCall by currentCallObserver.currentCall.collectAsState()
val currentCall by currentCallService.currentCall.collectAsState()
val isUserLocallyInTheCall by remember {
derivedStateOf {
(currentCall as? CurrentCall.RoomCall)?.roomId == room.roomId

View File

@@ -9,8 +9,8 @@ package io.element.android.features.roomcall.impl
import com.google.common.truth.Truth.assertThat
import io.element.android.features.call.api.CurrentCall
import io.element.android.features.call.api.CurrentCallObserver
import io.element.android.features.call.test.FakeCurrentCallObserver
import io.element.android.features.call.api.CurrentCallService
import io.element.android.features.call.test.FakeCurrentCallService
import io.element.android.features.roomcall.api.RoomCallState
import io.element.android.libraries.matrix.api.room.MatrixRoom
import io.element.android.libraries.matrix.test.room.FakeMatrixRoom
@@ -112,7 +112,7 @@ class RoomCallStatePresenterTest {
}
val presenter = createRoomCallStatePresenter(
matrixRoom = room,
currentCallObserver = FakeCurrentCallObserver(initialValue = CurrentCall.RoomCall(room.roomId)),
currentCallService = FakeCurrentCallService(initialValue = CurrentCall.RoomCall(room.roomId)),
)
presenter.test {
skipItems(1)
@@ -138,10 +138,10 @@ class RoomCallStatePresenterTest {
)
)
}
val currentCallObserver = FakeCurrentCallObserver(initialValue = CurrentCall.RoomCall(room.roomId))
val currentCallService = FakeCurrentCallService(initialValue = CurrentCall.RoomCall(room.roomId))
val presenter = createRoomCallStatePresenter(
matrixRoom = room,
currentCallObserver = currentCallObserver
currentCallService = currentCallService
)
presenter.test {
skipItems(1)
@@ -152,7 +152,7 @@ class RoomCallStatePresenterTest {
isUserLocallyInTheCall = true,
)
)
currentCallObserver.setCurrentCall(CurrentCall.None)
currentCallService.setCurrentCall(CurrentCall.None)
assertThat(awaitItem()).isEqualTo(
RoomCallState.OnGoing(
canJoinCall = true,
@@ -189,11 +189,11 @@ class RoomCallStatePresenterTest {
private fun createRoomCallStatePresenter(
matrixRoom: MatrixRoom,
currentCallObserver: CurrentCallObserver = FakeCurrentCallObserver(),
currentCallService: CurrentCallService = FakeCurrentCallService(),
): RoomCallStatePresenter {
return RoomCallStatePresenter(
room = matrixRoom,
currentCallObserver = currentCallObserver,
currentCallService = currentCallService,
)
}
}