Skip to content

Commit 0f00a58

Browse files
authored
Merge pull request #90 from rust-mobile/release-0.4.2
Release 0.4.2
2 parents 1ad3abd + 9a713c8 commit 0f00a58

File tree

16 files changed

+83
-21
lines changed

16 files changed

+83
-21
lines changed

android-activity/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
33
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
44

55
## [Unreleased]
6+
7+
8+
## [0.4.2] - 2022-02-16
69
### Changed
710
- The `Activity.finish()` method is now called when `android_main` returns so the `Activity` will be destroyed ([#67](https://github.com/rust-mobile/android-activity/issues/67))
11+
- The `native-activity` backend now propagates `NativeWindow` redraw/resize and `ContentRectChanged` callbacks to main loop ([#70](https://github.com/rust-mobile/android-activity/pull/70))
12+
- The `game-activity` implementation of `pointer_index()` was fixed to not always return `0` ([#80](https://github.com/rust-mobile/android-activity/pull/84))
13+
- Added `panic` guards around application's `android_main()` and native code that could potentially unwind across a Java FFI boundary ([#68](https://github.com/rust-mobile/android-activity/pull/68))
814

915
## [0.4.1] - 2022-02-16
1016
### Added

android-activity/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "android-activity"
3-
version = "0.4.1"
3+
version = "0.4.2"
44
edition = "2021"
55
keywords = ["android", "ndk"]
66
readme = "../README.md"

examples/agdk-mainloop/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ edition = "2021"
99
log = "0.4"
1010
android_logger = "0.11.0"
1111
android-activity = { path="../../android-activity", features = ["game-activity"] }
12+
ndk-sys = "0.4"
13+
ndk = "0.7"
1214

1315
[lib]
1416
name="main"

examples/agdk-mainloop/app/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ plugins {
33
}
44

55
android {
6+
ndkVersion "25.2.9519653"
67
compileSdk 31
78

89
defaultConfig {
@@ -32,6 +33,7 @@ android {
3233
sourceCompatibility JavaVersion.VERSION_1_8
3334
targetCompatibility JavaVersion.VERSION_1_8
3435
}
36+
namespace 'co.realfit.agdkmainloop'
3537
}
3638

3739
dependencies {

examples/agdk-mainloop/app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3-
package="co.realfit.agdkmainloop">
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
43

54
<application
65
android:allowBackup="true"

examples/agdk-mainloop/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Top-level build file where you can add configuration options common to all sub-projects/modules.
22
plugins {
3-
id 'com.android.application' version '7.1.2' apply false
4-
id 'com.android.library' version '7.1.2' apply false
3+
id 'com.android.application' version '8.0.0' apply false
4+
id 'com.android.library' version '8.0.0' apply false
55
}
66

77
task clean(type: Delete) {

examples/agdk-mainloop/gradle.properties

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,6 @@ android.useAndroidX=true
1818
# Enables namespacing of each library's R class so that its R class includes only the
1919
# resources declared in the library itself and none from the library's dependencies,
2020
# thereby reducing the size of the R class for that library
21-
android.nonTransitiveRClass=true
21+
android.nonTransitiveRClass=true
22+
android.defaults.buildfeatures.buildconfig=true
23+
android.nonFinalResIds=false
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#Mon May 02 15:39:12 BST 2022
22
distributionBase=GRADLE_USER_HOME
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
44
distributionPath=wrapper/dists
55
zipStorePath=wrapper/dists
66
zipStoreBase=GRADLE_USER_HOME

examples/agdk-mainloop/src/lib.rs

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ fn android_main(app: AndroidApp) {
77

88
let mut quit = false;
99
let mut redraw_pending = true;
10-
let mut render_state: Option<()> = Default::default();
10+
let mut native_window: Option<ndk::native_window::NativeWindow> = None;
1111

1212
while !quit {
1313
app.poll_events(
@@ -37,11 +37,11 @@ fn android_main(app: AndroidApp) {
3737
}
3838
}
3939
MainEvent::InitWindow { .. } => {
40-
render_state = Some(());
40+
native_window = app.native_window();
4141
redraw_pending = true;
4242
}
4343
MainEvent::TerminateWindow { .. } => {
44-
render_state = None;
44+
native_window = None;
4545
}
4646
MainEvent::WindowResized { .. } => {
4747
redraw_pending = true;
@@ -65,7 +65,7 @@ fn android_main(app: AndroidApp) {
6565
}
6666

6767
if redraw_pending {
68-
if let Some(_rs) = render_state {
68+
if let Some(native_window) = &native_window {
6969
redraw_pending = false;
7070

7171
// Handle input
@@ -75,9 +75,32 @@ fn android_main(app: AndroidApp) {
7575
});
7676

7777
info!("Render...");
78+
dummy_render(native_window);
7879
}
7980
}
8081
},
8182
);
8283
}
8384
}
85+
86+
/// Post a NOP frame to the window
87+
///
88+
/// Since this is a bare minimum test app we don't depend
89+
/// on any GPU graphics APIs but we do need to at least
90+
/// convince Android that we're drawing something and are
91+
/// responsive, otherwise it will stop delivering input
92+
/// events to us.
93+
fn dummy_render(native_window: &ndk::native_window::NativeWindow) {
94+
unsafe {
95+
let mut buf: ndk_sys::ANativeWindow_Buffer = std::mem::zeroed();
96+
let mut rect: ndk_sys::ARect = std::mem::zeroed();
97+
ndk_sys::ANativeWindow_lock(
98+
native_window.ptr().as_ptr() as _,
99+
&mut buf as _,
100+
&mut rect as _,
101+
);
102+
// Note: we don't try and touch the buffer since that
103+
// also requires us to handle various buffer formats
104+
ndk_sys::ANativeWindow_unlockAndPost(native_window.ptr().as_ptr() as _);
105+
}
106+
}

examples/na-mainloop/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ edition = "2021"
99
log = "0.4"
1010
android_logger = "0.11.0"
1111
android-activity = { path="../../android-activity", features = [ "native-activity" ] }
12+
ndk-sys = "0.4"
13+
ndk = "0.7"
1214

1315
[lib]
1416
#name="na_mainloop"

0 commit comments

Comments
 (0)