summaryrefslogtreecommitdiff
path: root/platform/android/java
diff options
context:
space:
mode:
Diffstat (limited to 'platform/android/java')
-rw-r--r--platform/android/java/app/res/values/themes.xml1
-rw-r--r--platform/android/java/lib/src/org/godotengine/godot/GodotIO.java26
2 files changed, 27 insertions, 0 deletions
diff --git a/platform/android/java/app/res/values/themes.xml b/platform/android/java/app/res/values/themes.xml
index 26912538d3..99f723f5ba 100644
--- a/platform/android/java/app/res/values/themes.xml
+++ b/platform/android/java/app/res/values/themes.xml
@@ -5,5 +5,6 @@
<style name="GodotAppSplashTheme" parent="@style/GodotAppMainTheme">
<item name="android:windowBackground">@drawable/splash_drawable</item>
+ <item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
</style>
</resources>
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 c2f3c88416..874fd88848 100644
--- a/platform/android/java/lib/src/org/godotengine/godot/GodotIO.java
+++ b/platform/android/java/lib/src/org/godotengine/godot/GodotIO.java
@@ -37,12 +37,16 @@ import android.content.*;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.res.AssetManager;
+import android.graphics.Point;
import android.media.*;
import android.net.Uri;
import android.os.*;
import android.util.DisplayMetrics;
import android.util.Log;
import android.util.SparseArray;
+import android.view.Display;
+import android.view.DisplayCutout;
+import android.view.WindowInsets;
import java.io.IOException;
import java.io.InputStream;
@@ -461,6 +465,28 @@ public class GodotIO {
return (int)(metrics.density * 160f);
}
+ public int[] screenGetUsableRect() {
+ DisplayMetrics metrics = activity.getResources().getDisplayMetrics();
+ Display display = activity.getWindowManager().getDefaultDisplay();
+ Point size = new Point();
+ display.getRealSize(size);
+
+ int result[] = { 0, 0, size.x, size.y };
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
+ WindowInsets insets = activity.getWindow().getDecorView().getRootWindowInsets();
+ DisplayCutout cutout = insets.getDisplayCutout();
+ if (cutout != null) {
+ int insetLeft = cutout.getSafeInsetLeft();
+ int insetTop = cutout.getSafeInsetTop();
+ result[0] = insetLeft;
+ result[1] = insetTop;
+ result[2] -= insetLeft + cutout.getSafeInsetRight();
+ result[3] -= insetTop + cutout.getSafeInsetBottom();
+ }
+ }
+ 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);