Android: per-bookmark "Show whisper controls", off by default

Whispering can't be gated on permissions: our i_client_whisper_power is
never reported (and guests may not permget it), and whether a whisper gets
through depends on the target's needed whisper power, which clients can't
see. So the whisper menu and the Whisper / Add to whisper list actions are
shown only for servers connected from a bookmark that asks for them; an
edit of that bookmark applies without reconnecting.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-10 21:03:00 +00:00
co-authored by Claude Opus 5.5
parent d3731e297b
commit 173e710960
7 changed files with 55 additions and 16 deletions
@@ -126,8 +126,27 @@ class ServerController internal constructor(
refresh()
}
/** The bookmark this server was connected from, if any. */
@Volatile
private var bookmarkId: String? = null
@Volatile
private var whisperControls = false
internal fun applyBookmark(bookmark: Bookmark) {
bookmarkId = bookmark.id
whisperControls = bookmark.showWhisperControls
refresh()
}
/** Takes on an edit of the bookmark we connected from, without reconnecting. */
internal fun bookmarkEdited(bookmark: Bookmark) {
if (bookmark.id == bookmarkId) applyBookmark(bookmark)
}
/** A bookmark leading back to this server, joining [channelId]; not yet saved. */
fun bookmark(channelId: Int): Bookmark? = session.toBookmark(conn.model.channelPath(channelId))
?.also { it.showWhisperControls = whisperControls }
fun disconnect() {
left = true
@@ -469,6 +488,7 @@ class ServerController internal constructor(
self = session.selfState(),
whisper = session.whisper()?.label,
whisperNobody = session.isWhisperingToNobody,
whisperControls = whisperControls,
)
}
@@ -70,6 +70,8 @@ data class SessionState(
val whisper: String? = null,
/** Whether none of the whisper's channels and clients are on the server, so nobody hears it. */
val whisperNobody: Boolean = false,
/** Whether the menus offer whispering, as the bookmark connected with says. */
val whisperControls: Boolean = false,
)
/** A file to share in chat, open for reading. */
@@ -201,6 +203,7 @@ class SessionController(private val context: Context) {
fun connect(bookmark: Bookmark) {
start {
it.conn.setMyTeamSpeakFeatures(bookmark.myTeamSpeakFeatures)
it.applyBookmark(bookmark)
it.start(bookmark.address, bookmark.port, bookmark.nickname.orEmpty(), bookmark.password,
bookmark.identityId, bookmark.channel, bookmark.channelPassword)
}
@@ -340,6 +343,7 @@ class SessionController(private val context: Context) {
all[index] = edited
}
saveBookmarks()
_servers.value.forEach { it.bookmarkEdited(edited) }
}
/** The channels of a server we are on at [host]:[port], to pick one to join. */
@@ -43,7 +43,7 @@ val BookmarkEditSaver = listSaver<BookmarkEdit?, Any>(
val b = edit?.bookmark ?: return@listSaver emptyList()
listOf(edit.index, b.label.orEmpty(), b.address.orEmpty(), b.port, b.nickname.orEmpty(), b.password,
b.identityId, b.channel, b.channelPassword, b.connectOnStartup, b.iconId, b.id,
b.myTeamSpeakFeatures)
b.myTeamSpeakFeatures, b.showWhisperControls)
},
restore = { saved ->
if (saved.isEmpty()) null
@@ -56,6 +56,7 @@ val BookmarkEditSaver = listSaver<BookmarkEdit?, Any>(
iconId = saved[10] as Long
id = saved[11] as String
myTeamSpeakFeatures = saved[12] as Boolean
showWhisperControls = saved[13] as Boolean
})
},
)
@@ -76,6 +77,7 @@ fun BookmarkScreen(vm: SessionController, edit: BookmarkEdit, onDone: () -> Unit
var channelPassword by rememberSaveable { mutableStateOf(b.channelPassword.orEmpty()) }
var connectOnStartup by rememberSaveable { mutableStateOf(b.connectOnStartup) }
var myTeamSpeakFeatures by rememberSaveable { mutableStateOf(b.myTeamSpeakFeatures) }
var showWhisperControls by rememberSaveable { mutableStateOf(b.showWhisperControls) }
val save = {
val (host, port) = SessionController.parseAddress(address)
@@ -90,6 +92,7 @@ fun BookmarkScreen(vm: SessionController, edit: BookmarkEdit, onDone: () -> Unit
it.channelPassword = channelPassword
it.connectOnStartup = connectOnStartup
it.myTeamSpeakFeatures = myTeamSpeakFeatures
it.showWhisperControls = showWhisperControls
})
onDone()
}
@@ -129,6 +132,11 @@ fun BookmarkScreen(vm: SessionController, edit: BookmarkEdit, onDone: () -> Unit
Text("Enable myTeamSpeak features", Modifier.weight(1f))
Switch(myTeamSpeakFeatures, { myTeamSpeakFeatures = it })
}
Row(Modifier.fillMaxWidth().clickable { showWhisperControls = !showWhisperControls },
verticalAlignment = Alignment.CenterVertically) {
Text("Show whisper controls", Modifier.weight(1f))
Switch(showWhisperControls, { showWhisperControls = it })
}
}
}
}
@@ -284,7 +284,7 @@ fun ServerScreen(
expandedHeight = 48.dp,
actions = {
state.hostButton?.let { HostButtonAction(it) { url -> runCatching { uriHandler.openUri(url) } } }
if (state.connected) WhisperMenu(vm, server, state) { whisperLists = true }
if (state.connected && state.whisperControls) WhisperMenu(vm, server, state) { whisperLists = true }
IconButton(onClick = find::show) { PackIcon("FIND", "Find") }
IconButton(onClick = onSettings) { PackIcon("SETTINGS", "Settings") }
},
@@ -398,11 +398,11 @@ fun ServerScreen(
onAddContact = { server.addContact(id, it) },
onEditContact = { clientSheet = null; onEditContact(client.uniqueId) },
onConnectionInfo = { clientSheet = null; connectionInfo = id },
onWhisper = { clientSheet = null; server.whisperToClient(id) },
onAddToWhisperList = {
onWhisper = if (state.whisperControls) ({ clientSheet = null; server.whisperToClient(id) }) else null,
onAddToWhisperList = if (state.whisperControls) ({
clientSheet = null
server.clientRef(id)?.let { ref -> toWhisperList = client.name to { it.clients.add(ref) } }
},
}) else null,
onMove = if (server.canMoveClients) ({ clientSheet = null; moving = id }) else null,
onMoveToOwnChannel = if (server.canMoveClients && tree.channel(state.channelId)?.clients?.none { it.id == id } == true) {
{ server.moveClient(id, state.channelId); clientSheet = null }
@@ -429,11 +429,11 @@ fun ServerScreen(
onJoin = { join(channel); channelSheet = null },
onSubscribe = { server.setSubscribed(id, it); channelSheet = null },
onBookmark = { channelSheet = null; bookmarkHere(id) },
onWhisper = { channelSheet = null; server.whisperToChannel(id) },
onAddToWhisperList = {
onWhisper = if (state.whisperControls) ({ channelSheet = null; server.whisperToChannel(id) }) else null,
onAddToWhisperList = if (state.whisperControls) ({
channelSheet = null
server.channelRef(id)?.let { ref -> toWhisperList = channel.name to { it.channels.add(ref) } }
},
}) else null,
onFiles = if (server.canBrowseFiles) ({
channelSheet = null
if (channel.locked) filesLocked = id else files = FilesOf(id, channel.name, "")
@@ -54,8 +54,9 @@ fun ClientSheet(
onAddContact: (ContactType) -> Unit,
onEditContact: () -> Unit,
onConnectionInfo: () -> Unit,
onWhisper: () -> Unit,
onAddToWhisperList: () -> Unit,
/** Both null when whisper controls are hidden. */
onWhisper: (() -> Unit)?,
onAddToWhisperList: (() -> Unit)?,
/** Null when the client cannot be moved. */
onMove: (() -> Unit)?,
/** Null when the client cannot be moved, or is in our channel already. */
@@ -97,8 +98,8 @@ fun ClientSheet(
} else {
Action("PLAYER_CHAT", "Send message", onClick = onMessage)
Action("POKE", "Poke") { poking = true }
Action("PLAYER_WHISPER", "Whisper", onClick = onWhisper)
Action("ON_WHISPERLIST", "Add to whisper list…", onClick = onAddToWhisperList)
onWhisper?.let { Action("PLAYER_WHISPER", "Whisper", onClick = it) }
onAddToWhisperList?.let { Action("ON_WHISPERLIST", "Add to whisper list…", onClick = it) }
onMove?.let { Action("CHANNEL_SWITCH", "Move to channel…", onClick = it) }
onMoveToOwnChannel?.let { Action("MOVE_CLIENT_TO_OWN_CHANNEL", "Move to own channel", onClick = it) }
moderation()
@@ -145,8 +146,9 @@ fun ChannelSheet(
onJoin: () -> Unit,
onSubscribe: (Boolean) -> Unit,
onBookmark: () -> Unit,
onWhisper: () -> Unit,
onAddToWhisperList: () -> Unit,
/** Both null when whisper controls are hidden. */
onWhisper: (() -> Unit)?,
onAddToWhisperList: (() -> Unit)?,
/** Each null when we may not. */
onFiles: (() -> Unit)?,
onCreateSub: (() -> Unit)?,
@@ -166,8 +168,8 @@ fun ChannelSheet(
} else {
Action("SUBSCRIBE_TO_CHANNEL", "Subscribe") { onSubscribe(true) }
}
Action("WHISPER", "Whisper", onClick = onWhisper)
Action("ON_WHISPERLIST", "Add to whisper list…", onClick = onAddToWhisperList)
onWhisper?.let { Action("WHISPER", "Whisper", onClick = it) }
onAddToWhisperList?.let { Action("ON_WHISPERLIST", "Add to whisper list…", onClick = it) }
onFiles?.let { Action("FILETRANSFER", "Browse files", onClick = it) }
Action("BOOKMARK_ADD", "Add to bookmarks", onClick = onBookmark)
onCreateSub?.let { Action("CHANNEL_CREATE_SUB", "Create sub-channel", onClick = it) }