Compact Android Bluetooth devices into two-line rows

This commit is contained in:
evgeny committed 2026-10-30 12:07:30 +01:00
1 parent 22d8d872c4
commit e6c35bc858
3 files changed
+28 -6

No files matched your search

@@ -11,10 +11,14 @@ import androidx.compose.foundation.text.selection.SelectionContainer
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.*
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalLifecycleOwner
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.lifecycle.Lifecycle
import com.utun.chat.ChatApplication
import com.utun.chat.R
@@ -124,12 +128,28 @@ fun BluetoothSettingsTab() {
Text(stringResource(R.string.ble_devices), style = MaterialTheme.typography.titleMedium)
if (peersFailed) Text(stringResource(R.string.ble_devices_failed), color = MaterialTheme.colorScheme.error)
else if (peers.isEmpty()) Text(stringResource(R.string.ble_devices_empty), style = MaterialTheme.typography.bodySmall)
peers.forEach { peer ->
key(peer.id) {
Column(verticalArrangement = Arrangement.spacedBy(4.dp)) {
Text(peer.name.ifEmpty { peer.id }, style = MaterialTheme.typography.bodyLarge)
SelectionContainer { Text(peer.address, style = MaterialTheme.typography.bodyMedium) }
Text("${peer.id} · ${if (peer.rssi == 127) "?" else peer.rssi} dBm", style = MaterialTheme.typography.bodySmall)
Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
peers.forEach { peer ->
key(peer.id) {
Row(Modifier.fillMaxWidth().padding(vertical = 3.dp),
horizontalArrangement = Arrangement.spacedBy(10.dp), verticalAlignment = Alignment.CenterVertically) {
Text(peer.name.ifEmpty { peer.id }, Modifier.weight(1f), style = MaterialTheme.typography.bodyMedium,
lineHeight = 16.sp, maxLines = 2, overflow = TextOverflow.Ellipsis)
SelectionContainer {
Column {
Text(peer.id, color = MaterialTheme.colorScheme.primary, fontFamily = FontFamily.Monospace,
style = MaterialTheme.typography.bodySmall, lineHeight = 16.sp, maxLines = 1, softWrap = false)
Text(peer.address, color = MaterialTheme.colorScheme.tertiary, fontFamily = FontFamily.Monospace,
style = MaterialTheme.typography.bodySmall, lineHeight = 16.sp, maxLines = 1, softWrap = false)
}
}
Column(Modifier.widthIn(min = 64.dp), horizontalAlignment = Alignment.End) {
Text("${if (peer.rssi == 127) "—" else peer.rssi} dBm", color = MaterialTheme.colorScheme.secondary,
style = MaterialTheme.typography.bodySmall, lineHeight = 16.sp, maxLines = 1, softWrap = false)
Text(stringResource(R.string.ble_lqi_unavailable), color = MaterialTheme.colorScheme.onSurfaceVariant,
style = MaterialTheme.typography.bodySmall, lineHeight = 16.sp, maxLines = 1, softWrap = false)
}
}
}
}
}
@@ -635,4 +635,5 @@
<string name="ble_devices">Устройства VibeChat поблизости</string>
<string name="ble_devices_empty">Поблизости пока не найдены устройства</string>
<string name="ble_devices_failed">Не удалось обновить список устройств</string>
<string name="ble_lqi_unavailable">LQI —</string>
</resources>
@@ -634,4 +634,5 @@
<string name="ble_devices">Nearby VibeChat devices</string>
<string name="ble_devices_empty">No nearby devices found yet</string>
<string name="ble_devices_failed">Could not refresh the device list</string>
<string name="ble_lqi_unavailable">LQI —</string>
</resources>