mirror of
https://github.com/JustinZeus/Wholphin.git
synced 2026-07-09 16:11:20 +02:00
Suport passout protection (#41)
Adds a setting to configure pass out protection which, when enabled, will stop auto playing next up episodes if the user hasn't interacted with the app within the configurable 1-3 hours.
This commit is contained in:
parent
c3cc284238
commit
8904360fb5
7 changed files with 56 additions and 7 deletions
|
|
@ -8,6 +8,7 @@ import com.github.damontecres.wholphin.ui.nav.Destination
|
|||
import com.github.damontecres.wholphin.ui.preferences.PreferenceGroup
|
||||
import com.github.damontecres.wholphin.ui.preferences.PreferenceScreenOption
|
||||
import com.github.damontecres.wholphin.ui.preferences.PreferenceValidation
|
||||
import kotlin.time.Duration.Companion.hours
|
||||
import kotlin.time.Duration.Companion.milliseconds
|
||||
import kotlin.time.Duration.Companion.minutes
|
||||
import kotlin.time.Duration.Companion.seconds
|
||||
|
|
@ -267,6 +268,28 @@ sealed interface AppPreference<T> {
|
|||
},
|
||||
)
|
||||
|
||||
val PassOutProtection =
|
||||
AppSliderPreference(
|
||||
title = R.string.pass_out_protection,
|
||||
defaultValue = 2,
|
||||
min = 0,
|
||||
max = 3,
|
||||
interval = 1,
|
||||
getter = { it.playbackPreferences.passOutProtectionMs.milliseconds.inWholeHours },
|
||||
setter = { prefs, value ->
|
||||
prefs.updatePlaybackPreferences {
|
||||
passOutProtectionMs = value.hours.inWholeMilliseconds
|
||||
}
|
||||
},
|
||||
summarizer = { value ->
|
||||
if (value == 0L) {
|
||||
"Disabled"
|
||||
} else {
|
||||
"$value hours"
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
private const val MEGA_BIT = 1024 * 1024L
|
||||
const val DEFAULT_BITRATE = 20 * MEGA_BIT
|
||||
private val bitrateValues =
|
||||
|
|
@ -529,6 +552,7 @@ val basicPreferences =
|
|||
AppPreference.ControllerTimeout,
|
||||
AppPreference.AutoPlayNextUp,
|
||||
AppPreference.AutoPlayNextDelay,
|
||||
AppPreference.PassOutProtection,
|
||||
AppPreference.SkipBackOnResume,
|
||||
),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import java.io.InputStream
|
|||
import java.io.OutputStream
|
||||
import java.util.UUID
|
||||
import javax.inject.Inject
|
||||
import kotlin.time.Duration.Companion.hours
|
||||
import kotlin.time.Duration.Companion.seconds
|
||||
|
||||
class AppPreferencesSerializer
|
||||
|
|
@ -42,6 +43,8 @@ class AppPreferencesSerializer
|
|||
skipCommercials = AppPreference.SkipCommercials.defaultValue
|
||||
skipPreviews = AppPreference.SkipPreviews.defaultValue
|
||||
skipRecaps = AppPreference.SkipRecaps.defaultValue
|
||||
passOutProtectionMs =
|
||||
AppPreference.PassOutProtection.defaultValue.hours.inWholeMilliseconds
|
||||
|
||||
overrides =
|
||||
PlaybackOverrides
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue