Releases: rust-mobile/android-activity
v0.6.0
What's Changed
- Bump MSRV to 1.69.0 considering we can't build cargo ndk with 1.68 by @rib in #156
- Upgrade to
ndk-sys 0.6.0
andndk 0.9.0
by @MarijnS95 in #155 - native-activity: Check for null
saved_state_in
pointer by @skibon02 in #157 - Release 0.6.0 by @rib in #158
New Contributors
Full Changelog: v0.5.2...v0.6.0
android-activity 0.5.2
What's Changed
- native-activity/input: AND with
EVENT_ACTION_MASK
when extracting MotionEvent action by @ArthurCose in #147
New Contributors
- @ArthurCose made their first contribution in #147
Full Changelog: v0.5.1...v0.5.2
android-activity 0.5.1
Changed
-
Avoids depending on default features for
ndk
crate to avoid pulling in anyraw-window-handle
dependencies (#142)Note: Technically, this could be observed as a breaking change in case you were depending on the
rwh_06
feature that was enabled by default in thendk
crate. This could be observed via theNativeWindow
type (exposed viaAndroidApp::native_window()
) no longer implementingrwh_06::HasWindowHandle
.In the unlikely case that you were depending on the
ndk
'srwh_06
API being enabled by default viaandroid-activity
'sndk
dependency, your crate should explicitly enable therwh_06
feature for thendk
crate.As far as could be seen though, it's not expected that anything was depending on this (e.g. anything based on Winit enables the
ndk
feature based on an equivalentwinit
feature).The benefit of the change is that it can help avoid a redundant
raw-window-handle 0.6
dependency in projects that still need to use older (non-default)raw-window-handle
versions. (Though note that this may be awkward to achieve in practice since other crates that depend on thendk
are still likely to use default features and also pull inraw-window-handles 0.6
) -
The IO thread now gets named
stdio-to-logcat
and main thread is namedandroid_main
(#145) -
Improved IO error handling in
stdio-to-logcat
IO loop. (#133)
New Contributors
Full Changelog: v0.5.0...v0.5.1
android-activity 0.5.0
Probably the most notable (breaking) change in this release is the updated API for reading input events to better support being able to use other AndroidApp
APIs while iterating input events, to support unicode character mapping for Keycodes
.
The other big change with this release is the update of the game-activity
backend, updating to GameActivity 2.0.2. Applications using the game-activity
backend will need to ensure they pull in the corresponding 2.0.2 .aar
from Google (For example, see https://github.com/rust-mobile/android-activity/blob/main/examples/agdk-mainloop/app/build.gradle)
Added
-
Added
KeyEvent::meta_state()
for being able to query the state of meta keys, needed for character mapping (#102) -
Added
KeyCharacterMap
JNI bindings to the corresponding Android SDK API (#102) -
Added
AndroidApp::device_key_character_map()
for being able to get aKeyCharacterMap
for a givendevice_id
for unicode character mapping (#102)Click here for an example of how to handle unicode character mapping:
let mut combining_accent = None; // Snip let combined_key_char = if let Ok(map) = app.device_key_character_map(device_id) { match map.get(key_event.key_code(), key_event.meta_state()) { Ok(KeyMapChar::Unicode(unicode)) => { let combined_unicode = if let Some(accent) = combining_accent { match map.get_dead_char(accent, unicode) { Ok(Some(key)) => { info!("KeyEvent: Combined '{unicode}' with accent '{accent}' to give '{key}'"); Some(key) } Ok(None) => None, Err(err) => { log::error!("KeyEvent: Failed to combine 'dead key' accent '{accent}' with '{unicode}': {err:?}"); None } } } else { info!("KeyEvent: Pressed '{unicode}'"); Some(unicode) }; combining_accent = None; combined_unicode.map(|unicode| KeyMapChar::Unicode(unicode)) } Ok(KeyMapChar::CombiningAccent(accent)) => { info!("KeyEvent: Pressed 'dead key' combining accent '{accent}'"); combining_accent = Some(accent); Some(KeyMapChar::CombiningAccent(accent)) } Ok(KeyMapChar::None) => { info!("KeyEvent: Pressed non-unicode key"); combining_accent = None; None } Err(err) => { log::error!("KeyEvent: Failed to get key map character: {err:?}"); combining_accent = None; None } } } else { None };
-
Added
TextEvent
Input Method event for supporting text editing via virtual keyboards (#24) -
Added
MotionEvent::action_button()
exposing the button associated with button press/release actions (#138)
Changed
-
rust-version bumped to 0.68 (#123)
-
Breaking: update to
ndk 0.8
andndk-sys 0.5
(#128) -
GameActivity updated to 2.0.2 (requires the corresponding 2.0.2
.aar
release from Google) (#88) -
AndroidApp::input_events()
is replaced byAndroidApp::input_events_iter()
(#102)Click here for an example of how to use `input_events_iter()`:
match app.input_events_iter() { Ok(mut iter) => { loop { let read_input = iter.next(|event| { let handled = match event { InputEvent::KeyEvent(key_event) => { // Snip } InputEvent::MotionEvent(motion_event) => { // Snip } event => { // Snip } }; handled }); if !read_input { break; } } } Err(err) => { log::error!("Failed to get input events iterator: {err:?}"); } }
-
The
Pointer
andPointerIter
types from thendk
crate are no longer directly exposed in the public API (#122) -
All input API enums based on Android SDK enums have been made runtime extensible via hidden
__Unknown(u32)
variants (#131)
New Contributors
- @lexi-the-cute made their first contribution in #88
- @daxpedda made their first contribution in #85
- @fornwall made their first contribution in #124
Full Changelog: v0.4.3...v0.5.0
android-activity 0.5.0-beta.1
This only updates the ndk
and ndk-sys
dependencies to pull in ndk 0.8.0-beta.0
and ndk-sys 0.5.0-beta.0
android-activity 0.5.0-beta.0
This is the first 0.5.0 beta that's aiming to be ready for the upcoming Winit 0.29 release
The main reason that a (breaking) semver bump was required was so we could update the API for reading input events to better support being able to use other AndroidApp APIs while iterating input events, to support unicode character mapping for Keycodes.
A big change with this release is the update of the game-activity
backend, updating to GameActivity 2.0.2. Applications using the game-activity
backend will need to ensure they pull in the corresponding 2.0.2 .aar
from Google (For example, see https://github.com/rust-mobile/android-activity/blob/main/examples/agdk-mainloop/app/build.gradle)
Added
-
Added
KeyEvent::meta_state()
for being able to query the state of meta keys, needed for character mapping (#102) -
Added
KeyCharacterMap
JNI bindings to the corresponding Android SDK API (#102) -
Added
AndroidApp::device_key_character_map()
for being able to get aKeyCharacterMap
for a givendevice_id
for unicode character mapping (#102)Click here for an example of how to handle unicode character mapping:
let mut combining_accent = None; // Snip let combined_key_char = if let Ok(map) = app.device_key_character_map(device_id) { match map.get(key_event.key_code(), key_event.meta_state()) { Ok(KeyMapChar::Unicode(unicode)) => { let combined_unicode = if let Some(accent) = combining_accent { match map.get_dead_char(accent, unicode) { Ok(Some(key)) => { info!("KeyEvent: Combined '{unicode}' with accent '{accent}' to give '{key}'"); Some(key) } Ok(None) => None, Err(err) => { log::error!("KeyEvent: Failed to combine 'dead key' accent '{accent}' with '{unicode}': {err:?}"); None } } } else { info!("KeyEvent: Pressed '{unicode}'"); Some(unicode) }; combining_accent = None; combined_unicode.map(|unicode| KeyMapChar::Unicode(unicode)) } Ok(KeyMapChar::CombiningAccent(accent)) => { info!("KeyEvent: Pressed 'dead key' combining accent '{accent}'"); combining_accent = Some(accent); Some(KeyMapChar::CombiningAccent(accent)) } Ok(KeyMapChar::None) => { info!("KeyEvent: Pressed non-unicode key"); combining_accent = None; None } Err(err) => { log::error!("KeyEvent: Failed to get key map character: {err:?}"); combining_accent = None; None } } } else { None };
-
Added
TextEvent
Input Method event for supporting text editing via virtual keyboards (#24)
Changed
-
GameActivity updated to 2.0.2 (requires the corresponding 2.0.2
.aar
release from Google) (#88) -
AndroidApp::input_events()
is replaced byAndroidApp::input_events_iter()
(#102)Click here for an example of how to use `input_events_iter()`:
match app.input_events_iter() { Ok(mut iter) => { loop { let read_input = iter.next(|event| { let handled = match event { InputEvent::KeyEvent(key_event) => { // Snip } InputEvent::MotionEvent(motion_event) => { // Snip } event => { // Snip } }; handled }); if !read_input { break; } } } Err(err) => { log::error!("Failed to get input events iterator: {err:?}"); } }
New Contributors
- @lexi-the-cute made their first contribution in #88
- @daxpedda made their first contribution in #85
Full Changelog: v0.4.3...v0.5.0-beta.0
android-activity 0.4.3
android-activity 0.4.2
What's Changed
- Add dependabot support by @notgull in #72
- native-activity: Propagate
NativeWindow
redraw/resize andContentRectChanged
callbacks to main loop by @MarijnS95 in #70 - Add MSRV policy to README and bump
rust_version
to 1.64, due tondk
->raw_window_handle
dependency by @rib in #76 - build(deps): update num_enum requirement from 0.5 to 0.6 by @dependabot in #74
- build(deps): bump actions/checkout from 2 to 3 by @dependabot in #73
- Fix rust_version typo s/0.64/1.64/ by @rib in #77
- Add panic guards to extern "C" functions by @notgull in #68
- game_activity: Fix
pointer_index()
always returning0
by @yunsash in #84 - README: Add badges to CI, crates.io, docs.rs and show the MSRV by @MarijnS95 in #86
- Call Activity.finish() when android_main returns by @rib in #81
- cargo: Fix
rust_version
->rust-version
property typo by @MarijnS95 in #87 - Release 0.4.2 by @rib in #90
New Contributors
- @notgull made their first contribution in #72
- @dependabot made their first contribution in #74 - good bot 🤖
- @yunsash made their first contribution in #84
Full Changelog: v0.4.1...v0.4.2
android-activity 0.4.1
What's Changed
Added
- Added
AndroidApp::vm_as_ptr()
to expose JNIJavaVM
pointer (#60) - Added
AndroidApp::activity_as_ptr()
to expose AndroidActivity
JNI reference as pointer (#60)
Changed
- Removed some overly-verbose logging in the
native-activity
backend (#49)
Removed
- Most of the examples were moved to https://github.com/rust-mobile/rust-android-examples (#50)
New Contributors
- @MarijnS95 made their first contribution in #47
Full Changelog: v0.4.0...v0.4.1
android-activity 0.4.0
What's Changed
Changed
- Breaking:
input_events
callback now return whether an event was handled or not to allow for fallback handling (#31) - The native-activity backend is now implemented in Rust only, without building on
android_native_app_glue.c
(#35)
Added
- Added
Pointer::tool_type()
API toGameActivity
backend for compatibility withndk
events API (#38)
New Contributors
- @msiglreith made their first contribution in #29
Full Changelog: v0.3.0...v0.4.0