mirror of
https://gitlab.com/suyu-emu/suyu.git
synced 2024-03-15 23:15:44 +00:00
android: Expose audio output engine setting
This commit is contained in:
parent
13a4de647d
commit
9f92104f3e
|
@ -8,6 +8,7 @@ enum class StringSetting(
|
||||||
override val section: String,
|
override val section: String,
|
||||||
override val defaultValue: String
|
override val defaultValue: String
|
||||||
) : AbstractStringSetting {
|
) : AbstractStringSetting {
|
||||||
|
AUDIO_OUTPUT_ENGINE("output_engine", Settings.SECTION_AUDIO, "auto"),
|
||||||
CUSTOM_RTC("custom_rtc", Settings.SECTION_SYSTEM, "0");
|
CUSTOM_RTC("custom_rtc", Settings.SECTION_SYSTEM, "0");
|
||||||
|
|
||||||
override var string: String = defaultValue
|
override var string: String = defaultValue
|
||||||
|
|
|
@ -7,20 +7,20 @@ import org.yuzu.yuzu_emu.features.settings.model.AbstractSetting
|
||||||
import org.yuzu.yuzu_emu.features.settings.model.AbstractStringSetting
|
import org.yuzu.yuzu_emu.features.settings.model.AbstractStringSetting
|
||||||
|
|
||||||
class StringSingleChoiceSetting(
|
class StringSingleChoiceSetting(
|
||||||
val key: String? = null,
|
|
||||||
setting: AbstractSetting?,
|
setting: AbstractSetting?,
|
||||||
titleId: Int,
|
titleId: Int,
|
||||||
descriptionId: Int,
|
descriptionId: Int,
|
||||||
val choicesId: Array<String>,
|
val choices: Array<String>,
|
||||||
private val valuesId: Array<String>?,
|
val values: Array<String>?,
|
||||||
|
val key: String? = null,
|
||||||
private val defaultValue: String? = null
|
private val defaultValue: String? = null
|
||||||
) : SettingsItem(setting, titleId, descriptionId) {
|
) : SettingsItem(setting, titleId, descriptionId) {
|
||||||
override val type = TYPE_STRING_SINGLE_CHOICE
|
override val type = TYPE_STRING_SINGLE_CHOICE
|
||||||
|
|
||||||
fun getValueAt(index: Int): String? {
|
fun getValueAt(index: Int): String? {
|
||||||
if (valuesId == null) return null
|
if (values == null) return null
|
||||||
return if (index >= 0 && index < valuesId.size) {
|
return if (index >= 0 && index < values.size) {
|
||||||
valuesId[index]
|
values[index]
|
||||||
} else {
|
} else {
|
||||||
""
|
""
|
||||||
}
|
}
|
||||||
|
@ -36,8 +36,8 @@ class StringSingleChoiceSetting(
|
||||||
val selectValueIndex: Int
|
val selectValueIndex: Int
|
||||||
get() {
|
get() {
|
||||||
val selectedValue = selectedValue
|
val selectedValue = selectedValue
|
||||||
for (i in valuesId!!.indices) {
|
for (i in values!!.indices) {
|
||||||
if (valuesId[i] == selectedValue) {
|
if (values[i] == selectedValue) {
|
||||||
return i
|
return i
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -138,7 +138,7 @@ class SettingsAdapter(
|
||||||
clickedItem = item
|
clickedItem = item
|
||||||
dialog = MaterialAlertDialogBuilder(context)
|
dialog = MaterialAlertDialogBuilder(context)
|
||||||
.setTitle(item.nameId)
|
.setTitle(item.nameId)
|
||||||
.setSingleChoiceItems(item.choicesId, item.selectValueIndex, this)
|
.setSingleChoiceItems(item.choices, item.selectValueIndex, this)
|
||||||
.show()
|
.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -353,18 +353,31 @@ class SettingsFragmentPresenter(private val fragmentView: SettingsFragmentView)
|
||||||
|
|
||||||
private fun addAudioSettings(sl: ArrayList<SettingsItem>) {
|
private fun addAudioSettings(sl: ArrayList<SettingsItem>) {
|
||||||
settingsActivity.setToolbarTitle(settingsActivity.getString(R.string.preferences_audio))
|
settingsActivity.setToolbarTitle(settingsActivity.getString(R.string.preferences_audio))
|
||||||
sl.add(
|
sl.apply {
|
||||||
SliderSetting(
|
add(
|
||||||
IntSetting.AUDIO_VOLUME,
|
StringSingleChoiceSetting(
|
||||||
R.string.audio_volume,
|
StringSetting.AUDIO_OUTPUT_ENGINE,
|
||||||
R.string.audio_volume_description,
|
R.string.audio_output_engine,
|
||||||
0,
|
0,
|
||||||
100,
|
settingsActivity.resources.getStringArray(R.array.outputEngineEntries),
|
||||||
"%",
|
settingsActivity.resources.getStringArray(R.array.outputEngineValues),
|
||||||
IntSetting.AUDIO_VOLUME.key,
|
StringSetting.AUDIO_OUTPUT_ENGINE.key,
|
||||||
IntSetting.AUDIO_VOLUME.defaultValue
|
StringSetting.AUDIO_OUTPUT_ENGINE.defaultValue
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
add(
|
||||||
|
SliderSetting(
|
||||||
|
IntSetting.AUDIO_VOLUME,
|
||||||
|
R.string.audio_volume,
|
||||||
|
R.string.audio_volume_description,
|
||||||
|
0,
|
||||||
|
100,
|
||||||
|
"%",
|
||||||
|
IntSetting.AUDIO_VOLUME.key,
|
||||||
|
IntSetting.AUDIO_VOLUME.defaultValue
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addThemeSettings(sl: ArrayList<SettingsItem>) {
|
private fun addThemeSettings(sl: ArrayList<SettingsItem>) {
|
||||||
|
|
|
@ -26,6 +26,14 @@ class SingleChoiceViewHolder(val binding: ListItemSettingBinding, adapter: Setti
|
||||||
for (i in values.indices) {
|
for (i in values.indices) {
|
||||||
if (values[i] == item.selectedValue) {
|
if (values[i] == item.selectedValue) {
|
||||||
binding.textSettingDescription.text = resMgr.getStringArray(item.choicesId)[i]
|
binding.textSettingDescription.text = resMgr.getStringArray(item.choicesId)[i]
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (item is StringSingleChoiceSetting) {
|
||||||
|
for (i in item.values!!.indices) {
|
||||||
|
if (item.values[i] == item.selectedValue) {
|
||||||
|
binding.textSettingDescription.text = item.choices[i]
|
||||||
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -236,4 +236,15 @@
|
||||||
<item>2</item>
|
<item>2</item>
|
||||||
</integer-array>
|
</integer-array>
|
||||||
|
|
||||||
|
<string-array name="outputEngineEntries">
|
||||||
|
<item>@string/auto</item>
|
||||||
|
<item>@string/cubeb</item>
|
||||||
|
<item>@string/string_null</item>
|
||||||
|
</string-array>
|
||||||
|
<string-array name="outputEngineValues">
|
||||||
|
<item>auto</item>
|
||||||
|
<item>cubeb</item>
|
||||||
|
<item>null</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -185,6 +185,7 @@
|
||||||
<string name="fastmem">Fastmem</string>
|
<string name="fastmem">Fastmem</string>
|
||||||
|
|
||||||
<!-- Audio settings strings -->
|
<!-- Audio settings strings -->
|
||||||
|
<string name="audio_output_engine">Output engine</string>
|
||||||
<string name="audio_volume">Volume</string>
|
<string name="audio_volume">Volume</string>
|
||||||
<string name="audio_volume_description">Specifies the volume of audio output.</string>
|
<string name="audio_volume_description">Specifies the volume of audio output.</string>
|
||||||
|
|
||||||
|
@ -203,6 +204,7 @@
|
||||||
<string name="learn_more">Learn more</string>
|
<string name="learn_more">Learn more</string>
|
||||||
<string name="auto">Auto</string>
|
<string name="auto">Auto</string>
|
||||||
<string name="submit">Submit</string>
|
<string name="submit">Submit</string>
|
||||||
|
<string name="string_null">Null</string>
|
||||||
|
|
||||||
<!-- GPU driver installation -->
|
<!-- GPU driver installation -->
|
||||||
<string name="select_gpu_driver">Select GPU driver</string>
|
<string name="select_gpu_driver">Select GPU driver</string>
|
||||||
|
@ -373,6 +375,9 @@
|
||||||
<string name="theme_mode_light">Light</string>
|
<string name="theme_mode_light">Light</string>
|
||||||
<string name="theme_mode_dark">Dark</string>
|
<string name="theme_mode_dark">Dark</string>
|
||||||
|
|
||||||
|
<!-- Audio output engines -->
|
||||||
|
<string name="cubeb">cubeb</string>
|
||||||
|
|
||||||
<!-- Black backgrounds theme -->
|
<!-- Black backgrounds theme -->
|
||||||
<string name="use_black_backgrounds">Black backgrounds</string>
|
<string name="use_black_backgrounds">Black backgrounds</string>
|
||||||
<string name="use_black_backgrounds_description">When using the dark theme, apply black backgrounds.</string>
|
<string name="use_black_backgrounds_description">When using the dark theme, apply black backgrounds.</string>
|
||||||
|
|
Loading…
Reference in a new issue