Merge pull request #6669 from Bnyro/master

fix: don't allow empty input in EditNumberPreference
This commit is contained in:
Bnyro 2024-10-28 11:31:10 +01:00 committed by GitHub
commit 88d92bda74
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -89,7 +89,7 @@ abstract class BasePreferenceFragment : PreferenceFragmentCompat() {
.setView(binding.root)
.setPositiveButton(android.R.string.ok) { _, _ ->
val newValue = binding.input.text.toString()
if (preference is EditNumberPreference && newValue.any { !it.isDigit() }) {
if (preference is EditNumberPreference && newValue.toIntOrNull() == null) {
Toast.makeText(context, R.string.invalid_input, Toast.LENGTH_LONG).show()
return@setPositiveButton
}