Adapt mesh views to phone rotation and toggle the exit from Quick Settings

Use the available width for the Android device table, keeping individual
peers expandable and their full details reachable in both orientations.
Show network selection and settings side by side in landscape and reuse
the VIP editor with a compact toolbar and width-aware backend columns.
Retain the selected network, expanded peer, traffic unit and VIP draft
across rotation.

Show data-channel readiness consistently in the tray and on Android.
Distinguish an establishing channel, a disabled data plane, an offline
peer and a transport failure. Use an animated arc for visible waiting
peers. Explain Phosphor controls on hover, focus and long press, and
provide a masked-by-default reveal button in the shared secret field.

Store the last confirmed exit network and endpoint in Android's private
preferences. A Quick Settings tap disconnects that selection or restores
the exact peer through the existing agent. First use opens the chooser.
On a cold start, wait for an authenticated exit offer outside the command
loop. Check the current selection again before changing the route. Only
changed exit offers wake roster subscribers. Wire formats, software
version and mesh identity storage remain compatible.

On macOS arm64, cargo fmt and strict workspace Clippy passed. The locked
workspace suite passed 598 tests with four opt-in tests ignored. Built the
tray, the ARM64 debug APK and its test APK. All three instrumentation tests
passed on an Android API 37 emulator. Opened the chooser from the actual
Quick Settings tile, rotated the activity and inspected rendered device
lists with ready, waiting, failed and offline peers. Physical phones and
native Linux and Windows builds were not exercised.
This commit is contained in:
Aleksandr Bogomiakov committed 2026-11-25 15:38:10 +02:00
1 parent 50c0ecea45
commit e3e6089d0b
29 files changed
+1688 -324

No files matched your search

+13 -1
View File
@@ -54,7 +54,16 @@ extern "system" fn Java_cy_hexor_tsunagi_Native_surface(mut env: JNIEnv, _: JObj
crate::view::configure(&ctx);
DISPLAY.with_borrow_mut(|d| {
// If Android discarded the old EGL context, its GPU resources are already gone.
let ui = d.take().map(|old| old.ui).unwrap_or_default();
let ui = d
.take()
.map(|old| {
// A rotation can recreate EGL. Keep expanded peers and scroll positions
// while the new context uploads its own font atlas.
let data = old.ctx.data_mut(std::mem::take);
ctx.data_mut(|current| *current = data);
old.ui
})
.unwrap_or_default();
*d = Some(Display {
painter,
ctx,
@@ -76,8 +85,10 @@ extern "system" fn Java_cy_hexor_tsunagi_Native_draw(
h: jint,
scale: jfloat,
service_started: jboolean,
landscape: jboolean,
) -> jlong {
with_display(|d| {
tsunagi_ui::widgets::set_landscape(&d.ctx, landscape != 0);
let size = egui::vec2(w as f32, h as f32) / scale;
let mut input = egui::RawInput {
screen_rect: Some(egui::Rect::from_min_size(Pos2::ZERO, size)),
@@ -231,6 +242,7 @@ extern "system" fn Java_cy_hexor_tsunagi_Native_input(
}
4 => d.ui.paste_secret(text),
5 => d.ui.error(text),
6 => d.ui.request_exit_picker(),
_ => {}
});
}
+52 -2
View File
@@ -265,9 +265,10 @@ fn update_exit_notification(
let Ok(mut env) = vm.attach_current_thread() else {
return;
};
let _ = env.with_local_frame(6, |env| -> jni::errors::Result<()> {
let _ = env.with_local_frame(8, |env| -> jni::errors::Result<()> {
let network = env.new_string(notice.map_or("", |n| &n.network))?;
let peer = env.new_string(notice.map_or("", |n| &n.peer))?;
let name = env.new_string(notice.map_or("", |n| &n.name))?;
let title = env.new_string(
notice
.map(|n| format!("Exit node · {}", n.name))
@@ -290,13 +291,15 @@ fn update_exit_notification(
env.call_method(
service,
"updateExitNotification",
"(JLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V",
"(JLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Z)V",
&[
JValue::Long(id),
JValue::Object(&network),
JValue::Object(&peer),
JValue::Object(&title),
JValue::Object(&text),
JValue::Object(&name),
JValue::Bool(notice.is_some_and(|n| n.online).into()),
],
)?;
Ok(())
@@ -334,6 +337,53 @@ extern "system" fn Java_cy_hexor_tsunagi_Native_disconnectExit(
.into()
}
#[unsafe(no_mangle)]
extern "system" fn Java_cy_hexor_tsunagi_Native_tileExit(
mut env: JNIEnv,
_: JObject,
id: jlong,
network: JString,
peer: JString,
connect: jni::sys::jboolean,
wait_for_discovery: jni::sys::jboolean,
) -> jni::sys::jstring {
// Called on the tile's background worker. Never hold the session lock while awaiting the agent.
let mut run = || -> Result<(), String> {
let network: String = env.get_string(&network).map_err(|e| e.to_string())?.into();
let peer: String = env.get_string(&peer).map_err(|e| e.to_string())?.into();
let (commands, mut state) = current()
.as_ref()
.filter(|s| s.id == id)
.map(|s| (s.commands.clone(), s.state.clone()))
.ok_or("Tsunagi Agent stopped")?;
if connect != 0 && wait_for_discovery != 0 {
tokio::runtime::Builder::new_current_thread()
.enable_time()
.build()
.map_err(|e| e.to_string())?
.block_on(crate::service::wait_for_exit_offer(
&mut state, &network, &peer,
))?;
}
let request = if connect != 0 {
Request::RestoreExit { network, peer }
} else {
Request::DisconnectExit { network, peer }
};
let (reply, result) = oneshot::channel();
commands
.try_send((request, reply))
.map_err(|_| "Tsunagi Agent is busy or stopped")?;
result
.blocking_recv()
.map_err(|_| "Tsunagi Agent stopped")??;
Ok(())
};
run()
.err()
.and_then(|e| env.new_string(e).ok())
.map_or(std::ptr::null_mut(), JString::into_raw)
}
#[unsafe(no_mangle)]
extern "system" fn Java_cy_hexor_tsunagi_Native_failed(
_: JNIEnv,
_: JObject,
+68
View File
@@ -25,6 +25,13 @@ pub enum Request {
/// Endpoint id captured at the same time.
peer: String,
},
/// Restore a remembered network/peer pair only while no other exit is selected.
RestoreExit {
/// Network saved at the last successful selection.
network: String,
/// Peer used in that network.
peer: String,
},
}
/// A configured default route stays visible if its remote peer goes offline.
@@ -72,6 +79,66 @@ pub async fn disconnect_exit(
Ok(())
}
async fn restore_exit(agent: &Agent, network: &str, peer: &str) -> Result<Outcome, String> {
let network = network.parse().map_err(|_| "Invalid saved network ID")?;
let peer = peer.parse().map_err(|_| "Invalid saved peer ID")?;
let status = agent.status().await.map_err(|e| e.to_string())?;
for n in &status.networks {
if n.state == tsunagi::agent::NetworkState::Active
&& let Some(current) = n.exit_via
{
return if n.network_id == network && current == peer {
Ok(Outcome::Applied)
} else {
Err("Another exit is already selected".into())
};
}
}
agent
.set_exit_via(network, Some(peer))
.await
.map_err(|e| e.to_string())?;
Ok(Outcome::Applied)
}
// On cold start the first snapshot often precedes peer discovery. Wait on the
// service's roster notifications, outside the command loop, then let the usual
// serialized command validate the selection again before touching the route.
#[cfg(any(target_os = "android", test))]
pub(crate) async fn wait_for_exit_offer(
state: &mut watch::Receiver<State>,
network: &str,
peer: &str,
) -> Result<(), String> {
tokio::time::timeout(std::time::Duration::from_secs(15), async {
loop {
match &*state.borrow_and_update() {
State::Ready(report, _) => {
let n = report
.networks
.iter()
.find(|n| n.network_id == network && n.active)
.ok_or("The saved exit network is no longer active")?;
if report
.networks
.iter()
.any(|n| n.active && n.exit.via.is_some())
|| n.peers.iter().any(|p| p.endpoint_id == peer && p.exit_node)
{
return Ok(());
}
}
State::Off => return Err("Tsunagi Agent stopped".into()),
State::Error(error) => return Err(error.clone()),
State::Starting => {}
}
state.changed().await.map_err(|_| "Tsunagi Agent stopped")?;
}
})
.await
.map_err(|_| "The saved peer is offline or no longer offers an exit")?
}
/// Private reply delivered only to the UI that requested the action.
pub enum Outcome {
/// The agent has applied the action.
@@ -256,6 +323,7 @@ pub async fn serve(
}
Request::DisconnectExit {network, peer} => disconnect_exit(&agent, &network, &peer).await
.map(|()| Outcome::Applied).map_err(|e| e.to_string()),
Request::RestoreExit {network, peer} => restore_exit(&agent, &network, &peer).await,
};
(Some((reply, result)), refresh_zones)
}
+138 -17
View File
@@ -65,8 +65,8 @@ async fn a_hidden_service_waits_for_mesh_changes_and_visible_stats_are_on_demand
#[tokio::test]
async fn notification_tracks_the_selected_exit_and_a_stale_disconnect_keeps_the_current_route() {
use crate::service::{ExitNotice, State, disconnect_exit, serve};
use tokio::sync::{mpsc, watch};
use crate::service::{ExitNotice, Request, State, disconnect_exit, serve, wait_for_exit_offer};
use tokio::sync::{mpsc, oneshot, watch};
use tsunagi_wg_quic::{WireguardConfig, WireguardPlugin};
async fn notice_matching(
notices: &mut watch::Receiver<Option<ExitNotice>>,
@@ -117,11 +117,11 @@ async fn notification_tracks_the_selected_exit_and_a_stale_disconnect_keeps_the_
.await
.unwrap();
let agent = phone.agent.clone();
let (_commands, requests) = mpsc::channel(4);
let (commands, requests) = mpsc::channel(4);
let (stop, stopped) = watch::channel(false);
let (published, mut notices) = watch::channel(None);
let (state, mut live) = watch::channel(State::Starting);
let task = tokio::spawn(async move {
let (state, _) = watch::channel(State::Starting);
serve(
agent,
wg,
@@ -142,6 +142,66 @@ async fn notification_tracks_the_selected_exit_and_a_stale_disconnect_keeps_the_
assert_eq!(notice.name, "gateway");
assert_eq!(notice.network_name, "travel");
assert!(notice.online);
let restore = |peer: String| {
let commands = commands.clone();
let network = notice.network.clone();
async move {
let (reply, result) = oneshot::channel();
commands
.send((Request::RestoreExit { network, peer }, reply))
.await
.unwrap();
result.await.unwrap()
}
};
disconnect_exit(&phone.agent, &notice.network, &notice.peer)
.await
.unwrap();
notice_matching(&mut notices, Option::is_none).await;
assert!(
restore(phone.agent.endpoint_id().to_string())
.await
.is_err()
);
assert!(
phone
.agent
.network_status(id)
.await
.unwrap()
.exit_via
.is_none()
);
// A cold service can publish its first status before the gateway advertises.
// Keep the command loop available while waiting for this exact peer.
exit.agent.set_exit_offer(id, false).await.unwrap();
drop(
tokio::time::timeout(
std::time::Duration::from_secs(5),
live.wait_for(|s| {
matches!(s, State::Ready(report, _) if
report.networks[0].peers.iter().any(|p| p.endpoint_id == notice.peer && !p.exit_node))
}),
)
.await
.unwrap()
.unwrap(),
);
let waiting = wait_for_exit_offer(&mut live, &notice.network, &notice.peer);
tokio::pin!(waiting);
tokio::select! {
biased;
_ = &mut waiting => panic!("restored before the peer offered an exit"),
result = exit.agent.set_exit_offer(id, true) => result.unwrap(),
}
waiting.await.unwrap();
assert!(restore(notice.peer.clone()).await.is_ok());
notice_matching(&mut notices, |n| n.as_ref().is_some_and(|n| n.online)).await;
assert!(
restore(phone.agent.endpoint_id().to_string())
.await
.is_err()
);
disconnect_exit(
&phone.agent,
&id.to_string(),
@@ -678,12 +738,14 @@ async fn network_cards_start_closed_and_keep_exit_traffic_visible_when_folded()
};
let opened = click(titles[0]);
assert_eq!(positions(&opened, "Show devices").len(), 1);
let y = |label| positions(&opened, label)[0].y;
assert!((0.0..=26.0).contains(&(y("host") - y("device"))));
assert!((0.0..=26.0).contains(&(y("range") - y("id"))));
assert!((0.0..=26.0).contains(&(y("peers") - y("addr"))));
assert!((y("VIP") - y("Show devices")).abs() < 2.0);
assert!((y("VIP") - y(&format!("{} Copy secret", egui_phosphor::regular::COPY))).abs() < 2.0);
use egui_phosphor::regular as icon;
let vip = format!("{} VIP", icon::NETWORK);
let y = |label: &str| positions(&opened, label)[0].y;
assert!((0.0..=26.0).contains(&(y(icon::DESKTOP_TOWER) - y(icon::FINGERPRINT))));
assert!((0.0..=26.0).contains(&(y(icon::TREE_STRUCTURE) - y(icon::HASH))));
assert!((0.0..=26.0).contains(&(y(icon::DEVICES) - y(icon::DEVICE_MOBILE))));
assert!((y(&vip) - y("Show devices")).abs() < 2.0);
assert!((y(&vip) - y(&format!("{} Copy secret", egui_phosphor::regular::COPY))).abs() < 2.0);
let folded = click(positions(&opened, name.as_str())[0]);
assert!(positions(&folded, "Show devices").is_empty());
assert_eq!(positions(&folded, "Exit via gateway").len(), 1);
@@ -691,7 +753,55 @@ async fn network_cards_start_closed_and_keep_exit_traffic_visible_when_folded()
}
#[test]
fn portrait_navigation_opens_the_tray_vip_overview_and_draft_without_writing() {
fn the_system_tile_waits_for_the_agent_and_distinguishes_networks_with_the_same_name() {
use crate::{
service::State,
view::{Phone, configure},
};
use std::{sync::Arc, time::Instant};
use tsunagi::ipc::{NetworkReport, StatusReport};
let ctx = egui::Context::default();
configure(&ctx);
let mut phone = Phone::default();
let draw = |phone: &mut Phone, state: &State| {
let out = ctx.run(egui::RawInput::default(), |ctx| {
phone.draw(ctx, state, |_| panic!("opening the tile selected a route"));
});
out.shapes
.into_iter()
.filter_map(|s| match s.shape {
egui::Shape::Text(t) => Some(t.galley.text().to_owned()),
_ => None,
})
.collect::<Vec<_>>()
};
phone.request_exit_picker();
draw(&mut phone, &State::Starting);
let networks =
[("alpha", true), ("bravo", true), ("paused", false)].map(|(id, active)| NetworkReport {
network_id: id.into(),
name: "home".into(),
active,
..Default::default()
});
let state = State::Ready(
Arc::new(StatusReport {
networks: networks.into(),
..Default::default()
}),
Instant::now(),
);
draw(&mut phone, &state);
let chooser = draw(&mut phone, &state);
assert!(chooser.iter().any(|s| s == "home · alpha"));
assert!(chooser.iter().any(|s| s == "home · bravo"));
assert!(!chooser.iter().any(|s| s.contains("paused")));
assert!(phone.back().is_none());
assert!(draw(&mut phone, &state).iter().any(|s| s == "tsunagi"));
}
#[test]
fn rotating_the_phone_keeps_the_selected_network_and_unsaved_vip_draft() {
use crate::service::State;
use crate::view::{Phone, configure};
use egui::{Event, PointerButton, Pos2, RawInput, Rect, Shape};
@@ -708,6 +818,7 @@ fn portrait_navigation_opens_the_tray_vip_overview_and_draft_without_writing() {
port: 8080,
};
let mut config = VipConfig::new("web");
let name_field = egui::Id::new(("vip-name", &config.id));
let mut listener = Listener::new(Protocol::Tcp, 80);
listener.backends.push(backend.clone());
config.listeners.push(listener);
@@ -747,10 +858,11 @@ fn portrait_navigation_opens_the_tray_vip_overview_and_draft_without_writing() {
let ctx = egui::Context::default();
configure(&ctx);
let mut phone = Phone::default();
let size = std::cell::Cell::new(egui::vec2(360., 800.));
let mut frame = |events| {
ctx.run(
RawInput {
screen_rect: Some(Rect::from_min_size(Pos2::ZERO, egui::vec2(360., 800.))),
screen_rect: Some(Rect::from_min_size(Pos2::ZERO, size.get())),
events,
..Default::default()
},
@@ -788,21 +900,30 @@ fn portrait_navigation_opens_the_tray_vip_overview_and_draft_without_writing() {
frame(vec![])
};
click("lab");
let live = click("VIP");
for label in ["Overview", "Configuration", "Next new flow", "node:8080"] {
size.set(egui::vec2(800., 360.));
let live = click(&format!("{} VIP", egui_phosphor::regular::NETWORK));
for label in ["Overview", "Configuration", "web.lab", "node:8080"] {
let p = position(&live, label);
assert!(
(0.0..360.0).contains(&p.x),
"{label} is outside the portrait view"
(0.0..800.0).contains(&p.x),
"{label} is outside the landscape view"
);
}
let editor = click("Configuration");
position(&editor, "Name");
ctx.memory_mut(|m| m.request_focus(name_field));
frame(vec![Event::Text("-draft".into())]);
size.set(egui::vec2(360., 800.));
let editor_portrait = frame(vec![]);
position(&editor_portrait, "Unsaved changes");
assert!(editor_portrait.shapes.iter().any(|s| matches!(&s.shape,
Shape::Text(t) if t.galley.text().contains("-draft"))));
for label in [
"Active TCP port checks",
"Checks and flow expiry",
"+ Backend",
"+ Listener",
] {
position(&editor, label);
position(&editor_portrait, label);
}
}
+152 -7
View File
@@ -24,6 +24,7 @@ enum Page {
Devices(String),
Vips(String),
Exit(String),
ExitNetworks,
Leave(String),
}
impl Page {
@@ -40,7 +41,7 @@ impl Page {
Self::Join => "Join a network",
Self::Devices(_) => "Devices",
Self::Vips(_) => "VIP",
Self::Exit(_) => "Exit node",
Self::Exit(_) | Self::ExitNetworks => "Exit node",
Self::Leave(_) => "Leave network",
}
}
@@ -90,10 +91,14 @@ pub struct Phone {
pending: Option<Pending>,
error: Option<String>,
clipboard: Option<Zeroizing<String>>,
landscape: bool,
pick_exit: bool,
before_picker: Option<Page>,
}
/// Keep reads at tray density. Extra hit area is reserved for the navigation bar.
pub fn configure(ctx: &Context) {
ctx.set_os(egui::os::OperatingSystem::Android);
ctx.set_fonts(tsunagi_ui::app_fonts());
ctx.style_mut(|style| {
style.spacing.interact_size.y = 19.0;
@@ -104,11 +109,15 @@ pub fn configure(ctx: &Context) {
impl Phone {
fn home(&mut self) {
if let Some(previous) = self.before_picker.take() {
self.forms.exit_confirm = None;
self.page = previous;
return;
}
if let Page::Vips(id) = &self.page {
self.forms.vip_windows.remove(id);
}
self.forms.join.name.clear();
self.forms.join.secret.zeroize();
self.forms.join = Default::default();
self.forms.exit_confirm = None;
self.forms.forget_confirm = None;
self.page = Page::Home;
@@ -127,6 +136,8 @@ impl Phone {
&& editor.dirty()
{
editor.request_close();
} else if self.page == Page::Home && self.landscape && self.forms.close_selection() {
return None;
} else if self.page == Page::Home {
return Some(SystemAction::Finish);
} else {
@@ -150,6 +161,99 @@ impl Phone {
self.error = Some(message);
}
/// The first tile tap opens the chooser once the agent is ready.
pub fn request_exit_picker(&mut self) {
self.pick_exit = true;
}
fn exit_networks(&mut self, ui: &mut egui::Ui, networks: &[tsunagi::ipc::NetworkReport]) {
if networks.is_empty() {
ui.label("Join a network to choose an exit node.");
if ui.button("Join or create a network").clicked() {
self.page = Page::Join;
}
return;
}
if !networks.iter().any(|n| n.active) {
ui.label("Start a network to choose an exit node.");
if ui.button("Show networks").clicked() {
self.home();
}
return;
}
ui.label("Choose a network for the exit node");
for n in networks.iter().filter(|n| n.active) {
let ambiguous = networks.iter().any(|other| {
other.active && other.name == n.name && other.network_id != n.network_id
});
let label = if ambiguous {
format!("{} · {}", n.name, tsunagi_ui::format::short(&n.network_id))
} else {
n.name.clone()
};
if ui.button(label).clicked() {
self.page = Page::Exit(n.network_id.clone());
}
}
}
fn landscape_home(
&mut self,
ui: &mut egui::Ui,
actions: &Actions,
report: &tsunagi::ipc::StatusReport,
) {
let width = (ui.available_width() / 3.)
.clamp(146., 300.)
.min(ui.available_width() * 0.45);
egui::SidePanel::left("network selector")
.resizable(false)
.exact_width(width)
.show_inside(ui, |ui| {
if ui.button("Join or create a network").clicked() {
self.page = Page::Join;
}
ui.separator();
egui::ScrollArea::vertical()
.id_salt("network list")
.show(ui, |ui| {
for network in &report.networks {
home::draw_network_selector(ui, network, report, &mut self.forms);
}
});
});
egui::CentralPanel::default().show_inside(ui, |ui| {
let selected = report
.networks
.iter()
.find(|n| self.forms.selected_network.as_deref() == Some(&n.network_id));
egui::ScrollArea::vertical()
.id_salt(("network settings", selected.map(|n| &n.network_id)))
.show(ui, |ui| {
if let Some(n) = selected {
ui.heading(&n.name);
ui.push_id(&n.network_id, |ui| {
if home::draw_network_details(
ui,
actions,
&mut self.forms,
&self.traffic,
n,
report,
false,
) {
self.page = Page::Exit(n.network_id.clone());
}
});
} else {
ui.heading("This device");
ui.label("Tsunagi Agent is running");
home::draw_header(ui, actions, &mut self.forms, report);
}
});
});
}
/// Take a secret once for the platform’s sensitive clipboard.
pub fn take_copied_secret(&mut self) -> Option<Zeroizing<String>> {
self.clipboard.take()
@@ -191,6 +295,7 @@ impl Phone {
mut submit: impl FnMut(Command) -> Result<Response, String>,
) -> Option<SystemAction> {
self.acknowledge();
self.landscape = tsunagi_ui::widgets::landscape(ctx);
let report = if let State::Ready(report, at) = state {
if self.snapshot.at != Some(*at) {
self.snapshot.generation = self.snapshot.generation.wrapping_add(1);
@@ -205,6 +310,25 @@ impl Phone {
{
self.home();
}
if self
.forms
.selected_network
.as_ref()
.is_some_and(|id| !report.networks.iter().any(|n| &n.network_id == id))
{
self.forms.close_selection();
}
if self.pick_exit && self.pending.is_none() {
self.pick_exit = false;
let mut active = report.networks.iter().filter(|n| n.active);
let picker = match (active.next(), active.next()) {
(Some(n), None) => Page::Exit(n.network_id.clone()),
_ => Page::ExitNetworks,
};
if !matches!(self.page, Page::Exit(_) | Page::ExitNetworks) {
self.before_picker = Some(std::mem::replace(&mut self.page, picker));
}
}
Some(report)
} else {
if self.page.network().is_some() || self.page == Page::Join {
@@ -222,14 +346,18 @@ impl Phone {
egui::TopBottomPanel::top("navigation").show(ctx, |ui| {
ui.horizontal(|ui| {
ui.spacing_mut().interact_size.y = 32.0;
if self.page != Page::Home && ui.button(icon::ARROW_LEFT).clicked() {
if self.page != Page::Home
&& tsunagi_ui::widgets::icon_button(ui, icon::ARROW_LEFT, "Back").clicked()
{
system = self.back();
}
ui.heading(self.page.title());
if self.page == Page::Home {
ui.weak(env!("CARGO_PKG_VERSION"));
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
if ui.button(icon::INFO).clicked() {
if tsunagi_ui::widgets::icon_button(ui, icon::INFO, "About Tsunagi")
.clicked()
{
self.page = Page::About;
}
if report.is_some() {
@@ -276,6 +404,10 @@ impl Phone {
}
_ => {
egui::CentralPanel::default().show(ctx, |ui| {
if let Some(report) = report && self.page == Page::Home && self.landscape {
self.landscape_home(ui, &actions, report);
return;
}
egui::ScrollArea::vertical().auto_shrink([false, false]).show(ui, |ui| {
let Some(report) = report else {
match state {
@@ -294,8 +426,6 @@ impl Phone {
if ui.button("Join or create a network").clicked() {self.page = Page::Join;}
for n in &report.networks {
if home::draw_network(ui, &actions, &mut self.forms, &self.traffic, n, report, false) {self.page = Page::Exit(n.network_id.clone());}
if self.forms.open_devices.remove(&n.network_id) {self.page = Page::Devices(n.network_id.clone());}
if self.forms.vip_windows.contains_key(&n.network_id) {self.page = Page::Vips(n.network_id.clone());}
}
}
Page::Join => {
@@ -307,6 +437,7 @@ impl Phone {
self.forms.exit_confirm = Some(choice);
}
}
Page::ExitNetworks => self.exit_networks(ui, &report.networks),
Page::Leave(id) => {
if let Some(n) = selected {
ui.label(format!("Leave {} on this phone? You will need its secret to join again.", n.name));
@@ -318,6 +449,20 @@ impl Phone {
}
});
});
if let Some(report) = report
&& self.page == Page::Home
{
for n in &report.networks {
if self.forms.open_devices.remove(&n.network_id) {
self.page = Page::Devices(n.network_id.clone());
break;
}
if self.forms.vip_windows.contains_key(&n.network_id) {
self.page = Page::Vips(n.network_id.clone());
break;
}
}
}
devices::confirm_exit(ctx, &actions, &mut self.forms.exit_confirm, None);
}
}