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:
@@ -126,8 +126,27 @@ class ServerController internal constructor(
|
|||||||
refresh()
|
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. */
|
/** A bookmark leading back to this server, joining [channelId]; not yet saved. */
|
||||||
fun bookmark(channelId: Int): Bookmark? = session.toBookmark(conn.model.channelPath(channelId))
|
fun bookmark(channelId: Int): Bookmark? = session.toBookmark(conn.model.channelPath(channelId))
|
||||||
|
?.also { it.showWhisperControls = whisperControls }
|
||||||
|
|
||||||
fun disconnect() {
|
fun disconnect() {
|
||||||
left = true
|
left = true
|
||||||
@@ -469,6 +488,7 @@ class ServerController internal constructor(
|
|||||||
self = session.selfState(),
|
self = session.selfState(),
|
||||||
whisper = session.whisper()?.label,
|
whisper = session.whisper()?.label,
|
||||||
whisperNobody = session.isWhisperingToNobody,
|
whisperNobody = session.isWhisperingToNobody,
|
||||||
|
whisperControls = whisperControls,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -70,6 +70,8 @@ data class SessionState(
|
|||||||
val whisper: String? = null,
|
val whisper: String? = null,
|
||||||
/** Whether none of the whisper's channels and clients are on the server, so nobody hears it. */
|
/** Whether none of the whisper's channels and clients are on the server, so nobody hears it. */
|
||||||
val whisperNobody: Boolean = false,
|
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. */
|
/** A file to share in chat, open for reading. */
|
||||||
@@ -201,6 +203,7 @@ class SessionController(private val context: Context) {
|
|||||||
fun connect(bookmark: Bookmark) {
|
fun connect(bookmark: Bookmark) {
|
||||||
start {
|
start {
|
||||||
it.conn.setMyTeamSpeakFeatures(bookmark.myTeamSpeakFeatures)
|
it.conn.setMyTeamSpeakFeatures(bookmark.myTeamSpeakFeatures)
|
||||||
|
it.applyBookmark(bookmark)
|
||||||
it.start(bookmark.address, bookmark.port, bookmark.nickname.orEmpty(), bookmark.password,
|
it.start(bookmark.address, bookmark.port, bookmark.nickname.orEmpty(), bookmark.password,
|
||||||
bookmark.identityId, bookmark.channel, bookmark.channelPassword)
|
bookmark.identityId, bookmark.channel, bookmark.channelPassword)
|
||||||
}
|
}
|
||||||
@@ -340,6 +343,7 @@ class SessionController(private val context: Context) {
|
|||||||
all[index] = edited
|
all[index] = edited
|
||||||
}
|
}
|
||||||
saveBookmarks()
|
saveBookmarks()
|
||||||
|
_servers.value.forEach { it.bookmarkEdited(edited) }
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The channels of a server we are on at [host]:[port], to pick one to join. */
|
/** 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()
|
val b = edit?.bookmark ?: return@listSaver emptyList()
|
||||||
listOf(edit.index, b.label.orEmpty(), b.address.orEmpty(), b.port, b.nickname.orEmpty(), b.password,
|
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.identityId, b.channel, b.channelPassword, b.connectOnStartup, b.iconId, b.id,
|
||||||
b.myTeamSpeakFeatures)
|
b.myTeamSpeakFeatures, b.showWhisperControls)
|
||||||
},
|
},
|
||||||
restore = { saved ->
|
restore = { saved ->
|
||||||
if (saved.isEmpty()) null
|
if (saved.isEmpty()) null
|
||||||
@@ -56,6 +56,7 @@ val BookmarkEditSaver = listSaver<BookmarkEdit?, Any>(
|
|||||||
iconId = saved[10] as Long
|
iconId = saved[10] as Long
|
||||||
id = saved[11] as String
|
id = saved[11] as String
|
||||||
myTeamSpeakFeatures = saved[12] as Boolean
|
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 channelPassword by rememberSaveable { mutableStateOf(b.channelPassword.orEmpty()) }
|
||||||
var connectOnStartup by rememberSaveable { mutableStateOf(b.connectOnStartup) }
|
var connectOnStartup by rememberSaveable { mutableStateOf(b.connectOnStartup) }
|
||||||
var myTeamSpeakFeatures by rememberSaveable { mutableStateOf(b.myTeamSpeakFeatures) }
|
var myTeamSpeakFeatures by rememberSaveable { mutableStateOf(b.myTeamSpeakFeatures) }
|
||||||
|
var showWhisperControls by rememberSaveable { mutableStateOf(b.showWhisperControls) }
|
||||||
|
|
||||||
val save = {
|
val save = {
|
||||||
val (host, port) = SessionController.parseAddress(address)
|
val (host, port) = SessionController.parseAddress(address)
|
||||||
@@ -90,6 +92,7 @@ fun BookmarkScreen(vm: SessionController, edit: BookmarkEdit, onDone: () -> Unit
|
|||||||
it.channelPassword = channelPassword
|
it.channelPassword = channelPassword
|
||||||
it.connectOnStartup = connectOnStartup
|
it.connectOnStartup = connectOnStartup
|
||||||
it.myTeamSpeakFeatures = myTeamSpeakFeatures
|
it.myTeamSpeakFeatures = myTeamSpeakFeatures
|
||||||
|
it.showWhisperControls = showWhisperControls
|
||||||
})
|
})
|
||||||
onDone()
|
onDone()
|
||||||
}
|
}
|
||||||
@@ -129,6 +132,11 @@ fun BookmarkScreen(vm: SessionController, edit: BookmarkEdit, onDone: () -> Unit
|
|||||||
Text("Enable myTeamSpeak features", Modifier.weight(1f))
|
Text("Enable myTeamSpeak features", Modifier.weight(1f))
|
||||||
Switch(myTeamSpeakFeatures, { myTeamSpeakFeatures = it })
|
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,
|
expandedHeight = 48.dp,
|
||||||
actions = {
|
actions = {
|
||||||
state.hostButton?.let { HostButtonAction(it) { url -> runCatching { uriHandler.openUri(url) } } }
|
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 = find::show) { PackIcon("FIND", "Find") }
|
||||||
IconButton(onClick = onSettings) { PackIcon("SETTINGS", "Settings") }
|
IconButton(onClick = onSettings) { PackIcon("SETTINGS", "Settings") }
|
||||||
},
|
},
|
||||||
@@ -398,11 +398,11 @@ fun ServerScreen(
|
|||||||
onAddContact = { server.addContact(id, it) },
|
onAddContact = { server.addContact(id, it) },
|
||||||
onEditContact = { clientSheet = null; onEditContact(client.uniqueId) },
|
onEditContact = { clientSheet = null; onEditContact(client.uniqueId) },
|
||||||
onConnectionInfo = { clientSheet = null; connectionInfo = id },
|
onConnectionInfo = { clientSheet = null; connectionInfo = id },
|
||||||
onWhisper = { clientSheet = null; server.whisperToClient(id) },
|
onWhisper = if (state.whisperControls) ({ clientSheet = null; server.whisperToClient(id) }) else null,
|
||||||
onAddToWhisperList = {
|
onAddToWhisperList = if (state.whisperControls) ({
|
||||||
clientSheet = null
|
clientSheet = null
|
||||||
server.clientRef(id)?.let { ref -> toWhisperList = client.name to { it.clients.add(ref) } }
|
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,
|
onMove = if (server.canMoveClients) ({ clientSheet = null; moving = id }) else null,
|
||||||
onMoveToOwnChannel = if (server.canMoveClients && tree.channel(state.channelId)?.clients?.none { it.id == id } == true) {
|
onMoveToOwnChannel = if (server.canMoveClients && tree.channel(state.channelId)?.clients?.none { it.id == id } == true) {
|
||||||
{ server.moveClient(id, state.channelId); clientSheet = null }
|
{ server.moveClient(id, state.channelId); clientSheet = null }
|
||||||
@@ -429,11 +429,11 @@ fun ServerScreen(
|
|||||||
onJoin = { join(channel); channelSheet = null },
|
onJoin = { join(channel); channelSheet = null },
|
||||||
onSubscribe = { server.setSubscribed(id, it); channelSheet = null },
|
onSubscribe = { server.setSubscribed(id, it); channelSheet = null },
|
||||||
onBookmark = { channelSheet = null; bookmarkHere(id) },
|
onBookmark = { channelSheet = null; bookmarkHere(id) },
|
||||||
onWhisper = { channelSheet = null; server.whisperToChannel(id) },
|
onWhisper = if (state.whisperControls) ({ channelSheet = null; server.whisperToChannel(id) }) else null,
|
||||||
onAddToWhisperList = {
|
onAddToWhisperList = if (state.whisperControls) ({
|
||||||
channelSheet = null
|
channelSheet = null
|
||||||
server.channelRef(id)?.let { ref -> toWhisperList = channel.name to { it.channels.add(ref) } }
|
server.channelRef(id)?.let { ref -> toWhisperList = channel.name to { it.channels.add(ref) } }
|
||||||
},
|
}) else null,
|
||||||
onFiles = if (server.canBrowseFiles) ({
|
onFiles = if (server.canBrowseFiles) ({
|
||||||
channelSheet = null
|
channelSheet = null
|
||||||
if (channel.locked) filesLocked = id else files = FilesOf(id, channel.name, "")
|
if (channel.locked) filesLocked = id else files = FilesOf(id, channel.name, "")
|
||||||
|
|||||||
@@ -54,8 +54,9 @@ fun ClientSheet(
|
|||||||
onAddContact: (ContactType) -> Unit,
|
onAddContact: (ContactType) -> Unit,
|
||||||
onEditContact: () -> Unit,
|
onEditContact: () -> Unit,
|
||||||
onConnectionInfo: () -> Unit,
|
onConnectionInfo: () -> Unit,
|
||||||
onWhisper: () -> Unit,
|
/** Both null when whisper controls are hidden. */
|
||||||
onAddToWhisperList: () -> Unit,
|
onWhisper: (() -> Unit)?,
|
||||||
|
onAddToWhisperList: (() -> Unit)?,
|
||||||
/** Null when the client cannot be moved. */
|
/** Null when the client cannot be moved. */
|
||||||
onMove: (() -> Unit)?,
|
onMove: (() -> Unit)?,
|
||||||
/** Null when the client cannot be moved, or is in our channel already. */
|
/** Null when the client cannot be moved, or is in our channel already. */
|
||||||
@@ -97,8 +98,8 @@ fun ClientSheet(
|
|||||||
} else {
|
} else {
|
||||||
Action("PLAYER_CHAT", "Send message", onClick = onMessage)
|
Action("PLAYER_CHAT", "Send message", onClick = onMessage)
|
||||||
Action("POKE", "Poke") { poking = true }
|
Action("POKE", "Poke") { poking = true }
|
||||||
Action("PLAYER_WHISPER", "Whisper", onClick = onWhisper)
|
onWhisper?.let { Action("PLAYER_WHISPER", "Whisper", onClick = it) }
|
||||||
Action("ON_WHISPERLIST", "Add to whisper list…", onClick = onAddToWhisperList)
|
onAddToWhisperList?.let { Action("ON_WHISPERLIST", "Add to whisper list…", onClick = it) }
|
||||||
onMove?.let { Action("CHANNEL_SWITCH", "Move to channel…", 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) }
|
onMoveToOwnChannel?.let { Action("MOVE_CLIENT_TO_OWN_CHANNEL", "Move to own channel", onClick = it) }
|
||||||
moderation()
|
moderation()
|
||||||
@@ -145,8 +146,9 @@ fun ChannelSheet(
|
|||||||
onJoin: () -> Unit,
|
onJoin: () -> Unit,
|
||||||
onSubscribe: (Boolean) -> Unit,
|
onSubscribe: (Boolean) -> Unit,
|
||||||
onBookmark: () -> Unit,
|
onBookmark: () -> Unit,
|
||||||
onWhisper: () -> Unit,
|
/** Both null when whisper controls are hidden. */
|
||||||
onAddToWhisperList: () -> Unit,
|
onWhisper: (() -> Unit)?,
|
||||||
|
onAddToWhisperList: (() -> Unit)?,
|
||||||
/** Each null when we may not. */
|
/** Each null when we may not. */
|
||||||
onFiles: (() -> Unit)?,
|
onFiles: (() -> Unit)?,
|
||||||
onCreateSub: (() -> Unit)?,
|
onCreateSub: (() -> Unit)?,
|
||||||
@@ -166,8 +168,8 @@ fun ChannelSheet(
|
|||||||
} else {
|
} else {
|
||||||
Action("SUBSCRIBE_TO_CHANNEL", "Subscribe") { onSubscribe(true) }
|
Action("SUBSCRIBE_TO_CHANNEL", "Subscribe") { onSubscribe(true) }
|
||||||
}
|
}
|
||||||
Action("WHISPER", "Whisper", onClick = onWhisper)
|
onWhisper?.let { Action("WHISPER", "Whisper", onClick = it) }
|
||||||
Action("ON_WHISPERLIST", "Add to whisper list…", onClick = onAddToWhisperList)
|
onAddToWhisperList?.let { Action("ON_WHISPERLIST", "Add to whisper list…", onClick = it) }
|
||||||
onFiles?.let { Action("FILETRANSFER", "Browse files", onClick = it) }
|
onFiles?.let { Action("FILETRANSFER", "Browse files", onClick = it) }
|
||||||
Action("BOOKMARK_ADD", "Add to bookmarks", onClick = onBookmark)
|
Action("BOOKMARK_ADD", "Add to bookmarks", onClick = onBookmark)
|
||||||
onCreateSub?.let { Action("CHANNEL_CREATE_SUB", "Create sub-channel", onClick = it) }
|
onCreateSub?.let { Action("CHANNEL_CREATE_SUB", "Create sub-channel", onClick = it) }
|
||||||
|
|||||||
@@ -26,6 +26,8 @@ public final class Bookmark {
|
|||||||
public boolean connectOnStartup = false;
|
public boolean connectOnStartup = false;
|
||||||
/** TeamSpeak's "Enable myTeamSpeak features" ({@code Bookmark_Data.send_mytsid_on_server}). */
|
/** TeamSpeak's "Enable myTeamSpeak features" ({@code Bookmark_Data.send_mytsid_on_server}). */
|
||||||
public boolean myTeamSpeakFeatures = true;
|
public boolean myTeamSpeakFeatures = true;
|
||||||
|
/** Offer whispering in this server's menus. */
|
||||||
|
public boolean showWhisperControls = false;
|
||||||
/** The server's icon as last seen there, 0 for none or not yet known. */
|
/** The server's icon as last seen there, 0 for none or not yet known. */
|
||||||
public long iconId = 0;
|
public long iconId = 0;
|
||||||
|
|
||||||
@@ -49,6 +51,7 @@ public final class Bookmark {
|
|||||||
b.channelPassword = channelPassword;
|
b.channelPassword = channelPassword;
|
||||||
b.connectOnStartup = connectOnStartup;
|
b.connectOnStartup = connectOnStartup;
|
||||||
b.myTeamSpeakFeatures = myTeamSpeakFeatures;
|
b.myTeamSpeakFeatures = myTeamSpeakFeatures;
|
||||||
|
b.showWhisperControls = showWhisperControls;
|
||||||
b.iconId = iconId;
|
b.iconId = iconId;
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -89,6 +89,7 @@ public final class Bookmarks {
|
|||||||
bm.channelPassword = p.getProperty(prefix + "channelPassword", "");
|
bm.channelPassword = p.getProperty(prefix + "channelPassword", "");
|
||||||
bm.connectOnStartup = Boolean.parseBoolean(p.getProperty(prefix + "connectOnStartup", "false"));
|
bm.connectOnStartup = Boolean.parseBoolean(p.getProperty(prefix + "connectOnStartup", "false"));
|
||||||
bm.myTeamSpeakFeatures = Boolean.parseBoolean(p.getProperty(prefix + "myTeamSpeakFeatures", "true"));
|
bm.myTeamSpeakFeatures = Boolean.parseBoolean(p.getProperty(prefix + "myTeamSpeakFeatures", "true"));
|
||||||
|
bm.showWhisperControls = Boolean.parseBoolean(p.getProperty(prefix + "showWhisperControls", "false"));
|
||||||
bm.iconId = parseLong(p.getProperty(prefix + "iconId"));
|
bm.iconId = parseLong(p.getProperty(prefix + "iconId"));
|
||||||
if (bm.address != null && !bm.address.isBlank()) b.entries.add(bm);
|
if (bm.address != null && !bm.address.isBlank()) b.entries.add(bm);
|
||||||
}
|
}
|
||||||
@@ -112,6 +113,7 @@ public final class Bookmarks {
|
|||||||
p.setProperty(prefix + "channelPassword", nullToEmpty(bm.channelPassword));
|
p.setProperty(prefix + "channelPassword", nullToEmpty(bm.channelPassword));
|
||||||
p.setProperty(prefix + "connectOnStartup", Boolean.toString(bm.connectOnStartup));
|
p.setProperty(prefix + "connectOnStartup", Boolean.toString(bm.connectOnStartup));
|
||||||
p.setProperty(prefix + "myTeamSpeakFeatures", Boolean.toString(bm.myTeamSpeakFeatures));
|
p.setProperty(prefix + "myTeamSpeakFeatures", Boolean.toString(bm.myTeamSpeakFeatures));
|
||||||
|
p.setProperty(prefix + "showWhisperControls", Boolean.toString(bm.showWhisperControls));
|
||||||
p.setProperty(prefix + "iconId", Long.toString(bm.iconId));
|
p.setProperty(prefix + "iconId", Long.toString(bm.iconId));
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user