diff --git a/features/call/api/src/main/kotlin/io/element/android/features/call/api/CurrentCallObserver.kt b/features/call/api/src/main/kotlin/io/element/android/features/call/api/CurrentCallService.kt similarity index 94% rename from features/call/api/src/main/kotlin/io/element/android/features/call/api/CurrentCallObserver.kt rename to features/call/api/src/main/kotlin/io/element/android/features/call/api/CurrentCallService.kt index c0f8eb35a8..9cc61ab96d 100644 --- a/features/call/api/src/main/kotlin/io/element/android/features/call/api/CurrentCallObserver.kt +++ b/features/call/api/src/main/kotlin/io/element/android/features/call/api/CurrentCallService.kt @@ -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 diff --git a/features/call/impl/src/main/kotlin/io/element/android/features/call/impl/utils/ActiveCallManager.kt b/features/call/impl/src/main/kotlin/io/element/android/features/call/impl/utils/ActiveCallManager.kt index ccdbc1b91a..d774a5133c 100644 --- a/features/call/impl/src/main/kotlin/io/element/android/features/call/impl/utils/ActiveCallManager.kt +++ b/features/call/impl/src/main/kotlin/io/element/android/features/call/impl/utils/ActiveCallManager.kt @@ -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)) } } } diff --git a/features/call/impl/src/main/kotlin/io/element/android/features/call/impl/utils/DefaultCurrentCallObserver.kt b/features/call/impl/src/main/kotlin/io/element/android/features/call/impl/utils/DefaultCurrentCallService.kt similarity index 84% rename from features/call/impl/src/main/kotlin/io/element/android/features/call/impl/utils/DefaultCurrentCallObserver.kt rename to features/call/impl/src/main/kotlin/io/element/android/features/call/impl/utils/DefaultCurrentCallService.kt index 4810d31ee6..a2a358483b 100644 --- a/features/call/impl/src/main/kotlin/io/element/android/features/call/impl/utils/DefaultCurrentCallObserver.kt +++ b/features/call/impl/src/main/kotlin/io/element/android/features/call/impl/utils/DefaultCurrentCallService.kt @@ -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.None) fun onCallStarted(call: CurrentCall) { diff --git a/features/call/impl/src/test/kotlin/io/element/android/features/call/utils/DefaultActiveCallManagerTest.kt b/features/call/impl/src/test/kotlin/io/element/android/features/call/utils/DefaultActiveCallManagerTest.kt index 93144ccd50..b9f6a524ae 100644 --- a/features/call/impl/src/test/kotlin/io/element/android/features/call/utils/DefaultActiveCallManagerTest.kt +++ b/features/call/impl/src/test/kotlin/io/element/android/features/call/utils/DefaultActiveCallManagerTest.kt @@ -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(), ) } diff --git a/features/call/test/src/main/kotlin/io/element/android/features/call/test/FakeCurrentCallObserver.kt b/features/call/test/src/main/kotlin/io/element/android/features/call/test/FakeCurrentCallService.kt similarity index 80% rename from features/call/test/src/main/kotlin/io/element/android/features/call/test/FakeCurrentCallObserver.kt rename to features/call/test/src/main/kotlin/io/element/android/features/call/test/FakeCurrentCallService.kt index d153047c66..ff0a9e9096 100644 --- a/features/call/test/src/main/kotlin/io/element/android/features/call/test/FakeCurrentCallObserver.kt +++ b/features/call/test/src/main/kotlin/io/element/android/features/call/test/FakeCurrentCallService.kt @@ -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) { diff --git a/features/roomcall/impl/src/main/kotlin/io/element/android/features/roomcall/impl/RoomCallStatePresenter.kt b/features/roomcall/impl/src/main/kotlin/io/element/android/features/roomcall/impl/RoomCallStatePresenter.kt index b6eb10b342..57ac545c19 100644 --- a/features/roomcall/impl/src/main/kotlin/io/element/android/features/roomcall/impl/RoomCallStatePresenter.kt +++ b/features/roomcall/impl/src/main/kotlin/io/element/android/features/roomcall/impl/RoomCallStatePresenter.kt @@ -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 { @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 diff --git a/features/roomcall/impl/src/test/kotlin/io/element/android/features/roomcall/impl/RoomCallStatePresenterTest.kt b/features/roomcall/impl/src/test/kotlin/io/element/android/features/roomcall/impl/RoomCallStatePresenterTest.kt index aa4a0eb676..ba0b425ec5 100644 --- a/features/roomcall/impl/src/test/kotlin/io/element/android/features/roomcall/impl/RoomCallStatePresenterTest.kt +++ b/features/roomcall/impl/src/test/kotlin/io/element/android/features/roomcall/impl/RoomCallStatePresenterTest.kt @@ -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, ) } }