mirror of
https://github.com/element-hq/element-android
synced 2024-11-24 18:35:40 +03:00
Fixes playback button state not tracking after onPause
This commit is contained in:
parent
931c0e9826
commit
fa56a5efa9
4 changed files with 16 additions and 3 deletions
|
@ -1265,7 +1265,7 @@ class TimelineFragment @Inject constructor(
|
|||
override fun onPause() {
|
||||
super.onPause()
|
||||
notificationDrawerManager.setCurrentRoom(null)
|
||||
audioMessagePlaybackTracker.untrack(AudioMessagePlaybackTracker.RECORDING_ID)
|
||||
audioMessagePlaybackTracker.pauseAllPlaybacks()
|
||||
|
||||
if (withState(messageComposerViewModel) { it.isVoiceRecording } && requireActivity().isChangingConfigurations) {
|
||||
// we're rotating, maintain any active recordings
|
||||
|
|
|
@ -881,7 +881,6 @@ class MessageComposerViewModel @AssistedInject constructor(
|
|||
private fun handleEntersBackground(composerText: String) {
|
||||
// Always stop all voice actions. It may be playing in timeline or active recording
|
||||
val playingAudioContent = voiceMessageHelper.stopAllVoiceActions(deleteRecord = false)
|
||||
voiceMessageHelper.clearTracker()
|
||||
|
||||
val isVoiceRecording = com.airbnb.mvrx.withState(this) { it.isVoiceRecording }
|
||||
if (isVoiceRecording) {
|
||||
|
|
|
@ -50,6 +50,12 @@ class AudioMessagePlaybackTracker @Inject constructor() {
|
|||
listeners.remove(id)
|
||||
}
|
||||
|
||||
fun pauseAllPlaybacks() {
|
||||
listeners.keys.forEach { key ->
|
||||
pausePlayback(key)
|
||||
}
|
||||
}
|
||||
|
||||
fun makeAllPlaybacksIdle() {
|
||||
listeners.keys.forEach { key ->
|
||||
setState(key, Listener.State.Idle)
|
||||
|
|
|
@ -18,6 +18,7 @@ package im.vector.app.features.home.room.detail.timeline.item
|
|||
|
||||
import android.content.res.ColorStateList
|
||||
import android.graphics.Color
|
||||
import android.graphics.Paint
|
||||
import android.text.format.DateUtils
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageButton
|
||||
|
@ -27,6 +28,7 @@ import com.airbnb.epoxy.EpoxyAttribute
|
|||
import com.airbnb.epoxy.EpoxyModelClass
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.epoxy.ClickListener
|
||||
import im.vector.app.core.epoxy.onClick
|
||||
import im.vector.app.features.home.room.detail.timeline.helper.AudioMessagePlaybackTracker
|
||||
import im.vector.app.features.home.room.detail.timeline.helper.ContentDownloadStateTrackerBinder
|
||||
import im.vector.app.features.home.room.detail.timeline.helper.ContentUploadStateTrackerBinder
|
||||
|
@ -64,8 +66,8 @@ abstract class MessageAudioItem : AbsMessageItem<MessageAudioItem.Holder>() {
|
|||
override fun bind(holder: Holder) {
|
||||
super.bind(holder)
|
||||
renderSendState(holder.rootLayout, null)
|
||||
bindFilenameViewAttributes(holder)
|
||||
bindUploadState(holder)
|
||||
holder.filenameView.text = filename
|
||||
applyLayoutTint(holder)
|
||||
holder.audioPlaybackControlButton.setOnClickListener { playbackControlButtonClickListener?.invoke(it) }
|
||||
renderStateBasedOnAudioPlayback(holder)
|
||||
|
@ -91,6 +93,12 @@ abstract class MessageAudioItem : AbsMessageItem<MessageAudioItem.Holder>() {
|
|||
holder.mainLayout.backgroundTintList = ColorStateList.valueOf(backgroundTint)
|
||||
}
|
||||
|
||||
private fun bindFilenameViewAttributes(holder: Holder) {
|
||||
holder.filenameView.text = filename
|
||||
holder.filenameView.onClick(attributes.itemClickListener)
|
||||
holder.filenameView.paintFlags = (holder.filenameView.paintFlags or Paint.UNDERLINE_TEXT_FLAG)
|
||||
}
|
||||
|
||||
private fun renderStateBasedOnAudioPlayback(holder: Holder) {
|
||||
audioMessagePlaybackTracker.track(attributes.informationData.eventId, object : AudioMessagePlaybackTracker.Listener {
|
||||
override fun onUpdate(state: AudioMessagePlaybackTracker.Listener.State) {
|
||||
|
|
Loading…
Reference in a new issue