Fix issue with waveform rendering
This commit is contained in:
parent
df795d1881
commit
0cf10b2f84
|
@ -80,7 +80,7 @@ internal class WaveFormSanitizer @Inject constructor() {
|
|||
positiveList
|
||||
}
|
||||
|
||||
Timber.d("Sanitize from ${waveForm.size} items to ${finalList.size} items")
|
||||
Timber.d("Sanitize from ${waveForm.size} items to ${finalList.size} items. Max value was $max")
|
||||
return finalList
|
||||
}
|
||||
}
|
||||
|
|
|
@ -257,7 +257,7 @@ class MessageItemFactory @Inject constructor(
|
|||
return MessageVoiceItem_()
|
||||
.attributes(attributes)
|
||||
.duration(messageContent.audioWaveformInfo?.duration ?: 0)
|
||||
.waveform(messageContent.audioWaveformInfo?.waveform ?: emptyList())
|
||||
.waveform(messageContent.audioWaveformInfo?.waveform?.toFft().orEmpty())
|
||||
.playbackControlButtonClickListener(playbackControlButtonClickListener)
|
||||
.voiceMessagePlaybackTracker(voiceMessagePlaybackTracker)
|
||||
.izLocalFile(localFilesHelper.isLocalFile(fileUrl))
|
||||
|
@ -622,6 +622,13 @@ class MessageItemFactory @Inject constructor(
|
|||
.highlighted(highlight)
|
||||
}
|
||||
|
||||
private fun List<Int>?.toFft(): List<Int>? {
|
||||
return this?.map {
|
||||
// Value comes from AudioRecordView.maxReportableAmp, and 1024 is the max value in the Matrix spec
|
||||
it * 22760 / 1024
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val MAX_NUMBER_OF_EMOJI_FOR_BIG_FONT = 5
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue