diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/view/InputDeviceSetting.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/view/InputDeviceSetting.java deleted file mode 100644 index f02de2e3f3..0000000000 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/view/InputDeviceSetting.java +++ /dev/null @@ -1,70 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later - -package org.dolphinemu.dolphinemu.features.input.model.view; - -import android.content.Context; - -import org.dolphinemu.dolphinemu.features.input.model.ControllerInterface; -import org.dolphinemu.dolphinemu.features.input.model.controlleremu.EmulatedController; -import org.dolphinemu.dolphinemu.features.settings.model.Settings; -import org.dolphinemu.dolphinemu.features.settings.model.view.StringSingleChoiceSetting; - -public class InputDeviceSetting extends StringSingleChoiceSetting -{ - private final EmulatedController mController; - - public InputDeviceSetting(Context context, int titleId, int descriptionId, - EmulatedController controller) - { - super(context, null, titleId, descriptionId, null, null, null); - - mController = controller; - - refreshChoicesAndValues(); - } - - @Override - public String getSelectedChoice() - { - return mController.getDefaultDevice(); - } - - @Override - public String getSelectedValue() - { - return mController.getDefaultDevice(); - } - - @Override - public void setSelectedValue(Settings settings, String newValue) - { - mController.setDefaultDevice(newValue); - } - - @Override - public void refreshChoicesAndValues() - { - String[] devices = ControllerInterface.getAllDeviceStrings(); - - setChoices(devices); - setValues(devices); - } - - @Override - public boolean isEditable() - { - return true; - } - - @Override - public boolean canClear() - { - return true; - } - - @Override - public void clear(Settings settings) - { - setSelectedValue(settings, ""); - } -} diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/view/InputDeviceSetting.kt b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/view/InputDeviceSetting.kt new file mode 100644 index 0000000000..c98af542c7 --- /dev/null +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/view/InputDeviceSetting.kt @@ -0,0 +1,42 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + +package org.dolphinemu.dolphinemu.features.input.model.view + +import android.content.Context +import org.dolphinemu.dolphinemu.features.input.model.ControllerInterface +import org.dolphinemu.dolphinemu.features.input.model.controlleremu.EmulatedController +import org.dolphinemu.dolphinemu.features.settings.model.Settings +import org.dolphinemu.dolphinemu.features.settings.model.view.StringSingleChoiceSetting + +class InputDeviceSetting( + context: Context, + titleId: Int, + descriptionId: Int, + private val controller: EmulatedController +) : StringSingleChoiceSetting(context, null, titleId, descriptionId, null, null, null) { + init { + refreshChoicesAndValues() + } + + override val selectedChoice: String + get() = controller.getDefaultDevice() + + override val selectedValue: String + get() = controller.getDefaultDevice() + + override fun setSelectedValue(settings: Settings, selection: String) = + controller.setDefaultDevice(selection) + + override fun refreshChoicesAndValues() { + val devices = ControllerInterface.getAllDeviceStrings() + + choices = devices + values = devices + } + + override val isEditable: Boolean = true + + override fun canClear(): Boolean = true + + override fun clear(settings: Settings) = setSelectedValue(settings, "") +} diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/PostProcessing.kt b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/PostProcessing.kt index 1bb1aa04d7..04fe2734bb 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/PostProcessing.kt +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/PostProcessing.kt @@ -4,14 +4,14 @@ package org.dolphinemu.dolphinemu.features.settings.model object PostProcessing { @JvmStatic - val shaderList: Array + val shaderList: Array external get @JvmStatic - val anaglyphShaderList: Array + val anaglyphShaderList: Array external get @JvmStatic - val passiveShaderList: Array + val passiveShaderList: Array external get } diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/StringSingleChoiceSetting.kt b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/StringSingleChoiceSetting.kt index 62301e23ef..a67992ce2b 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/StringSingleChoiceSetting.kt +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/StringSingleChoiceSetting.kt @@ -17,9 +17,9 @@ open class StringSingleChoiceSetting : SettingsItem { override val setting: AbstractSetting? get() = stringSetting - var choices: Array? + var choices: Array? protected set - var values: Array? + var values: Array? protected set val menuTag: MenuTag? var noChoicesAvailableString = 0 @@ -37,8 +37,8 @@ open class StringSingleChoiceSetting : SettingsItem { setting: AbstractStringSetting?, titleId: Int, descriptionId: Int, - choices: Array?, - values: Array?, + choices: Array?, + values: Array?, menuTag: MenuTag? = null ) : super(context, titleId, descriptionId) { stringSetting = setting @@ -52,8 +52,8 @@ open class StringSingleChoiceSetting : SettingsItem { setting: AbstractStringSetting, titleId: Int, descriptionId: Int, - choices: Array, - values: Array, + choices: Array, + values: Array, noChoicesAvailableString: Int ) : this(context, setting, titleId, descriptionId, choices, values) { this.noChoicesAvailableString = noChoicesAvailableString @@ -102,8 +102,8 @@ open class StringSingleChoiceSetting : SettingsItem { return -1 } - open fun setSelectedValue(settings: Settings?, selection: String?) { - stringSetting!!.setString(settings!!, selection!!) + open fun setSelectedValue(settings: Settings, selection: String) { + stringSetting!!.setString(settings, selection) } open fun refreshChoicesAndValues() {} diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsAdapter.kt b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsAdapter.kt index e3e745fafa..3623f167bb 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsAdapter.kt +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsAdapter.kt @@ -474,7 +474,7 @@ class SettingsAdapter( val value = scSetting.getValueAt(which) if (scSetting.selectedValue != value) fragmentView.onSettingChanged() - scSetting.setSelectedValue(settings, value) + scSetting.setSelectedValue(settings!!, value!!) closeDialog() } diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragmentPresenter.kt b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragmentPresenter.kt index 2ec27cff72..f339f7538c 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragmentPresenter.kt +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragmentPresenter.kt @@ -1339,13 +1339,8 @@ class SettingsFragmentPresenter( val shaderList = if (stereoModeValue == anaglyphMode) PostProcessing.anaglyphShaderList else PostProcessing.shaderList - val shaderListEntries = arrayOfNulls(shaderList.size + 1) - shaderListEntries[0] = context.getString(R.string.off) - System.arraycopy(shaderList, 0, shaderListEntries, 1, shaderList.size) - - val shaderListValues = arrayOfNulls(shaderList.size + 1) - shaderListValues[0] = "" - System.arraycopy(shaderList, 0, shaderListValues, 1, shaderList.size) + val shaderListEntries = arrayOf(context.getString(R.string.off), *shaderList) + val shaderListValues = arrayOf("", *shaderList) sl.add( StringSingleChoiceSetting(