mirror of
https://github.com/JustinZeus/Wholphin.git
synced 2026-07-08 23:51:21 +02:00
Rearrange settings based on player backend
This commit is contained in:
parent
adbbd1c648
commit
24e4acec11
4 changed files with 35 additions and 11 deletions
|
|
@ -8,6 +8,7 @@ import androidx.preference.PreferenceManager
|
||||||
import com.github.damontecres.wholphin.R
|
import com.github.damontecres.wholphin.R
|
||||||
import com.github.damontecres.wholphin.WholphinApplication
|
import com.github.damontecres.wholphin.WholphinApplication
|
||||||
import com.github.damontecres.wholphin.ui.nav.Destination
|
import com.github.damontecres.wholphin.ui.nav.Destination
|
||||||
|
import com.github.damontecres.wholphin.ui.preferences.ConditionalPreferences
|
||||||
import com.github.damontecres.wholphin.ui.preferences.PreferenceGroup
|
import com.github.damontecres.wholphin.ui.preferences.PreferenceGroup
|
||||||
import com.github.damontecres.wholphin.ui.preferences.PreferenceScreenOption
|
import com.github.damontecres.wholphin.ui.preferences.PreferenceScreenOption
|
||||||
import com.github.damontecres.wholphin.ui.preferences.PreferenceValidation
|
import com.github.damontecres.wholphin.ui.preferences.PreferenceValidation
|
||||||
|
|
@ -769,6 +770,7 @@ val advancedPreferences =
|
||||||
preferences =
|
preferences =
|
||||||
listOf(
|
listOf(
|
||||||
AppPreference.OneClickPause,
|
AppPreference.OneClickPause,
|
||||||
|
AppPreference.GlobalContentScale,
|
||||||
AppPreference.SkipIntros,
|
AppPreference.SkipIntros,
|
||||||
AppPreference.SkipOutros,
|
AppPreference.SkipOutros,
|
||||||
AppPreference.SkipCommercials,
|
AppPreference.SkipCommercials,
|
||||||
|
|
@ -776,20 +778,27 @@ val advancedPreferences =
|
||||||
AppPreference.SkipRecaps,
|
AppPreference.SkipRecaps,
|
||||||
AppPreference.MaxBitrate,
|
AppPreference.MaxBitrate,
|
||||||
AppPreference.PlaybackDebugInfo,
|
AppPreference.PlaybackDebugInfo,
|
||||||
AppPreference.PlayerBackendPref,
|
|
||||||
AppPreference.MpvHardwareDecoding,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
PreferenceGroup(
|
PreferenceGroup(
|
||||||
title = R.string.playback_overrides,
|
title = R.string.player_backend,
|
||||||
preferences =
|
preferences = listOf(AppPreference.PlayerBackendPref),
|
||||||
|
conditionalPreferences =
|
||||||
listOf(
|
listOf(
|
||||||
AppPreference.GlobalContentScale,
|
ConditionalPreferences(
|
||||||
AppPreference.DownMixStereo,
|
{ it.playbackPreferences.playerBackend == PlayerBackend.EXO_PLAYER },
|
||||||
AppPreference.Ac3Supported,
|
listOf(
|
||||||
AppPreference.DirectPlayAss,
|
AppPreference.FfmpegPreference,
|
||||||
AppPreference.DirectPlayPgs,
|
AppPreference.DownMixStereo,
|
||||||
AppPreference.FfmpegPreference,
|
AppPreference.Ac3Supported,
|
||||||
|
AppPreference.DirectPlayAss,
|
||||||
|
AppPreference.DirectPlayPgs,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
ConditionalPreferences(
|
||||||
|
{ it.playbackPreferences.playerBackend == PlayerBackend.MPV },
|
||||||
|
listOf(AppPreference.MpvHardwareDecoding),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
PreferenceGroup(
|
PreferenceGroup(
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package com.github.damontecres.wholphin.ui.preferences
|
||||||
|
|
||||||
import androidx.annotation.StringRes
|
import androidx.annotation.StringRes
|
||||||
import com.github.damontecres.wholphin.preferences.AppPreference
|
import com.github.damontecres.wholphin.preferences.AppPreference
|
||||||
|
import com.github.damontecres.wholphin.preferences.AppPreferences
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -10,6 +11,12 @@ import kotlinx.serialization.Serializable
|
||||||
data class PreferenceGroup(
|
data class PreferenceGroup(
|
||||||
@param:StringRes val title: Int,
|
@param:StringRes val title: Int,
|
||||||
val preferences: List<AppPreference<out Any?>>,
|
val preferences: List<AppPreference<out Any?>>,
|
||||||
|
val conditionalPreferences: List<ConditionalPreferences> = listOf(),
|
||||||
|
)
|
||||||
|
|
||||||
|
data class ConditionalPreferences(
|
||||||
|
val condition: (AppPreferences) -> Boolean,
|
||||||
|
val preferences: List<AppPreference<out Any?>>,
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -175,7 +175,13 @@ fun PreferencesContent(
|
||||||
.padding(top = 8.dp, bottom = 4.dp),
|
.padding(top = 8.dp, bottom = 4.dp),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
group.preferences.forEachIndexed { prefIndex, pref ->
|
val groupPreferences =
|
||||||
|
group.preferences +
|
||||||
|
group.conditionalPreferences
|
||||||
|
.filter { it.condition.invoke(preferences) }
|
||||||
|
.map { it.preferences }
|
||||||
|
.flatten()
|
||||||
|
groupPreferences.forEachIndexed { prefIndex, pref ->
|
||||||
pref as AppPreference<Any>
|
pref as AppPreference<Any>
|
||||||
item {
|
item {
|
||||||
val interactionSource = remember { MutableInteractionSource() }
|
val interactionSource = remember { MutableInteractionSource() }
|
||||||
|
|
|
||||||
|
|
@ -147,6 +147,8 @@
|
||||||
<string name="player_backend">Playback Backend</string>
|
<string name="player_backend">Playback Backend</string>
|
||||||
<string name="mpv_hardware_decoding">MPV: Use hardware decoding</string>
|
<string name="mpv_hardware_decoding">MPV: Use hardware decoding</string>
|
||||||
<string name="disable_if_crash">Disable if you experience crashes</string>
|
<string name="disable_if_crash">Disable if you experience crashes</string>
|
||||||
|
<string name="mpv_options">MPV Options</string>
|
||||||
|
<string name="exoplayer_options">ExoPlayer Options</string>
|
||||||
|
|
||||||
<plurals name="downloads">
|
<plurals name="downloads">
|
||||||
<item quantity="zero">%d downloads</item>
|
<item quantity="zero">%d downloads</item>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue