add <config:android layoutInDisplayCutoutMode/>

Options are default, always, never, and shortEdges. Defaults to default.

What default means depends on which Android SDK version is used.

According to the Android docs, starting with Android SDK 35, most options will be forced to act the same as always. However, for SDK 34 (which is the current minimum on Google Play) this should remain configurable.

https://developer.android.com/develop/ui/views/layout/display-cutout
This commit is contained in:
Josh Tynjala
2025-02-07 09:23:20 -08:00
parent af2299670f
commit 41ac2fc8b6
2 changed files with 30 additions and 0 deletions

View File

@@ -19,6 +19,7 @@ import android.view.KeyEvent;
import android.view.OrientationEventListener;
import android.view.View;
import android.view.WindowInsets;
import android.view.WindowManager;
import android.webkit.MimeTypeMap;
import android.Manifest;
import org.haxe.extension.Extension;
@@ -210,6 +211,34 @@ public class GameActivity extends SDLActivity {
Extension.mainView = mLayout;
Extension.packageName = getApplicationContext ().getPackageName ();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
switch ("::ANDROID_DISPLAY_CUTOUT::") {
case "always":
getWindow().getAttributes().layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
break;
case "never":
getWindow().getAttributes().layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER;
break;
case "shortEdges":
getWindow().getAttributes().layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
break;
case "default":
getWindow().getAttributes().layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT;
break;
default:
getWindow().getAttributes().layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT;
break;
}
}
if (extensions == null) {
extensions = new ArrayList<Extension> ();