Kha icon indicating copy to clipboard operation
Kha copied to clipboard

[Android-Native] Support display cutouts

Open datee opened this issue 4 years ago • 16 comments

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

datee avatar Mar 18 '20 16:03 datee

That's the same thing that was discussed on IRC yesterday and turned out to only relate to some devices, right?

RobDangerous avatar Mar 18 '20 16:03 RobDangerous

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?

datee avatar Mar 18 '20 17:03 datee

So you were not one of those who discussed it yesterday?

RobDangerous avatar Mar 18 '20 17:03 RobDangerous

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?

datee avatar Mar 18 '20 17:03 datee

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 :)

RobDangerous avatar Mar 18 '20 17:03 RobDangerous

Sure, i can do some extended testing on different devices and Android versions and share my results!

datee avatar Mar 18 '20 17:03 datee

That would be most excellent.

RobDangerous avatar Mar 18 '20 17:03 RobDangerous

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.

sh-dave avatar Mar 18 '20 22:03 sh-dave

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) Screenshot_20200319-104625_Floyds Puzzle

datee avatar Mar 19 '20 09:03 datee

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:

sh-dave avatar Mar 19 '20 11:03 sh-dave

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. Screenshot_20200319-130709_Floyds Puzzle

datee avatar Mar 19 '20 12:03 datee

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...

datee avatar Mar 19 '20 12:03 datee

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 no_notch

Samsung s10+ OneUI 2 - Notch /pinhole cam width_notch

datee avatar Mar 27 '20 19:03 datee

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.

RobDangerous avatar Mar 28 '20 04:03 RobDangerous

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]

datee avatar Mar 28 '20 08:03 datee

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.

Huyston avatar Apr 24 '20 16:04 Huyston