Skip to content

Commit

Permalink
feat: also use opener plugin on android (#619)
Browse files Browse the repository at this point in the history
  • Loading branch information
hrzlgnm authored Dec 15, 2024
1 parent f06f06b commit c8e52fb
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ tauri-build = { version = "2.0.0", features = [] }
[target."cfg(not(any(target_os = \"android\", target_os = \"ios\")))".dependencies]
clap = { version = "4.5.19", features = ["derive"] }
tauri-plugin-log = "2.0.0"
tauri-plugin-opener = "2.2.0"
tauri-plugin-updater = "2.0.1"
thiserror = "2.0.0"
tokio = "1.40.0"
Expand All @@ -24,6 +23,7 @@ serde = { version = "1.0.210", features = ["derive"] }
serde_json = "1.0.128"
tauri = { version = "2.0.0", features = [] }
tauri-plugin-clipboard-manager = "2.0.0"
tauri-plugin-opener = "2.2.0"

# local
models = { path = "../models" }
Expand Down
3 changes: 2 additions & 1 deletion src-tauri/capabilities/mobile.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
],
"permissions": [
"core:default",
"clipboard-manager:allow-write-text"
"clipboard-manager:allow-write-text",
"opener:allow-open-url"
],
"platforms": [
"android"
Expand Down
8 changes: 3 additions & 5 deletions src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,9 @@ use std::{
net::IpAddr,
sync::{Arc, Mutex},
};
#[cfg(desktop)]
use tauri::AppHandle;
use tauri::Emitter;
use tauri::{Manager, State, Window};
use tauri::{AppHandle, Manager, State, Window};
use tauri_plugin_clipboard_manager::ClipboardExt;
#[cfg(desktop)]
use tauri_plugin_opener::OpenerExt;

#[cfg(desktop)]
Expand Down Expand Up @@ -232,7 +229,6 @@ fn send_metrics(window: Window, state: State<ManagedState>) {
}
}

#[cfg(desktop)]
#[tauri::command]
fn open_url(app: AppHandle, url: String) {
let opener = app.opener();
Expand Down Expand Up @@ -503,13 +499,15 @@ pub fn run() {
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run_mobile() {
tauri::Builder::default()
.plugin(tauri_plugin_opener::init())
.plugin(tauri_plugin_clipboard_manager::init())
.manage(ManagedState::new())
.invoke_handler(tauri::generate_handler![
browse_many,
browse_types,
copy_to_clipboard,
is_desktop,
open_url,
send_metrics,
stop_browse,
verify,
Expand Down

0 comments on commit c8e52fb

Please sign in to comment.