Fix the SponsorBlock marker size

This commit is contained in:
Bnyro 2022-12-25 16:59:55 +01:00
parent dd1c215ba7
commit 1109a93d23
3 changed files with 7 additions and 5 deletions

View File

@ -8,10 +8,12 @@ import android.util.AttributeSet
import com.github.libretube.R import com.github.libretube.R
import com.github.libretube.api.obj.Segment import com.github.libretube.api.obj.Segment
import com.github.libretube.constants.PreferenceKeys import com.github.libretube.constants.PreferenceKeys
import com.github.libretube.extensions.toPixel
import com.github.libretube.util.PreferenceHelper import com.github.libretube.util.PreferenceHelper
import com.github.libretube.util.ThemeHelper import com.github.libretube.util.ThemeHelper
import com.google.android.exoplayer2.Player import com.google.android.exoplayer2.Player
import com.google.android.exoplayer2.ui.DefaultTimeBar import com.google.android.exoplayer2.ui.DefaultTimeBar
import kotlin.math.roundToInt
/** /**
* TimeBar that can be marked with SponsorBlock Segments * TimeBar that can be marked with SponsorBlock Segments
@ -44,7 +46,7 @@ class MarkableTimeBar(
canvas.drawRect( canvas.drawRect(
Rect( Rect(
(it.segment.first() + HORIZONTAL_OFFSET).toLength(), (it.segment.first() + HORIZONTAL_OFFSET).toLength(),
marginY - 1, marginY,
(it.segment.last() + HORIZONTAL_OFFSET).toLength(), (it.segment.last() + HORIZONTAL_OFFSET).toLength(),
canvas.height - marginY canvas.height - marginY
), ),
@ -74,6 +76,6 @@ class MarkableTimeBar(
companion object { companion object {
const val HORIZONTAL_OFFSET = 10 const val HORIZONTAL_OFFSET = 10
const val PROGRESS_BAR_HEIGHT = 4 val PROGRESS_BAR_HEIGHT = (2).toPixel().roundToInt()
} }
} }

View File

@ -9,7 +9,7 @@ object DataSaverMode {
return when (pref) { return when (pref) {
"enabled" -> true "enabled" -> true
"disabled" -> false "disabled" -> false
"metered"-> NetworkHelper.isNetworkMobile(context) "metered" -> NetworkHelper.isNetworkMobile(context)
else -> throw IllegalArgumentException() else -> throw IllegalArgumentException()
} }
} }

View File

@ -298,11 +298,11 @@
<com.github.libretube.ui.views.MarkableTimeBar <com.github.libretube.ui.views.MarkableTimeBar
android:id="@id/exo_progress" android:id="@id/exo_progress"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="15dp" android:layout_height="16dp"
app:bar_height="2dp" app:bar_height="2dp"
app:played_color="?attr/colorSecondary" app:played_color="?attr/colorSecondary"
app:scrubber_color="?attr/colorSecondary" app:scrubber_color="?attr/colorSecondary"
app:scrubber_dragged_size="15dp" app:scrubber_dragged_size="16dp"
app:scrubber_enabled_size="12dp" /> app:scrubber_enabled_size="12dp" />
</LinearLayout> </LinearLayout>