mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-26 08:51:23 -04:00
Add factory reset button
This commit is contained in:
@@ -349,6 +349,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.
|
||||
*/
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -88,4 +88,16 @@
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/shutdownButton"
|
||||
app:layout_constraintTop_toTopOf="@id/shutdownButton" />
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/factoryResetButton"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:text="@string/factory_reset"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/shutdownButton" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -155,4 +155,7 @@
|
||||
<string name="message">Message</string>
|
||||
<string name="mode_append">Append to message</string>
|
||||
<string name="mode_instant">Instantly send</string>
|
||||
<string name="factory_reset">Factory reset</string>
|
||||
<string name="are_you_sure_factory_reset">Are you sure you want to factory reset?</string>
|
||||
<string name="factory_reset_description">This will clear all device configuration you have done.</string>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user