From 2bcf10dd0bb78fe34309e76c0fca3f4e68dad5c9 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Mon, 27 Apr 2026 17:04:12 +0200 Subject: [PATCH] `CallScreenEvents` -> `CallScreenEvent` --- .../ui/{CallScreenEvents.kt => CallScreenEvent.kt} | 8 ++++---- .../features/call/impl/ui/CallScreenPresenter.kt | 8 ++++---- .../features/call/impl/ui/CallScreenState.kt | 2 +- .../call/impl/ui/CallScreenStateProvider.kt | 2 +- .../features/call/impl/ui/CallScreenView.kt | 10 +++++----- .../features/call/impl/ui/ElementCallActivity.kt | 6 +++--- .../features/call/ui/CallScreenPresenterTest.kt | 14 +++++++------- 7 files changed, 25 insertions(+), 25 deletions(-) rename features/call/impl/src/main/kotlin/io/element/android/features/call/impl/ui/{CallScreenEvents.kt => CallScreenEvent.kt} (78%) diff --git a/features/call/impl/src/main/kotlin/io/element/android/features/call/impl/ui/CallScreenEvents.kt b/features/call/impl/src/main/kotlin/io/element/android/features/call/impl/ui/CallScreenEvent.kt similarity index 78% rename from features/call/impl/src/main/kotlin/io/element/android/features/call/impl/ui/CallScreenEvents.kt rename to features/call/impl/src/main/kotlin/io/element/android/features/call/impl/ui/CallScreenEvent.kt index 8fbbce896f..357559c3f9 100644 --- a/features/call/impl/src/main/kotlin/io/element/android/features/call/impl/ui/CallScreenEvents.kt +++ b/features/call/impl/src/main/kotlin/io/element/android/features/call/impl/ui/CallScreenEvent.kt @@ -10,8 +10,8 @@ package io.element.android.features.call.impl.ui import io.element.android.features.call.impl.utils.WidgetMessageInterceptor -sealed interface CallScreenEvents { - data object Hangup : CallScreenEvents - data class SetupMessageChannels(val widgetMessageInterceptor: WidgetMessageInterceptor) : CallScreenEvents - data class OnWebViewError(val description: String?) : CallScreenEvents +sealed interface CallScreenEvent { + data object Hangup : CallScreenEvent + data class SetupMessageChannels(val widgetMessageInterceptor: WidgetMessageInterceptor) : CallScreenEvent + data class OnWebViewError(val description: String?) : CallScreenEvent } diff --git a/features/call/impl/src/main/kotlin/io/element/android/features/call/impl/ui/CallScreenPresenter.kt b/features/call/impl/src/main/kotlin/io/element/android/features/call/impl/ui/CallScreenPresenter.kt index b9bd6640b4..7d8e20967f 100644 --- a/features/call/impl/src/main/kotlin/io/element/android/features/call/impl/ui/CallScreenPresenter.kt +++ b/features/call/impl/src/main/kotlin/io/element/android/features/call/impl/ui/CallScreenPresenter.kt @@ -152,9 +152,9 @@ class CallScreenPresenter( } } - fun handleEvent(event: CallScreenEvents) { + fun handleEvent(event: CallScreenEvent) { when (event) { - is CallScreenEvents.Hangup -> { + is CallScreenEvent.Hangup -> { val widgetId = callWidgetDriver.value?.id val interceptor = messageInterceptor.value if (widgetId != null && interceptor != null && isWidgetLoaded) { @@ -174,10 +174,10 @@ class CallScreenPresenter( } } } - is CallScreenEvents.SetupMessageChannels -> { + is CallScreenEvent.SetupMessageChannels -> { messageInterceptor.value = event.widgetMessageInterceptor } - is CallScreenEvents.OnWebViewError -> { + is CallScreenEvent.OnWebViewError -> { if (!ignoreWebViewError) { webViewError = event.description.orEmpty() } diff --git a/features/call/impl/src/main/kotlin/io/element/android/features/call/impl/ui/CallScreenState.kt b/features/call/impl/src/main/kotlin/io/element/android/features/call/impl/ui/CallScreenState.kt index 3608a2b620..86b4cc439f 100644 --- a/features/call/impl/src/main/kotlin/io/element/android/features/call/impl/ui/CallScreenState.kt +++ b/features/call/impl/src/main/kotlin/io/element/android/features/call/impl/ui/CallScreenState.kt @@ -15,5 +15,5 @@ data class CallScreenState( val webViewError: String?, val userAgent: String, val isCallActive: Boolean, - val eventSink: (CallScreenEvents) -> Unit, + val eventSink: (CallScreenEvent) -> Unit, ) diff --git a/features/call/impl/src/main/kotlin/io/element/android/features/call/impl/ui/CallScreenStateProvider.kt b/features/call/impl/src/main/kotlin/io/element/android/features/call/impl/ui/CallScreenStateProvider.kt index 036bb6103a..155c5d3380 100644 --- a/features/call/impl/src/main/kotlin/io/element/android/features/call/impl/ui/CallScreenStateProvider.kt +++ b/features/call/impl/src/main/kotlin/io/element/android/features/call/impl/ui/CallScreenStateProvider.kt @@ -26,7 +26,7 @@ internal fun aCallScreenState( webViewError: String? = null, userAgent: String = "", isCallActive: Boolean = true, - eventSink: (CallScreenEvents) -> Unit = {}, + eventSink: (CallScreenEvent) -> Unit = {}, ): CallScreenState { return CallScreenState( urlState = urlState, diff --git a/features/call/impl/src/main/kotlin/io/element/android/features/call/impl/ui/CallScreenView.kt b/features/call/impl/src/main/kotlin/io/element/android/features/call/impl/ui/CallScreenView.kt index f8657a9ece..a945f3c844 100644 --- a/features/call/impl/src/main/kotlin/io/element/android/features/call/impl/ui/CallScreenView.kt +++ b/features/call/impl/src/main/kotlin/io/element/android/features/call/impl/ui/CallScreenView.kt @@ -68,7 +68,7 @@ internal fun CallScreenView( if (pipState.supportPip) { pipState.eventSink.invoke(PictureInPictureEvents.EnterPictureInPicture) } else { - state.eventSink(CallScreenEvents.Hangup) + state.eventSink(CallScreenEvent.Hangup) } } @@ -84,7 +84,7 @@ internal fun CallScreenView( append(stringResource(CommonStrings.error_unknown)) state.webViewError.takeIf { it.isNotEmpty() }?.let { append("\n\n").append(it) } }, - onSubmit = { state.eventSink(CallScreenEvents.Hangup) }, + onSubmit = { state.eventSink(CallScreenEvent.Hangup) }, ) } else { var webViewAudioManager by remember { mutableStateOf(null) } @@ -123,14 +123,14 @@ internal fun CallScreenView( Timber.d("Can't start in-call audio mode since the app is already in it.") } }, - onError = { state.eventSink(CallScreenEvents.OnWebViewError(it)) }, + onError = { state.eventSink(CallScreenEvent.OnWebViewError(it)) }, ) webViewAudioManager = WebViewAudioManager( webView = webView, coroutineScope = coroutineScope, onInvalidAudioDeviceAdded = { invalidAudioDeviceReason = it }, ) - state.eventSink(CallScreenEvents.SetupMessageChannels(interceptor)) + state.eventSink(CallScreenEvent.SetupMessageChannels(interceptor)) val pipController = WebViewPipController(webView) pipState.eventSink(PictureInPictureEvents.SetPipController(pipController)) }, @@ -147,7 +147,7 @@ internal fun CallScreenView( Timber.e(state.urlState.error, "WebView failed to load URL: ${state.urlState.error.message}") ErrorDialog( content = state.urlState.error.message.orEmpty(), - onSubmit = { state.eventSink(CallScreenEvents.Hangup) }, + onSubmit = { state.eventSink(CallScreenEvent.Hangup) }, ) } is AsyncData.Success -> Unit diff --git a/features/call/impl/src/main/kotlin/io/element/android/features/call/impl/ui/ElementCallActivity.kt b/features/call/impl/src/main/kotlin/io/element/android/features/call/impl/ui/ElementCallActivity.kt index dddcfceb50..bce882ec2d 100644 --- a/features/call/impl/src/main/kotlin/io/element/android/features/call/impl/ui/ElementCallActivity.kt +++ b/features/call/impl/src/main/kotlin/io/element/android/features/call/impl/ui/ElementCallActivity.kt @@ -79,7 +79,7 @@ class ElementCallActivity : private val webViewTarget = mutableStateOf(null) - private var eventSink: ((CallScreenEvents) -> Unit)? = null + private var eventSink: ((CallScreenEvent) -> Unit)? = null override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -172,7 +172,7 @@ class ElementCallActivity : pipEventSink(PictureInPictureEvents.OnPictureInPictureModeChanged(isInPictureInPictureMode)) if (!isInPictureInPictureMode && !lifecycle.currentState.isAtLeast(Lifecycle.State.STARTED)) { Timber.tag(loggerTag.value).d("Exiting PiP mode: Hangup the call") - eventSink?.invoke(CallScreenEvents.Hangup) + eventSink?.invoke(CallScreenEvent.Hangup) } } addOnPictureInPictureModeChangedListener(onPictureInPictureModeChangedListener) @@ -280,7 +280,7 @@ class ElementCallActivity : } override fun hangUp() { - eventSink?.invoke(CallScreenEvents.Hangup) + eventSink?.invoke(CallScreenEvent.Hangup) } } diff --git a/features/call/impl/src/test/kotlin/io/element/android/features/call/ui/CallScreenPresenterTest.kt b/features/call/impl/src/test/kotlin/io/element/android/features/call/ui/CallScreenPresenterTest.kt index c2c576999c..99f10b46fc 100644 --- a/features/call/impl/src/test/kotlin/io/element/android/features/call/ui/CallScreenPresenterTest.kt +++ b/features/call/impl/src/test/kotlin/io/element/android/features/call/ui/CallScreenPresenterTest.kt @@ -14,7 +14,7 @@ import app.cash.turbine.test import com.google.common.truth.Truth.assertThat import im.vector.app.features.analytics.plan.MobileScreen import io.element.android.features.call.api.CallData -import io.element.android.features.call.impl.ui.CallScreenEvents +import io.element.android.features.call.impl.ui.CallScreenEvent import io.element.android.features.call.impl.ui.CallScreenNavigator import io.element.android.features.call.impl.ui.CallScreenPresenter import io.element.android.features.call.impl.utils.WidgetMessageSerializer @@ -109,7 +109,7 @@ class CallScreenPresenterTest { advanceTimeBy(1.seconds) val initialState = awaitItem() - initialState.eventSink(CallScreenEvents.SetupMessageChannels(messageInterceptor)) + initialState.eventSink(CallScreenEvent.SetupMessageChannels(messageInterceptor)) // And incoming message from the Widget Driver is passed to the WebView widgetDriver.givenIncomingMessage("A message") @@ -143,9 +143,9 @@ class CallScreenPresenterTest { // Give it time to load the URL and WidgetDriver advanceTimeBy(1.seconds) - initialState.eventSink(CallScreenEvents.SetupMessageChannels(messageInterceptor)) + initialState.eventSink(CallScreenEvent.SetupMessageChannels(messageInterceptor)) - initialState.eventSink(CallScreenEvents.Hangup) + initialState.eventSink(CallScreenEvent.Hangup) // Let background coroutines run and the widget drive be received runCurrent() @@ -177,7 +177,7 @@ class CallScreenPresenterTest { // Give it time to load the URL and WidgetDriver advanceTimeBy(1.seconds) - initialState.eventSink(CallScreenEvents.SetupMessageChannels(messageInterceptor)) + initialState.eventSink(CallScreenEvent.SetupMessageChannels(messageInterceptor)) messageInterceptor.givenInterceptedMessage("""{"action":"io.element.close","api":"fromWidget","widgetId":"1","requestId":"1"}""") @@ -212,7 +212,7 @@ class CallScreenPresenterTest { skipItems(2) val initialState = awaitItem() assertThat(initialState.isCallActive).isFalse() - initialState.eventSink(CallScreenEvents.SetupMessageChannels(messageInterceptor)) + initialState.eventSink(CallScreenEvent.SetupMessageChannels(messageInterceptor)) messageInterceptor.givenInterceptedMessage( """ { @@ -249,7 +249,7 @@ class CallScreenPresenterTest { skipItems(2) val initialState = awaitItem() assertThat(initialState.isCallActive).isFalse() - initialState.eventSink(CallScreenEvents.SetupMessageChannels(messageInterceptor)) + initialState.eventSink(CallScreenEvent.SetupMessageChannels(messageInterceptor)) skipItems(2) // Wait for the timeout to trigger