Merge branch 'feat/mobile-multi-window' into feat/mobile-file-association

This commit is contained in:
Lucas Nogueira
2025-12-03 13:07:04 -03:00
9 changed files with 111 additions and 14 deletions

22
Cargo.lock generated
View File

@@ -1319,7 +1319,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "117725a109d387c937a1533ce01b450cbde6b88abceea8473c4d7a85853cda3c"
dependencies = [
"lazy_static",
"windows-sys 0.59.0",
"windows-sys 0.52.0",
]
[[package]]
@@ -2348,7 +2348,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d"
dependencies = [
"libc",
"windows-sys 0.59.0",
"windows-sys 0.52.0",
]
[[package]]
@@ -5848,7 +5848,7 @@ dependencies = [
"aes-gcm",
"aes-kw",
"argon2",
"base64 0.22.1",
"base64 0.21.7",
"bitfield",
"block-padding",
"blowfish",
@@ -6428,7 +6428,7 @@ dependencies = [
"once_cell",
"socket2",
"tracing",
"windows-sys 0.59.0",
"windows-sys 0.52.0",
]
[[package]]
@@ -7147,7 +7147,7 @@ dependencies = [
"errno",
"libc",
"linux-raw-sys 0.4.15",
"windows-sys 0.59.0",
"windows-sys 0.52.0",
]
[[package]]
@@ -7160,7 +7160,7 @@ dependencies = [
"errno",
"libc",
"linux-raw-sys 0.9.4",
"windows-sys 0.59.0",
"windows-sys 0.52.0",
]
[[package]]
@@ -8444,7 +8444,7 @@ dependencies = [
[[package]]
name = "tao"
version = "0.34.5"
source = "git+https://github.com/tauri-apps/tao?branch=feat/opened-event-android#036d76ac7e795fd62f814731fd439e23c7489374"
source = "git+https://github.com/tauri-apps/tao?branch=feat/opened-event-android#2268fac61116813c2f8c4b04f30a050b37803c84"
dependencies = [
"bitflags 2.7.0",
"block2 0.6.0",
@@ -8495,7 +8495,7 @@ dependencies = [
[[package]]
name = "tao-macros"
version = "0.1.3"
source = "git+https://github.com/tauri-apps/tao?branch=feat/opened-event-android#036d76ac7e795fd62f814731fd439e23c7489374"
source = "git+https://github.com/tauri-apps/tao?branch=feat/opened-event-android#2268fac61116813c2f8c4b04f30a050b37803c84"
dependencies = [
"proc-macro2",
"quote",
@@ -9042,7 +9042,7 @@ dependencies = [
"getrandom 0.2.15",
"once_cell",
"rustix 0.38.43",
"windows-sys 0.59.0",
"windows-sys 0.52.0",
]
[[package]]
@@ -10358,7 +10358,7 @@ version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
dependencies = [
"windows-sys 0.59.0",
"windows-sys 0.52.0",
]
[[package]]
@@ -10991,7 +10991,7 @@ checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51"
[[package]]
name = "wry"
version = "0.53.5"
source = "git+https://github.com/tauri-apps/wry?branch=feat/android-on-new-intent#435ca59b9eabe094bb8b40c28d583e989aa896d6"
source = "git+https://github.com/tauri-apps/wry?branch=feat/android-on-new-intent#25cfa68f8e80ed51eb4cbd664da64a1c51c32a45"
dependencies = [
"base64 0.22.1",
"block2 0.6.0",

View File

@@ -152,7 +152,8 @@ pub fn generate_gradle_files(project_dir: PathBuf) -> Result<()> {
"// THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.\n".to_string();
let mut app_build_gradle = "// THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
val implementation by configurations
dependencies {"
dependencies {
implementation(\"androidx.lifecycle:lifecycle-process:2.10.0\")"
.to_string();
for (env, value) in std::env::vars_os() {

View File

@@ -68,6 +68,7 @@ dependencies {
implementation("androidx.appcompat:appcompat:1.7.1")
implementation("androidx.activity:activity-ktx:1.10.1")
implementation("com.google.android.material:material:1.12.0")
implementation("androidx.lifecycle:lifecycle-process:2.10.0")
testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.1.4")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.0")

View File

@@ -168,6 +168,7 @@ const PLUGINS: &[(&str, &[(&str, bool)])] = &[
("bundle_type", true),
("register_listener", true),
("remove_listener", true),
("supports_multiple_windows", true),
],
),
(

View File

@@ -11,6 +11,7 @@ Default permissions for the plugin.
- `allow-bundle-type`
- `allow-register-listener`
- `allow-remove-listener`
- `allow-supports-multiple-windows`
## Permission Table
@@ -336,6 +337,32 @@ Denies the set_dock_visibility command without any pre-configured scope.
<tr>
<td>
`core:app:allow-supports-multiple-windows`
</td>
<td>
Enables the supports_multiple_windows command without any pre-configured scope.
</td>
</tr>
<tr>
<td>
`core:app:deny-supports-multiple-windows`
</td>
<td>
Denies the supports_multiple_windows command without any pre-configured scope.
</td>
</tr>
<tr>
<td>
`core:app:allow-tauri-version`
</td>

File diff suppressed because one or more lines are too long

View File

@@ -651,6 +651,18 @@ impl<R: Runtime> AppHandle<R> {
pub fn set_device_event_filter(&self, filter: DeviceEventFilter) {
self.runtime_handle.set_device_event_filter(filter);
}
/// Whether the application supports multiple windows.
#[cfg(target_os = "ios")]
pub fn supports_multiple_windows(&self) -> bool {
let (tx, rx) = std::sync::mpsc::channel();
self.run_on_main_thread(move || unsafe {
let mtm = objc2::MainThreadMarker::new().unwrap();
let ui_application = objc2_ui_kit::UIApplication::sharedApplication(mtm);
tx.send(ui_application.supportsMultipleScenes()).unwrap();
});
rx.recv().unwrap()
}
}
impl<R: Runtime> Manager<R> for AppHandle<R> {
@@ -1084,6 +1096,40 @@ macro_rules! shared_app_impl {
pub fn invoke_key(&self) -> &str {
self.manager.invoke_key()
}
/// Whether the application supports multiple windows.
#[cfg(desktop)]
pub fn supports_multiple_windows(&self) -> bool {
true
}
/// Whether the application supports multiple windows.
#[cfg(target_os = "android")]
pub fn supports_multiple_windows(&self) -> bool {
let runtime_handle = match self.runtime() {
RuntimeOrDispatch::Runtime(runtime) => runtime.handle(),
RuntimeOrDispatch::RuntimeHandle(handle) => handle,
_ => unreachable!(),
};
let (tx, rx) = std::sync::mpsc::channel();
runtime_handle.run_on_android_context(move |env, _activity, _webview| {
let supports = (|| {
let version_class = env.find_class("android/os/Build$VERSION")?;
let sdk = env
.get_static_field(version_class, "SDK_INT", "I")?
.i()
.unwrap_or_default();
crate::Result::Ok(sdk >= 32)
})()
.unwrap_or(false);
let _ = tx.send(supports);
});
rx.recv().unwrap_or(false)
}
}
impl<R: Runtime> Listener<R> for $app {
@@ -1183,6 +1229,16 @@ impl<R: Runtime> App<R> {
&self.handle
}
/// Whether the application supports multiple windows.
#[cfg(target_os = "ios")]
pub fn supports_multiple_windows(&self) -> bool {
unsafe {
let mtm = objc2::MainThreadMarker::new().unwrap();
let ui_application = objc2_ui_kit::UIApplication::sharedApplication(mtm);
ui_application.supportsMultipleScenes()
}
}
/// Sets the activation policy for the application. It is set to `NSApplicationActivationPolicyRegular` by default.
///
/// # Examples

View File

@@ -115,6 +115,11 @@ pub fn bundle_type() -> Option<BundleType> {
tauri_utils::platform::bundle_type()
}
#[command(root = "crate")]
pub fn supports_multiple_windows<R: Runtime>(app: AppHandle<R>) -> bool {
app.supports_multiple_windows()
}
pub fn init<R: Runtime>() -> TauriPlugin<R> {
Builder::new("app")
.invoke_handler(crate::generate_handler![
@@ -131,6 +136,7 @@ pub fn init<R: Runtime>() -> TauriPlugin<R> {
set_app_theme,
set_dock_visibility,
bundle_type,
supports_multiple_windows,
])
.setup(|_app, _api| {
#[cfg(target_os = "android")]

View File

@@ -274,6 +274,10 @@ async function onBackButtonPress(
)
}
async function supportsMultipleWindows(): Promise<boolean> {
return invoke('plugin:app|supports_multiple_windows')
}
export {
getName,
getVersion,
@@ -288,5 +292,6 @@ export {
setDockVisibility,
getBundleType,
type OnBackButtonPressPayload,
onBackButtonPress
onBackButtonPress,
supportsMultipleWindows
}