diff --git a/app/src/main/java/com/geeksville/mesh/model/UIState.kt b/app/src/main/java/com/geeksville/mesh/model/UIState.kt
index 00664b17b..d2711e238 100644
--- a/app/src/main/java/com/geeksville/mesh/model/UIState.kt
+++ b/app/src/main/java/com/geeksville/mesh/model/UIState.kt
@@ -346,6 +346,17 @@ class UIViewModel @Inject constructor(
meshService?.requestReboot(DataPacket.ID_LOCAL)
}
+ fun requestFactoryReset() {
+ val config = _localConfig.value
+ if (config != null) {
+ val builder = config.device.toBuilder()
+ builder.factoryReset = true
+ val newConfig = ConfigProtos.Config.newBuilder()
+ newConfig.device = builder.build()
+ setDeviceConfig(newConfig.build())
+ }
+ }
+
/**
* Write the persisted packet data out to a CSV file in the specified location.
*/
diff --git a/app/src/main/java/com/geeksville/mesh/ui/AdvancedSettingsFragment.kt b/app/src/main/java/com/geeksville/mesh/ui/AdvancedSettingsFragment.kt
index 53faed41b..501bed195 100644
--- a/app/src/main/java/com/geeksville/mesh/ui/AdvancedSettingsFragment.kt
+++ b/app/src/main/java/com/geeksville/mesh/ui/AdvancedSettingsFragment.kt
@@ -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) {
@@ -132,5 +133,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()
+ }
}
}
\ No newline at end of file
diff --git a/app/src/main/res/layout/advanced_settings.xml b/app/src/main/res/layout/advanced_settings.xml
index e19cedb84..4d2ce438b 100644
--- a/app/src/main/res/layout/advanced_settings.xml
+++ b/app/src/main/res/layout/advanced_settings.xml
@@ -88,4 +88,16 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/shutdownButton"
app:layout_constraintTop_toTopOf="@id/shutdownButton" />
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 58a385dee..69004fb23 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -156,4 +156,7 @@
Append to message
Instantly send
Empty channel names use the default encryption key (any device on %s can read your messages).
+ Factory reset
+ Are you sure you want to factory reset?
+ This will clear all device configuration you have done.