feat: Disable logging in Protocol and ProtocolManager for improved performance and cleaner UI

This commit is contained in:
k1ngsterr1
2026-01-18 22:57:53 +05:00
parent 89d639a474
commit 6b839d2729
3 changed files with 7 additions and 145 deletions

View File

@@ -255,27 +255,19 @@ fun ChatsListScreen(
}
*/
// Enable UI logs when status dialog is shown
LaunchedEffect(showStatusDialog) {
ProtocolManager.enableUILogs(showStatusDialog)
}
// Status dialog with logs
// Status dialog
if (showStatusDialog) {
val clipboardManager = androidx.compose.ui.platform.LocalClipboardManager.current
val scrollState = rememberScrollState()
AlertDialog(
onDismissRequest = { showStatusDialog = false },
title = {
Text(
"Connection Status & Logs",
"Connection Status",
fontWeight = FontWeight.Bold,
color = textColor
)
},
text = {
Column(modifier = Modifier.fillMaxWidth().heightIn(max = 500.dp)) {
Column(modifier = Modifier.fillMaxWidth()) {
// Status indicator
Row(
verticalAlignment = Alignment.CenterVertically,
@@ -313,110 +305,6 @@ fun ChatsListScreen(
color = textColor
)
}
Divider(
color = if (isDarkTheme) Color(0xFF424242) else Color(0xFFE0E0E0),
modifier = Modifier.padding(vertical = 8.dp)
)
// Logs header with copy button
Row(
modifier = Modifier.fillMaxWidth().padding(bottom = 8.dp),
horizontalArrangement = Arrangement.SpaceBetween,
verticalAlignment = Alignment.CenterVertically
) {
Text(
"Debug Logs:",
fontSize = 14.sp,
fontWeight = FontWeight.Bold,
color = secondaryTextColor
)
TextButton(
onClick = {
val logsText = debugLogs.joinToString("\n")
clipboardManager.setText(
androidx.compose.ui.text.AnnotatedString(logsText)
)
android.widget.Toast.makeText(
context,
"Logs copied to clipboard!",
android.widget.Toast.LENGTH_SHORT
)
.show()
},
enabled = debugLogs.isNotEmpty()
) {
Text(
"Copy All",
fontSize = 12.sp,
color =
if (debugLogs.isNotEmpty()) PrimaryBlue
else Color.Gray
)
}
}
// Logs content
Box(
modifier =
Modifier.fillMaxWidth()
.weight(1f, fill = false)
.clip(RoundedCornerShape(8.dp))
.background(
if (isDarkTheme) Color(0xFF1A1A1A)
else Color(0xFFF5F5F5)
)
.padding(8.dp)
) {
if (debugLogs.isEmpty()) {
Text(
"No logs available.\nLogs are disabled by default for performance.\n\nEnable with:\nProtocolManager.enableUILogs(true)",
fontSize = 12.sp,
color = secondaryTextColor,
modifier = Modifier.padding(8.dp)
)
} else {
Column(
modifier =
Modifier.fillMaxWidth().verticalScroll(scrollState)
) {
debugLogs.forEach { log ->
Text(
log,
fontSize = 11.sp,
fontFamily = FontFamily.Monospace,
color = textColor,
modifier =
Modifier.fillMaxWidth()
.padding(vertical = 2.dp)
)
}
}
}
}
// Enable/Disable logs button
TextButton(
onClick = {
ProtocolManager.enableUILogs(!debugLogs.isNotEmpty())
android.widget.Toast.makeText(
context,
if (debugLogs.isEmpty()) "Logs enabled"
else "Logs disabled",
android.widget.Toast.LENGTH_SHORT
)
.show()
},
modifier = Modifier.fillMaxWidth().padding(top = 8.dp)
) {
Text(
if (debugLogs.isEmpty()) "⚠️ Enable Logs" else "Disable Logs",
fontSize = 12.sp,
color =
if (debugLogs.isEmpty()) Color(0xFFFFC107)
else Color.Gray
)
}
}
},
confirmButton = {