android: add MainActivity.java hooks for ResizingLayout #596
+19
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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