mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 16:03:29 +00:00
Implement OS.get_window_safe_area() for Android
This commit is contained in:
parent
b370aa75dd
commit
96e22bd9fb
5 changed files with 48 additions and 2 deletions
|
@ -52,6 +52,7 @@ GodotIOJavaWrapper::GodotIOJavaWrapper(JNIEnv *p_env, jobject p_godot_io_instanc
|
|||
_get_locale = p_env->GetMethodID(cls, "getLocale", "()Ljava/lang/String;");
|
||||
_get_model = p_env->GetMethodID(cls, "getModel", "()Ljava/lang/String;");
|
||||
_get_screen_DPI = p_env->GetMethodID(cls, "getScreenDPI", "()I");
|
||||
_screen_get_usable_rect = p_env->GetMethodID(cls, "screenGetUsableRect", "()[I"),
|
||||
_get_unique_id = p_env->GetMethodID(cls, "getUniqueID", "()Ljava/lang/String;");
|
||||
_show_keyboard = p_env->GetMethodID(cls, "showKeyboard", "(Ljava/lang/String;ZIII)V");
|
||||
_hide_keyboard = p_env->GetMethodID(cls, "hideKeyboard", "()V");
|
||||
|
@ -118,6 +119,19 @@ int GodotIOJavaWrapper::get_screen_dpi() {
|
|||
}
|
||||
}
|
||||
|
||||
void GodotIOJavaWrapper::screen_get_usable_rect(int (&p_rect_xywh)[4]) {
|
||||
if (_screen_get_usable_rect) {
|
||||
JNIEnv *env = ThreadAndroid::get_env();
|
||||
jintArray returnArray = (jintArray)env->CallObjectMethod(godot_io_instance, _screen_get_usable_rect);
|
||||
ERR_FAIL_COND(env->GetArrayLength(returnArray) != 4);
|
||||
jint *arrayBody = env->GetIntArrayElements(returnArray, JNI_FALSE);
|
||||
for (int i = 0; i < 4; i++) {
|
||||
p_rect_xywh[i] = arrayBody[i];
|
||||
}
|
||||
env->ReleaseIntArrayElements(returnArray, arrayBody, 0);
|
||||
}
|
||||
}
|
||||
|
||||
String GodotIOJavaWrapper::get_unique_id() {
|
||||
if (_get_unique_id) {
|
||||
JNIEnv *env = ThreadAndroid::get_env();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue