Add experimental settings & video tunneling (#1624)

## Description
This PR introduces the concept of "experimental" settings or features.
These may cause instabilities or may need further testing. They may be
changed or removed any time. Also, the developers won't provide lots of
support for them.

The goal is expose some specialized settings that might only apply to a
small subset of users or test out tweaks to playback.

The first experimental feature is a toggle to enable [video
tunneling](https://developer.android.com/media/media3/exoplayer/track-selection#tunneling).

### Related issues
Related to #1283

### Testing
Emulator

## Screenshots
N/A

## AI or LLM usage
None
This commit is contained in:
Damontecres 2026-06-27 14:29:37 -04:00 • committed by GitHub
parent 21e720c420
commit 083d4e4fa8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 183 additions and 14 deletions

View file

@ -1266,8 +1266,16 @@ val advancedPreferences =
AppPreference.DebugLogging,
AppPreference.ImageDiskCacheSize,
AppPreference.ClearImageCache,
ExperimentalPreference.Enable,
AppPreference.OssLicenseInfo,
),
conditionalPreferences =
listOf(
ConditionalPreferences(
condition = { it.experimentalPreferences.enabled },
preferences = listOf(ExperimentalPreference.ExperimentalSettings),
),
),
),
)
}

View file

@ -174,6 +174,14 @@ class AppPreferencesSerializer
showLyrics = true
showAlbumArt = true
}.build()
experimentalPreferences =
ExperimentalPreferences
.newBuilder()
.apply {
enabled = false
videoTunnelingEnabled = false
}.build()
}.build()
override suspend fun readFrom(input: InputStream): AppPreferences {
@ -252,6 +260,11 @@ inline fun AppPreferences.updateMusicPreferences(block: MusicPreferences.Builder
musicPreferences = musicPreferences.toBuilder().apply(block).build()
}
inline fun AppPreferences.updateExperimentalPreferences(block: ExperimentalPreferences.Builder.() -> Unit): AppPreferences =
update {
experimentalPreferences = experimentalPreferences.toBuilder().apply(block).build()
}
fun SubtitlePreferences.Builder.resetSubtitles() {
fontSize = SubtitleSettings.FontSize.defaultValue.toInt()
fontColor = SubtitleSettings.FontColor.defaultValue.toArgb()

View file

@ -0,0 +1,58 @@
package com.github.damontecres.wholphin.preferences
import com.github.damontecres.wholphin.R
import com.github.damontecres.wholphin.ui.nav.Destination
import com.github.damontecres.wholphin.ui.preferences.PreferenceGroup
import com.github.damontecres.wholphin.ui.preferences.PreferenceScreenOption
object ExperimentalPreference {
val Enable =
AppSwitchPreference<AppPreferences>(
title = R.string.experimental_settings,
defaultValue = false,
getter = { it.experimentalPreferences.enabled },
setter = { prefs, value ->
prefs.updateExperimentalPreferences { enabled = value }
},
summaryOn = R.string.enabled,
summaryOff = R.string.disabled,
)
val ExperimentalSettings =
AppDestinationPreference<AppPreferences>(
title = R.string.experimental_settings,
destination = Destination.Settings(PreferenceScreenOption.EXPERIMENTAL),
)
val VideoTunneling =
AppSwitchPreference<AppPreferences>(
title = R.string.video_tunneling,
defaultValue = false,
getter = { it.experimentalPreferences.videoTunnelingEnabled },
setter = { prefs, value ->
prefs.updateExperimentalPreferences { videoTunnelingEnabled = value }
},
summaryOn = R.string.enabled,
summaryOff = R.string.disabled,
)
}
val experimentalPreferences =
buildList {
add(
PreferenceGroup(
title = R.string.experimental_settings,
preferences =
listOf(
ExperimentalPreference.VideoTunneling,
),
),
)
}
/**
* Get a value from [ExperimentalPreference] or null if not enabled
*/
fun <T> ExperimentalPreferences.get(block: ExperimentalPreferences.() -> T): T? = if (enabled) block.invoke(this) else null
fun ExperimentalPreferences.enabled(block: ExperimentalPreferences.() -> Boolean): Boolean = enabled && block.invoke(this)