fix: open external links on android in system browser

This commit is contained in:
lunar-seal committed 2026-07-24 22:18:23 +02:00
1 parent 4d63acde4b
commit 0a6503c1a4
3 files changed
+29 -5

No files matched your search

@@ -1,5 +0,0 @@
---
default: patch
---
tauri: use external browser to follow homeserver url in profile chip
+5
View File
@@ -0,0 +1,5 @@
---
default: patch
---
tauri: make sure external links open in separate browser, instead of replacing the app
+24
View File
@@ -141,6 +141,30 @@ pub fn show_or_create_main_window(app: &AppHandle<crate::BrowserEngine>) -> taur
.use_https_scheme(true)
.background_color(tauri::window::Color(0x1A, 0x1C, 0x28, 0xFF));
// Only android: intercept navigation to external URLs and open them in the system browser
// Other platforms: might need other URI schemes, and on_navigation might get called on iframe urls
// (as of now, the following is confirmed not to work with linux/webkit2gtk)
#[cfg(target_os = "android")]
let builder = {
let nav_handle = app.clone();
builder.on_navigation(move |url| {
let internal = url.scheme() == "tauri"
|| url.host_str() == Some("tauri.localhost")
|| (cfg!(dev) && url.host_str() == Some("localhost"));
if !internal {
// open in new thread
// open_url blocks on the ui thread but we are on the ui thread...
let handle = nav_handle.clone();
let url = url.to_string();
std::thread::spawn(move || {
use tauri_plugin_opener::OpenerExt;
let _ = handle.opener().open_url(url, None::<&str>);
});
}
internal
})
};
#[cfg(desktop)]
let title = main_window_title(app);