From 75093485bde26134b0bf063760f64178b0c49636 Mon Sep 17 00:00:00 2001 From: haex Date: Mon, 10 Nov 2025 02:13:44 +0100 Subject: [PATCH] Add showImage handler stub and mobile file provider foundation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add haextension.fs.showImage handler that delegates to frontend PhotoSwipe - Add mobile.rs with open_file_with_provider command for future Android FileProvider integration - Keep showImage as backwards-compatible no-op since image viewing is now handled client-side 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src-tauri/src/mobile.rs | 33 ++++++++++++++++++++++++++ src/composables/handlers/filesystem.ts | 9 +++++++ 2 files changed, 42 insertions(+) create mode 100644 src-tauri/src/mobile.rs diff --git a/src-tauri/src/mobile.rs b/src-tauri/src/mobile.rs new file mode 100644 index 0000000..f7663a1 --- /dev/null +++ b/src-tauri/src/mobile.rs @@ -0,0 +1,33 @@ +use tauri::command; + +#[command] +pub async fn open_file_with_provider(path: String, mime_type: Option) -> Result<(), String> { + #[cfg(target_os = "android")] + { + open_file_android(path, mime_type).await + } + + #[cfg(not(target_os = "android"))] + { + // On other platforms, use the opener plugin + use tauri_plugin_opener::OpenerExt; + tauri::AppHandle::opener() + .open_path(path, None::<&str>) + .map_err(|e| e.to_string()) + } +} + +#[cfg(target_os = "android")] +async fn open_file_android(path: String, mime_type: Option) -> Result<(), String> { + use jni::{ + objects::{JObject, JString, JValue}, + JNIEnv, + }; + use tauri::Manager; + + // This will be called from the Rust side + // We need to call into the Android Activity to use FileProvider + + // For now, return an error - we need to implement the Java/Kotlin side first + Err("Android FileProvider implementation needed".to_string()) +} diff --git a/src/composables/handlers/filesystem.ts b/src/composables/handlers/filesystem.ts index 7d1d4f1..d453232 100644 --- a/src/composables/handlers/filesystem.ts +++ b/src/composables/handlers/filesystem.ts @@ -44,6 +44,15 @@ export async function handleFilesystemMethodAsync( } } + case 'haextension.fs.showImage': { + // This method is now handled by the frontend using PhotoSwipe + // We keep it for backwards compatibility but it's a no-op + return { + success: true, + useFrontend: true, + } + } + case 'haextension.fs.openFile': { const params = request.params as { data: number[]