mirror of
https://github.com/permissionlesstech/bitchat-android.git
synced 2026-07-25 05:25:20 +00:00
fix some debug settings (#383)
This commit is contained in:
@@ -277,7 +277,6 @@ class BluetoothConnectionTracker(
|
|||||||
fun cleanupDeviceConnection(deviceAddress: String) {
|
fun cleanupDeviceConnection(deviceAddress: String) {
|
||||||
connectedDevices.remove(deviceAddress)?.let { deviceConn ->
|
connectedDevices.remove(deviceAddress)?.let { deviceConn ->
|
||||||
subscribedDevices.removeAll { it.address == deviceAddress }
|
subscribedDevices.removeAll { it.address == deviceAddress }
|
||||||
addressPeerMap.remove(deviceAddress)
|
|
||||||
}
|
}
|
||||||
pendingConnections.remove(deviceAddress)
|
pendingConnections.remove(deviceAddress)
|
||||||
Log.d(TAG, "Cleaned up device connection for $deviceAddress")
|
Log.d(TAG, "Cleaned up device connection for $deviceAddress")
|
||||||
|
|||||||
@@ -172,6 +172,8 @@ fun DebugSettingsSheet(
|
|||||||
steps = 30
|
steps = 30
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
val overallCount = connectedDevices.size
|
||||||
|
Text("connections: $overallCount / $maxOverall", fontFamily = FontFamily.Monospace, fontSize = 11.sp, color = colorScheme.onSurface.copy(alpha = 0.7f))
|
||||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||||
Text("max overall", fontFamily = FontFamily.Monospace, modifier = Modifier.width(90.dp))
|
Text("max overall", fontFamily = FontFamily.Monospace, modifier = Modifier.width(90.dp))
|
||||||
Slider(
|
Slider(
|
||||||
@@ -217,24 +219,28 @@ fun DebugSettingsSheet(
|
|||||||
}
|
}
|
||||||
val maxValRaw = series.maxOrNull() ?: 0f
|
val maxValRaw = series.maxOrNull() ?: 0f
|
||||||
val maxVal = if (maxValRaw > 0f) maxValRaw else 0f
|
val maxVal = if (maxValRaw > 0f) maxValRaw else 0f
|
||||||
Box(Modifier.fillMaxWidth().height(48.dp)) {
|
val leftGutter = 40.dp
|
||||||
|
Box(Modifier.fillMaxWidth().height(56.dp)) {
|
||||||
|
// Graph canvas
|
||||||
androidx.compose.foundation.Canvas(Modifier.fillMaxSize()) {
|
androidx.compose.foundation.Canvas(Modifier.fillMaxSize()) {
|
||||||
val axisPx = 28.dp.toPx() // leave room on left for ticks
|
val axisPx = leftGutter.toPx() // reserved left gutter for labels
|
||||||
val barCount = series.size
|
val barCount = series.size
|
||||||
val availW = (size.width - axisPx).coerceAtLeast(1f)
|
val availW = (size.width - axisPx).coerceAtLeast(1f)
|
||||||
val w = availW / barCount
|
val w = availW / barCount
|
||||||
val h = size.height
|
val h = size.height
|
||||||
// draw baseline at y=0 (bottom)
|
// Baseline at bottom (y = 0)
|
||||||
drawLine(
|
drawLine(
|
||||||
color = Color(0x33888888),
|
color = Color(0x33888888),
|
||||||
start = androidx.compose.ui.geometry.Offset(axisPx, h - 1f),
|
start = androidx.compose.ui.geometry.Offset(axisPx, h - 1f),
|
||||||
end = androidx.compose.ui.geometry.Offset(size.width, h - 1f),
|
end = androidx.compose.ui.geometry.Offset(size.width, h - 1f),
|
||||||
strokeWidth = 1f
|
strokeWidth = 1f
|
||||||
)
|
)
|
||||||
|
// Bars from bottom-up; skip zeros entirely
|
||||||
series.forEachIndexed { i, value ->
|
series.forEachIndexed { i, value ->
|
||||||
val ratio = if (maxVal > 0f) (value / maxVal).coerceIn(0f, 1f) else 0f // min always 0
|
if (value > 0f && maxVal > 0f) {
|
||||||
val barHeight = h * ratio
|
val ratio = (value / maxVal).coerceIn(0f, 1f)
|
||||||
// Draw bars from bottom up, starting after left axis area
|
val barHeight = (h * ratio).coerceAtLeast(0f)
|
||||||
|
if (barHeight > 0.5f) {
|
||||||
drawRect(
|
drawRect(
|
||||||
color = Color(0xFF00C851),
|
color = Color(0xFF00C851),
|
||||||
topLeft = androidx.compose.ui.geometry.Offset(x = axisPx + i * w, y = h - barHeight),
|
topLeft = androidx.compose.ui.geometry.Offset(x = axisPx + i * w, y = h - barHeight),
|
||||||
@@ -242,11 +248,37 @@ fun DebugSettingsSheet(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Y-axis ticks (min/max) in the left margin
|
}
|
||||||
Text("0", fontFamily = FontFamily.Monospace, fontSize = 10.sp, color = colorScheme.onSurface.copy(alpha = 0.7f), modifier = Modifier.align(Alignment.BottomStart).padding(start = 4.dp, bottom = 2.dp))
|
}
|
||||||
Text("${maxVal.toInt()}", fontFamily = FontFamily.Monospace, fontSize = 10.sp, color = colorScheme.onSurface.copy(alpha = 0.7f), modifier = Modifier.align(Alignment.TopStart).padding(start = 4.dp, top = 2.dp))
|
// Left gutter layout: unit + ticks neatly aligned
|
||||||
// Y-axis unit label (vertical)
|
Row(Modifier.fillMaxSize()) {
|
||||||
Text("p/s", fontFamily = FontFamily.Monospace, fontSize = 9.sp, color = colorScheme.onSurface.copy(alpha = 0.7f), modifier = Modifier.align(Alignment.CenterStart).padding(start = 2.dp).rotate(-90f))
|
Box(Modifier.width(leftGutter).fillMaxHeight()) {
|
||||||
|
// Unit label on the far left, centered vertically
|
||||||
|
Text(
|
||||||
|
"p/s",
|
||||||
|
fontFamily = FontFamily.Monospace,
|
||||||
|
fontSize = 10.sp,
|
||||||
|
color = colorScheme.onSurface.copy(alpha = 0.7f),
|
||||||
|
modifier = Modifier.align(Alignment.CenterStart).padding(start = 2.dp).rotate(-90f)
|
||||||
|
)
|
||||||
|
// Tick labels right-aligned in gutter, top and bottom aligned
|
||||||
|
Text(
|
||||||
|
"${maxVal.toInt()}",
|
||||||
|
fontFamily = FontFamily.Monospace,
|
||||||
|
fontSize = 10.sp,
|
||||||
|
color = colorScheme.onSurface.copy(alpha = 0.7f),
|
||||||
|
modifier = Modifier.align(Alignment.TopEnd).padding(end = 4.dp, top = 0.dp)
|
||||||
|
)
|
||||||
|
Text(
|
||||||
|
"0",
|
||||||
|
fontFamily = FontFamily.Monospace,
|
||||||
|
fontSize = 10.sp,
|
||||||
|
color = colorScheme.onSurface.copy(alpha = 0.7f),
|
||||||
|
modifier = Modifier.align(Alignment.BottomEnd).padding(end = 4.dp, bottom = 0.dp)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
Spacer(Modifier.weight(1f))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user