Android: notifications that read like the app's voice bar
The voice service's notification said "In voice on <server>" with Mute
and Disconnect, and the screen-sharing one only "Sharing your screen".
The voice notification now shows what the app's voice card shows: the
channel as its title, the server and how many are there ("Home · 3 in
voice", "just you"), the time in voice as a chronometer, and Mute,
Deafen and Leave, which act on every voice session as the old Mute did.
Several servers at once read "In voice on 2 servers" with their names.
Tapping it opens the voice channel screen (the activity forwards the
action to Rust, which queues it until the window runs). While our
stream is live the screen-sharing notification says where it goes and
how many watch ("Live in Chill Zone", "Home · 2 watching"). Both use
the app's accent colour.
The window takes such platform requests through a small inbox in
voelin-ui (`voelin_ui::request`), handled on the window's thread and
outside the app's borrow, since navigating calls back into Rust.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e0cc4fe76d
commit
f3c41264bb
15 files changed
+529
-98
No files matched your search
@@ -621,6 +621,8 @@ pub fn run(options: RunOptions) -> Result<()> {
|
||||
});
|
||||
|
||||
let _dev = crate::dev::start(&ui, &switches);
|
||||
// What the platform asked for before the window ran.
|
||||
crate::inbox::take();
|
||||
|
||||
ui.run()?;
|
||||
// With our own engine, leave servers properly, so no ghost client stays
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
//! Requests from the platform around the window: on Android a tapped
|
||||
//! notification. They can come from any thread and before the window runs;
|
||||
//! [`request`] keeps them until the window takes them on its thread.
|
||||
|
||||
use std::sync::{Mutex, PoisonError};
|
||||
|
||||
use slint::ComponentHandle;
|
||||
|
||||
use crate::app::{Nav, Page, with_app};
|
||||
|
||||
/// What the platform asks the window to do.
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub enum Request {
|
||||
/// Show the voice channel we are in (the phone's voice screen).
|
||||
ShowVoice,
|
||||
}
|
||||
|
||||
static PENDING: Mutex<Vec<Request>> = Mutex::new(Vec::new());
|
||||
|
||||
/// Hand `request` to the window: at once if it runs, else when it starts.
|
||||
pub fn request(request: Request) {
|
||||
PENDING.lock().unwrap_or_else(PoisonError::into_inner).push(request);
|
||||
// Fails without an event loop yet; `run` takes them then.
|
||||
let _ = slint::invoke_from_event_loop(take);
|
||||
}
|
||||
|
||||
/// Handle what is pending, on the window's thread; kept while there is no
|
||||
/// window.
|
||||
pub(crate) fn take() {
|
||||
let Some(ui) = with_app(|app| app.ui.upgrade()).flatten() else { return };
|
||||
let requests = std::mem::take(&mut *PENDING.lock().unwrap_or_else(PoisonError::into_inner));
|
||||
// Not inside `with_app`: navigating calls back into Rust, which borrows
|
||||
// the app again.
|
||||
let nav = ui.global::<Nav>();
|
||||
for request in requests {
|
||||
match request {
|
||||
Request::ShowVoice => {
|
||||
nav.invoke_show(Page::Server);
|
||||
nav.invoke_show_voice(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ mod dev;
|
||||
mod emoji;
|
||||
mod hotkey;
|
||||
mod images;
|
||||
mod inbox;
|
||||
mod members;
|
||||
mod servers;
|
||||
mod settings;
|
||||
@@ -18,3 +19,4 @@ mod video;
|
||||
mod vm;
|
||||
|
||||
pub use app::{HostedEngine, RunOptions, run};
|
||||
pub use inbox::{Request, request};
|
||||
Reference in new issue
Block a user