Compare commits
1
Commits
d0fcb45a55
...
2581c79f49
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2581c79f49 |
@@ -33,6 +33,7 @@ import androidx.compose.material.icons.filled.Map
|
||||
import androidx.compose.material.icons.filled.NotificationsActive
|
||||
import androidx.compose.material.icons.filled.VerticalAlignBottom
|
||||
import androidx.compose.material.icons.filled.Warning
|
||||
import androidx.compose.material3.AlertDialog
|
||||
import androidx.compose.material3.Badge
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.ButtonDefaults
|
||||
@@ -46,6 +47,7 @@ import androidx.compose.material3.IconButtonDefaults
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TextButton
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.collectAsState
|
||||
@@ -165,6 +167,32 @@ fun MqttTopicViewerScreen(
|
||||
val isConnected = effectiveState == MqttConnectionState.CONNECTED
|
||||
val isConnecting = effectiveState == MqttConnectionState.CONNECTING
|
||||
|
||||
// Disconnecting drops live V2X data and any running log until the OBU is connected again, and
|
||||
// the icon sits next to the map button, so a stray tap must not do it. Connecting needs no
|
||||
// confirmation: it cannot lose anything.
|
||||
var confirmDisconnect by rememberSaveable { mutableStateOf(false) }
|
||||
if (confirmDisconnect) {
|
||||
AlertDialog(
|
||||
onDismissRequest = { confirmDisconnect = false },
|
||||
title = { Text(stringResource(R.string.mqtt_disconnect_confirm_title)) },
|
||||
text = { Text(stringResource(R.string.mqtt_disconnect_confirm_text)) },
|
||||
confirmButton = {
|
||||
TextButton(onClick = {
|
||||
confirmDisconnect = false
|
||||
// Route to whichever transport this hardware actually uses.
|
||||
if (isEsp32) viewModel.disconnectEsp32() else viewModel.disconnect()
|
||||
}) {
|
||||
Text(stringResource(R.string.mqtt_disconnect), color = MaterialTheme.colorScheme.error)
|
||||
}
|
||||
},
|
||||
dismissButton = {
|
||||
TextButton(onClick = { confirmDisconnect = false }) {
|
||||
Text(stringResource(R.string.log_cancel))
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
Column(modifier = Modifier.fillMaxSize()) {
|
||||
|
||||
// ── Inline header — replaces the removed inner TopAppBar ──────────────
|
||||
@@ -214,13 +242,9 @@ fun MqttTopicViewerScreen(
|
||||
Spacer(Modifier.width(2.dp))
|
||||
IconButton(
|
||||
onClick = {
|
||||
// Route to whichever transport this hardware actually uses.
|
||||
if (isEsp32) {
|
||||
if (isConnected || isConnecting) viewModel.disconnectEsp32()
|
||||
else viewModel.connectEsp32()
|
||||
} else {
|
||||
if (isConnected || isConnecting) viewModel.disconnect() else viewModel.connect()
|
||||
}
|
||||
if (isConnected || isConnecting) confirmDisconnect = true
|
||||
else if (isEsp32) viewModel.connectEsp32()
|
||||
else viewModel.connect()
|
||||
},
|
||||
colors = IconButtonDefaults.iconButtonColors(
|
||||
contentColor = if (isConnected) ErrorRed else ConnectedGreen,
|
||||
|
||||
@@ -356,4 +356,6 @@
|
||||
<string name="v2xlog_share_chooser">V2X-Log teilen</string>
|
||||
<string name="v2xlog_delete_title">Log löschen?</string>
|
||||
<string name="v2xlog_delete_text">%1$s wird dauerhaft vom Gerät entfernt.</string>
|
||||
<string name="mqtt_disconnect_confirm_title">OBU trennen?</string>
|
||||
<string name="mqtt_disconnect_confirm_text">Die V2X-Livedaten stoppen, und ein laufendes V2X-Log erhält nichts, bis du wieder verbindest.</string>
|
||||
</resources>
|
||||
|
||||
@@ -363,4 +363,6 @@
|
||||
<string name="v2xlog_share_chooser">Share V2X log</string>
|
||||
<string name="v2xlog_delete_title">Delete log?</string>
|
||||
<string name="v2xlog_delete_text">This permanently removes %1$s from the device.</string>
|
||||
<string name="mqtt_disconnect_confirm_title">Disconnect the OBU?</string>
|
||||
<string name="mqtt_disconnect_confirm_text">Live V2X data stops, and a running V2X log gets nothing, until you connect again.</string>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user