feat: warn user that adb isn't installed when installing the wivrn apk (#31)

This commit is contained in:
Gabriele Musco 2023-06-22 21:57:57 +02:00
parent 551769baf6
commit dd3eedba3c
No known key found for this signature in database
GPG key ID: 1068D795C80E51DE
3 changed files with 32 additions and 6 deletions

View file

@ -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(),
}
}

View file

@ -2,3 +2,4 @@ pub mod monado_deps;
pub mod libsurvive_deps;
pub mod basalt_deps;
pub mod wivrn_deps;
pub mod adb_dep;

View file

@ -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<JoinHandle<Result<(), reqwest::Error>>>,
#[tracker::do_not_track]
install_runner: Option<Runner>,
#[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<Self>,
) -> ComponentParts<Self> {
let adb_missing_dialog = adw::MessageDialog::builder()
.modal(true)
.transient_for(root.root().unwrap().downcast_ref::<gtk::Window>().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,
};