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