mirror of
https://git.eden-emu.dev/eden-emu/eden
synced 2026-05-13 17:28:35 +02:00
[android, ui] fixed setting reset to defaults infinite loop (#3659)
fixed a bug discovered by Pavel in which the settings' "reset to defaults" dialog would get stuck in a infinite loop, due to a recall prior to cleaning state. Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3659 Reviewed-by: MaranBr <maranbr@eden-emu.dev> Reviewed-by: DraVee <chimera@dravee.dev> Reviewed-by: CamilleLaVey <camillelavey99@gmail.com> Co-authored-by: xbzk <xbzk@eden-emu.dev> Co-committed-by: xbzk <xbzk@eden-emu.dev>
This commit is contained in:
parent
70c1e9abed
commit
05f6942bef
2 changed files with 20 additions and 27 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
// SPDX-FileCopyrightText: 2023 yuzu Emulator Project
|
// SPDX-FileCopyrightText: 2023 yuzu Emulator Project
|
||||||
|
|
@ -68,7 +68,9 @@ class SettingsDialogFragment : DialogFragment(), DialogInterface.OnClickListener
|
||||||
MaterialAlertDialogBuilder(requireContext())
|
MaterialAlertDialogBuilder(requireContext())
|
||||||
.setMessage(R.string.reset_setting_confirmation)
|
.setMessage(R.string.reset_setting_confirmation)
|
||||||
.setPositiveButton(android.R.string.ok) { _: DialogInterface, _: Int ->
|
.setPositiveButton(android.R.string.ok) { _: DialogInterface, _: Int ->
|
||||||
when (val item = settingsViewModel.clickedItem) {
|
val item = settingsViewModel.clickedItem ?: return@setPositiveButton
|
||||||
|
clearDialogState()
|
||||||
|
when (item) {
|
||||||
is AnalogInputSetting -> {
|
is AnalogInputSetting -> {
|
||||||
val stickParam = NativeInput.getStickParam(
|
val stickParam = NativeInput.getStickParam(
|
||||||
item.playerIndex,
|
item.playerIndex,
|
||||||
|
|
@ -107,12 +109,17 @@ class SettingsDialogFragment : DialogFragment(), DialogInterface.OnClickListener
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> {
|
else -> {
|
||||||
settingsViewModel.clickedItem!!.setting.reset()
|
item.setting.reset()
|
||||||
settingsViewModel.setAdapterItemChanged(position)
|
settingsViewModel.setAdapterItemChanged(position)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.setNegativeButton(android.R.string.cancel, null)
|
.setNegativeButton(android.R.string.cancel) { _: DialogInterface, _: Int ->
|
||||||
|
clearDialogState()
|
||||||
|
}
|
||||||
|
.setOnCancelListener {
|
||||||
|
clearDialogState()
|
||||||
|
}
|
||||||
.create()
|
.create()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -186,27 +193,6 @@ class SettingsDialogFragment : DialogFragment(), DialogInterface.OnClickListener
|
||||||
updateButtonState(isValid)
|
updateButtonState(isValid)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* xbzk: these two events, along with attachRepeat feature,
|
|
||||||
* were causing spinbox buttons to respond twice per press
|
|
||||||
* cutting these out to retain accelerated press functionality
|
|
||||||
* TODO: clean this out later if no issues arise
|
|
||||||
*
|
|
||||||
spinboxBinding.buttonDecrement.setOnClickListener {
|
|
||||||
val current = spinboxBinding.editValue.text.toString().toIntOrNull() ?: currentValue
|
|
||||||
val newValue = current - 1
|
|
||||||
spinboxBinding.editValue.setText(newValue.toString())
|
|
||||||
updateValidity(newValue)
|
|
||||||
}
|
|
||||||
|
|
||||||
spinboxBinding.buttonIncrement.setOnClickListener {
|
|
||||||
val current = spinboxBinding.editValue.text.toString().toIntOrNull() ?: currentValue
|
|
||||||
val newValue = current + 1
|
|
||||||
spinboxBinding.editValue.setText(newValue.toString())
|
|
||||||
updateValidity(newValue)
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
fun attachRepeat(button: View, delta: Int) {
|
fun attachRepeat(button: View, delta: Int) {
|
||||||
val handler = Handler(Looper.getMainLooper())
|
val handler = Handler(Looper.getMainLooper())
|
||||||
var runnable: Runnable? = null
|
var runnable: Runnable? = null
|
||||||
|
|
@ -439,9 +425,13 @@ class SettingsDialogFragment : DialogFragment(), DialogInterface.OnClickListener
|
||||||
|
|
||||||
private fun closeDialog() {
|
private fun closeDialog() {
|
||||||
settingsViewModel.setAdapterItemChanged(position)
|
settingsViewModel.setAdapterItemChanged(position)
|
||||||
|
clearDialogState()
|
||||||
|
dismiss()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun clearDialogState() {
|
||||||
settingsViewModel.clickedItem = null
|
settingsViewModel.clickedItem = null
|
||||||
settingsViewModel.setSliderProgress(-1f)
|
settingsViewModel.setSliderProgress(-1f)
|
||||||
dismiss()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getValueForSingleChoiceSelection(item: SingleChoiceSetting, which: Int): Int {
|
private fun getValueForSingleChoiceSelection(item: SingleChoiceSetting, which: Int): Int {
|
||||||
|
|
|
||||||
|
|
@ -1066,7 +1066,10 @@ class SettingsFragmentPresenter(
|
||||||
IntSetting.THEME.getValueAsString()
|
IntSetting.THEME.getValueAsString()
|
||||||
|
|
||||||
override val defaultValue: Int = IntSetting.THEME.defaultValue
|
override val defaultValue: Int = IntSetting.THEME.defaultValue
|
||||||
override fun reset() = IntSetting.THEME.setInt(defaultValue)
|
override fun reset() {
|
||||||
|
IntSetting.THEME.setInt(defaultValue)
|
||||||
|
settingsViewModel.setShouldRecreate(true)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
add(HeaderSetting(R.string.app_settings))
|
add(HeaderSetting(R.string.app_settings))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue