diff --git a/app/src/main/java/com/github/libretube/constants/PreferenceKeys.kt b/app/src/main/java/com/github/libretube/constants/PreferenceKeys.kt index 747346c5a..56eec35ea 100644 --- a/app/src/main/java/com/github/libretube/constants/PreferenceKeys.kt +++ b/app/src/main/java/com/github/libretube/constants/PreferenceKeys.kt @@ -75,6 +75,7 @@ object PreferenceKeys { const val SKIP_BUTTONS = "skip_buttons" const val PICTURE_IN_PICTURE = "picture_in_picture" const val PLAYER_RESIZE_MODE = "player_resize_mode" + const val SB_SKIP_MANUALLY = "sb_skip_manually" /** * Background mode diff --git a/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt b/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt index a60ea1b94..b5bda5e3b 100644 --- a/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt @@ -169,6 +169,7 @@ class PlayerFragment : BaseFragment() { private var sponsorBlockNotifications = true private var skipButtonsEnabled = false private var pipEnabled = true + private var skipSegmentsManually = false /** * for autoplay @@ -336,6 +337,11 @@ class PlayerFragment : BaseFragment() { PreferenceKeys.PICTURE_IN_PICTURE, true ) + + skipSegmentsManually = PreferenceHelper.getBoolean( + PreferenceKeys.SB_SKIP_MANUALLY, + false + ) } @SuppressLint("ClickableViewAccessibility") @@ -709,21 +715,36 @@ class PlayerFragment : BaseFragment() { Handler(Looper.getMainLooper()).postDelayed(this::checkForSegments, 100) - if (!::segmentData.isInitialized || segmentData.segments.isEmpty()) { - return - } + if (!::segmentData.isInitialized || segmentData.segments.isEmpty()) return + val currentPosition = exoPlayer.currentPosition segmentData.segments.forEach { segment: Segment -> val segmentStart = (segment.segment!![0] * 1000f).toLong() val segmentEnd = (segment.segment[1] * 1000f).toLong() - val currentPosition = exoPlayer.currentPosition + if (currentPosition in segmentStart until segmentEnd) { - if (sponsorBlockNotifications) { - Toast.makeText(context, R.string.segment_skipped, Toast.LENGTH_SHORT).show() + if (skipSegmentsManually) { + binding.sbSkipBtn.visibility = View.VISIBLE + binding.sbSkipBtn.setOnClickListener { + exoPlayer.seekTo(segmentEnd) + } } + + if (sponsorBlockNotifications) { + Toast + .makeText( + context, + R.string.segment_skipped, + Toast.LENGTH_SHORT + ).show() + } + exoPlayer.seekTo(segmentEnd) + return } } + + if (skipSegmentsManually) binding.sbSkipBtn.visibility = View.GONE } private fun playVideo() { diff --git a/app/src/main/res/layout/fragment_player.xml b/app/src/main/res/layout/fragment_player.xml index baf56d2b0..f7eb9c695 100644 --- a/app/src/main/res/layout/fragment_player.xml +++ b/app/src/main/res/layout/fragment_player.xml @@ -378,8 +378,34 @@ android:layout_gravity="center" android:gravity="center" /> - + + + + + + + + Mobile data Indicator for new videos Show a badge with the amount of new videos if there are some. + Skip segment + Skip manually + Don\'t skip segments automatically, always prompt before. diff --git a/app/src/main/res/xml/sponsorblock_settings.xml b/app/src/main/res/xml/sponsorblock_settings.xml index 5a0f6a077..8e7291d2c 100644 --- a/app/src/main/res/xml/sponsorblock_settings.xml +++ b/app/src/main/res/xml/sponsorblock_settings.xml @@ -16,6 +16,12 @@ app:key="sb_notifications_key" app:title="@string/sponsorblock_notifications" /> + +