mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
refactor: recommended and required firmware updates (#2012)
This commit is contained in:
parent
868d705b2d
commit
38982bc37b
8 changed files with 57 additions and 7 deletions
|
|
@ -49,6 +49,7 @@ import androidx.compose.material3.TopAppBar
|
|||
import androidx.compose.material3.rememberTooltipState
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.collectAsState
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.livedata.observeAsState
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
|
|
@ -195,6 +196,8 @@ private fun VersionChecks(
|
|||
val connectionState by viewModel.connectionState.collectAsStateWithLifecycle()
|
||||
val myNodeInfo by viewModel.myNodeInfo.collectAsStateWithLifecycle()
|
||||
val context = LocalContext.current
|
||||
val latestStableFirmwareRelease by
|
||||
viewModel.latestStableFirmwareRelease.collectAsState(DeviceVersion("2.6.4"))
|
||||
// Check if the device is running an old app version or firmware version
|
||||
LaunchedEffect(connectionState, myNodeInfo) {
|
||||
if (connectionState == MeshService.ConnectionState.CONNECTED) {
|
||||
|
|
@ -211,18 +214,31 @@ private fun VersionChecks(
|
|||
MeshService.changeDeviceAddress(context, service, "n")
|
||||
}
|
||||
)
|
||||
} else if (curVer < MeshService.minDeviceVersion) {
|
||||
} else if (curVer < MeshService.absoluteMinDeviceVersion) {
|
||||
val title = context.getString(R.string.firmware_too_old)
|
||||
val message = context.getString(R.string.firmware_old)
|
||||
viewModel.showAlert(
|
||||
title = title,
|
||||
message = message,
|
||||
html = message,
|
||||
dismissable = false,
|
||||
onConfirm = {
|
||||
val service = viewModel.meshService ?: return@showAlert
|
||||
MeshService.changeDeviceAddress(context, service, "n")
|
||||
}
|
||||
)
|
||||
} else if (curVer < MeshService.minDeviceVersion) {
|
||||
val title = context.getString(R.string.should_update_firmware)
|
||||
val message =
|
||||
context.getString(
|
||||
R.string.should_update,
|
||||
latestStableFirmwareRelease.asString
|
||||
)
|
||||
viewModel.showAlert(
|
||||
title = title,
|
||||
message = message,
|
||||
dismissable = false,
|
||||
onConfirm = {}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ fun SimpleAlertDialog(
|
|||
style = SpanStyle(
|
||||
textDecoration = TextDecoration.Underline,
|
||||
fontStyle = FontStyle.Italic,
|
||||
color = MaterialTheme.colorScheme.tertiary
|
||||
color = MaterialTheme.colorScheme.primary
|
||||
)
|
||||
)
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue