From a10ac8aaabc780e6bff0b66b45cdc20e953b11ec Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 31 Dec 2025 09:48:46 +0100 Subject: [PATCH] VoiceMessageEvents -> VoiceMessageEvent --- .../components/event/TimelineItemVoiceView.kt | 8 +++---- .../impl/gallery/ui/VoiceItemView.kt | 8 +++---- ...eMessageEvents.kt => VoiceMessageEvent.kt} | 8 +++---- .../voiceplayer/api/VoiceMessageState.kt | 2 +- .../voiceplayer/impl/VoiceMessagePresenter.kt | 10 ++++---- .../impl/VoiceMessagePresenterTest.kt | 24 +++++++++---------- 6 files changed, 30 insertions(+), 30 deletions(-) rename libraries/voiceplayer/api/src/main/kotlin/io/element/android/libraries/voiceplayer/api/{VoiceMessageEvents.kt => VoiceMessageEvent.kt} (58%) diff --git a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/event/TimelineItemVoiceView.kt b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/event/TimelineItemVoiceView.kt index 45534e9591..203fd8f1da 100644 --- a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/event/TimelineItemVoiceView.kt +++ b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/event/TimelineItemVoiceView.kt @@ -53,7 +53,7 @@ import io.element.android.libraries.designsystem.theme.components.IconButton import io.element.android.libraries.designsystem.theme.components.Text import io.element.android.libraries.ui.strings.CommonStrings import io.element.android.libraries.ui.utils.time.isTalkbackActive -import io.element.android.libraries.voiceplayer.api.VoiceMessageEvents +import io.element.android.libraries.voiceplayer.api.VoiceMessageEvent import io.element.android.libraries.voiceplayer.api.VoiceMessageState import io.element.android.libraries.voiceplayer.api.VoiceMessageStateProvider import kotlinx.coroutines.delay @@ -66,7 +66,7 @@ fun TimelineItemVoiceView( modifier: Modifier = Modifier, ) { fun playPause() { - state.eventSink(VoiceMessageEvents.PlayPause) + state.eventSink(VoiceMessageEvent.PlayPause) } val a11y = stringResource(CommonStrings.common_voice_message) @@ -118,7 +118,7 @@ fun TimelineItemVoiceView( ) { PlaybackSpeedButton( speed = state.playbackSpeed, - onClick = { state.eventSink(VoiceMessageEvents.ChangePlaybackSpeed) }, + onClick = { state.eventSink(VoiceMessageEvent.ChangePlaybackSpeed) }, ) Text( text = state.time, @@ -137,7 +137,7 @@ fun TimelineItemVoiceView( .weight(1f) .height(34.dp), seekEnabled = !isTalkbackActive(), - onSeek = { state.eventSink(VoiceMessageEvents.Seek(it)) }, + onSeek = { state.eventSink(VoiceMessageEvent.Seek(it)) }, ) } } diff --git a/libraries/mediaviewer/impl/src/main/kotlin/io/element/android/libraries/mediaviewer/impl/gallery/ui/VoiceItemView.kt b/libraries/mediaviewer/impl/src/main/kotlin/io/element/android/libraries/mediaviewer/impl/gallery/ui/VoiceItemView.kt index 9b2eaa2b32..f608236e49 100644 --- a/libraries/mediaviewer/impl/src/main/kotlin/io/element/android/libraries/mediaviewer/impl/gallery/ui/VoiceItemView.kt +++ b/libraries/mediaviewer/impl/src/main/kotlin/io/element/android/libraries/mediaviewer/impl/gallery/ui/VoiceItemView.kt @@ -52,7 +52,7 @@ import io.element.android.libraries.designsystem.theme.components.Text import io.element.android.libraries.mediaviewer.impl.model.MediaItem import io.element.android.libraries.mediaviewer.impl.model.aMediaItemVoice import io.element.android.libraries.ui.strings.CommonStrings -import io.element.android.libraries.voiceplayer.api.VoiceMessageEvents +import io.element.android.libraries.voiceplayer.api.VoiceMessageEvent import io.element.android.libraries.voiceplayer.api.VoiceMessageState import io.element.android.libraries.voiceplayer.api.VoiceMessageStateProvider import io.element.android.libraries.voiceplayer.api.aVoiceMessageState @@ -94,7 +94,7 @@ private fun VoiceInfoRow( onLongClick: () -> Unit, ) { fun playPause() { - state.eventSink(VoiceMessageEvents.PlayPause) + state.eventSink(VoiceMessageEvent.PlayPause) } Row( @@ -128,7 +128,7 @@ private fun VoiceInfoRow( ) { PlaybackSpeedButton( speed = state.playbackSpeed, - onClick = { state.eventSink(VoiceMessageEvents.ChangePlaybackSpeed) }, + onClick = { state.eventSink(VoiceMessageEvent.ChangePlaybackSpeed) }, ) Text( text = if (state.progress > 0f) state.time else voice.mediaInfo.duration ?: state.time, @@ -147,7 +147,7 @@ private fun VoiceInfoRow( playbackProgress = state.progress, waveform = voice.mediaInfo.waveform.orEmpty().toImmutableList(), onSeek = { - state.eventSink(VoiceMessageEvents.Seek(it)) + state.eventSink(VoiceMessageEvent.Seek(it)) }, seekEnabled = true, ) diff --git a/libraries/voiceplayer/api/src/main/kotlin/io/element/android/libraries/voiceplayer/api/VoiceMessageEvents.kt b/libraries/voiceplayer/api/src/main/kotlin/io/element/android/libraries/voiceplayer/api/VoiceMessageEvent.kt similarity index 58% rename from libraries/voiceplayer/api/src/main/kotlin/io/element/android/libraries/voiceplayer/api/VoiceMessageEvents.kt rename to libraries/voiceplayer/api/src/main/kotlin/io/element/android/libraries/voiceplayer/api/VoiceMessageEvent.kt index 01910ddcd6..bec03f3943 100644 --- a/libraries/voiceplayer/api/src/main/kotlin/io/element/android/libraries/voiceplayer/api/VoiceMessageEvents.kt +++ b/libraries/voiceplayer/api/src/main/kotlin/io/element/android/libraries/voiceplayer/api/VoiceMessageEvent.kt @@ -8,8 +8,8 @@ package io.element.android.libraries.voiceplayer.api -sealed interface VoiceMessageEvents { - data object PlayPause : VoiceMessageEvents - data class Seek(val percentage: Float) : VoiceMessageEvents - data object ChangePlaybackSpeed : VoiceMessageEvents +sealed interface VoiceMessageEvent { + data object PlayPause : VoiceMessageEvent + data class Seek(val percentage: Float) : VoiceMessageEvent + data object ChangePlaybackSpeed : VoiceMessageEvent } diff --git a/libraries/voiceplayer/api/src/main/kotlin/io/element/android/libraries/voiceplayer/api/VoiceMessageState.kt b/libraries/voiceplayer/api/src/main/kotlin/io/element/android/libraries/voiceplayer/api/VoiceMessageState.kt index a66209c5db..36fa13a268 100644 --- a/libraries/voiceplayer/api/src/main/kotlin/io/element/android/libraries/voiceplayer/api/VoiceMessageState.kt +++ b/libraries/voiceplayer/api/src/main/kotlin/io/element/android/libraries/voiceplayer/api/VoiceMessageState.kt @@ -14,7 +14,7 @@ data class VoiceMessageState( val time: String, val showCursor: Boolean, val playbackSpeed: Float, - val eventSink: (event: VoiceMessageEvents) -> Unit, + val eventSink: (event: VoiceMessageEvent) -> Unit, ) { enum class Button { Play, diff --git a/libraries/voiceplayer/impl/src/main/kotlin/io/element/android/libraries/voiceplayer/impl/VoiceMessagePresenter.kt b/libraries/voiceplayer/impl/src/main/kotlin/io/element/android/libraries/voiceplayer/impl/VoiceMessagePresenter.kt index 95c9554731..c58838963a 100644 --- a/libraries/voiceplayer/impl/src/main/kotlin/io/element/android/libraries/voiceplayer/impl/VoiceMessagePresenter.kt +++ b/libraries/voiceplayer/impl/src/main/kotlin/io/element/android/libraries/voiceplayer/impl/VoiceMessagePresenter.kt @@ -22,7 +22,7 @@ import io.element.android.libraries.core.extensions.flatMap import io.element.android.libraries.core.extensions.runCatchingExceptions import io.element.android.libraries.matrix.api.core.EventId import io.element.android.libraries.ui.utils.time.formatShort -import io.element.android.libraries.voiceplayer.api.VoiceMessageEvents +import io.element.android.libraries.voiceplayer.api.VoiceMessageEvent import io.element.android.libraries.voiceplayer.api.VoiceMessageException import io.element.android.libraries.voiceplayer.api.VoiceMessageState import io.element.android.services.analytics.api.AnalyticsService @@ -87,9 +87,9 @@ class VoiceMessagePresenter( } } - fun handleEvent(event: VoiceMessageEvents) { + fun handleEvent(event: VoiceMessageEvent) { when (event) { - is VoiceMessageEvents.PlayPause -> { + is VoiceMessageEvent.PlayPause -> { if (playerState.isPlaying) { player.pause() } else if (playerState.isReady) { @@ -111,10 +111,10 @@ class VoiceMessagePresenter( } } } - is VoiceMessageEvents.Seek -> { + is VoiceMessageEvent.Seek -> { player.seekTo((event.percentage * duration).toLong()) } - is VoiceMessageEvents.ChangePlaybackSpeed -> { + is VoiceMessageEvent.ChangePlaybackSpeed -> { playbackSpeedIndex.intValue = (playbackSpeedIndex.intValue + 1) % VoicePlayerConfig.availablePlaybackSpeeds.size player.setPlaybackSpeed(VoicePlayerConfig.availablePlaybackSpeeds[playbackSpeedIndex.intValue]) } diff --git a/libraries/voiceplayer/impl/src/test/kotlin/io/element/android/libraries/voiceplayer/impl/VoiceMessagePresenterTest.kt b/libraries/voiceplayer/impl/src/test/kotlin/io/element/android/libraries/voiceplayer/impl/VoiceMessagePresenterTest.kt index 87f7ffbc34..3d9c452c2a 100644 --- a/libraries/voiceplayer/impl/src/test/kotlin/io/element/android/libraries/voiceplayer/impl/VoiceMessagePresenterTest.kt +++ b/libraries/voiceplayer/impl/src/test/kotlin/io/element/android/libraries/voiceplayer/impl/VoiceMessagePresenterTest.kt @@ -13,7 +13,7 @@ import io.element.android.libraries.core.mimetype.MimeTypes import io.element.android.libraries.matrix.api.core.EventId import io.element.android.libraries.matrix.api.media.MediaSource import io.element.android.libraries.mediaplayer.test.FakeMediaPlayer -import io.element.android.libraries.voiceplayer.api.VoiceMessageEvents +import io.element.android.libraries.voiceplayer.api.VoiceMessageEvent import io.element.android.libraries.voiceplayer.api.VoiceMessageException import io.element.android.libraries.voiceplayer.api.VoiceMessageState import io.element.android.services.analytics.api.AnalyticsService @@ -51,7 +51,7 @@ class VoiceMessagePresenterTest { assertThat(it.time).isEqualTo("0:02") } - initialState.eventSink(VoiceMessageEvents.PlayPause) + initialState.eventSink(VoiceMessageEvent.PlayPause) awaitItem().also { assertThat(it.button).isEqualTo(VoiceMessageState.Button.Downloading) @@ -87,7 +87,7 @@ class VoiceMessagePresenterTest { assertThat(it.time).isEqualTo("0:02") } - initialState.eventSink(VoiceMessageEvents.PlayPause) + initialState.eventSink(VoiceMessageEvent.PlayPause) awaitItem().also { assertThat(it.button).isEqualTo(VoiceMessageState.Button.Downloading) @@ -121,7 +121,7 @@ class VoiceMessagePresenterTest { assertThat(it.time).isEqualTo("0:02") } - initialState.eventSink(VoiceMessageEvents.PlayPause) + initialState.eventSink(VoiceMessageEvent.PlayPause) skipItems(2) // skip downloading states val playingState = awaitItem().also { @@ -130,7 +130,7 @@ class VoiceMessagePresenterTest { assertThat(it.time).isEqualTo("0:01") } - playingState.eventSink(VoiceMessageEvents.PlayPause) + playingState.eventSink(VoiceMessageEvent.PlayPause) awaitItem().also { assertThat(it.button).isEqualTo(VoiceMessageState.Button.Play) assertThat(it.progress).isEqualTo(0.5f) @@ -166,7 +166,7 @@ class VoiceMessagePresenterTest { assertThat(it.time).isEqualTo("0:10") } - initialState.eventSink(VoiceMessageEvents.Seek(0.5f)) + initialState.eventSink(VoiceMessageEvent.Seek(0.5f)) awaitItem().also { assertThat(it.button).isEqualTo(VoiceMessageState.Button.Play) @@ -188,7 +188,7 @@ class VoiceMessagePresenterTest { assertThat(it.time).isEqualTo("0:10") } - initialState.eventSink(VoiceMessageEvents.PlayPause) + initialState.eventSink(VoiceMessageEvent.PlayPause) skipItems(2) // skip downloading states @@ -196,7 +196,7 @@ class VoiceMessagePresenterTest { assertThat(it.button).isEqualTo(VoiceMessageState.Button.Pause) assertThat(it.progress).isEqualTo(0.1f) assertThat(it.time).isEqualTo("0:01") - it.eventSink(VoiceMessageEvents.Seek(0.5f)) + it.eventSink(VoiceMessageEvent.Seek(0.5f)) } awaitItem().also { @@ -215,19 +215,19 @@ class VoiceMessagePresenterTest { presenter.test { awaitItem().also { assertThat(it.playbackSpeed).isEqualTo(1.0f) - it.eventSink(VoiceMessageEvents.ChangePlaybackSpeed) + it.eventSink(VoiceMessageEvent.ChangePlaybackSpeed) } awaitItem().also { assertThat(it.playbackSpeed).isEqualTo(1.5f) - it.eventSink(VoiceMessageEvents.ChangePlaybackSpeed) + it.eventSink(VoiceMessageEvent.ChangePlaybackSpeed) } awaitItem().also { assertThat(it.playbackSpeed).isEqualTo(2.0f) - it.eventSink(VoiceMessageEvents.ChangePlaybackSpeed) + it.eventSink(VoiceMessageEvent.ChangePlaybackSpeed) } awaitItem().also { assertThat(it.playbackSpeed).isEqualTo(0.5f) - it.eventSink(VoiceMessageEvents.ChangePlaybackSpeed) + it.eventSink(VoiceMessageEvent.ChangePlaybackSpeed) } awaitItem().also { assertThat(it.playbackSpeed).isEqualTo(1.0f)