mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-27 03:55:16 +00:00
Fix voice message duration view (#948)
The seconds for a voice message duration, and also its decreasing duration when played, were just the total duration of the audio. So, a 3 minute audio would appear as 3:180 at the audio's right, and 2:170 for example when said audio is being played. I added a modulo operator for 60 after the time millisecond to seconds conversion, just before setting it as viewable text, same for the progress function.
This commit is contained in:
parent
d9a815a729
commit
95298bb9e3
@ -78,7 +78,7 @@ class VoiceMessageView : RelativeLayout, AudioSlidePlayer.Listener {
|
||||
binding.voiceMessageViewDurationTextView.visibility = View.VISIBLE
|
||||
binding.voiceMessageViewDurationTextView.text = String.format("%01d:%02d",
|
||||
TimeUnit.MILLISECONDS.toMinutes(audioExtras.durationMs),
|
||||
TimeUnit.MILLISECONDS.toSeconds(audioExtras.durationMs))
|
||||
TimeUnit.MILLISECONDS.toSeconds(audioExtras.durationMs) % 60)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -102,7 +102,7 @@ class VoiceMessageView : RelativeLayout, AudioSlidePlayer.Listener {
|
||||
this.progress = progress
|
||||
binding.voiceMessageViewDurationTextView.text = String.format("%01d:%02d",
|
||||
TimeUnit.MILLISECONDS.toMinutes(duration - (progress * duration.toDouble()).roundToLong()),
|
||||
TimeUnit.MILLISECONDS.toSeconds(duration - (progress * duration.toDouble()).roundToLong()))
|
||||
TimeUnit.MILLISECONDS.toSeconds(duration - (progress * duration.toDouble()).roundToLong()) % 60)
|
||||
val layoutParams = binding.progressView.layoutParams as RelativeLayout.LayoutParams
|
||||
layoutParams.width = (width.toFloat() * progress.toFloat()).roundToInt()
|
||||
binding.progressView.layoutParams = layoutParams
|
||||
|
Loading…
Reference in New Issue
Block a user