Commit Graph

318 Commits

Author SHA1 Message Date
Alex Touchet 4e93184d8b Update Readme links 2026-02-18 03:07:36 +00:00
Alex Touchet 31feb32f07 Update MSRV badge in Readme 2026-02-17 23:54:39 +00:00
Robert Bragg 25f4220fef Bump MSRV to 1.85.0 (will be required by jni 0.22)
This re-generates the FFI bindings with `--rust-target '1.85.0'`
2026-02-17 22:19:08 +00:00
Robert Bragg 7e8990fd92 Add support for InputEvent::TextAction events
This exposes IME actions via an InputEvent::TextAction event so that
it's possible to recognise when text entry via an input method is
finished.

This adds a `TextInputAction` enum to represent the action key on a soft
keyboard, such as "Done".

For example, this makes it possible to emit Ime::Commit events in Winit.
2026-02-17 21:58:59 +00:00
Robert Bragg fe2c50ccc6 game-activty: ignore APP_CMD_SOFTWARE_KB_VIS_CHANGED w/o panic
APP_CMD_SOFTWARE_KB_VIS_CHANGED in the GameActivity backend is
intended for notifying the android_main thread that the soft keyboard
visibility has changed.

There's currently no Rust event / API for this, and so it wasn't being
handled in poll_events but that was leading to a unreachable panic when
GameActivity would send this APP_CMD when showing soft keyboards.

We don't currently plan to expose any public API / event for this since
it's based on monitoring IME insets and applications should instead be able
to check insets after getting InsetsChanged events.

For the sake of minimizing patches to the upstream GameActivity code
this makes it so poll_events can ignore this APP_CMD as a NOOP.
2026-02-17 21:46:27 +00:00
Robert Bragg a20a7e4ee4 Import android-games-sdk changes for 4.0.0
This imports the SDK from commit 8fa58b0e145ec28e726fa2b1c7e7a52af925ca35, from:
https://github.com/rust-mobile/android-games-sdk/commits/android-activity-4.0.0

This includes one "notify android_main of editor actions" patch which will make
it possible to forward editor actions and support IME Commit events in Winit)

# notify android_main of editor actions

This adds a pendingEditorActions member to android_app that is set via
onEditorAction and the android_main thread is notified via notifyInput
instead of re-instating APP_CMD_EDITOR_ACTION.

The idea is that the android_main thread should check for
android_app->pendingEditorActions whenever input events are polled/iterated.

# FFI bindings update

Also updates the FFI bindings via generate-bindings.sh
2026-02-17 21:45:22 +00:00
Marijn Suijten 0b0e19ed44 Revert "input: Replace open-coded types with ndk::event definitions (#163)"
This reverts commit 51d05d48c8 for
backwards compatibility with the existing `0.6` releases.

For now, it's creating a lot of busy work having to always make this
revert in order to test various topic branch changes with winit 0.30.

Lets save this breaking change until we have more reasons to break
semver compatibility (in itself this doesn't fix or enable any features,
so we can live without it for now).
2026-02-17 21:43:52 +00:00
Mads Marquart e686e80112 Allow building as dependency on docs.rs with no features enabled 2026-01-07 16:51:08 +00:00
Mads Marquart b9e883866e Clean up gitignores 2026-01-07 16:51:08 +00:00
Marijn Suijten 9e8c85c647 Assert that the thread Looper matches the main one 2025-12-18 15:26:24 +00:00
Marijn Suijten a97cf1ceae native_activity: Only wait for state to update while main thread is running
We see that some Android callbacks like `onStart()` deadlock,
specifically when returning out of the main thread before running
any event loop (but likely also whenever terminating the event loop),
because they don't check if the thread is still even running and are
otherwise guaranteed receive an `activity_state` update or other state
change to unblock themselves.

This is a followup to [#94] which only concerned itself with a deadlock
caused by a destructor not running because that very object was kept
alive to poll on the `destroyed` field that destructor was supposed to
set, but its new `thread_state` can be reused to disable these condvar
waits when the "sending" thread has disappeared.

Separately, that PR mentions `Activity` recreates because of
configuration changes which isn't supported anyway because `Activity` is
still wrongly assumed to be a global singleton.

[#94]: https://togithub.com/rust-mobile/android-activity/pull/94
2025-12-18 15:26:24 +00:00
daxpedda 1652ebb229 Add package.include to Cargo.toml
This reduces package size and notably prevents any bash files from landing on a users device.
2025-08-11 13:23:54 +01:00
Robert Bragg b943f58863 Merge pull request #184 from rust-mobile/doctest
Build-test documentation and fix broken doc samples
2025-08-11 13:15:57 +01:00
Marijn Suijten 019ad634a2 Switch doctests back to native cross-compilation, supported since Rust 1.89
https://blog.rust-lang.org/2025/08/07/Rust-1.89.0/#cross-compiled-doctests
2025-08-11 13:57:02 +02:00
Marijn Suijten 87cda3c560 Build-test (documentation) on the host and fix broken doc samples 2025-08-11 13:57:02 +02:00
Robert Bragg bde1cb3436 Merge pull request #191 from jb55/agdk-submodule
Update to GameActivity 4.0.0
2025-08-11 11:57:45 +01:00
Robert Bragg 69f3642499 Update android-games-sdk/README.md
Update the notes on how to update to new GameActivity releases
2025-04-04 16:41:26 +01:00
Robert Bragg c0f3fa6754 Check $ANDROID_GAMES_SDK for GameActivity source
For convenience, when updating to new GameActivity versions, this makes
it possible to build against the out-of-tree `android-games-sdk` repo.

This also updates `generate-bindings.sh` to point at $ANDROID_GAMES_SDK
if set.

E.g.

```
git clone git@github.com:rust-mobile/android-games-sdk.git \
    --branch android-activity-4.0.0
export ANDROID_GAMES_SDK=$PWD/android-games-sdk

./generate-bindings.sh
cargo build --features=game-activity --target=aarch64-linux-android
```
2025-04-01 15:41:51 +01:00
Robert Bragg 42af0cccfa examples/agdk-mainloop: pull in games-activity:4.0.0 2025-04-01 15:41:51 +01:00
Robert Bragg 5d7616e30e examples/agdk-mainloop: Use Gradle 8.4 (compatible with Java 21) 2025-04-01 15:41:51 +01:00
Robert Bragg 3755ed7e7a game-activity: build fixes for rust-bindgen 0.71 ffi API 2025-04-01 15:41:51 +01:00
Robert Bragg 5367c865e3 Re-generate bindings with rust-bindgen 0.71.1 2025-04-01 15:41:51 +01:00
William Casarin eacddd744a bindgen: update paths
Signed-off-by: William Casarin <jb55@jb55.com>
2025-04-01 15:41:51 +01:00
Robert Bragg 36832feacf Add import-games-sdk.sh and import some APP_CMD_ changes for 4.0.0
This replaces `copy-files` + `file_list.txt` (subjective simplification)

This imports the SDK from commit 1b544f896646b29e798c5be0a151a488906797f7, from:
https://github.com/rust-mobile/android-games-sdk/commits/android-activity-4.0.0
2025-04-01 15:41:51 +01:00
Robert Bragg 88714f0b6a Add CHANGELOG.md entry for GameActivity bump to 4.0.0 2025-04-01 15:41:49 +01:00
William Casarin 85eb7274f4 android-game-sdk-rs: bump v2.0.2 -> v4.0.0
Signed-off-by: William Casarin <jb55@jb55.com>
2025-04-01 15:41:33 +01:00
William Casarin 49f2b86424 switch to android-game-sdk-rs grafted repo at v2.0.2
Also includes our patches on top (branch android-activity-2.0.2). This
is mainly to test to make sure everything is still working. We will
switch to the android-activity-4.0.0 branch when we're done

Signed-off-by: William Casarin <jb55@jb55.com>
2025-04-01 15:41:33 +01:00
William Casarin 976e9d06af tree: remove local copy of v2.0.2 android-games-sdk
We are going to use a submodule so that it is easier to track and rebase
our local changes onto new versions of android-games-sdk

Signed-off-by: William Casarin <jb55@jb55.com>
2025-04-01 15:41:33 +01:00
Robert Bragg ac2e17e977 Re-export 'ndk' and 'ndk_sys' crates
Since we expose `ndk` types in the public API it makes sense to
re-export these APIs so users of android-activity can defer to these
without needing to manually sync the versions for explicit dependencies.
2025-04-01 15:38:44 +01:00
Robert Bragg db3ea3386f Bump rust-version to 1.73.0
There was a fix for the definition of the `stat` struct on Android in
1.73, and even though it's unlikely to affect many applications it still
seems worthwhile to draw a line under this and ensure that all
android-activity based applications will have that fix.

Rust 1.73 was released October 2023, which is still well over a year old
and very conservative.

This updates `generate-bindings.sh` to pass `--rust-target 1.73.0` so we
avoid generating bindings that require a more recent compiler.

(This doesn't actually regenerate the bindings but does ensure that
future updates will be constrained to generate code that is backwards
compatible with 1.73.)
2025-04-01 15:29:59 +01:00
Marijn Suijten 51d05d48c8 input: Replace open-coded types with ndk::event definitions (#163) 2025-01-27 18:12:06 +01:00
Marijn Suijten fe171bc532 Fix various codebase rots (stale CI, new Rust lints, broken MSRV checks by transitive dependency upgrades) (#164)
* game_activity/ffi: Drop cfg for inexistant `target_arch = "armv7"`

[Rust 1.80 from July 25th 2024] points out that `armv7` is not a known,
valid value for the `target_arch` cfg variable.  This is confirmed by
the docs not listing it either:
https://doc.rust-lang.org/reference/conditional-compilation.html#target_arch

Hence drop this entirely, and rely purely on `target_arch = "arm"`.

[Rust 1.80 from July 25th 2024]: https://blog.rust-lang.org/2024/07/25/Rust-1.80.0.html

* Fix `unexpected-cfgs` by adding `api-level-30` feature and removing `test`

Some code copied from the NDK carried over the respective `feature`
`cfg` guards, without ever adding the feature to the `[features]` list
in `Cargo.toml`.  Now that Rust detects these mishaps, we can fix it
by removing `test` (bindings don't seem to be run-tested) and reexpose
`ConfigurationRef::screen_round()` which was behind a previously
unsettable `feature = "api-level-30"`.

Also remove `unsafe impl Send/Sync for ConfigurationRef` since the
upstream `ndk` already declares `Configuration` to be `Send` and `Sync`,
and `RwLock` and `Arc` carry that through.

* native_activity: Fix clippy lints around `NativeActivityGlue` not `SendSync` and unwritten `redraw_needed` field

* CI: Remove deprecated/unmaintained `actions-rs` toolchain setup

The `actions-rs` containers haven't been maintained and updated for
years and don't need to: GitHub's actions environment already comes
fully loaded with a complete `stable` Rust installation with the
standard tools (in this case `rustfmt`).  Remove the remaining toolchain
setup (which was already replaced with `hecrj/setup-rust-action`
elsewhere) to get rid of ancient Node 12 deprecation warnings.

* Bump dependency patch-versions to fix `-Zminimal-versions` and MSRV check

Use `-Zminimal-versions` in our MSRV check.  This not only ensures
our minimum version bounds are actually solid and tested (even if
they may be a bit conservative at times, i.e. we could allow older
versions except for the crates that are bumped in this patch which were
explicitly build-tested), it also allows us to use this as a base for
the MSRV test, and preempt us from failing it whenever a (transitive!)
dependency bumps its MSRV beyond ours in a *semver-compatible* release.

* Elide redundant `impl` block lifetimes following stricter Rust 1.83 lint

Rust now points out that `impl<'a> (Trait for) Struct<'a>` is
superfluous whenever `'a` is not used anywhere else in the `impl` block.
2025-01-27 17:14:13 +01:00
Robert Bragg 0d299300f4 Merge pull request #158 from rust-mobile/release-0.6.0
Release 0.6.0
v0.6.0
2024-04-26 17:23:04 +01:00
Robert Bragg 0a87a84c57 Release 0.6.0 2024-04-26 17:16:38 +01:00
SkyGrel19 7bd3ba6dde native-activity: Check for null saved_state_in pointer
Avoids calling `std::slice::from_raw_parts` with a null `saved_state_in`
pointer.

Fixes: #153
2024-04-26 16:37:42 +01:00
Marijn Suijten 6a0197c28f Upgrade to ndk-sys 0.6.0 and ndk 0.9.0
The next breaking `ndk` release puts a lot of emphasis in improving
`enum`s to finally be marked `non_exhaustive`, and carry possible future
values in `__Unknown(i32)` variants.  This removes the lossy conversions
that previously required `android-activity` to redefine its types, which
could all be removed again.

The `repr()` types have also been updated, as `enum` constants in C are
translated to `u32` by default in `bindgen` even though they're commonly
passed as `int` to every API function that consumes them.
2024-04-26 16:36:38 +01:00
Robert Bragg e5b8242ff2 Bump MSRV to 1.69.0 considering we can't build cargo ndk with 1.68
cargo ndk will fail to build with 1.68 due to a toml_edit dep.

Technically android-activity itself should still build with 1.68
but it's simpler to synchronize the `rust-version` with the minimum
version that we actually test in CI (where we need to build cargo ndk)
2024-04-26 16:11:36 +01:00
Robert Bragg c9faa9c44e Merge pull request #151 from rust-mobile/release-0.5.2
Release 0.5.2
v0.5.2
2024-01-30 13:09:08 +00:00
Robert Bragg 4b9b8d754b Force cargo-ndk to only be built with stable toolchain
This fixes CI builds with rust 0.68 because cargo ndk depends on
cargo platform which depends on 0.70.
2024-01-30 12:42:36 +00:00
Robert Bragg 526d39c1f3 Release 0.5.2 2024-01-30 12:15:21 +00:00
Robert Bragg 4ffa3ac2e1 Merge pull request #147 from ArthurCose/motion-event-mask
native-activity/input: OR with `EVENT_ACTION_MASK` when extracting action
2024-01-30 12:05:30 +00:00
Robert Bragg 967882f3d9 Merge pull request #149 from rust-mobile/release-0.5.1
Release 0.5.1
v0.5.1
2023-12-20 22:11:18 +00:00
Robert Bragg 35e080baf0 Release 0.5.1 2023-12-20 22:03:15 +00:00
Robert Bragg 5cb67a2b89 Remove ndk dev-dependency added in #142
Although this crate has some examples that depend on the ndk, they
aren't regular Cargo examples, they are completely standalone apps
that depend on dev-dependencies.
2023-12-20 17:12:25 +00:00
Arthur Cosentino 672360c5e6 Fix multitouch MotionActions processing as unknown in native activities 2023-12-13 09:05:59 -05:00
Robert Bragg 9fce890219 Merge pull request #143 from rust-mobile/readme-update-versions
README: Update crate version in `Cargo.toml` example
2023-11-20 16:13:38 +00:00
Robert Bragg 2deec162b5 Merge pull request #145 from fornwall/android-main-thread-name
Name spawned threads
2023-11-20 16:10:27 +00:00
Fredrik Fornwall eeeb80209f Fix error after merge conflict 2023-11-20 15:36:04 +01:00
Fredrik Fornwall 6c3583dc24 Merge branch 'main' into android-main-thread-name 2023-11-20 14:35:37 +01:00
Robert Bragg bfd8bfd04c Merge pull request #133 from rust-mobile/marijn/bail-log-thread-on-read_line-error
Stop log-forwarding thread on IO errors
2023-11-20 13:24:23 +00:00