From dca379b80fe09184cf730151b0125710bb6a16f1 Mon Sep 17 00:00:00 2001 From: Florian Renaud Date: Wed, 9 Nov 2022 11:29:12 +0100 Subject: [PATCH 1/2] Persist the playback state of voice messages across different screens --- .../features/home/room/detail/composer/AudioMessageHelper.kt | 4 ++-- .../home/room/detail/composer/MessageComposerViewModel.kt | 2 +- .../detail/timeline/helper/AudioMessagePlaybackTracker.kt | 3 +-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/composer/AudioMessageHelper.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/composer/AudioMessageHelper.kt index eddfe500b3..07d7ad4d0e 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/composer/AudioMessageHelper.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/composer/AudioMessageHelper.kt @@ -253,8 +253,8 @@ class AudioMessageHelper @Inject constructor( playbackTicker = null } - fun clearTracker() { - playbackTracker.clear() + fun stopTracking() { + playbackTracker.unregisterListeners() } fun stopAllVoiceActions(deleteRecord: Boolean = true): MultiPickerAudioType? { diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/composer/MessageComposerViewModel.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/composer/MessageComposerViewModel.kt index 23d6e71114..a8be2be5e2 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/composer/MessageComposerViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/composer/MessageComposerViewModel.kt @@ -960,7 +960,7 @@ class MessageComposerViewModel @AssistedInject constructor( } fun endAllVoiceActions(deleteRecord: Boolean = true) { - audioMessageHelper.clearTracker() + audioMessageHelper.stopTracking() audioMessageHelper.stopAllVoiceActions(deleteRecord) } diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/helper/AudioMessagePlaybackTracker.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/helper/AudioMessagePlaybackTracker.kt index 91f27ce5a8..b7b3846a10 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/helper/AudioMessagePlaybackTracker.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/helper/AudioMessagePlaybackTracker.kt @@ -136,12 +136,11 @@ class AudioMessagePlaybackTracker @Inject constructor() { } } - fun clear() { + fun unregisterListeners() { listeners.forEach { it.value.onUpdate(Listener.State.Idle) } listeners.clear() - states.clear() } companion object { From a73e707f33b492964c272145229c188f001df7f1 Mon Sep 17 00:00:00 2001 From: Florian Renaud Date: Mon, 14 Nov 2022 15:19:22 +0100 Subject: [PATCH 2/2] Changelog --- changelog.d/7582.feature | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/7582.feature diff --git a/changelog.d/7582.feature b/changelog.d/7582.feature new file mode 100644 index 0000000000..3aae4759ee --- /dev/null +++ b/changelog.d/7582.feature @@ -0,0 +1 @@ +Voice messages - Persist the playback position across different screens