mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-03 16:10:00 +00:00
Expose the write sides of the current-call and ringing state
`CurrentCallService` and `ActiveCallManager` are read by the whole app but written only by whoever is actually running a call. Writing has so far been reachable only from inside `features/call/impl`, because that is where both implementations live. Adds `CurrentCallTracker` and `RingingCallTracker` to `features/call/api`, so that a call implementation in another module can report the call it is running and answer a ring, without depending on `features/call/impl`. No behaviour change: both interfaces are implemented by the existing classes, and their methods are aliases of methods that already existed. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
+14
-2
@@ -19,9 +19,11 @@ import coil3.annotation.DelicateCoilApi
|
||||
import dev.zacsweers.metro.AppScope
|
||||
import dev.zacsweers.metro.ContributesBinding
|
||||
import dev.zacsweers.metro.SingleIn
|
||||
import dev.zacsweers.metro.binding
|
||||
import io.element.android.appconfig.ElementCallConfig
|
||||
import io.element.android.features.call.api.CallData
|
||||
import io.element.android.features.call.api.CurrentCall
|
||||
import io.element.android.features.call.api.RingingCallTracker
|
||||
import io.element.android.features.call.impl.notifications.CallNotificationData
|
||||
import io.element.android.features.call.impl.notifications.RingingCallNotificationCreator
|
||||
import io.element.android.libraries.core.extensions.runCatchingExceptions
|
||||
@@ -90,7 +92,8 @@ interface ActiveCallManager {
|
||||
}
|
||||
|
||||
@SingleIn(AppScope::class)
|
||||
@ContributesBinding(AppScope::class)
|
||||
@ContributesBinding(AppScope::class, binding = binding<ActiveCallManager>())
|
||||
@ContributesBinding(AppScope::class, binding = binding<RingingCallTracker>())
|
||||
class DefaultActiveCallManager(
|
||||
@ApplicationContext context: Context,
|
||||
@AppCoroutineScope
|
||||
@@ -103,7 +106,16 @@ class DefaultActiveCallManager(
|
||||
private val appForegroundStateService: AppForegroundStateService,
|
||||
private val imageLoaderHolder: ImageLoaderHolder,
|
||||
private val systemClock: SystemClock,
|
||||
) : ActiveCallManager {
|
||||
) : ActiveCallManager, RingingCallTracker {
|
||||
/**
|
||||
* The two [RingingCallTracker] entry points are the existing methods under the names a caller
|
||||
* outside this module can reach. Deliberately not new behaviour: answering has always had to do
|
||||
* exactly this, and the native path simply could not say so from another module.
|
||||
*/
|
||||
override suspend fun onCallJoined(callData: CallData) = joinedCall(callData)
|
||||
|
||||
override suspend fun onCallEnded(callData: CallData) = hangUpCall(callData)
|
||||
|
||||
private val tag = "ActiveCallManager"
|
||||
private var timedOutCallJob: Job? = null
|
||||
|
||||
|
||||
+7
-4
@@ -11,20 +11,23 @@ package io.element.android.features.call.impl.utils
|
||||
import dev.zacsweers.metro.AppScope
|
||||
import dev.zacsweers.metro.ContributesBinding
|
||||
import dev.zacsweers.metro.SingleIn
|
||||
import dev.zacsweers.metro.binding
|
||||
import io.element.android.features.call.api.CurrentCall
|
||||
import io.element.android.features.call.api.CurrentCallService
|
||||
import io.element.android.features.call.api.CurrentCallTracker
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
|
||||
@SingleIn(AppScope::class)
|
||||
@ContributesBinding(AppScope::class)
|
||||
class DefaultCurrentCallService : CurrentCallService {
|
||||
@ContributesBinding(AppScope::class, binding = binding<CurrentCallService>())
|
||||
@ContributesBinding(AppScope::class, binding = binding<CurrentCallTracker>())
|
||||
class DefaultCurrentCallService : CurrentCallService, CurrentCallTracker {
|
||||
override val currentCall = MutableStateFlow<CurrentCall>(CurrentCall.None)
|
||||
|
||||
fun onCallStarted(call: CurrentCall) {
|
||||
override fun onCallStarted(call: CurrentCall) {
|
||||
currentCall.value = call
|
||||
}
|
||||
|
||||
fun onCallEnded() {
|
||||
override fun onCallEnded() {
|
||||
currentCall.value = CurrentCall.None
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user