add decoded payload to debug panel (#2472)

This commit is contained in:
DaneEvans 2025-07-21 23:15:21 +10:00 committed by GitHub
parent 9339958398
commit 085ccf566f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 130 additions and 10 deletions

View file

@ -237,6 +237,14 @@ internal fun DebugItem(
color = colorScheme.onSurface
)
)
// Show decoded payload if available
if (!log.decodedPayload.isNullOrBlank()) {
DecodedPayloadBlock(
decodedPayload = log.decodedPayload,
isSelected = isSelected,
colorScheme = colorScheme
)
}
}
}
}
@ -780,3 +788,42 @@ private suspend fun exportAllLogs(context: Context, logs: List<UiMeshLog>) = wit
warn("Error:IOException: " + e.toString())
}
}
@Composable
private fun DecodedPayloadBlock(
decodedPayload: String,
isSelected: Boolean,
colorScheme: ColorScheme
) {
val commonTextStyle = TextStyle(
fontSize = if (isSelected) 10.sp else 8.sp,
fontWeight = FontWeight.Bold,
color = colorScheme.primary
)
Text(
text = stringResource(id = R.string.debug_decoded_payload),
style = commonTextStyle,
modifier = Modifier.padding(top = 8.dp, bottom = 4.dp)
)
Text(
text = "{",
style = commonTextStyle,
modifier = Modifier.padding(start = 8.dp, bottom = 2.dp)
)
Text(
text = decodedPayload,
softWrap = true,
style = TextStyle(
fontSize = if (isSelected) 10.sp else 8.sp,
fontFamily = FontFamily.Monospace,
color = colorScheme.onSurface.copy(alpha = 0.8f)
),
modifier = Modifier.padding(start = 16.dp, bottom = 0.dp)
)
Text(
text = "}",
style = commonTextStyle,
modifier = Modifier.padding(start = 8.dp, bottom = 4.dp)
)
}