diff options
author | Marcel Admiraal <madmiraal@users.noreply.github.com> | 2022-04-24 21:12:22 +0200 |
---|---|---|
committer | Marcel Admiraal <madmiraal@users.noreply.github.com> | 2022-04-26 13:51:21 +0200 |
commit | 71ce5857ecb76fdca3afc1a0882a575a3879d148 (patch) | |
tree | 4bcf19ee57f16ee5e0bf32e6c7516f7bb93fa46e /platform/android/java/lib/src | |
parent | bfc727d9709beea73a1486b47eb745749c3ad0d1 (diff) |
Add a method for obtaining display cutouts on Android
Diffstat (limited to 'platform/android/java/lib/src')
-rw-r--r-- | platform/android/java/lib/src/org/godotengine/godot/GodotIO.java | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/platform/android/java/lib/src/org/godotengine/godot/GodotIO.java b/platform/android/java/lib/src/org/godotengine/godot/GodotIO.java index e8e292df5d..af1b54dbac 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/GodotIO.java +++ b/platform/android/java/lib/src/org/godotengine/godot/GodotIO.java @@ -38,6 +38,7 @@ import android.content.Intent; import android.content.pm.ActivityInfo; import android.content.res.AssetManager; import android.graphics.Point; +import android.graphics.Rect; import android.net.Uri; import android.os.Build; import android.os.Environment; @@ -51,6 +52,7 @@ import android.view.DisplayCutout; import android.view.WindowInsets; import java.io.IOException; +import java.util.List; import java.util.Locale; // Wrapper for native library @@ -260,6 +262,25 @@ public class GodotIO { return result; } + public int[] getDisplayCutouts() { + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P) + return new int[0]; + DisplayCutout cutout = activity.getWindow().getDecorView().getRootWindowInsets().getDisplayCutout(); + if (cutout == null) + return new int[0]; + List<Rect> rects = cutout.getBoundingRects(); + int cutouts = rects.size(); + int[] result = new int[cutouts * 4]; + int index = 0; + for (Rect rect : rects) { + result[index++] = rect.left; + result[index++] = rect.top; + result[index++] = rect.width(); + result[index++] = rect.height(); + } + return result; + } + public void showKeyboard(String p_existing_text, boolean p_multiline, int p_max_input_length, int p_cursor_start, int p_cursor_end) { if (edit != null) edit.showKeyboard(p_existing_text, p_multiline, p_max_input_length, p_cursor_start, p_cursor_end); |