Add setting to change default content scaling (#77)

Closes #53 #71

Adds an advanced playback setting to set a different default global
content scaling. It can still be changed per playback as well.
This commit is contained in:
damontecres 2025-10-27 14:25:07 -04:00 committed by GitHub
parent 4269d27dad
commit bafd635402
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 48 additions and 2 deletions

View file

@ -522,6 +522,19 @@ sealed interface AppPreference<T> {
valueToIndex = { it.number },
)
val GlobalContentScale =
AppChoicePreference<PrefContentScale>(
title = R.string.global_content_scale,
defaultValue = PrefContentScale.FIT,
getter = { it.playbackPreferences.globalContentScale },
setter = { prefs, value ->
prefs.updatePlaybackPreferences { globalContentScale = value }
},
displayValues = R.array.content_scale,
indexToValue = { PrefContentScale.forNumber(it) },
valueToIndex = { it.number },
)
val ClearImageCache =
AppClickablePreference(
title = R.string.clear_image_cache,
@ -639,6 +652,7 @@ val advancedPreferences =
title = R.string.playback_overrides,
preferences =
listOf(
AppPreference.GlobalContentScale,
AppPreference.DownMixStereo,
AppPreference.Ac3Supported,
AppPreference.DirectPlayAss,

View file

@ -1,6 +1,7 @@
package com.github.damontecres.wholphin.ui.playback
import androidx.compose.ui.layout.ContentScale
import com.github.damontecres.wholphin.preferences.PrefContentScale
val playbackScaleOptions =
mapOf(
@ -12,3 +13,15 @@ val playbackScaleOptions =
ContentScale.FillWidth to "Fill Width",
ContentScale.FillHeight to "Fill Height",
)
val PrefContentScale.scale: ContentScale
get() =
when (this) {
PrefContentScale.FIT -> ContentScale.Fit
PrefContentScale.NONE -> ContentScale.None
PrefContentScale.CROP -> ContentScale.Crop
PrefContentScale.FILL -> ContentScale.FillBounds
PrefContentScale.Fill_WIDTH -> ContentScale.FillWidth
PrefContentScale.FILL_HEIGHT -> ContentScale.FillHeight
PrefContentScale.UNRECOGNIZED -> ContentScale.Fit
}

View file

@ -37,7 +37,6 @@ import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.RectangleShape
import androidx.compose.ui.input.key.onKeyEvent
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.unit.dp
import androidx.compose.ui.viewinterop.AndroidView
import androidx.hilt.lifecycle.viewmodel.compose.hiltViewModel
@ -147,7 +146,7 @@ fun PlaybackPage(
onDispose { player.removeListener(cueListener) }
}
AmbientPlayerListener(player)
var contentScale by remember { mutableStateOf(ContentScale.Fit) }
var contentScale by remember { mutableStateOf(prefs.globalContentScale.scale) }
var playbackSpeed by remember { mutableFloatStateOf(1.0f) }
LaunchedEffect(playbackSpeed) { player.setPlaybackSpeed(playbackSpeed) }