-
Notifications
You must be signed in to change notification settings - Fork 109
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
Record and send voice messages #1596
Conversation
📱 Scan the QR code below to install the build (arm64 only) for this PR. |
c42b093
to
c4328be
Compare
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## develop #1596 +/- ##
===========================================
+ Coverage 59.12% 59.21% +0.09%
===========================================
Files 1229 1246 +17
Lines 31881 32268 +387
Branches 6562 6618 +56
===========================================
+ Hits 18849 19109 +260
- Misses 10177 10289 +112
- Partials 2855 2870 +15
☔ View full report in Codecov by Sentry. |
885e100
to
be88988
Compare
|
be88988
to
f28e9ee
Compare
Do you think we can split this into logically independent smaller blocks? |
Yeah it has grown pretty large! No problem, I can split this down. |
f28e9ee
to
e3f0e64
Compare
encoder = encoderProvider.get().apply { | ||
init(file.absolutePath, sampleRate) | ||
setBitrate(bitRate) | ||
// TODO check encoder application: 2048 (voice, default is typically 2049 as audio) |
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've checked on this and it's not currently possible with libopusencoder-android and needs changes to the underlying libopusencoder library. After we merge this, I'll create an issue in this repo and link to element-hq/libopusencoder-android#4.
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.
Very well done! LGTM
Comments are mainly for simplifying some things but not really blocking.
@@ -71,10 +71,14 @@ internal fun MessageComposerView( | |||
} | |||
} | |||
|
|||
fun onVoiceRecordButtonEvent(press: PressEvent) { | |||
val onVoiceRecordButtonEvent = { press: PressEvent -> |
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.
Just wondering: why val instead of fun? What's the difference?
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.
Actually here it shouldn't make a difference, but generally I'm starting to prefer val
over fun
so that changes in captured variables will trigger recomposition. With fun
I've found that subtle bugs can sneak in easily.
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.
@@ -16,10 +16,15 @@ | |||
|
|||
package io.element.android.features.messages.impl.voicemessages |
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 would suggest moving all the contents of this package to io.element.android.features.messages.impl.voicemessages.record
so it'll match best with io.element.android.features.messages.impl.voicemessages.play
from #1503
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.
Can I make this refactor in a follow-up PR as I've built some features on top of this branch?
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.
Ofc!
...rc/main/kotlin/io/element/android/libraries/textcomposer/components/VoiceMessageRecording.kt
Outdated
Show resolved
Hide resolved
* | ||
* @property level The current audio level of the recording as a fraction of 1. | ||
*/ | ||
data class Recording(val level: Double) : VoiceRecorderState() |
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.
Not that big of a deal but perhaps a Float
is more than enough here since we don't care about absolute precision as much as we care about performance and responsiveness of the UI.
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 couldn't find a source for this, but I think operations involving float and double have similar performance nowadays, since 64 bit processors became the norm? But happy to be corrected!
.../impl/src/main/kotlin/io/element/android/libraries/voicerecorder/impl/audio/SampleRateExt.kt
Outdated
Show resolved
Hide resolved
...pl/src/main/kotlin/io/element/android/libraries/voicerecorder/impl/di/VoiceRecorderModule.kt
Outdated
Show resolved
Hide resolved
.../main/kotlin/io/element/android/libraries/voicerecorder/impl/file/DefaultVoiceFileManager.kt
Outdated
Show resolved
Hide resolved
.../main/kotlin/io/element/android/libraries/voicerecorder/impl/file/DefaultVoiceFileManager.kt
Outdated
Show resolved
Hide resolved
.../main/kotlin/io/element/android/libraries/voicerecorder/impl/file/DefaultVoiceFileManager.kt
Outdated
Show resolved
Hide resolved
… jonny/voice-message-sending
ba7cf44
to
4c1d431
Compare
SonarCloud Quality Gate failed. 0 Bugs 0.0% Coverage Catch issues before they fail your Quality Gate with our IDE extension SonarLint |
Super! Thanks for all the changes! |
Type of change
Content
Note that where commented the UI and text is still placeholder content which will be replaced in follow up PRs.
Motivation and context
Screenshots / GIFs
1000009088.mp4
Tests
Tested devices
Checklist