-
-
Notifications
You must be signed in to change notification settings - Fork 332
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Move player preferences into their own menu (#1819)
- Loading branch information
Showing
22 changed files
with
1,167 additions
and
314 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
...n/java/eu/kanade/presentation/more/settings/screen/player/PlayerSettingsAdvancedScreen.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package eu.kanade.presentation.more.settings.screen.player | ||
|
||
import android.content.Intent | ||
import android.net.Uri | ||
import android.os.Build | ||
import android.os.Environment | ||
import android.provider.Settings | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.ReadOnlyComposable | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.runtime.rememberCoroutineScope | ||
import androidx.compose.ui.platform.LocalContext | ||
import eu.kanade.presentation.more.settings.Preference | ||
import eu.kanade.presentation.more.settings.screen.SearchableSettings | ||
import eu.kanade.tachiyomi.ui.player.settings.PlayerPreferences | ||
import tachiyomi.i18n.MR | ||
import tachiyomi.presentation.core.i18n.stringResource | ||
import uy.kohesive.injekt.Injekt | ||
import uy.kohesive.injekt.api.get | ||
|
||
object PlayerSettingsAdvancedScreen : SearchableSettings { | ||
|
||
@ReadOnlyComposable | ||
@Composable | ||
override fun getTitleRes() = MR.strings.pref_player_advanced | ||
|
||
@Composable | ||
override fun getPreferences(): List<Preference> { | ||
val playerPreferences = remember { Injekt.get<PlayerPreferences>() } | ||
val scope = rememberCoroutineScope() | ||
val context = LocalContext.current | ||
|
||
val enableScripts = playerPreferences.mpvScripts() | ||
val mpvConf = playerPreferences.mpvConf() | ||
val mpvInput = playerPreferences.mpvInput() | ||
|
||
return listOf( | ||
Preference.PreferenceItem.SwitchPreference( | ||
title = stringResource(MR.strings.pref_mpv_scripts), | ||
subtitle = stringResource(MR.strings.pref_mpv_scripts_summary), | ||
pref = enableScripts, | ||
onValueChanged = { | ||
// Ask for external storage permission | ||
if (it) { | ||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R && !Environment.isExternalStorageManager()) { | ||
val intent = Intent(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION) | ||
intent.data = Uri.fromParts("package", context.packageName, null) | ||
context.startActivity(intent) | ||
} | ||
} | ||
true | ||
}, | ||
), | ||
Preference.PreferenceItem.MPVConfPreference( | ||
pref = mpvConf, | ||
title = stringResource(MR.strings.pref_mpv_conf), | ||
fileName = "mpv.conf", | ||
scope = scope, | ||
context = context, | ||
), | ||
Preference.PreferenceItem.MPVConfPreference( | ||
pref = mpvInput, | ||
title = stringResource(MR.strings.pref_mpv_input), | ||
fileName = "input.conf", | ||
scope = scope, | ||
context = context, | ||
), | ||
) | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
...main/java/eu/kanade/presentation/more/settings/screen/player/PlayerSettingsAudioScreen.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package eu.kanade.presentation.more.settings.screen.player | ||
|
||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.ReadOnlyComposable | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.runtime.remember | ||
import eu.kanade.presentation.more.settings.Preference | ||
import eu.kanade.presentation.more.settings.screen.SearchableSettings | ||
import eu.kanade.tachiyomi.ui.player.settings.PlayerPreferences | ||
import eu.kanade.tachiyomi.ui.player.viewer.AudioChannels | ||
import kotlinx.collections.immutable.toImmutableMap | ||
import tachiyomi.i18n.MR | ||
import tachiyomi.presentation.core.i18n.stringResource | ||
import tachiyomi.presentation.core.util.collectAsState | ||
import uy.kohesive.injekt.Injekt | ||
import uy.kohesive.injekt.api.get | ||
|
||
object PlayerSettingsAudioScreen : SearchableSettings { | ||
|
||
@ReadOnlyComposable | ||
@Composable | ||
override fun getTitleRes() = MR.strings.pref_player_audio | ||
|
||
@Composable | ||
override fun getPreferences(): List<Preference> { | ||
val playerPreferences = remember { Injekt.get<PlayerPreferences>() } | ||
|
||
val prefLangs = playerPreferences.preferredAudioLanguages() | ||
val pitchCorrection = playerPreferences.enablePitchCorrection() | ||
val audioChannels = playerPreferences.audioChannels() | ||
val boostCapPref = playerPreferences.volumeBoostCap() | ||
val boostCap by boostCapPref.collectAsState() | ||
|
||
return listOf( | ||
Preference.PreferenceItem.EditTextInfoPreference( | ||
pref = prefLangs, | ||
title = stringResource(MR.strings.pref_player_audio_lang), | ||
dialogSubtitle = stringResource(MR.strings.pref_player_audio_lang_info), | ||
), | ||
Preference.PreferenceItem.SwitchPreference( | ||
pref = pitchCorrection, | ||
title = stringResource(MR.strings.pref_player_audio_pitch_correction), | ||
subtitle = stringResource(MR.strings.pref_player_audio_pitch_correction_summary), | ||
), | ||
Preference.PreferenceItem.ListPreference( | ||
pref = audioChannels, | ||
title = stringResource(MR.strings.pref_player_audio_channels), | ||
entries = AudioChannels.entries.associateWith { | ||
stringResource(it.textRes) | ||
}.toImmutableMap(), | ||
), | ||
Preference.PreferenceItem.SliderPreference( | ||
value = boostCap, | ||
title = stringResource(MR.strings.pref_player_audio_boost_cap), | ||
subtitle = boostCap.toString(), | ||
min = 0, | ||
max = 200, | ||
onValueChanged = { | ||
boostCapPref.set(it) | ||
true | ||
}, | ||
), | ||
) | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
...in/java/eu/kanade/presentation/more/settings/screen/player/PlayerSettingsDecoderScreen.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package eu.kanade.presentation.more.settings.screen.player | ||
|
||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.ReadOnlyComposable | ||
import androidx.compose.runtime.remember | ||
import eu.kanade.presentation.more.settings.Preference | ||
import eu.kanade.presentation.more.settings.screen.SearchableSettings | ||
import eu.kanade.tachiyomi.ui.player.settings.PlayerPreferences | ||
import eu.kanade.tachiyomi.ui.player.viewer.VideoDebanding | ||
import kotlinx.collections.immutable.toImmutableMap | ||
import tachiyomi.i18n.MR | ||
import tachiyomi.presentation.core.i18n.stringResource | ||
import uy.kohesive.injekt.Injekt | ||
import uy.kohesive.injekt.api.get | ||
|
||
object PlayerSettingsDecoderScreen : SearchableSettings { | ||
|
||
@ReadOnlyComposable | ||
@Composable | ||
override fun getTitleRes() = MR.strings.pref_player_decoder | ||
|
||
@Composable | ||
override fun getPreferences(): List<Preference> { | ||
val playerPreferences = remember { Injekt.get<PlayerPreferences>() } | ||
|
||
val tryHw = playerPreferences.tryHWDecoding() | ||
val useGpuNext = playerPreferences.gpuNext() | ||
val debanding = playerPreferences.videoDebanding() | ||
val yuv420p = playerPreferences.useYUV420P() | ||
|
||
return listOf( | ||
Preference.PreferenceItem.SwitchPreference( | ||
pref = tryHw, | ||
title = stringResource(MR.strings.pref_try_hw), | ||
), | ||
Preference.PreferenceItem.SwitchPreference( | ||
pref = useGpuNext, | ||
title = stringResource(MR.strings.pref_gpu_next_title), | ||
subtitle = stringResource(MR.strings.pref_gpu_next_subtitle), | ||
), | ||
Preference.PreferenceItem.ListPreference( | ||
pref = debanding, | ||
title = stringResource(MR.strings.pref_debanding_title), | ||
entries = VideoDebanding.entries.associateWith { | ||
stringResource(it.stringRes) | ||
}.toImmutableMap(), | ||
), | ||
Preference.PreferenceItem.SwitchPreference( | ||
pref = yuv420p, | ||
title = stringResource(MR.strings.pref_use_yuv420p_title), | ||
subtitle = stringResource(MR.strings.pref_use_yuv420p_subtitle), | ||
), | ||
) | ||
} | ||
} |
Oops, something went wrong.