mirror of
https://github.com/element-hq/element-android
synced 2024-11-27 03:48:12 +03:00
Replace the player timeline (#7821)
This commit is contained in:
parent
3c3c44b344
commit
92ed663068
3 changed files with 32 additions and 12 deletions
1
changelog.d/7821.misc
Normal file
1
changelog.d/7821.misc
Normal file
|
@ -0,0 +1 @@
|
|||
[Voice Broadcast] Replace the player timeline
|
|
@ -122,10 +122,14 @@ abstract class MessageVoiceBroadcastListeningItem : AbsMessageVoiceBroadcastItem
|
|||
|
||||
private fun bindSeekBar(holder: Holder) {
|
||||
with(holder) {
|
||||
durationView.text = formatPlaybackTime(duration)
|
||||
remainingTimeView.text = formatRemainingTime(duration)
|
||||
elapsedTimeView.text = formatPlaybackTime(0)
|
||||
seekBar.max = duration
|
||||
seekBar.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener {
|
||||
override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) = Unit
|
||||
override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
|
||||
remainingTimeView.text = formatRemainingTime(duration - progress)
|
||||
elapsedTimeView.text = formatPlaybackTime(progress)
|
||||
}
|
||||
|
||||
override fun onStartTrackingTouch(seekBar: SeekBar) {
|
||||
isUserSeeking = true
|
||||
|
@ -156,6 +160,7 @@ abstract class MessageVoiceBroadcastListeningItem : AbsMessageVoiceBroadcastItem
|
|||
}
|
||||
|
||||
private fun formatPlaybackTime(time: Int) = DateUtils.formatElapsedTime((time / 1000).toLong())
|
||||
private fun formatRemainingTime(time: Int) = if (time < 1000) formatPlaybackTime(time) else String.format("-%s", formatPlaybackTime(time))
|
||||
|
||||
override fun unbind(holder: Holder) {
|
||||
super.unbind(holder)
|
||||
|
@ -177,7 +182,8 @@ abstract class MessageVoiceBroadcastListeningItem : AbsMessageVoiceBroadcastItem
|
|||
val fastBackwardButton by bind<ImageButton>(R.id.fastBackwardButton)
|
||||
val fastForwardButton by bind<ImageButton>(R.id.fastForwardButton)
|
||||
val seekBar by bind<SeekBar>(R.id.seekBar)
|
||||
val durationView by bind<TextView>(R.id.playbackDuration)
|
||||
val remainingTimeView by bind<TextView>(R.id.remainingTime)
|
||||
val elapsedTimeView by bind<TextView>(R.id.elapsedTime)
|
||||
val broadcasterNameMetadata by bind<VoiceBroadcastMetadataView>(R.id.broadcasterNameMetadata)
|
||||
val voiceBroadcastMetadata by bind<VoiceBroadcastMetadataView>(R.id.voiceBroadcastMetadata)
|
||||
val listenersCountMetadata by bind<VoiceBroadcastMetadataView>(R.id.listenersCountMetadata)
|
||||
|
|
|
@ -140,27 +140,40 @@
|
|||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="24dp"
|
||||
android:layout_marginEnd="6dp"
|
||||
android:paddingStart="0dp"
|
||||
android:paddingEnd="0dp"
|
||||
android:progressDrawable="@drawable/bg_seek_bar"
|
||||
android:thumbTint="?vctr_content_secondary"
|
||||
android:thumbOffset="3dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@id/playbackDuration"
|
||||
android:thumbTint="?vctr_content_secondary"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/controllerButtonsFlow"
|
||||
tools:progress="0" />
|
||||
tools:progress="50" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/playbackDuration"
|
||||
android:id="@+id/elapsedTime"
|
||||
style="@style/Widget.Vector.TextView.Caption"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="4dp"
|
||||
android:layout_marginTop="-3dp"
|
||||
android:textColor="?vctr_content_tertiary"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/seekBar"
|
||||
tools:ignore="NegativeMargin"
|
||||
tools:text="0:11" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/remainingTime"
|
||||
style="@style/Widget.Vector.TextView.Caption"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="-3dp"
|
||||
android:layout_marginEnd="4dp"
|
||||
android:textColor="?vctr_content_tertiary"
|
||||
app:layout_constraintBottom_toBottomOf="@id/seekBar"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@id/seekBar"
|
||||
tools:text="0:23" />
|
||||
app:layout_constraintTop_toBottomOf="@id/seekBar"
|
||||
tools:ignore="NegativeMargin"
|
||||
tools:text="-0:12" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
|
Loading…
Reference in a new issue