diff --git a/Cargo.toml b/Cargo.toml index fa885f4..c683611 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,6 +20,9 @@ name = "vimit-gui" path = "src/bin/vimit-gui.rs" required-features = ["gui"] +[lib] +crate-type = ["rlib", "cdylib"] + [profile.release] opt-level = "z" lto = "thin" diff --git a/src/lib.rs b/src/lib.rs index 9e6379d..74be7eb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -7,6 +7,9 @@ pub mod parse; pub use api::*; pub use parse::*; +#[cfg(all(target_os = "android", feature = "android-gui"))] +slint::include_modules!(); + use chrono::{SecondsFormat, Utc}; use serde_json::{Value, json}; use std::collections::{HashMap, HashSet}; @@ -49,6 +52,16 @@ pub const DEFAULT_WARNING_THRESHOLD: f64 = 75.0; pub const DEFAULT_DANGER_THRESHOLD: f64 = 90.0; pub const DEFAULT_ABTOP_BIN: &str = "abtop"; +#[cfg(all(target_os = "android", feature = "android-gui"))] +#[unsafe(no_mangle)] +pub fn android_main(app: slint::android::AndroidApp) { + slint::android::init(app).expect("cannot initialize Android backend"); + AppWindow::new() + .expect("cannot initialize Slint window") + .run() + .expect("cannot run Slint window"); +} + pub const WINDOWS: [(&str, &str, &str, &str); 4] = [ ( "5h",