openfl / lime

A foundational Haxe framework for cross-platform development
https://lime.openfl.org/
MIT License
761 stars 376 forks source link

Support for notch displays in mobile? #1606

Open MAJigsaw77 opened 1 year ago

MAJigsaw77 commented 1 year ago

This might be useful in games for example.

joshtynjala commented 1 year ago

Adobe AIR 50 has a new safeArea API in flash.display.Screen

https://airsdk.dev/reference/actionscript/3.0/flash/display/Screen.html#safeArea

It would be useful to expose this information in Lime so that OpenFL can implement the same API.

I wonder if any newer versions of SDL expose the safe area?

In the meantime, this extension may be useful:

https://github.com/HaxeExtension/extension-safearea

MAJigsaw77 commented 1 year ago

👍

joshtynjala commented 1 year ago

Based on some quick research, SDL does not seem to have an API for notch/safearea yet.

Here's their open issue: libsdl-org/SDL#3243

MAJigsaw77 commented 5 months ago

By modifying GameActivity from the android template i could get a some results but the offsets doesn't seem so accurate.

Screenshot_20240609-081415 Screenshot_20240609-081411 Screenshot_20240609-081337

This is the code i used in any case.

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P)
{
    getWindow().getAttributes().layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
}