Skip to content

Commit

Permalink
add <config:android layoutInDisplayCutoutMode/>
Browse files Browse the repository at this point in the history
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
  • Loading branch information
joshtynjala committed Feb 7, 2025
1 parent af22996 commit 41ac2fc
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
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;
Expand Down Expand Up @@ -210,6 +211,34 @@ else if (degrees >= 225 && degrees < 315)
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> ();
Expand Down
1 change: 1 addition & 0 deletions tools/platforms/AndroidPlatform.hx
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,7 @@ class AndroidPlatform extends PlatformTarget
context.ANDROID_GRADLE_PLUGIN = project.config.getString("android.gradle-plugin", "8.7.3");
context.ANDROID_USE_ANDROIDX = project.config.getString("android.useAndroidX", "true");
context.ANDROID_ENABLE_JETIFIER = project.config.getString("android.enableJetifier", "false");
context.ANDROID_DISPLAY_CUTOUT = project.config.getString("android.layoutInDisplayCutoutMode", "default");

context.ANDROID_APPLICATION = project.config.getKeyValueArray("android.application", {
"android:label": project.meta.title,
Expand Down

0 comments on commit 41ac2fc

Please sign in to comment.