|
|
|
|
@ -60,14 +60,7 @@ import kotlinx.coroutines.withContext
|
|
|
|
|
import java.util.UUID |
|
|
|
|
import java.io.IOException |
|
|
|
|
|
|
|
|
|
private val LEVELS = listOf("NONE", "ERROR", "WARN", "INFO", "DEBUG", "TRACE") |
|
|
|
|
private val CATEGORIES = listOf( |
|
|
|
|
"sys", "connection", "etcp", "crypto", |
|
|
|
|
"config", "tun", "routing", "timers", "bgp", "chat", |
|
|
|
|
"socket", "control", "dump", "traffic", "debug", "general", |
|
|
|
|
"nat", "keepalive", "media", "etcp_route", "etcp_dump", |
|
|
|
|
"chat_sync", "member_sync", "proxy", "radio", "vad" |
|
|
|
|
) |
|
|
|
|
private val LEVELS = listOf("DISABLED", "NONE", "ERROR", "WARN", "INFO", "DEBUG", "TRACE") |
|
|
|
|
private val PROTOCOLS = listOf("tcp", "udp") |
|
|
|
|
|
|
|
|
|
@OptIn(ExperimentalMaterial3Api::class) |
|
|
|
|
@ -173,6 +166,7 @@ private fun DeveloperSettingsTab(vm: ChatViewModel, onDirty: (Boolean) -> Unit,
|
|
|
|
|
var showClearDb by remember { mutableStateOf(false) } |
|
|
|
|
var clearingDb by remember { mutableStateOf(false) } |
|
|
|
|
var catLevels by remember { mutableStateOf<Map<String, String>>(emptyMap()) } |
|
|
|
|
val debugCategories = remember { NativeLib.getDebugCategories() } |
|
|
|
|
var servers by remember { mutableStateOf<List<ServerEntry>>(emptyList()) } |
|
|
|
|
var availableIfaces by remember { mutableStateOf<List<Pair<String, String>>>(emptyList()) } |
|
|
|
|
var connectionMode by remember { mutableStateOf("manual") } |
|
|
|
|
@ -219,11 +213,10 @@ private fun DeveloperSettingsTab(vm: ChatViewModel, onDirty: (Boolean) -> Unit,
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
val setDebug = { level: String -> |
|
|
|
|
onDirty(true); NativeLib.setDebugLevel("", level) |
|
|
|
|
NativeLib.setDebugLevel("", level) |
|
|
|
|
scope.launch { provider.setValue("debug.console_level", level) }; debugLevel = level |
|
|
|
|
} |
|
|
|
|
val setCatLevel = { cat: String, lvl: String -> |
|
|
|
|
onDirty(true) |
|
|
|
|
val updated = catLevels.toMutableMap() |
|
|
|
|
if (lvl == "") updated.remove(cat) else updated[cat] = lvl |
|
|
|
|
catLevels = updated |
|
|
|
|
@ -474,7 +467,7 @@ private fun DeveloperSettingsTab(vm: ChatViewModel, onDirty: (Boolean) -> Unit,
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (showDebugCategories) { |
|
|
|
|
items(CATEGORIES, key = { "debug-$it" }) { cat -> |
|
|
|
|
items(debugCategories, key = { "debug-$it" }) { cat -> |
|
|
|
|
val current = catLevels[cat] ?: "" |
|
|
|
|
DebugLevelDropdown(label = cat, current = current.ifEmpty { stringResource(R.string.global_level_hint) }, |
|
|
|
|
onSelect = { setCatLevel(cat, if (it == "NONE") "" else it) }, compact = true) |
|
|
|
|
@ -1141,10 +1134,10 @@ private fun DebugLevelDropdown(label: String, current: String, onSelect: (String
|
|
|
|
|
if (compact) { |
|
|
|
|
Row(verticalAlignment = Alignment.CenterVertically) { |
|
|
|
|
Text(label, modifier = Modifier.width(120.dp), style = MaterialTheme.typography.labelMedium) |
|
|
|
|
ExposedDropdownMenuBox(expanded = expanded, onExpandedChange = { expanded = it }) { |
|
|
|
|
ExposedDropdownMenuBox(expanded = expanded, onExpandedChange = { expanded = it }, modifier = Modifier.weight(1f)) { |
|
|
|
|
OutlinedTextField(current, {}, readOnly = true, |
|
|
|
|
trailingIcon = { ExposedDropdownMenuDefaults.TrailingIcon(expanded) }, |
|
|
|
|
modifier = Modifier.menuAnchor().height(48.dp).weight(1f), singleLine = true) |
|
|
|
|
modifier = Modifier.menuAnchor().fillMaxWidth().heightIn(min = 56.dp), singleLine = true) |
|
|
|
|
ExposedDropdownMenu(expanded, onDismissRequest = { expanded = false }) { |
|
|
|
|
LEVELS.forEach { lvl -> |
|
|
|
|
DropdownMenuItem(text = { Text(lvl) }, onClick = { onSelect(lvl); expanded = false }) |
|
|
|
|
@ -1153,10 +1146,10 @@ private fun DebugLevelDropdown(label: String, current: String, onSelect: (String
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
ExposedDropdownMenuBox(expanded = expanded, onExpandedChange = { expanded = it }) { |
|
|
|
|
ExposedDropdownMenuBox(expanded = expanded, onExpandedChange = { expanded = it }, modifier = Modifier.fillMaxWidth()) { |
|
|
|
|
OutlinedTextField(current, {}, readOnly = true, label = { Text(stringResource(R.string.debug_level_label, label)) }, |
|
|
|
|
trailingIcon = { ExposedDropdownMenuDefaults.TrailingIcon(expanded) }, |
|
|
|
|
modifier = Modifier.menuAnchor(), singleLine = true) |
|
|
|
|
modifier = Modifier.menuAnchor().fillMaxWidth().heightIn(min = 56.dp), singleLine = true) |
|
|
|
|
ExposedDropdownMenu(expanded, onDismissRequest = { expanded = false }) { |
|
|
|
|
LEVELS.forEach { lvl -> |
|
|
|
|
DropdownMenuItem(text = { Text(lvl) }, onClick = { onSelect(lvl); expanded = false }) |
|
|
|
|
|