From dd3eedba3c003d8043f37d61d2ac552821441509 Mon Sep 17 00:00:00 2001 From: Gabriele Musco Date: Thu, 22 Jun 2023 21:57:57 +0200 Subject: [PATCH] feat: warn user that adb isn't installed when installing the wivrn apk (#31) --- src/dependencies/adb_dep.rs | 9 +++++++++ src/dependencies/mod.rs | 1 + src/ui/install_wivrn_box.rs | 28 ++++++++++++++++++++++------ 3 files changed, 32 insertions(+), 6 deletions(-) create mode 100644 src/dependencies/adb_dep.rs diff --git a/src/dependencies/adb_dep.rs b/src/dependencies/adb_dep.rs new file mode 100644 index 0000000..cb15a46 --- /dev/null +++ b/src/dependencies/adb_dep.rs @@ -0,0 +1,9 @@ +use crate::depcheck::{DepType, Dependency}; + +pub fn adb_dep() -> Dependency { + Dependency { + name: "adb".into(), + dep_type: DepType::Executable, + filename: "adb".into(), + } +} diff --git a/src/dependencies/mod.rs b/src/dependencies/mod.rs index e50dd18..f4b219f 100644 --- a/src/dependencies/mod.rs +++ b/src/dependencies/mod.rs @@ -2,3 +2,4 @@ pub mod monado_deps; pub mod libsurvive_deps; pub mod basalt_deps; pub mod wivrn_deps; +pub mod adb_dep; diff --git a/src/ui/install_wivrn_box.rs b/src/ui/install_wivrn_box.rs index 117c200..b96dab8 100644 --- a/src/ui/install_wivrn_box.rs +++ b/src/ui/install_wivrn_box.rs @@ -3,7 +3,7 @@ use crate::{ downloader::download_file, paths::wivrn_apk_download_path, profile::{Profile, XRServiceType}, - runner::{Runner, RunnerStatus}, + runner::{Runner, RunnerStatus}, depcheck::check_dependency, dependencies::adb_dep::adb_dep, }; use gtk::prelude::*; use relm4::prelude::*; @@ -24,6 +24,8 @@ pub struct InstallWivrnBox { download_thread: Option>>, #[tracker::do_not_track] install_runner: Option, + #[tracker::do_not_track] + adb_missing_dialog: adw::MessageDialog, } #[derive(Debug)] @@ -170,11 +172,16 @@ impl SimpleComponent for InstallWivrnBox { } } Self::Input::DownloadWivrn => { - self.set_install_wivrn_status(InstallWivrnStatus::InProgress); - self.download_thread = Some(download_file( - "https://github.com/Meumeu/WiVRn/releases/latest/download/WiVRn-oculus-release.apk".into(), - wivrn_apk_download_path() - )); + if !check_dependency(adb_dep()) { + self.adb_missing_dialog.present(); + } + else { + self.set_install_wivrn_status(InstallWivrnStatus::InProgress); + self.download_thread = Some(download_file( + "https://github.com/Meumeu/WiVRn/releases/latest/download/WiVRn-oculus-release.apk".into(), + wivrn_apk_download_path() + )); + } } Self::Input::InstallWivrnApk => { let mut runner = get_adb_install_runner(&wivrn_apk_download_path()); @@ -192,11 +199,20 @@ impl SimpleComponent for InstallWivrnBox { root: &Self::Root, sender: ComponentSender, ) -> ComponentParts { + let adb_missing_dialog = adw::MessageDialog::builder() + .modal(true) + .transient_for(root.root().unwrap().downcast_ref::().unwrap()) + .title("ADB is not installed") + .body("Please install ADB on your computer to install WiVRn on your Android headset") + .hide_on_close(true) + .build(); + let model = Self { selected_profile: init.selected_profile, install_wivrn_status: InstallWivrnStatus::Done(None), download_thread: None, install_runner: None, + adb_missing_dialog, tracker: 0, };