fix(android): add channel password join action

This commit is contained in:
Edison Jwa
2026-05-20 14:52:34 +09:00
parent 42d0ca0953
commit 273eaf21c1
+35 -17
View File
@@ -703,15 +703,17 @@ class _BetaHomeState extends State<_BetaHome> {
} }
} }
Future<void> _onJoinChannel(rust.BridgeChannel ch) async { Future<void> _onJoinChannel(
rust.BridgeChannel ch, {
bool askForPassword = false,
}) async {
if (!_canJoinVoiceChannel) return; if (!_canJoinVoiceChannel) return;
if (_pendingVoiceChannelId != null) return; if (_pendingVoiceChannelId != null) return;
if (ch.id == _currentVoiceChannelId) return; if (ch.id == _currentVoiceChannelId) return;
final l10n = AppL10n.of(context); final l10n = AppL10n.of(context);
final messenger = ScaffoldMessenger.of(context); final messenger = ScaffoldMessenger.of(context);
String? password; String? password;
// Heuristic: a channel name annotated with a lock prompts. if (askForPassword) {
if (ch.name.contains('🔒') || ch.name.toLowerCase().contains('password')) {
password = await _askChannelPassword(l10n); password = await _askChannelPassword(l10n);
if (password == null) return; // cancelled if (password == null) return; // cancelled
} }
@@ -1414,7 +1416,9 @@ class _BetaHomeState extends State<_BetaHome> {
pendingVoiceChannelId: _pendingVoiceChannelId, pendingVoiceChannelId: _pendingVoiceChannelId,
hasJoinPending: _pendingVoiceChannelId != null, hasJoinPending: _pendingVoiceChannelId != null,
canJoinVoiceChannel: _canJoinVoiceChannel, canJoinVoiceChannel: _canJoinVoiceChannel,
onJoinChannel: _onJoinChannel, onJoinChannel: (ch) => _onJoinChannel(ch),
onJoinChannelWithPassword: (ch) =>
_onJoinChannel(ch, askForPassword: true),
); );
const voiceBarWidthWide = 320.0; const voiceBarWidthWide = 320.0;
if (constraints.maxWidth >= wideBreakpoint) { if (constraints.maxWidth >= wideBreakpoint) {
@@ -2057,6 +2061,7 @@ class _SnapshotView extends StatelessWidget {
required this.hasJoinPending, required this.hasJoinPending,
required this.canJoinVoiceChannel, required this.canJoinVoiceChannel,
required this.onJoinChannel, required this.onJoinChannel,
required this.onJoinChannelWithPassword,
}); });
final rust.BridgeSnapshot snapshot; final rust.BridgeSnapshot snapshot;
@@ -2065,6 +2070,7 @@ class _SnapshotView extends StatelessWidget {
final bool hasJoinPending; final bool hasJoinPending;
final bool canJoinVoiceChannel; final bool canJoinVoiceChannel;
final ValueChanged<rust.BridgeChannel> onJoinChannel; final ValueChanged<rust.BridgeChannel> onJoinChannel;
final ValueChanged<rust.BridgeChannel> onJoinChannelWithPassword;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@@ -2143,19 +2149,31 @@ class _SnapshotView extends StatelessWidget {
subtitle: Text('id=${ch.id} parent=${ch.parent}'), subtitle: Text('id=${ch.id} parent=${ch.parent}'),
trailing: ch.id == currentVoiceChannelId trailing: ch.id == currentVoiceChannelId
? null ? null
: IconButton( : Row(
icon: Icon( mainAxisSize: MainAxisSize.min,
ch.id == pendingVoiceChannelId children: [
? Icons.hourglass_top IconButton(
: Icons.login, icon: const Icon(Icons.lock_outline),
), tooltip: l10n.channelPasswordTitle,
tooltip: ch.id == pendingVoiceChannelId onPressed: hasJoinPending
? l10n.statusConnecting ? null
: l10n.joinChannelAction, : () => onJoinChannelWithPassword(ch),
onPressed: ),
hasJoinPending || ch.id == pendingVoiceChannelId IconButton(
? null icon: Icon(
: () => onJoinChannel(ch), ch.id == pendingVoiceChannelId
? Icons.hourglass_top
: Icons.login,
),
tooltip: ch.id == pendingVoiceChannelId
? l10n.statusConnecting
: l10n.joinChannelAction,
onPressed:
hasJoinPending || ch.id == pendingVoiceChannelId
? null
: () => onJoinChannel(ch),
),
],
), ),
selected: ch.id == currentVoiceChannelId, selected: ch.id == currentVoiceChannelId,
onTap: onTap: