From 7eecfa32756ff78c63c0f6031626ce3110b351ef Mon Sep 17 00:00:00 2001 From: Logan McNaughton <848146+loganmc10@users.noreply.github.com> Date: Tue, 19 May 2026 10:50:42 +0200 Subject: [PATCH] use robius open (#915) * use robius open * more --- Cargo.lock | 136 ++++++++++++++++++++++++------------ Cargo.toml | 2 +- src/ui/gui.rs | 12 ++-- src/ui/retroachievements.rs | 2 +- 4 files changed, 97 insertions(+), 55 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index abdb3e8..055dda8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -212,9 +212,9 @@ dependencies = [ [[package]] name = "android-build" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cac4c64175d504608cf239756339c07f6384a476f97f20a7043f92920b0b8fd" +checksum = "f9fc9904ad2ad097c3c1cfe2eacaaf0fc24710936fa9ed941cb310b7c6ed2ab7" dependencies = [ "windows-sys 0.52.0", ] @@ -735,6 +735,25 @@ dependencies = [ "hybrid-array", ] +[[package]] +name = "block-sys" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae85a0696e7ea3b835a453750bf002770776609115e6d25c6d2ff28a8200f7e7" +dependencies = [ + "objc-sys", +] + +[[package]] +name = "block2" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e58aa60e59d8dbfcc36138f5f18be5f24394d33b38b24f7fd0b1caa33095f22f" +dependencies = [ + "block-sys", + "objc2 0.5.2", +] + [[package]] name = "block2" version = "0.5.1" @@ -2248,12 +2267,12 @@ dependencies = [ "fatfs", "futures", "mimalloc", - "open", "postcard", "rand 0.10.1", "regex", "reqwest", "rfd", + "robius-open", "sdl3-image-sys", "sdl3-sys", "sdl3-ttf-sys", @@ -2874,6 +2893,16 @@ dependencies = [ "cc", ] +[[package]] +name = "icrate" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fb69199826926eb864697bddd27f73d9fddcffc004f5733131e15b465e30642" +dependencies = [ + "block2 0.4.0", + "objc2 0.5.2", +] + [[package]] name = "icu_collections" version = "2.2.0" @@ -3152,25 +3181,6 @@ version = "2.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d98f6fed1fde3f8c21bc40a1abb88dd75e67924f9cffc3ef95607bad8017f8e2" -[[package]] -name = "is-docker" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "928bae27f42bc99b60d9ac7334e3a21d10ad8f1835a4e12ec3ec0464765ed1b3" -dependencies = [ - "once_cell", -] - -[[package]] -name = "is-wsl" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "173609498df190136aa7dea1a91db051746d339e18476eed5ca40521f02d7aa5" -dependencies = [ - "is-docker", - "once_cell", -] - [[package]] name = "is_terminal_polyfill" version = "1.70.2" @@ -3848,9 +3858,9 @@ dependencies = [ [[package]] name = "num-conv" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6673768db2d862beb9b39a78fdcb1a69439615d5794a1be50caa9bc92c81967" +checksum = "521739c6d2bac4aa25192232afe6841231376b2b26d4d9fae5ecf8ca5772e441" [[package]] name = "num-derive" @@ -4315,17 +4325,6 @@ version = "1.70.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe" -[[package]] -name = "open" -version = "5.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fbaa89d2ddc8473c78a3adf69eea8cffa28c483b8e02a971ef31527cd0fc92c" -dependencies = [ - "is-wsl", - "libc", - "pathdiff", -] - [[package]] name = "openssl-probe" version = "0.2.1" @@ -4450,12 +4449,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "35fb2e5f958ec131621fdd531e9fc186ed768cbe395337403ae56c17a74c68ec" -[[package]] -name = "pathdiff" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df94ce210e5bc13cb6651479fa48d14f601d9858cfe0467f43ae157023b938d3" - [[package]] name = "pbkdf2" version = "0.13.0" @@ -5169,6 +5162,30 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "robius-android-env" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "087fcb3061ccc432658a605cb868edd44e0efb08e7a159b486f02804a7616bef" +dependencies = [ + "jni 0.21.1", + "ndk-context", +] + +[[package]] +name = "robius-open" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "243e2abbc8c1ca8ddc283056d4675b67e452fd527c3741c5318642da37840ff3" +dependencies = [ + "cfg-if", + "icrate", + "jni 0.21.1", + "objc2 0.5.2", + "robius-android-env", + "windows 0.54.0", +] + [[package]] name = "rowan" version = "0.16.1" @@ -6141,9 +6158,9 @@ dependencies = [ [[package]] name = "tar" -version = "0.4.45" +version = "0.4.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22692a6476a21fa75fdfc11d452fda482af402c008cdbaf3476414e122040973" +checksum = "3f6221d9a6003c78398e3b239969f352578258df48c8eb051caadae0015bc840" dependencies = [ "filetime", "libc", @@ -6497,9 +6514,9 @@ dependencies = [ [[package]] name = "tower-http" -version = "0.6.10" +version = "0.6.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68d6fdd9f81c2819c9a8b0e0cd91660e7746a8e6ea2ba7c6b2b057985f6bcb51" +checksum = "4cfcf7e2740e6fc6d4d688b4ef00650406bb94adf4731e43c096c3a19fe40840" dependencies = [ "bitflags 2.11.1", "bytes", @@ -7306,6 +7323,16 @@ dependencies = [ "windows-sys 0.61.2", ] +[[package]] +name = "windows" +version = "0.54.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9252e5725dbed82865af151df558e754e4a3c2c30818359eb17465f1346a1b49" +dependencies = [ + "windows-core 0.54.0", + "windows-targets 0.52.6", +] + [[package]] name = "windows" version = "0.61.3" @@ -7349,6 +7376,16 @@ dependencies = [ "windows-core 0.62.2", ] +[[package]] +name = "windows-core" +version = "0.54.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12661b9c89351d684a50a8a643ce5f608e20243b9fb84687800163429f161d65" +dependencies = [ + "windows-result 0.1.2", + "windows-targets 0.52.6", +] + [[package]] name = "windows-core" version = "0.61.2" @@ -7462,6 +7499,15 @@ dependencies = [ "windows-strings 0.5.1", ] +[[package]] +name = "windows-result" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e383302e8ec8515204254685643de10811af0ed97ea37210dc26fb0032647f8" +dependencies = [ + "windows-targets 0.52.6", +] + [[package]] name = "windows-result" version = "0.3.4" diff --git a/Cargo.toml b/Cargo.toml index 8bf37f3..89d0357 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,6 +19,7 @@ serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" serde-big-array = "0.5" sha2 = "0.11" +robius-open = { version = "0.1", default-features = false } sdl3-sys = { version = "0.6", features = ["build-from-source-static"] } sdl3-ttf-sys = { version = "0.6", features = ["build-static-vendored", "no-sdlttf-harfbuzz", "no-sdlttf-plutosvg"] } sdl3-image-sys = { version = "0.6", features = ["build-static-vendored"] } @@ -42,7 +43,6 @@ discord-rich-presence = "1.1" slint = { version = "1.16", default-features = false, features = ["compat-1-2", "std", "unstable-winit-030", "backend-winit", "renderer-femtovg-wgpu", "accessibility"], optional = true } rfd = {version = "0.17", optional = true } dirs = "6.0" -open = "5.3" [target.'cfg(target_os = "android")'.dependencies] slint = { version = "1.16", default-features = false, features = ["compat-1-2", "std", "backend-android-activity-06", "accessibility"], optional = true } diff --git a/src/ui/gui.rs b/src/ui/gui.rs index 65ff13e..4751bd6 100644 --- a/src/ui/gui.rs +++ b/src/ui/gui.rs @@ -46,16 +46,12 @@ fn check_latest_version(weak: slint::Weak) { }); } -#[cfg(not(target_os = "android"))] -pub fn open_uri(path: impl AsRef) { - if let Err(e) = open::that_detached(path) { - eprintln!("Error opening path: {}", e); +pub fn open_uri(path: &str) { + if let Err(e) = robius_open::Uri::new(path).open() { + eprintln!("Error opening path: {:?}", e); } } -#[cfg(target_os = "android")] -pub fn open_uri(_path: impl AsRef) {} - fn run_with_path(weak: slint::Weak, path: std::path::PathBuf) { let weak2 = weak.clone(); weak.upgrade_in_event_loop(move |handle| { @@ -137,7 +133,7 @@ fn local_game_window(app: &AppWindow, config: &ui::config::Config) { let saves_path = dirs.data_dir.join("saves"); app.on_saves_folder_button_clicked(move || { - open_uri(&saves_path); + open_uri(saves_path.to_str().unwrap()); }); #[cfg(not(target_os = "android"))] file_dropped(app); diff --git a/src/ui/retroachievements.rs b/src/ui/retroachievements.rs index d383553..a410a56 100644 --- a/src/ui/retroachievements.rs +++ b/src/ui/retroachievements.rs @@ -100,7 +100,7 @@ pub fn ra_window(app: &ui::gui::AppWindow) { }); app.on_ra_show_profile_clicked(move || { - ui::gui::open_uri(format!( + ui::gui::open_uri(&format!( "https://retroachievements.org/user/{}", retroachievements::get_username().unwrap_or_default() ));