diff --git a/ndk/src/native_activity.rs b/ndk/src/native_activity.rs index c64a3cb0..9b7a3fe0 100644 --- a/ndk/src/native_activity.rs +++ b/ndk/src/native_activity.rs @@ -3,6 +3,7 @@ //! See also [the NDK //! docs](https://developer.android.com/ndk/reference/struct/a-native-activity.html) +use crate::hardware_buffer::HardwareBufferFormat; use std::ffi::CStr; use std::os::raw::c_void; use std::ptr::NonNull; @@ -11,6 +12,8 @@ use std::ptr::NonNull; /// /// This is either provided in `ANativeActivity_onCreate`, or accessible in /// `android_native_app_glue`'s android_app. +/// +/// #[derive(Debug)] pub struct NativeActivity { ptr: NonNull, @@ -169,11 +172,13 @@ impl NativeActivity { unsafe { ffi::ANativeActivity_hideSoftInput(self.ptr.as_ptr(), flag) } } - /*/// Set the window format. Performs the Java `.getWindow().setFormat()`. + /// Change the window format of the given activity. + /// + /// Calls [`getWindow().setFormat()`] of the given activity. Note that this method can be called from any thread; it will send a message to the main thread of the process where the Java finish call will take place. /// - /// See also [the relevant - /// javadoc](https://developer.android.com/reference/android/view/Window#setFormat(int)) - pub unsafe fn set_window_format(&self, format: WindowFormat) { - unsafe { ffi::ANativeActivity_setWindowFormat(self.ptr.as_ptr(), format.into()) } - }*/ + /// [`getWindow().setFormat()`]: https://developer.android.com/reference/android/view/Window#setFormat(int) + pub fn set_window_format(&self, format: HardwareBufferFormat) { + let format: u32 = format.into(); + unsafe { ffi::ANativeActivity_setWindowFormat(self.ptr.as_ptr(), format as i32) } + } }