Merge pull request #3846 from Bnyro/master

Fix the position of the SponsorBlock markers
This commit is contained in:
Bnyro 2023-05-29 10:28:20 +02:00 committed by GitHub
commit 1e598740ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -38,23 +38,20 @@ class MarkableTimeBar(
} }
private fun drawSegments(canvas: Canvas) { private fun drawSegments(canvas: Canvas) {
if (player == null) return val markersEnabled = PreferenceHelper.getBoolean(PreferenceKeys.SB_SHOW_MARKERS, true)
if (player == null || !markersEnabled) return
if (!PreferenceHelper.getBoolean(PreferenceKeys.SB_SHOW_MARKERS, true)) return
val horizontalOffset = (parent as View).marginLeft
canvas.save() 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 val marginY = canvas.height / 2 - progressBarHeight / 2
segments.forEach { segments.forEach {
canvas.drawRect( canvas.drawRect(
Rect( Rect(
(it.segment.first() + horizontalOffset).toLength(), it.segment.first().toLength() + horizontalOffset,
marginY, marginY,
(it.segment.last() + horizontalOffset).toLength(), it.segment.last().toLength() + horizontalOffset,
canvas.height - marginY, canvas.height - marginY,
), ),
Paint().apply { Paint().apply {