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

Move slider preferences to gestures #1860

Merged
merged 3 commits into from
Dec 30, 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 @@ -25,18 +25,13 @@ object PlayerSettingsAudioScreen : SearchableSettings {
override fun getPreferences(): List<Preference> {
val audioPreferences = remember { Injekt.get<AudioPreferences>() }

val rememberDelay = audioPreferences.rememberAudioDelay()
val prefLangs = audioPreferences.preferredAudioLanguages()
val pitchCorrection = audioPreferences.enablePitchCorrection()
val audioChannels = audioPreferences.audioChannels()
val boostCapPref = audioPreferences.volumeBoostCap()
val boostCap by boostCapPref.collectAsState()

return listOf(
Preference.PreferenceItem.SwitchPreference(
pref = rememberDelay,
title = stringResource(MR.strings.player_audio_remember_delay),
),
Preference.PreferenceItem.EditTextInfoPreference(
pref = prefLangs,
title = stringResource(MR.strings.pref_player_audio_lang),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,33 @@ object PlayerSettingsGesturesScreen : SearchableSettings {
val gesturePreferences = remember { Injekt.get<GesturePreferences>() }

return listOf(
getSlidersGroup(gesturePreferences = gesturePreferences),
getSeekingGroup(gesturePreferences = gesturePreferences),
getDoubleTapGroup(gesturePreferences = gesturePreferences),
getMediaControlsGroup(gesturePreferences = gesturePreferences),
)
}

@Composable
private fun getSlidersGroup(gesturePreferences: GesturePreferences): Preference.PreferenceGroup {
val enableVolumeBrightnessGestures = gesturePreferences.gestureVolumeBrightness()
val swapVol = gesturePreferences.swapVolumeBrightness()

return Preference.PreferenceGroup(
title = stringResource(MR.strings.pref_category_player_sliders),
preferenceItems = persistentListOf(
Preference.PreferenceItem.SwitchPreference(
pref = enableVolumeBrightnessGestures,
title = stringResource(MR.strings.enable_volume_brightness_gestures),
),
Preference.PreferenceItem.SwitchPreference(
pref = swapVol,
title = stringResource(MR.strings.pref_controls_swap_vol_brightness),
),
),
)
}

@Composable
private fun getSeekingGroup(gesturePreferences: GesturePreferences): Preference.PreferenceGroup {
val scope = rememberCoroutineScope()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,8 @@ object PlayerSettingsPlayerScreen : SearchableSettings {
@Composable
private fun getControlsGroup(playerPreferences: PlayerPreferences): Preference.PreferenceGroup {
val allowGestures = playerPreferences.allowGestures()
val displayVol = playerPreferences.displayVolPer()
val swapVol = playerPreferences.swapVolumeBrightness()
val showLoading = playerPreferences.showLoadingCircle()
val showChapter = playerPreferences.showCurrentChapter()
val enableVolumeBrightnessGestures = playerPreferences.gestureVolumeBrightness()
val rememberPlayerBrightness = playerPreferences.rememberPlayerBrightness()
val rememberPlayerVolume = playerPreferences.rememberPlayerVolume()

Expand All @@ -106,18 +103,6 @@ object PlayerSettingsPlayerScreen : SearchableSettings {
title = stringResource(MR.strings.pref_controls_show_chapter_indicator),
subtitle = stringResource(MR.strings.pref_controls_show_chapter_indicator_info),
),
Preference.PreferenceItem.SwitchPreference(
pref = enableVolumeBrightnessGestures,
title = stringResource(MR.strings.enable_volume_brightness_gestures),
),
Preference.PreferenceItem.SwitchPreference(
pref = displayVol,
title = stringResource(MR.strings.pref_controls_display_volume_percentage),
),
Preference.PreferenceItem.SwitchPreference(
pref = swapVol,
title = stringResource(MR.strings.pref_controls_swap_vol_brightness),
),
Preference.PreferenceItem.SwitchPreference(
pref = rememberPlayerBrightness,
title = stringResource(MR.strings.pref_remember_brightness),
Expand All @@ -134,6 +119,7 @@ object PlayerSettingsPlayerScreen : SearchableSettings {
private fun getDisplayGroup(playerPreferences: PlayerPreferences): Preference.PreferenceGroup {
val fullScreen = playerPreferences.playerFullscreen()
val hideControls = playerPreferences.hideControls()
val displayVol = playerPreferences.displayVolPer()
val showSystemBar = playerPreferences.showSystemStatusBar()
val reduceMotion = playerPreferences.reduceMotion()
val hideTime = playerPreferences.playerTimeToDisappear()
Expand All @@ -154,6 +140,10 @@ object PlayerSettingsPlayerScreen : SearchableSettings {
pref = hideControls,
title = stringResource(MR.strings.pref_player_hide_controls),
),
Preference.PreferenceItem.SwitchPreference(
pref = displayVol,
title = stringResource(MR.strings.pref_controls_display_volume_percentage),
),
Preference.PreferenceItem.SwitchPreference(
pref = showSystemBar,
title = stringResource(MR.strings.pref_show_system_bar),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,11 @@ object PlayerSettingsSubtitleScreen : SearchableSettings {
override fun getPreferences(): List<Preference> {
val subtitlePreferences = remember { Injekt.get<SubtitlePreferences>() }

val rememberDelay = subtitlePreferences.rememberSubtitlesDelay()
val langPref = subtitlePreferences.preferredSubLanguages()
val whitelist = subtitlePreferences.subtitleWhitelist()
val blacklist = subtitlePreferences.subtitleBlacklist()

return listOf(
Preference.PreferenceItem.SwitchPreference(
pref = rememberDelay,
title = stringResource(MR.strings.player_subtitle_remember_delay),
),
Preference.PreferenceItem.EditTextInfoPreference(
pref = langPref,
title = stringResource(MR.strings.pref_player_subtitle_lang),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ fun GestureHandler(
viewModel.hideSeekBar()
}

val gestureVolumeBrightness = playerPreferences.gestureVolumeBrightness().get()
val swapVolumeBrightness by playerPreferences.swapVolumeBrightness().collectAsState()
val gestureVolumeBrightness = gesturePreferences.gestureVolumeBrightness().get()
val swapVolumeBrightness by gesturePreferences.swapVolumeBrightness().collectAsState()
val seekGesture by gesturePreferences.gestureHorizontalSeek().collectAsState()
val preciseSeeking by gesturePreferences.playerSmoothSeek().collectAsState()
val showSeekbar by gesturePreferences.showSeekBar().collectAsState()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ fun PlayerControls(
val brightness by viewModel.currentBrightness.collectAsState()
val volume by viewModel.currentVolume.collectAsState()
val mpvVolume by viewModel.currentMPVVolume.collectAsState()
val swapVolumeAndBrightness by playerPreferences.swapVolumeBrightness().collectAsState()
val swapVolumeAndBrightness by gesturePreferences.swapVolumeBrightness().collectAsState()
val reduceMotion by playerPreferences.reduceMotion().collectAsState()

LaunchedEffect(volume, mpvVolume, isVolumeSliderShown) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import tachiyomi.i18n.MR
class AudioPreferences(
private val preferenceStore: PreferenceStore,
) {
fun rememberAudioDelay() = preferenceStore.getBoolean("pref_remember_audio_delay", false)
fun preferredAudioLanguages() = preferenceStore.getString("pref_audio_lang", "")
fun enablePitchCorrection() = preferenceStore.getBoolean("pref_audio_pitch_correction", true)
fun audioChannels() = preferenceStore.getEnum("pref_audio_config", AudioChannels.AutoSafe)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ import tachiyomi.core.common.preference.getEnum
class GesturePreferences(
private val preferenceStore: PreferenceStore,
) {
// Sliders
fun gestureVolumeBrightness() = preferenceStore.getBoolean(
"pref_gesture_volume_brightness",
true,
)
fun swapVolumeBrightness() = preferenceStore.getBoolean("pref_swap_volume_and_brightness", false)

// Seeking

fun gestureHorizontalSeek() = preferenceStore.getBoolean("pref_gesture_horizontal_seek", true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,8 @@ class PlayerPreferences(
// Controls

fun allowGestures() = preferenceStore.getBoolean("pref_allow_gestures_in_panels", false)
fun displayVolPer() = preferenceStore.getBoolean("pref_display_vol_as_per", true)
fun swapVolumeBrightness() = preferenceStore.getBoolean("pref_swap_volume_and_brightness", false)
fun showLoadingCircle() = preferenceStore.getBoolean("pref_show_loading", true)
fun showCurrentChapter() = preferenceStore.getBoolean("pref_show_current_chapter", true)
fun gestureVolumeBrightness() = preferenceStore.getBoolean(
"pref_gesture_volume_brightness",
true,
)
fun rememberPlayerBrightness() = preferenceStore.getBoolean("pref_remember_brightness", false)
fun playerBrightnessValue() = preferenceStore.getFloat("player_brightness_value", -1.0F)
fun rememberPlayerVolume() = preferenceStore.getBoolean("pref_remember_volume", false)
Expand All @@ -38,6 +32,7 @@ class PlayerPreferences(

fun playerFullscreen() = preferenceStore.getBoolean("player_fullscreen", true)
fun hideControls() = preferenceStore.getBoolean("player_hide_controls", false)
fun displayVolPer() = preferenceStore.getBoolean("pref_display_vol_as_per", true)
fun showSystemStatusBar() = preferenceStore.getBoolean("pref_show_system_status_bar", false)
fun reduceMotion() = preferenceStore.getBoolean("pref_reduce_motion", false)
fun playerTimeToDisappear() = preferenceStore.getInt("pref_player_time_to_disappear", 4000)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@ import tachiyomi.core.common.preference.getEnum
class SubtitlePreferences(
private val preferenceStore: PreferenceStore,
) {
fun rememberSubtitlesDelay() = preferenceStore.getBoolean(
"pref_remember_subtitles_delay",
false,
)

fun preferredSubLanguages() = preferenceStore.getString("pref_subtitle_lang", "")
fun subtitleWhitelist() = preferenceStore.getString("pref_subtitle_whitelist", "")
fun subtitleBlacklist() = preferenceStore.getString("pref_subtitle_blacklist", "")
Expand Down
8 changes: 4 additions & 4 deletions i18n/src/commonMain/moko-resources/base/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,7 @@
<string name="pref_controls_show_loading">Show loading circle</string>
<string name="pref_controls_show_chapter_indicator">Show current chapter indicator</string>
<string name="pref_controls_show_chapter_indicator_info">Only appears if the video has chapters</string>
<string name="enable_volume_brightness_gestures">Enable Volume and Brightness Gestures</string>
<string name="pref_controls_display_volume_percentage">Display volume as percentage</string>
<string name="pref_controls_swap_vol_brightness">Swap volume and brightness slider</string>
<string name="pref_remember_brightness">Remember and switch to the last used brightness</string>
<string name="pref_remember_volume">Remember and switch to the last used volume</string>

Expand All @@ -234,6 +232,10 @@
<string name="pref_player_gestures">Gestures</string>
<string name="pref_player_gestures_summary">Seeking, double tap, media controls</string>

<string name="pref_category_player_sliders">Sliders</string>
<string name="enable_volume_brightness_gestures">Enable Volume and Brightness Gestures</string>
<string name="pref_controls_swap_vol_brightness">Swap volume and brightness slider</string>

<string name="pref_category_player_seeking">Seeking</string>
<string name="enable_horizontal_seek_gesture">Enable Horizontal Seek Gesture</string>
<string name="pref_show_seekbar">Show seekbar when seeking</string>
Expand Down Expand Up @@ -294,7 +296,6 @@
<!-- Player settings - Subtitles -->
<string name="pref_player_subtitle">Subtitles</string>
<string name="pref_player_subtitle_summary">Preferred languages, whitelist, blacklist</string>
<string name="player_subtitle_remember_delay">Remember subtitle delay</string>
<string name="pref_player_subtitle_lang">Preferred languages</string>
<string name="pref_player_subtitle_lang_info">Subtitle language(s) to be selected by default on a video with multiple subtitles, Two- or three-letter languages codes work. Multiple values can be delimited by a comma.</string>
<string name="pref_player_subtitle_whitelist">Whitelist</string>
Expand All @@ -305,7 +306,6 @@
<!-- Player settings - Audio -->
<string name="pref_player_audio">Audio</string>
<string name="pref_player_audio_summary">Preferred languages, pitch correction, audio channels</string>
<string name="player_audio_remember_delay">Remember audio delay</string>
<string name="pref_player_audio_lang">Preferred languages</string>
<string name="pref_player_audio_lang_info">Audio language(s) to be selected by default on a video with multiple audio streams, Two- or three-letter languages codes work. Multiple values can be delimited by a comma.</string>
<string name="pref_player_audio_pitch_correction">Enable audio pitch correction</string>
Expand Down
Loading