Skip to content
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 Message #3598

Merged
merged 69 commits into from
Jul 30, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
69350ef
Voice message UI initial implementation.
Jun 17, 2021
cb96886
Send voice message.
Jun 17, 2021
5676226
Voice message recording view implementations.
Jul 1, 2021
9d48b39
Voice message playback implementation.
Jul 1, 2021
7a1b138
Merge branch 'develop' into feature/ons/voice_message
Jul 6, 2021
6cb53c9
Fix visibility of microphone icon.
Jul 6, 2021
5856e56
Put voice message preference under labs.
Jul 7, 2021
8452f75
Lint fix.
Jul 7, 2021
b1c7cb3
Lint fixes.
Jul 7, 2021
a9beded
Lint fix.
Jul 7, 2021
3372177
Design review fixes.
Jul 7, 2021
b400f3c
Small cleanup
bmarty Jul 9, 2021
558cd6f
Cleanup
bmarty Jul 9, 2021
7a1c6b7
Move the style to the layout, for code clarity. Style are not reused,…
bmarty Jul 9, 2021
9dea519
Fix issue with play / pause button alignment
bmarty Jul 9, 2021
2792d73
Apply missing tint
bmarty Jul 9, 2021
a2671bc
Fix touchable area to delete the voice message
bmarty Jul 9, 2021
2c1335a
Theme for Toast
bmarty Jul 9, 2021
a69ac96
Fix bad timer display
bmarty Jul 9, 2021
79f4053
Use DimensionConverter
bmarty Jul 9, 2021
2ca0a99
Follow the spec
bmarty Jul 9, 2021
963eb9d
Fix missing duration in audio event, and move `AudioWaveformInfo` to …
bmarty Jul 9, 2021
984112e
Also copy waveform when sending again
bmarty Jul 9, 2021
db80ea6
Prefer testing attachment.waveform to see if it's a voice message
bmarty Jul 9, 2021
e391a13
Merge branch 'develop' into feature/ons/voice_message
bmarty Jul 9, 2021
0382ae8
Swipe to reply on voice message
bmarty Jul 9, 2021
c5b8755
Trick for a better alignment of voice message in the timeline.
bmarty Jul 9, 2021
e49290b
Fix mic visible for invite room mode.
bmarty Jul 12, 2021
8b852a2
Fix glitch when opening a room invite
bmarty Jul 12, 2021
9df874c
Merge branch 'develop' into feature/ons/voice_message
bmarty Jul 13, 2021
83bf48d
Fix denied permission issue
bmarty Jul 13, 2021
c69bc12
Be more precise if the timer is paused and resume.
bmarty Jul 13, 2021
78e9a4f
Use CountUpTimer
bmarty Jul 13, 2021
cae927b
Use CountUpTimer
bmarty Jul 13, 2021
fa7c1a7
Render the wave form more often
bmarty Jul 13, 2021
bf14fa9
Fix rendering issue of time when playing in the timeline - still buggy
bmarty Jul 13, 2021
7937c99
Untrack
bmarty Jul 13, 2021
bff2c6e
Better handling of Paused/Play state
bmarty Jul 13, 2021
6283846
Cleanup
bmarty Jul 13, 2021
a52d5f6
Renaming
bmarty Jul 13, 2021
4c5be39
Fix background color of Play/Pause button
bmarty Jul 13, 2021
14dbbee
Fix background color of voice message item
bmarty Jul 13, 2021
6530440
Fix an issue in the color
bmarty Jul 13, 2021
cf4e603
Fix background color of voice message recorder
bmarty Jul 13, 2021
9e0f3a1
Fix other color issue
bmarty Jul 13, 2021
f40e6b5
Fix other color issue
bmarty Jul 13, 2021
013174d
License file
bmarty Jul 13, 2021
95bb796
Fix color
bmarty Jul 13, 2021
6a0ea11
Follow the spec regarding waveform content
bmarty Jul 13, 2021
c938a30
Change filename.
bmarty Jul 13, 2021
df795d1
Cleanup
bmarty Jul 13, 2021
0cf10b2
Fix issue with waveform rendering
bmarty Jul 13, 2021
276808c
Fix issue in RTL
bmarty Jul 13, 2021
6ab9b46
Fix mic button color
bmarty Jul 15, 2021
bb742eb
Handle record/play error
bmarty Jul 15, 2021
6f947e9
Split to sub fun
bmarty Jul 15, 2021
bfc70be
Record voice on Android 21
bmarty Jul 15, 2021
343ea42
Fix issue on Android 21
bmarty Jul 15, 2021
13ae0ba
Convert voice message to be able to play on Android 28 and below
bmarty Jul 16, 2021
6da4f1d
Add comment
bmarty Jul 16, 2021
30bb918
Fix issue about move overflow.
bmarty Jul 16, 2021
6caa2b9
Fix issue with RTL
bmarty Jul 16, 2021
a119417
Code review fixes.
Jul 23, 2021
bd2ed4c
Stop playback when deleting record on locked mode.
Jul 23, 2021
4c8a8d8
Design review fixes.
Jul 27, 2021
cdd2fca
Design review fixes.
Jul 29, 2021
e945b89
Hide mic if there is a draft message.
Jul 30, 2021
cfe64ee
Update initial recording state to restore from background.
Jul 30, 2021
1aa706d
Lint fixes.
Jul 30, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion library/ui-styles/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,6 @@

<attr name="vctr_voice_message_toast_background" format="color" />
<color name="vctr_voice_message_toast_background_light">@color/palette_black_900</color>
<color name="vctr_voice_message_toast_background_dark">@color/palette_gray_450</color>
<color name="vctr_voice_message_toast_background_dark">@color/palette_gray_400</color>

</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<item name="chunkSoftTransition">true</item>
<item name="chunkSpace">2dp</item>
<item name="chunkWidth">2dp</item>
<item name="direction">leftToRight</item>
<item name="direction">rightToLeft</item>
</style>

<style name="Widget.Vector.TextView.Caption.Toast">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import android.os.Build
import android.os.Bundle
import android.os.Parcelable
import android.text.Spannable
import android.text.format.DateUtils
import android.view.HapticFeedbackConstants
import android.view.KeyEvent
import android.view.LayoutInflater
Expand Down Expand Up @@ -987,7 +988,12 @@ class RoomDetailFragment @Inject constructor(
}

val messageContent: MessageContent? = event.getLastMessageContent()
val nonFormattedBody = messageContent?.body ?: ""
val nonFormattedBody = if (messageContent is MessageAudioContent && messageContent.voiceMessageIndicator != null) {
val formattedDuration = DateUtils.formatElapsedTime(((messageContent.audioInfo?.duration ?: 0) / 1000).toLong())
getString(R.string.voice_message_reply_content, formattedDuration)
} else {
messageContent?.body ?: ""
}
var formattedBody: CharSequence? = null
if (messageContent is MessageTextContent && messageContent.format == MessageFormat.FORMAT_MATRIX_HTML) {
val parser = Parser.builder().build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,11 @@ class VoiceMessageHelper @Inject constructor(
return outputFileUri
?.toMultiPickerAudioType(context)
?.apply {
waveform = amplitudeList
waveform = if (amplitudeList.size < 50) {
amplitudeList
} else {
amplitudeList.chunked(amplitudeList.size / 50) { items -> items.maxOrNull() ?: 0 }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the limit of waveform list size on the SDK can be removed / commented out?

}
}
} ?: return null
} catch (e: FileNotFoundException) {
Expand Down Expand Up @@ -154,7 +158,7 @@ class VoiceMessageHelper @Inject constructor(

private fun startRecordingAmplitudes() {
amplitudeTicker?.stop()
amplitudeTicker = CountUpTimer(100).apply {
amplitudeTicker = CountUpTimer(50).apply {
tickListener = object : CountUpTimer.TickListener {
override fun onTick(milliseconds: Long) {
onAmplitudeTick()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@

package im.vector.app.features.home.room.detail.composer

import android.animation.Animator
import android.content.Context
import android.text.format.DateUtils
import android.util.AttributeSet
import android.view.MotionEvent
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.view.isVisible
import androidx.core.view.updateLayoutParams
import com.visualizer.amplitude.AudioRecordView
import im.vector.app.BuildConfig
import im.vector.app.R
import im.vector.app.core.hardware.vibrate
Expand Down Expand Up @@ -192,7 +194,7 @@ class VoiceMessageRecorderView @JvmOverloads constructor(
views.voiceMessageLockArrow.translationY = 0F
}
RecordingState.LOCKING -> {
views.voiceMessageLockImage.setImageResource(R.drawable.ic_voice_message_unlocked)
views.voiceMessageLockImage.setImageResource(R.drawable.ic_voice_message_locked)
val translationAmount = -distanceY.coerceIn(0F, distanceToLock)
views.voiceMessageMicButton.translationY = translationAmount
views.voiceMessageLockArrow.translationY = translationAmount
Expand Down Expand Up @@ -320,7 +322,7 @@ class VoiceMessageRecorderView @JvmOverloads constructor(
views.voicePlaybackWaveform.apply {
post {
// TODO We could avoid recreating the whole view here and just call update() with the new value(s).
recreate()
//recreate()
amplitudeList.forEach { amplitude ->
update(amplitude)
}
Expand Down Expand Up @@ -349,6 +351,7 @@ class VoiceMessageRecorderView @JvmOverloads constructor(
views.voiceMessageTimer.isVisible = true
views.voiceMessageSlideToCancel.alpha = 1f
views.voiceMessageSendButton.isVisible = false
views.voiceMessageLockImage.setImageResource(R.drawable.ic_voice_message_unlocked)
}

private fun hideRecordingViews() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ abstract class MessageVoiceItem : AbsMessageItem<MessageVoiceItem.Holder>() {
holder.progressLayout.isVisible = false
}

holder.voicePlaybackWaveform.setOnLongClickListener(attributes.itemLongClickListener)

holder.voicePlaybackWaveform.post {
holder.voicePlaybackWaveform.recreate()
waveform.forEach { amplitude ->
Expand Down
3 changes: 2 additions & 1 deletion vector/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3449,10 +3449,11 @@
<string name="a11y_delete_recorded_voice_message">Delete recorded voice message</string>
<string name="voice_message_release_to_send_toast">Hold to record, release to send</string>
<string name="voice_message_n_seconds_warning_toast">%1$ds left</string>
<string name="voice_message_tap_on_waveform_to_stop_toast">Tap on the waveform to stop and playback</string>
<string name="voice_message_tap_on_waveform_to_stop_toast">Tap on your recording to stop or listen</string>
<string name="labs_use_voice_message">Enable voice message</string>
<string name="voice_message_tap_to_stop_toast">Tap on the wavelength to stop and playback</string>
<string name="error_voice_message_unable_to_play">Cannot play this voice message</string>
<string name="error_voice_message_unable_to_record">Cannot record a voice message</string>
<string name="error_voice_message_cannot_reply_or_edit">Cannot reply or edit while voice message is active</string>
<string name="voice_message_reply_content">Voice Message (%1$s)</string>
</resources>