-
Notifications
You must be signed in to change notification settings - Fork 857
Voice Draft support #4527
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Voice Draft support #4527
Changes from 18 commits
1c8fd30
3cc57f2
eaf063c
e97c065
a459692
dfd6884
e5865bf
bfdacfe
2d81260
a345f26
95e5c12
5687c36
6e8c545
e790091
b9b51af
00b954f
cd4e991
4b67a6d
7655c25
94161b2
517a0d6
c11bc2d
60ed9ec
bf968cc
f360021
bb2239c
c2ec157
be103fc
ff2dc71
9939298
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Fixing queued voice message failing to send or retry |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Voice messages: Persist drafts of voice messages when navigating between rooms |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -205,6 +205,7 @@ import org.matrix.android.sdk.api.session.room.model.message.MessageFormat | |
| import org.matrix.android.sdk.api.session.room.model.message.MessageImageInfoContent | ||
| import org.matrix.android.sdk.api.session.room.model.message.MessageStickerContent | ||
| import org.matrix.android.sdk.api.session.room.model.message.MessageTextContent | ||
| import org.matrix.android.sdk.api.session.room.model.message.MessageType | ||
| import org.matrix.android.sdk.api.session.room.model.message.MessageVerificationRequestContent | ||
| import org.matrix.android.sdk.api.session.room.model.message.MessageVideoContent | ||
| import org.matrix.android.sdk.api.session.room.model.message.MessageWithAttachmentContent | ||
|
|
@@ -392,7 +393,13 @@ class RoomDetailFragment @Inject constructor( | |
| return@onEach | ||
| } | ||
| when (mode) { | ||
| is SendMode.REGULAR -> renderRegularMode(mode.text) | ||
| is SendMode.REGULAR -> { | ||
| if (mode.messageType == MessageType.MSGTYPE_AUDIO) { | ||
|
||
| renderVoiceMessageMode(mode.text) | ||
| } else { | ||
| renderRegularMode(mode.text) | ||
| } | ||
| } | ||
| is SendMode.EDIT -> renderSpecialMode(mode.timelineEvent, R.drawable.ic_edit, R.string.edit, mode.text) | ||
| is SendMode.QUOTE -> renderSpecialMode(mode.timelineEvent, R.drawable.ic_quote, R.string.quote, mode.text) | ||
| is SendMode.REPLY -> renderSpecialMode(mode.timelineEvent, R.drawable.ic_reply, R.string.reply, mode.text) | ||
|
|
@@ -471,6 +478,13 @@ class RoomDetailFragment @Inject constructor( | |
| } | ||
| } | ||
|
|
||
| private fun renderVoiceMessageMode(content: String) { | ||
| ContentAttachmentData.fromJsonString(content)?.let { audioAttachmentData -> | ||
| views.voiceMessageRecorderView.isVisible = true | ||
| messageComposerViewModel.handle(MessageComposerAction.InitializeVoiceRecorder(audioAttachmentData)) | ||
| } | ||
| } | ||
|
|
||
| private fun handleSendButtonVisibilityChanged(event: MessageComposerViewEvents.AnimateSendButtonVisibility) { | ||
| if (event.isVisible) { | ||
| views.voiceMessageRecorderView.isVisible = false | ||
|
|
@@ -1044,10 +1058,10 @@ class RoomDetailFragment @Inject constructor( | |
| .show() | ||
| } | ||
|
|
||
| private fun renderRegularMode(text: String) { | ||
| private fun renderRegularMode(content: String) { | ||
| autoCompleter.exitSpecialMode() | ||
| views.composerLayout.collapse() | ||
| views.composerLayout.setTextIfDifferent(text) | ||
| views.composerLayout.setTextIfDifferent(content) | ||
| views.composerLayout.views.sendButton.contentDescription = getString(R.string.send) | ||
| } | ||
|
|
||
|
|
@@ -1131,14 +1145,8 @@ class RoomDetailFragment @Inject constructor( | |
|
|
||
| override fun onPause() { | ||
| super.onPause() | ||
|
|
||
| notificationDrawerManager.setCurrentRoom(null) | ||
|
|
||
| messageComposerViewModel.handle(MessageComposerAction.SaveDraft(views.composerLayout.text.toString())) | ||
|
|
||
| // We should improve the UX to support going into playback mode when paused and delete the media when the view is destroyed. | ||
| messageComposerViewModel.handle(MessageComposerAction.EndAllVoiceActions(deleteRecord = false)) | ||
| views.voiceMessageRecorderView.render(RecordingUiState.None) | ||
| messageComposerViewModel.handle(MessageComposerAction.OnEntersBackground(views.composerLayout.text.toString())) | ||
| } | ||
|
|
||
| private val attachmentFileActivityResultLauncher = registerStartForActivityResult { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering if
Voiceshould be a dedicated draft type rather than amessageTypesub type 🤔There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the code would be clearer with a VOICE data class (they are allcaps...). But I do not know if we will end up with many other cases. @onurays WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it would also mean we can avoid any database entity changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. That make sense and yes we are preserving the
draftModeinDraftEntity. So no migration will be needed.