android: add MainActivity.java hooks for ResizingLayout#596
android: add MainActivity.java hooks for ResizingLayout#596not-fl3 merged 1 commit intonot-fl3:masterfrom
Conversation
|
An alternative solution is that in miniquad we keep the canvas unchanged (like I'm doing) and instead fire resize events with the newly calculated screen size (after insets). However this would make GL calculations for transform matrixes wrong since we need the full canvas size. So then we would have to maybe introduce a separate event handler like Let me know which direction you prefer. I just picked this for now as the lowest impact on miniquad, but happy to workout other ideas. Anyway regardless we should still merge this since having the |
|
I am so behind your miniquad/android experience at this point to be honest, you say its useful - I merge 🫡 Thanks for PR! |
|
Thanks, I will prepare a doc at some point with all my findings. First I also want to explore the iOS experience more too so I can compare them both. |
See this provided comment:
Basically before miniquad used to use the whole canvas and not resize when IME (keyboard in android speak) was shown/hidden. So then I added the
ResizingLayoutto make it automatically resize the canvas.However this causes a noticeable flicker since the program flow goes like this:
ResizingLayout apply insets -> resize canvas -> surface changed -> native android -> resize event
during which time the screen is being drawn by android and whatever is there gets resized before the user has a chance to hit update()/draw() and redo the entire canvas.
The solution then in my case was to disable the screen resize and listen myself for the insets but this would then introduce complexity into miniquad. I've introduced these hooks for now as the lowest impact solution but I'm also open to alternative solutions if we think having this directly in miniquad is useful.
Here is my application code using these hooks:
java/MainActivity.java:
android ndk handler code:
This way the canvas remains unchanged. It is my user code that does the resizing. Another benefit is I can draw below the navigation and system bars too.
Also check not-fl3/cargo-quad-apk#13