Add factory reset button

This commit is contained in:
Douile 2022-08-23 11:13:47 +01:00
parent 2a74d4fa69
commit 7adf3cd0f5
No known key found for this signature in database
GPG key ID: DC9D70626CEF33D0
4 changed files with 39 additions and 0 deletions

View file

@ -55,6 +55,7 @@ class AdvancedSettingsFragment : ScreenFragment("Advanced Settings"), Logging {
binding.lsSleepSwitch.isEnabled = connected && model.isESP32()
binding.shutdownButton.isEnabled = connected && model.hasAXP()
binding.rebootButton.isEnabled = connected
binding.factoryResetButton.isEnabled = connected
}
binding.positionBroadcastPeriodEditText.on(EditorInfo.IME_ACTION_DONE) {
@ -130,5 +131,17 @@ class AdvancedSettingsFragment : ScreenFragment("Advanced Settings"), Logging {
}
.show()
}
binding.factoryResetButton.setOnClickListener {
MaterialAlertDialogBuilder(requireContext())
.setTitle(R.string.are_you_sure_factory_reset)
.setMessage(R.string.factory_reset_description)
.setNeutralButton(R.string.cancel) { _, _ ->
}
.setPositiveButton(R.string.okay) { _, _ ->
model.requestFactoryReset()
}
.show()
}
}
}