make it a preference

This commit is contained in:
Bnyro 2022-10-28 21:27:04 +02:00
parent b997b60d19
commit 31a52f004e
3 changed files with 13 additions and 2 deletions

View File

@ -77,6 +77,7 @@ object PreferenceKeys {
const val PICTURE_IN_PICTURE = "picture_in_picture"
const val PLAYER_RESIZE_MODE = "player_resize_mode"
const val SB_SKIP_MANUALLY = "sb_skip_manually_key"
const val SB_SHOW_MARKERS = "sb_show_markers"
const val LIMIT_HLS = "limit_hls"
const val PROGRESSIVE_LOADING_INTERVAL_SIZE = "progressive_loading_interval"

View File

@ -7,6 +7,8 @@ import android.graphics.Paint
import android.graphics.Rect
import android.util.AttributeSet
import com.github.libretube.api.obj.Segment
import com.github.libretube.constants.PreferenceKeys
import com.github.libretube.util.PreferenceHelper
import com.google.android.exoplayer2.Player
import com.google.android.exoplayer2.ui.DefaultTimeBar
@ -30,6 +32,8 @@ class MarkableTimeBar(
private fun drawSegments(canvas: Canvas) {
if (player == null) return
if (!PreferenceHelper.getBoolean(PreferenceKeys.SB_SHOW_MARKERS, false)) return
canvas.save()
length = canvas.width - 2 * HORIZONTAL_OFFSET
@ -38,9 +42,9 @@ class MarkableTimeBar(
segments.forEach {
canvas.drawRect(
Rect(
it.segment!!.first().toLength() + HORIZONTAL_OFFSET,
(it.segment!!.first() + HORIZONTAL_OFFSET).toLength(),
marginY,
it.segment.last().toLength(),
(it.segment.last() + HORIZONTAL_OFFSET).toLength(),
canvas.height - marginY
),
Paint().apply {

View File

@ -22,6 +22,12 @@
app:key="sb_skip_manually_key"
app:title="@string/sb_skip_manual" />
<SwitchPreferenceCompat
android:summary="@string/sb_markers_summary"
app:defaultValue="false"
app:key="sb_show_markers"
app:title="@string/sb_markers" />
<PreferenceCategory app:title="@string/category_segments">
<SwitchPreferenceCompat