From e5555216c52feca50d8c872eaae23edcf019480b Mon Sep 17 00:00:00 2001 From: Himadri Bhattacharjee <107522312+lavafroth@users.noreply.github.com> Date: Tue, 16 Dec 2025 20:14:08 +0530 Subject: [PATCH] feat: show loading screen when device is not connected --- Cargo.lock | 9 +++++++++ Cargo.toml | 1 + src/main.rs | 30 ++++++++++++++++++------------ 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b15bd6d..092c3d1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1121,6 +1121,15 @@ dependencies = [ "winit", ] +[[package]] +name = "egui_alignments" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01becb6d7cb509f1fcb5496887e4bad9397e01ac0bb3eb6efa2593d0493ad589" +dependencies = [ + "egui", +] + [[package]] name = "egui_extras" version = "0.33.2" diff --git a/Cargo.toml b/Cargo.toml index ea60895..85f7616 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,4 +7,5 @@ edition = "2024" adb_client = "2.1.18" eframe = "0.33.2" egui = "0.33.2" +egui_alignments = "0.3.6" egui_extras = "0.33.2" diff --git a/src/main.rs b/src/main.rs index cee9182..90070c1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,7 +3,8 @@ use adb_client::ADBUSBDevice; use eframe::egui; -use egui::{Button, Layout, RichText, Sense, TextEdit}; +use egui::{Align, Button, Label, Layout, RichText, Sense, Spinner, TextEdit}; +use egui_alignments::{center_horizontal, column}; fn main() -> eframe::Result { // env_logger::init(); // Log to stderr (if you run with `RUST_LOG=debug`). @@ -93,18 +94,23 @@ impl Default for App { impl eframe::App for App { fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) { - let maybe_device = ADBUSBDevice::autodetect(); - if self.device.is_none() { - if let Ok(device) = maybe_device { - self.device.replace(device); - println!("wow I found a device"); - } else { - println!("looking ..."); - }; - } - egui::CentralPanel::default().show(ctx, |ui| { - ctx.set_pixels_per_point(1.5); + ctx.set_pixels_per_point(1.5); + if self.device.is_none() { + egui::CentralPanel::default().show(ctx, |ui| { + center_horizontal(ui, |ui| { + column(ui, Align::Center, |ui| { + ui.add(Spinner::new()); + ui.add(Label::new("Waiting for a device.\nPlease connect your Android device via USB ensuring\nthat USB debugging is enabled in developer settings.")); + }); + }); + }); + + self.device = ADBUSBDevice::autodetect().ok(); + return; + } + + egui::CentralPanel::default().show(ctx, |ui| { ui.take_available_width(); ui.horizontal(|ui| { ui.take_available_width();