From 70fdd10a21ab2051544af12a111c62a0cff82ae3 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Mon, 29 May 2023 10:28:25 +0200 Subject: [PATCH] Fix the position of the SponsorBlock markers --- .../github/libretube/ui/views/MarkableTimeBar.kt | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/com/github/libretube/ui/views/MarkableTimeBar.kt b/app/src/main/java/com/github/libretube/ui/views/MarkableTimeBar.kt index 62ff1e429..7d1151bdc 100644 --- a/app/src/main/java/com/github/libretube/ui/views/MarkableTimeBar.kt +++ b/app/src/main/java/com/github/libretube/ui/views/MarkableTimeBar.kt @@ -38,23 +38,20 @@ class MarkableTimeBar( } private fun drawSegments(canvas: Canvas) { - if (player == null) return - - if (!PreferenceHelper.getBoolean(PreferenceKeys.SB_SHOW_MARKERS, true)) return - - val horizontalOffset = (parent as View).marginLeft + val markersEnabled = PreferenceHelper.getBoolean(PreferenceKeys.SB_SHOW_MARKERS, true) + if (player == null || !markersEnabled) return canvas.save() - length = canvas.width - 2 * horizontalOffset - + val horizontalOffset = (parent as View).marginLeft + length = canvas.width - horizontalOffset * 2 val marginY = canvas.height / 2 - progressBarHeight / 2 segments.forEach { canvas.drawRect( Rect( - (it.segment.first() + horizontalOffset).toLength(), + it.segment.first().toLength() + horizontalOffset, marginY, - (it.segment.last() + horizontalOffset).toLength(), + it.segment.last().toLength() + horizontalOffset, canvas.height - marginY, ), Paint().apply {