From 93b10284ca538e455fc240a8693bdb8bb398d9f7 Mon Sep 17 00:00:00 2001 From: xodapi <4956501+xodapi@users.noreply.github.com> Date: Wed, 1 Jul 2026 21:22:33 +0700 Subject: [PATCH] feat(android): add minimal APK entrypoint (closes #95) Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com> --- Cargo.toml | 3 +++ src/lib.rs | 13 +++++++++++++ 2 files changed, 16 insertions(+) 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",