From 30cb9815f1303e80cbfe8909ee10cc7924856159 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Sat, 5 Nov 2022 17:27:13 +0100 Subject: [PATCH] reset btns for speed and pitch --- .../libretube/ui/sheets/PlaybackSpeedSheet.kt | 20 +++++-- .../main/res/layout/playback_bottom_sheet.xml | 59 +++++++++++++++---- 2 files changed, 61 insertions(+), 18 deletions(-) diff --git a/app/src/main/java/com/github/libretube/ui/sheets/PlaybackSpeedSheet.kt b/app/src/main/java/com/github/libretube/ui/sheets/PlaybackSpeedSheet.kt index 33f8ac00f..6583fca95 100644 --- a/app/src/main/java/com/github/libretube/ui/sheets/PlaybackSpeedSheet.kt +++ b/app/src/main/java/com/github/libretube/ui/sheets/PlaybackSpeedSheet.kt @@ -31,18 +31,28 @@ class PlaybackSpeedSheet( binding.pitch.value = player.playbackParameters.pitch binding.speed.addOnChangeListener { _, value, _ -> - onChange(value, binding.pitch.value.round(2)) + onChange() } binding.pitch.addOnChangeListener { _, value, _ -> - onChange(binding.speed.value.round(2), value) + onChange() + } + + binding.resetSpeed.setOnClickListener { + binding.speed.value = 1f + onChange() + } + + binding.resetPitch.setOnClickListener { + binding.pitch.value = 1f + onChange() } } - private fun onChange(speed: Float, pitch: Float) { + private fun onChange() { player.playbackParameters = PlaybackParameters( - speed, - pitch + binding.speed.value.round(2), + binding.pitch.value.round(2) ) } diff --git a/app/src/main/res/layout/playback_bottom_sheet.xml b/app/src/main/res/layout/playback_bottom_sheet.xml index 913345c1f..ab34782c3 100644 --- a/app/src/main/res/layout/playback_bottom_sheet.xml +++ b/app/src/main/res/layout/playback_bottom_sheet.xml @@ -34,28 +34,61 @@ android:layout_height="wrap_content" android:text="@string/playback_speed" /> - + android:layout_height="wrap_content"> + + + + + + - + android:orientation="horizontal"> + + + + + +