Kha
Kha copied to clipboard
[Android-Native] Support display cutouts
As far as i understand, in my khafile, setting
project.targetOptions.android_native.disableStickyImmersiveMode
-should- enable immersive mode on Android..?
But as far as i can see it does not... Seems that whatever i do, my application always has a black bar at the top where the status bar comes down when swiping from the top, and when rotating to landscape mode the black bar is on the side of the screen.
Screenshot here : https://www.dropbox.com/s/d4chnkjzu9nb3sm/Screenshot_20200316-224320_UIX.jpg?dl=0
Tested on Samsung Galaxy S10+ , Android 10, Android Studio 3.6 / Win10, NDK r21
That's the same thing that was discussed on IRC yesterday and turned out to only relate to some devices, right?
That i cant say.. But it does not work on the android phones i have tested.. Perhaps it is related to newer android / NDK versions?
So you were not one of those who discussed it yesterday?
I was part of a talk on IRC yesterday about this yes. But i have not found a solution, and i really cant say if it is related to only some devices or not. Wouldnt this be consistent atleast on similar Android versions?
I don't know. In the discussion yesterday I think dave mentioned that he couldn't reproduce your problem on some device which is very important information. I think we need to get a rough overview of devices and Android versions of where it does or does not work. Or somebody has to have a look into the documentation to see what changed this time :)
Sure, i can do some extended testing on different devices and Android versions and share my results!
That would be most excellent.
can you install https://github.com/mio-edition/floyds-puzzle from google play and check if this works on your devices? i built this a couple of months back, and try to find the old build files to check sdk/ndk versions and such if it does.
can you install https://github.com/mio-edition/floyds-puzzle from google play and check if this works on your devices? i built this a couple of months back, and try to find the old build files to check sdk/ndk versions and such if it does.
Ok, tried it and it is the same as in my tests - black bar on the side of the screen (since it is in landscape mode)
So it looks like it is indeed somehow device dependent :disappointed:
Edit: the only course of action now is for you to send us all your devices so we can test them! :smiling_imp:
Actually, this is odd - could it be that is infact not immersive mode itself that is the issue here? I mean.. There should not be a black bar on the side of the screen in landscape mode no matter what.. And in landscape mode the menu at the top is actually going away like it should..
Perhaps the application does not use the correct screen size available when immersive mode is on or something? See the attached screenshot.. It looks strange.
It seems that going into android settings and changing fullscreen mode for the specified app from automatic to forced fullscreen fixes the issue and the black bar is gone. So it seems to be somehow fullscreen related and for some reason automatic doesnt work for the kha apps i have tested.. Will investigate further...
So ... i've investigated this for a while and tested many phones.
And it seems the cause of the different behavior is related to if the phone has a notch/pinhole camera in the screen. All versions of android and phone types i've tested without a pinhole / notch works like it should. But on phones with a notch / pinhole the app defaults to "LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER" in android. But overriding the fullscreen mode in android settings enables true fullscreenmode.
As far as i can tell it seems like support for display-cutout is needed to utilize max screen area for these kind of devices. (There is quite a lot of them nowadays... )
Display cutout documentation: https://developer.android.com/guide/topics/display-cutout
So, if possible - an option to use "LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES" would assumably solve the isse.
ref testing photos:
Samsung s9+ OneUI 2 - no Notch
Samsung s10+ OneUI 2 - Notch /pinhole cam
Aha! Hm, I don't even think we should automatically go beyond the notches, it's not nice when part of the image is missing unexpectedly. Have to get an overview of all of that (also cut corners, those are not nice either) and extend the API somehow.
No, not automaticly.. but perhaps an option to enable extending the image with an LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES option in the androidnative settings ? Then its up to the developer if they want to support it or not.
[Edit : i changed the title to be more correct]
It seems that going into android settings and changing fullscreen mode for the specified app from automatic to forced fullscreen fixes the issue and the black bar is gone. So it seems to be somehow fullscreen related and for some reason automatic doesnt work for the kha apps i have tested.. Will investigate further...
I had this problem before. The problem, in my case, was due to the android soft buttons (back, home, etc). A workaround is to disable the soft buttons from hiding. I was working on Android Java Backend tough. My issue was reproducible using the android emulator. Check which model and android version you can reproduce the issue.