slint-ui/slint

Add support for Android’s application life cycle model to Slint.

Closed this issue · 4 comments

Add support for Android’s application life cycle model to Slint.

Since we use the winit backend, we should use the android-activity crate.
But the thing is that winit is an internal dependency of Slint right now, and we want to update winit's major version without updating slint's major version. So we can't expose any type.
winit uses android-activity crate and re-export its type.
The initialization is done with a #[no_mangle] fn android_main(app: android_activity::AndroidApp) function. That expose the android_activity crate. Can we avoid that?

Perhaps android_main should be implemented in i_slint_backend_winit, and our user should declare a #[no_mangle] fn slint_android_main() function (that is called by our winit backend). The i_slint_backend_winit could have a getter to get the AndroidApp if the user uses the internal API

I agree about not exposing the types. Yes, either we require #[no_mangle] fn slint_android_main() or we introduce a #[slint::mobile_main] proc-macro to be used with main(). This is what Bevy does.

With regards to supporting the life cycle model in Slint by somehow making the developer aware when to save state and when to resume, I see the problem that winit swallows the SaveState event from android-activity.

We offer a callback from the android-activity backend to handle SaveState and Resume. The todo demo has an example of it