Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use "Ask to skip" by default for intros and outros #4111

Merged
merged 1 commit into from
Oct 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@ import org.jellyfin.androidtv.preference.constant.RatingType
import org.jellyfin.androidtv.preference.constant.RefreshRateSwitchingBehavior
import org.jellyfin.androidtv.preference.constant.WatchedIndicatorBehavior
import org.jellyfin.androidtv.preference.constant.ZoomMode
import org.jellyfin.androidtv.ui.playback.segment.MediaSegmentAction
import org.jellyfin.androidtv.ui.playback.segment.toMediaSegmentActionsString
import org.jellyfin.preference.booleanPreference
import org.jellyfin.preference.enumPreference
import org.jellyfin.preference.floatPreference
import org.jellyfin.preference.intPreference
import org.jellyfin.preference.longPreference
import org.jellyfin.preference.store.SharedPreferenceStore
import org.jellyfin.preference.stringPreference
import org.jellyfin.sdk.model.api.MediaSegmentType
import kotlin.time.Duration.Companion.minutes

/**
Expand Down Expand Up @@ -210,7 +213,13 @@ class UserPreferences(context: Context) : SharedPreferenceStore(
/**
* The actions to take for each media segment type. Managed by the [MediaSegmentRepository].
*/
var mediaSegmentActions = stringPreference("media_segment_actions", "")
var mediaSegmentActions = stringPreference(
key = "media_segment_actions",
defaultValue = mapOf(
MediaSegmentType.INTRO to MediaSegmentAction.ASK_TO_SKIP,
MediaSegmentType.OUTRO to MediaSegmentAction.ASK_TO_SKIP,
).toMediaSegmentActionsString()
)

/**
* Preferred behavior for player aspect ratio (zoom mode).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ interface MediaSegmentRepository {
fun getMediaSegmentAction(segment: MediaSegmentDto): MediaSegmentAction
}

fun Map<MediaSegmentType, MediaSegmentAction>.toMediaSegmentActionsString() =
map { "${it.key.serialName}=${it.value.name}" }
.joinToString(",")

class MediaSegmentRepositoryImpl(
private val userPreferences: UserPreferences,
private val api: ApiClient,
Expand All @@ -70,9 +74,7 @@ class MediaSegmentRepositoryImpl(
}

private fun saveMediaTypeActions() {
userPreferences[UserPreferences.mediaSegmentActions] = mediaTypeActions
.map { "${it.key.serialName}=${it.value.name}" }
.joinToString(",")
userPreferences[UserPreferences.mediaSegmentActions] = mediaTypeActions.toMediaSegmentActionsString()
}

override fun getDefaultSegmentTypeAction(type: MediaSegmentType): MediaSegmentAction {
Expand Down
Loading