Skip to content

Commit f0307e7

Browse files
committed
feat(Preferences/SponsorBlock): drop VISIBLE option
Drops the `VISIBLE` option for SponsorBlock, as it provides no additional value and leads to bad UX, as a user is able to see the segment, but able to skip it. Existing users are migrated to the `MANUAL` option. Ref: libre-tube@f5c4015 Ref: libre-tube@9ceb258
1 parent 62a8f27 commit f0307e7

4 files changed

Lines changed: 18 additions & 5 deletions

File tree

app/src/main/java/com/github/libretube/enums/SbSkipOptions.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package com.github.libretube.enums
22

33
enum class SbSkipOptions {
44
OFF,
5-
VISIBLE,
65
MANUAL,
76
AUTOMATIC,
87
AUTOMATIC_ONCE

app/src/main/java/com/github/libretube/helpers/PreferenceHelper.kt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ import android.util.Log
66
import androidx.core.content.edit
77
import androidx.preference.PreferenceManager
88
import com.github.libretube.BuildConfig
9+
import com.github.libretube.LibreTubeApp
10+
import com.github.libretube.R
911
import com.github.libretube.constants.PreferenceKeys
12+
import com.github.libretube.enums.SbSkipOptions
1013

1114
object PreferenceHelper {
1215
private val TAG = PreferenceHelper::class.simpleName
@@ -43,6 +46,19 @@ object PreferenceHelper {
4346
if (prefVersion == BuildConfig.VERSION_CODE)
4447
return
4548

49+
if (prefVersion < 63) {
50+
Log.i(TAG, "Migration to prefs v63")
51+
LibreTubeApp.instance.resources
52+
.getStringArray(R.array.sponsorBlockSegments)
53+
.forEach { category ->
54+
val key = "${category}_category"
55+
val stored = getString(key, "visible")
56+
if (stored == "visible") {
57+
putString(key, SbSkipOptions.MANUAL.name.lowercase())
58+
}
59+
}
60+
}
61+
4662
// mark as successfully migrated
4763
putInt(PreferenceKeys.PREFERENCE_VERSION, BuildConfig.VERSION_CODE)
4864
}

app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,8 +1014,8 @@ class PlayerFragment : Fragment(R.layout.fragment_player), OnlinePlayerOptions {
10141014
if (segmentData != null && commonPlayerViewModel.isMiniPlayerVisible.value != true) {
10151015
val (segment, sbSkipOption) = segmentData
10161016

1017-
val autoSkipTemporarilyDisabled = !binding.player.sponsorBlockAutoSkip &&
1018-
sbSkipOption !in arrayOf(SbSkipOptions.OFF, SbSkipOptions.VISIBLE)
1017+
val autoSkipTemporarilyDisabled =
1018+
!binding.player.sponsorBlockAutoSkip && sbSkipOption != SbSkipOptions.OFF
10191019

10201020
if (sbSkipOption in arrayOf(
10211021
SbSkipOptions.AUTOMATIC_ONCE,

app/src/main/res/values/array.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -422,15 +422,13 @@
422422

423423
<string-array name="sb_skip_options">
424424
<item>@string/off</item>
425-
<item>@string/visible</item>
426425
<item>@string/manual</item>
427426
<item>@string/automatic</item>
428427
<item>@string/automatic_once</item>
429428
</string-array>
430429

431430
<string-array name="sb_skip_options_values">
432431
<item>off</item>
433-
<item>visible</item>
434432
<item>manual</item>
435433
<item>automatic</item>
436434
<item>automatic_once</item>

0 commit comments

Comments
 (0)