From f78e4fcd66ddbb2e22e8787233c90691e3881a4e Mon Sep 17 00:00:00 2001 From: ericek111 Date: Sat, 10 Oct 2026 16:33:54 +0000 Subject: [PATCH] Android: tidier client group dialogs The group dialogs list a group we may not assign only when the client is in it, and the rows drop the 48dp minimum touch target for a 6dp padding. The Server groups and Channel group actions share one row. Co-Authored-By: Claude Opus 5.5 --- .../ts3j/client/android/ui/Moderation.kt | 60 +++++++++++-------- 1 file changed, 35 insertions(+), 25 deletions(-) diff --git a/android/app/src/main/java/eu/lixko/ts3j/client/android/ui/Moderation.kt b/android/app/src/main/java/eu/lixko/ts3j/client/android/ui/Moderation.kt index d732ec9..9180a0a 100644 --- a/android/app/src/main/java/eu/lixko/ts3j/client/android/ui/Moderation.kt +++ b/android/app/src/main/java/eu/lixko/ts3j/client/android/ui/Moderation.kt @@ -15,12 +15,14 @@ import androidx.compose.material3.AlertDialog import androidx.compose.material3.Checkbox import androidx.compose.material3.DropdownMenu import androidx.compose.material3.DropdownMenuItem +import androidx.compose.material3.LocalMinimumInteractiveComponentSize import androidx.compose.material3.OutlinedButton import androidx.compose.material3.OutlinedTextField import androidx.compose.material3.RadioButton import androidx.compose.material3.Text import androidx.compose.material3.TextButton import androidx.compose.runtime.Composable +import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember @@ -30,6 +32,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.draw.alpha import androidx.compose.ui.text.input.KeyboardType import androidx.compose.ui.text.style.TextAlign +import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import eu.lixko.ts3j.client.android.ClientItem import eu.lixko.ts3j.client.android.ServerController @@ -132,7 +135,8 @@ internal fun BanDurationField(state: BanDurationState, maxSeconds: Long, modifie /** * A client's groups to tick: several server groups, or with [single] the one channel group. - * Groups we have no power over show greyed out; a change shows once the server made it. + * Groups we may not assign are listed only when the client is in them, greyed out; a change shows once the server + * made it. */ @Composable fun GroupsDialog( @@ -146,28 +150,30 @@ fun GroupsDialog( onDismissRequest = onDismiss, title = { Text(title) }, text = { - LazyColumn { - items(choices, key = { it.group().id }) { choice -> - val group = choice.group() - // A client always has one channel group: picking another is the only change. - val changeable = choice.allowed() && !(single && choice.assigned()) - val toggle = { if (changeable) onChange(group.id, !choice.assigned()) } - Row( - Modifier.fillMaxWidth() - .clickable(enabled = changeable, onClick = toggle) - .alpha(if (choice.allowed()) 1f else 0.38f) - .padding(vertical = 2.dp), - verticalAlignment = Alignment.CenterVertically, - ) { - if (single) { - RadioButton(choice.assigned(), onClick = toggle, enabled = choice.allowed()) - } else { - Checkbox(choice.assigned(), onCheckedChange = { toggle() }, enabled = choice.allowed()) + CompositionLocalProvider(LocalMinimumInteractiveComponentSize provides Dp.Unspecified) { + LazyColumn { + items(choices.filter { it.allowed() || it.assigned() }, key = { it.group().id }) { choice -> + val group = choice.group() + // A client always has one channel group: picking another is the only change. + val changeable = choice.allowed() && !(single && choice.assigned()) + val toggle = { if (changeable) onChange(group.id, !choice.assigned()) } + Row( + Modifier.fillMaxWidth() + .clickable(enabled = changeable, onClick = toggle) + .alpha(if (choice.allowed()) 1f else 0.38f) + .padding(vertical = 6.dp), + verticalAlignment = Alignment.CenterVertically, + ) { + if (single) { + RadioButton(choice.assigned(), onClick = toggle, enabled = choice.allowed()) + } else { + Checkbox(choice.assigned(), onCheckedChange = { toggle() }, enabled = choice.allowed()) + } + Box(Modifier.width(24.dp), contentAlignment = Alignment.Center) { + if (group.iconId != 0L) ServerIcon(group.iconId) + } + Text(group.name, Modifier.padding(start = 8.dp)) } - Box(Modifier.width(24.dp), contentAlignment = Alignment.Center) { - if (group.iconId != 0L) ServerIcon(group.iconId) - } - Text(group.name, Modifier.padding(start = 8.dp)) } } } @@ -190,9 +196,13 @@ fun ClientModeration(server: ServerController, client: ClientItem, onDone: () -> if (server.canKickFromServer) Action("KICK_FROM_SERVER", "Kick from server") { kick = true } if (server.canBanClients) Action("BAN_CLIENT", "Ban") { banning = true } } - if (serverGroups.any { it.allowed() }) Action("PERMISSIONS_SERVER_GROUPS", "Server groups") { groups = true } - if (channelGroups.any { it.allowed() && !it.assigned() }) { - Action("PERMISSIONS_CHANNEL_GROUPS", "Channel group") { groups = false } + val showServerGroups = serverGroups.any { it.allowed() } + val showChannelGroups = channelGroups.any { it.allowed() && !it.assigned() } + if (showServerGroups || showChannelGroups) { + Row { + if (showServerGroups) Action("PERMISSIONS_SERVER_GROUPS", "Server groups", Modifier.weight(1f)) { groups = true } + if (showChannelGroups) Action("PERMISSIONS_CHANNEL_GROUPS", "Channel group", Modifier.weight(1f)) { groups = false } + } } kick?.let { fromServer ->