diff --git a/CHANGELOG.md b/CHANGELOG.md index 115e6af4b..9495cb849 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Unreleased +* Implement Android suspend/resume cycle using the existing "respawn" API. * Add `APP.is_suspended` var. * Add `VIEW_PROCESS_SUSPENDED_EVENT`. * `VIEW_PROCESS_INITED_EVENT` now notifies a "respawn" on resume after suspension. diff --git a/crates/cargo-zng/README.md b/crates/cargo-zng/README.md index ebbd676f3..bd81fd75a 100644 --- a/crates/cargo-zng/README.md +++ b/crates/cargo-zng/README.md @@ -478,6 +478,9 @@ $ cargo zng res --tools .zr-fail @ cargo-zng Print an error message and fail the build +.zr-apk @ cargo-zng + Build an Android APK from the parent folder + call 'cargo zng res --help tool' to read full help from a tool ``` diff --git a/crates/zng-app/README.md b/crates/zng-app/README.md index 0e7445350..6f7853bff 100644 --- a/crates/zng-app/README.md +++ b/crates/zng-app/README.md @@ -52,7 +52,7 @@ Note that this can cause very large trace files and bad performance. #### `"crash_handler"` Allow app-process crash handler. -Only enabled in `cfg(not(target_arch = "wasm32"))` builds. +Only enables in `not(any(target_arch = "wasm32", target_os = "android"))` builds. #### `"ipc"` Enables IPC tasks and pre-build views and connecting to views running in another process. diff --git a/crates/zng-task/README.md b/crates/zng-task/README.md index ce2a1895c..dd6ff46ca 100644 --- a/crates/zng-task/README.md +++ b/crates/zng-task/README.md @@ -13,7 +13,7 @@ Enables parking_lot deadlock detection. #### `"ipc"` Enables ipc tasks. -Only enabled in `cfg(not(target_arch = "wasm32"))` builds. +Only enables in `cfg(not(any(target_os = "android", target_arch = "wasm32")))` builds. #### `"http"` Enables http tasks. diff --git a/crates/zng-view-api/README.md b/crates/zng-view-api/README.md index a90778670..13c3c0ed3 100644 --- a/crates/zng-view-api/README.md +++ b/crates/zng-view-api/README.md @@ -10,8 +10,7 @@ This crate provides 2 feature flags, 1 enabled by default. #### `"ipc"` Enables creation of separate or pre-build view. -When this is enabled communication with the view is (de)serialized which can add a -minor cost, something like a 1ms per 3MB frame request. +Only enables in `cfg(not(any(target_os = "android", target_arch = "wasm32")))` builds. *Enabled by default.* diff --git a/crates/zng-view/README.md b/crates/zng-view/README.md index 882b391b2..a6cab5c3f 100644 --- a/crates/zng-view/README.md +++ b/crates/zng-view/README.md @@ -5,7 +5,7 @@ This crate is part of the [`zng`](https://github.com/zng-ui/zng?tab=readme-ov-fi ## Cargo Features -This crate provides 3 feature flags, 2 enabled by default. +This crate provides 5 feature flags, 2 enabled by default. #### `"ipc"` Enables pre-build and init as view-process. @@ -13,6 +13,8 @@ Enables pre-build and init as view-process. If this is enabled all communication with the view is serialized/deserialized, even in same-process mode. +Only enables in `cfg(not(target_os = "android"))` builds. + *Enabled by default.* #### `"software"` @@ -29,6 +31,16 @@ Needs `cargo-about` and Internet connection during build. Not enabled by default. Note that `"view_prebuilt"` always bundles licenses. +#### `"android_game_activity"` +Standard Android backend that requires a build system that can compile Java or Kotlin and fetch Android dependencies. + +See `https://docs.rs/winit/latest/winit/platform/android/` for more details. + +#### `"android_native_activity"` +Basic Android backend that does not require Java. + +See `https://docs.rs/winit/latest/winit/platform/android/` for more details. + diff --git a/crates/zng-view/src/window.rs b/crates/zng-view/src/window.rs index d117e6d41..48f7a9b44 100644 --- a/crates/zng-view/src/window.rs +++ b/crates/zng-view/src/window.rs @@ -1727,7 +1727,6 @@ impl Window { #[cfg(target_os = "android")] pub(crate) fn message_dialog(&self, dialog: dlg_api::MsgDialog, id: dlg_api::DialogId, event_sender: AppEventSender) { - // !!: TODO let _ = dialog; let _ = event_sender.send(AppEvent::Notify(Event::MsgDialogResponse( id, @@ -1785,7 +1784,6 @@ impl Window { #[cfg(target_os = "android")] pub(crate) fn file_dialog(&self, dialog: dlg_api::FileDialog, id: dlg_api::DialogId, event_sender: AppEventSender) { - // !!: TODO let _ = dialog; let _ = event_sender.send(AppEvent::Notify(Event::MsgDialogResponse( id, diff --git a/crates/zng-wgt-inspector/README.md b/crates/zng-wgt-inspector/README.md index 764dc34fa..06c860e9e 100644 --- a/crates/zng-wgt-inspector/README.md +++ b/crates/zng-wgt-inspector/README.md @@ -18,6 +18,8 @@ Compiles the interactive inspector. #### `"crash_handler"` Compiles the debug crash handler. +Only enables in `not(any(target_arch = "wasm32", target_os = "android"))` builds. + diff --git a/crates/zng/README.md b/crates/zng/README.md index 082cb544c..74a7d8ff3 100644 --- a/crates/zng/README.md +++ b/crates/zng/README.md @@ -60,17 +60,17 @@ The example above installs `cargo-zng` and uses it to generate a new './my-app' ## Cargo Features -This crate provides 29 feature flags, 4 enabled by default. +This crate provides 31 feature flags, 4 enabled by default. #### `"view"` Include the default view-process implementation. -Only enabled in `cfg(not(target_arch = "wasm32"))` builds. +Only enables in `not(target_arch = "wasm32")` builds. #### `"view_prebuilt"` Include the default view-process implementation as an embedded precompiled binary. -Only enabled in `cfg(not(target_arch = "wasm32"))` builds. +Only enables in `not(any(target_arch = "wasm32", target_os = "android"))` builds. #### `"http"` Enables HTTP tasks and web features of widgets and services. @@ -94,6 +94,8 @@ Enable hot reload builds. Note that you must configure the target library to hot reload, see `zng::hot_reload` for details. +Only enables in `not(any(target_arch = "wasm32", target_os = "android"))` builds. + #### `"dyn_app_extension"` Use dynamic dispatch at the app-extension level. @@ -122,12 +124,14 @@ Enables single app-process instance mode. Builds with this feature only allow one app-process, subsequent attempts to spawn the app redirect to the running app-process. +Only enables in `not(any(target_arch = "wasm32", target_os = "android"))` builds. + #### `"crash_handler"` Allow app-process crash handler. Builds with this feature spawn a crash monitor-process for each app-process. -Only enabled in `cfg(not(target_arch = "wasm32"))` builds. +Only enables in `not(any(target_arch = "wasm32", target_os = "android"))` builds. *Enabled by default.* @@ -191,7 +195,7 @@ Not enabled by default. Note that `"view_prebuilt"` always bundles licenses. #### `"ipc"` Enables IPC tasks, pre-build views and connecting to views running in another process. -Only enabled in `cfg(not(target_arch = "wasm32"))` builds. +Only enables in `not(any(target_os = "android", target_arch = "wasm32"))` builds. *Enabled by default.* @@ -200,6 +204,16 @@ Check if `zng::env::res` path is available in `init_built_res` first. Enabled by default in debug builds. +#### `"android_game_activity"` +Standard Android backend that requires a build system that can compile Java or Kotlin and fetch Android dependencies. + +See `https://docs.rs/winit/latest/winit/platform/android/` for more details. + +#### `"android_native_activity"` +Basic Android backend that does not require Java. + +See `https://docs.rs/winit/latest/winit/platform/android/` for more details. + ## Repository diff --git a/examples/README.md b/examples/README.md index f4edb562e..c2516741a 100644 --- a/examples/README.md +++ b/examples/README.md @@ -204,6 +204,27 @@ cargo do run markdown Demonstrates the `Markdown!` widget. +### `multi` + +multi screenshot + +Source: [multi/src](./multi/src) + +```console +cargo do run multi +``` + +Demonstrates a web, mobile and desktop app setup. + +Use `cargo do run multi` to run on the desktop. + +Use `cargo do build-apk multi` to build a package and Android Studio "Profile or Debug APK" to run on a device. + +Use `cargo do run-wasm multi` to run on the browser. + +Note that web support is very limited, only a small subset of services are supported and +only headless (without renderer) apps can run. + ### `respawn` respawn screenshot @@ -264,20 +285,6 @@ cargo do run transform Demonstrates 2D and 3D transforms, touch transforms. -### `web` - -Source: [web/src](./web/src) - -```console -cargo do run web -``` - -Demonstrates a hybrid web and desktop app setup. - -Note that only a small subset of services are supported and only headless (without renderer) apps can run. - -Use `cargo do run-wasm web` to run on the browser and `cargo do run web` to run standalone. - ### `window` window screenshot diff --git a/examples/multi/res/screenshot.png b/examples/multi/res/screenshot.png new file mode 100644 index 000000000..e266ed5e6 Binary files /dev/null and b/examples/multi/res/screenshot.png differ diff --git a/examples/multi/src/main.rs b/examples/multi/src/main.rs index d91f7b809..fa1f98b20 100644 --- a/examples/multi/src/main.rs +++ b/examples/multi/src/main.rs @@ -1,13 +1,13 @@ //! Demonstrates a web, mobile and desktop app setup. //! -//! Note that web support is very limited, only a small subset of services are supported and -//! only headless (without renderer) apps can run. -//! //! Use `cargo do run multi` to run on the desktop. //! +//! Use `cargo do build-apk multi` to build a package and Android Studio "Profile or Debug APK" to run on a device. +//! //! Use `cargo do run-wasm multi` to run on the browser. //! -//! Use `cargo do build-apk multi` to build a package and Android Studio "Profile or Debug APK" to run on a device. +//! Note that web support is very limited, only a small subset of services are supported and +//! only headless (without renderer) apps can run. mod app;