Skip to content

Commit

Permalink
Add a skip option for UI suppression
Browse files Browse the repository at this point in the history
  • Loading branch information
AbandonedCart committed Oct 14, 2024
1 parent 58b0f60 commit 9c1054f
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,14 @@ public void switchChannel(UUID id, boolean hideGuide) {
}
}

public void hideImmediately() {
if (mIsVisible) {
mHandler.removeCallbacks(mHideTask);
hide();
leanbackOverlayFragment.hideOverlay();
}
}

private void startFadeTimer() {
mFadeEnabled = true;
mHandler.removeCallbacks(mHideTask);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@ import org.jellyfin.androidtv.ui.playback.segments.SegmentMode

class SelectSkipAction(
context: Context,
customPlaybackTransportControlGlue: CustomPlaybackTransportControlGlue,
val customPlaybackTransportControlGlue: CustomPlaybackTransportControlGlue,
userPreferences: UserPreferences
) : CustomAction(context, customPlaybackTransportControlGlue) {
private val preferences = userPreferences
private val customPlaybackTransportControlGlue1 = customPlaybackTransportControlGlue

private val SegmentMode.icon: Int
get() = when (this) {
Expand Down Expand Up @@ -53,7 +52,7 @@ class SelectSkipAction(
preferences[UserPreferences.skipMode] = SegmentMode.entries[item.itemId]

initializeWithIcon(preferences[UserPreferences.skipMode].icon)
customPlaybackTransportControlGlue1.notifyActionChanged(this@SelectSkipAction)
customPlaybackTransportControlGlue.notifyActionChanged(this@SelectSkipAction)
true
}
}.show()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,26 +43,25 @@ class SegmentSkipFragment : Fragment() {
super.onViewCreated(view, savedInstanceState)

button = view.findViewById<Button>(R.id.skip_segment_button).apply {
setOnClickListener {
doSkip()
}
setOnClickListener { doSkip() }
}
}

private fun doSkip() {
private fun doSkip(isAuto: Boolean = false) {
lastSegment?.let { segment ->
playbackControllerContainer.playbackController?.run {
if ((segment.endTime + 3).millis > getDuration() && hasNextItem()) {
next()
} else {
seek(segment.endTime.millis)
if (isAuto) fragment.hideImmediately()
}
}
}
}

fun handleProgress(currentPosition: Long) {
// Check if server is full auto
// Check if server is full auto or missing plugin
if ((buttonConfig?.autoSkip == true && buttonConfig?.autoSkipCredits == true) || buttonConfig?.skipButtonVisible == null) {
button.isVisible = false
return
Expand All @@ -75,7 +74,7 @@ class SegmentSkipFragment : Fragment() {

preferences[UserPreferences.skipMode].let { setting ->
when {
isSkipSegment && setting == SegmentMode.AUTO_SKIP -> doSkip()
isSkipSegment && setting == SegmentMode.AUTO_SKIP -> { doSkip(true) }
isSkipSegment && setting == SegmentMode.SHOW_SKIP_BUTTON -> {
if (!button.isVisible) {
button.text = when (currentSegment.type) {
Expand All @@ -87,9 +86,7 @@ class SegmentSkipFragment : Fragment() {
button.requestFocus()
}
}
else -> {
button.isVisible = false
}
else -> { button.isVisible = false }
}
}
}
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/layout/fragment_segment_skip.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
android:layout_marginEnd="56dp"
android:layout_marginBottom="32.5dp"
android:elevation="0dp"
android:text="Skip"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="MissingTranslation">
<string name="app_name_release" translatable="false" tools:ignore="UnusedResources">Jellyfin (iSkip)</string>
<string name="app_name_debug" translatable="false" tools:ignore="UnusedResources">Jellyfin Debug</string>
<string name="app_name_release" translatable="false" tools:ignore="UnusedResources">Jellyfang</string>
<string name="app_name_debug" translatable="false" tools:ignore="UnusedResources">Jellyfang Debug</string>
<string name="video_error_unknown_error">Failed to load video</string>
<string name="loading">Loading…</string>
<string name="btn_cancel">Cancel</string>
Expand Down

0 comments on commit 9c1054f

Please sign in to comment.