mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 11:28:06 +00:00
Automatically play next message voice record, if any
This commit is contained in:
parent
213e62d125
commit
2d2a5e26f6
5 changed files with 39 additions and 3 deletions
|
|
@ -32,6 +32,7 @@ Group changes to describe their impact on the project, as follows:
|
|||
- Media & documents exchanged in a conversation can be easily found through a dedicated screen.
|
||||
- A brand new chat message search feature has been added to conversations.
|
||||
- You can now react to a chat message using any emoji.
|
||||
- If next message is also a voice recording, playback will automatically start after the currently playing one ends.
|
||||
- Chat while in call: a shortcut to a conversation screen with the remote.
|
||||
- Chat while in a conference: if the conference has a text stream enabled, you can chat with the other participants of the conference while it lasts. At the end, you'll find the messages history in the call history (and not in the list of conversations).
|
||||
- Screen sharing in conference: only desktop app starting with 6.0 version is able to start it, but on mobiles you'll be able to see it.
|
||||
|
|
|
|||
|
|
@ -502,6 +502,30 @@ open class ConversationFragment : SlidingPaneChildFragment() {
|
|||
}
|
||||
}
|
||||
|
||||
viewModel.voiceRecordPlaybackEndedEvent.observe(viewLifecycleOwner) {
|
||||
it.consume { id ->
|
||||
Log.i(
|
||||
"$TAG Voice record playback finished, looking for voice record in next message"
|
||||
)
|
||||
val list = viewModel.eventsList
|
||||
val model = list.find {
|
||||
(it.model as? MessageModel)?.id == id
|
||||
}
|
||||
if (model != null) {
|
||||
val index = list.indexOf(model)
|
||||
if (index < list.size - 1) {
|
||||
val nextModel = list[index + 1].model as? MessageModel
|
||||
if (nextModel?.isVoiceRecord?.value == true) {
|
||||
Log.i(
|
||||
"$TAG Next message model is also a voice record, start playing it"
|
||||
)
|
||||
nextModel.togglePlayPauseVoiceRecord()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
viewModel.updateEvents.observe(viewLifecycleOwner) {
|
||||
it.consume {
|
||||
val items = viewModel.eventsList
|
||||
|
|
|
|||
|
|
@ -35,7 +35,8 @@ class EventLogModel @WorkerThread constructor(
|
|||
onJoinConferenceClicked: ((uri: String) -> Unit)? = null,
|
||||
onWebUrlClicked: ((url: String) -> Unit)? = null,
|
||||
onContactClicked: ((friendRefKey: String) -> Unit)? = null,
|
||||
onRedToastToShow: ((pair: Pair<Int, Int>) -> Unit)? = null
|
||||
onRedToastToShow: ((pair: Pair<Int, Int>) -> Unit)? = null,
|
||||
onVoiceRecordingPlaybackEnded: ((id: String) -> Unit)? = null
|
||||
) {
|
||||
companion object {
|
||||
private const val TAG = "[Event Log Model]"
|
||||
|
|
@ -85,7 +86,8 @@ class EventLogModel @WorkerThread constructor(
|
|||
onJoinConferenceClicked,
|
||||
onWebUrlClicked,
|
||||
onContactClicked,
|
||||
onRedToastToShow
|
||||
onRedToastToShow,
|
||||
onVoiceRecordingPlaybackEnded
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -79,7 +79,8 @@ class MessageModel @WorkerThread constructor(
|
|||
private val onJoinConferenceClicked: ((uri: String) -> Unit)? = null,
|
||||
private val onWebUrlClicked: ((url: String) -> Unit)? = null,
|
||||
private val onContactClicked: ((friendRefKey: String) -> Unit)? = null,
|
||||
private val onRedToastToShow: ((pair: Pair<Int, Int>) -> Unit)? = null
|
||||
private val onRedToastToShow: ((pair: Pair<Int, Int>) -> Unit)? = null,
|
||||
private val onVoiceRecordingPlaybackEnded: ((id: String) -> Unit)? = null
|
||||
) {
|
||||
companion object {
|
||||
private const val TAG = "[Message Model]"
|
||||
|
|
@ -182,6 +183,7 @@ class MessageModel @WorkerThread constructor(
|
|||
private val playerListener = PlayerListener {
|
||||
Log.i("$TAG End of file reached")
|
||||
stopVoiceRecordPlayer()
|
||||
onVoiceRecordingPlaybackEnded?.invoke(id)
|
||||
}
|
||||
// End of voice record related fields
|
||||
|
||||
|
|
|
|||
|
|
@ -130,6 +130,10 @@ class ConversationViewModel @UiThread constructor() : AbstractConversationViewMo
|
|||
MutableLiveData<Event<MessageModel>>()
|
||||
}
|
||||
|
||||
val voiceRecordPlaybackEndedEvent: MutableLiveData<Event<String>> by lazy {
|
||||
MutableLiveData<Event<String>>()
|
||||
}
|
||||
|
||||
var eventsList = arrayListOf<EventLogModel>()
|
||||
|
||||
var pendingForwardMessage: MessageModel? = null
|
||||
|
|
@ -752,6 +756,9 @@ class ConversationViewModel @UiThread constructor() : AbstractConversationViewMo
|
|||
},
|
||||
{ redToast ->
|
||||
showRedToastEvent.postValue(Event(redToast))
|
||||
},
|
||||
{ id ->
|
||||
voiceRecordPlaybackEndedEvent.postValue(Event(id))
|
||||
}
|
||||
)
|
||||
eventsList.add(model)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue