summaryrefslogtreecommitdiffstats
path: root/platform/android
diff options
context:
space:
mode:
Diffstat (limited to 'platform/android')
-rw-r--r--platform/android/detect.py35
-rw-r--r--platform/android/display_server_android.cpp42
-rw-r--r--platform/android/display_server_android.h6
-rw-r--r--platform/android/java/lib/res/values/dimens.xml2
-rw-r--r--platform/android/java/lib/res/values/strings.xml3
-rw-r--r--platform/android/java/lib/src/org/godotengine/godot/Godot.kt47
-rw-r--r--platform/android/java/lib/src/org/godotengine/godot/GodotIO.java23
-rw-r--r--platform/android/java/lib/src/org/godotengine/godot/GodotLib.java5
-rw-r--r--platform/android/java_godot_io_wrapper.cpp11
-rw-r--r--platform/android/java_godot_io_wrapper.h2
-rw-r--r--platform/android/java_godot_lib_jni.cpp8
-rw-r--r--platform/android/java_godot_lib_jni.h1
-rw-r--r--platform/android/java_godot_wrapper.cpp18
-rw-r--r--platform/android/java_godot_wrapper.h2
14 files changed, 193 insertions, 12 deletions
diff --git a/platform/android/detect.py b/platform/android/detect.py
index 937bdbaa07..4bc7e9474b 100644
--- a/platform/android/detect.py
+++ b/platform/android/detect.py
@@ -96,6 +96,15 @@ def install_ndk_if_needed(env: "SConsEnvironment"):
env["ANDROID_NDK_ROOT"] = get_android_ndk_root(env)
+def detect_swappy():
+ archs = ["arm64-v8a", "armeabi-v7a", "x86", "x86_64"]
+ has_swappy = True
+ for arch in archs:
+ if not os.path.isfile("thirdparty/swappy-frame-pacing/" + arch + "/libswappy_static.a"):
+ has_swappy = False
+ return has_swappy
+
+
def configure(env: "SConsEnvironment"):
# Validate arch.
supported_arches = ["x86_32", "x86_64", "arm32", "arm64"]
@@ -170,19 +179,42 @@ def configure(env: "SConsEnvironment"):
CCFLAGS=("-fpic -ffunction-sections -funwind-tables -fstack-protector-strong -fvisibility=hidden".split())
)
+ has_swappy = detect_swappy()
+ if not has_swappy:
+ print_warning(
+ "Swappy Frame Pacing not detected! It is strongly recommended you download it from https://github.com/darksylinc/godot-swappy/releases and extract it so that the following files can be found:\n"
+ + " thirdparty/swappy-frame-pacing/arm64-v8a/libswappy_static.a\n"
+ + " thirdparty/swappy-frame-pacing/armeabi-v7a/libswappy_static.a\n"
+ + " thirdparty/swappy-frame-pacing/x86/libswappy_static.a\n"
+ + " thirdparty/swappy-frame-pacing/x86_64/libswappy_static.a\n"
+ + "Without Swappy, Godot apps on Android will inevitable suffer stutter and struggle to keep consistent 30/60/90/120 fps. Though Swappy cannot guarantee your app will be stutter-free, not having Swappy will guarantee there will be stutter even on the best phones and the most simple of scenes."
+ )
+ if env["swappy"]:
+ print_error("Use build option `swappy=no` to ignore missing Swappy dependency and build without it.")
+ sys.exit(255)
+
if get_min_sdk_version(env["ndk_platform"]) >= 24:
env.Append(CPPDEFINES=[("_FILE_OFFSET_BITS", 64)])
if env["arch"] == "x86_32":
# The NDK adds this if targeting API < 24, so we can drop it when Godot targets it at least
env.Append(CCFLAGS=["-mstackrealign"])
+ if has_swappy:
+ env.Append(LIBPATH=["../../thirdparty/swappy-frame-pacing/x86"])
+ elif env["arch"] == "x86_64":
+ if has_swappy:
+ env.Append(LIBPATH=["../../thirdparty/swappy-frame-pacing/x86_64"])
elif env["arch"] == "arm32":
env.Append(CCFLAGS="-march=armv7-a -mfloat-abi=softfp".split())
env.Append(CPPDEFINES=["__ARM_ARCH_7__", "__ARM_ARCH_7A__"])
env.Append(CPPDEFINES=["__ARM_NEON__"])
+ if has_swappy:
+ env.Append(LIBPATH=["../../thirdparty/swappy-frame-pacing/armeabi-v7a"])
elif env["arch"] == "arm64":
env.Append(CCFLAGS=["-mfix-cortex-a53-835769"])
env.Append(CPPDEFINES=["__ARM_ARCH_8A__"])
+ if has_swappy:
+ env.Append(LIBPATH=["../../thirdparty/swappy-frame-pacing/arm64-v8a"])
env.Append(CCFLAGS=["-ffp-contract=off"])
@@ -197,6 +229,9 @@ def configure(env: "SConsEnvironment"):
if env["vulkan"]:
env.Append(CPPDEFINES=["VULKAN_ENABLED", "RD_ENABLED"])
+ if has_swappy:
+ env.Append(CPPDEFINES=["SWAPPY_FRAME_PACING_ENABLED"])
+ env.Append(LIBS=["swappy_static"])
if not env["use_volk"]:
env.Append(LIBS=["vulkan"])
diff --git a/platform/android/display_server_android.cpp b/platform/android/display_server_android.cpp
index 1352259ae9..ba2c82d7f0 100644
--- a/platform/android/display_server_android.cpp
+++ b/platform/android/display_server_android.cpp
@@ -73,7 +73,7 @@ bool DisplayServerAndroid::has_feature(Feature p_feature) const {
case FEATURE_MOUSE:
//case FEATURE_MOUSE_WARP:
//case FEATURE_NATIVE_DIALOG:
- //case FEATURE_NATIVE_DIALOG_INPUT:
+ case FEATURE_NATIVE_DIALOG_INPUT:
//case FEATURE_NATIVE_DIALOG_FILE:
//case FEATURE_NATIVE_ICON:
//case FEATURE_WINDOW_TRANSPARENCY:
@@ -178,6 +178,19 @@ bool DisplayServerAndroid::clipboard_has() const {
}
}
+Error DisplayServerAndroid::dialog_input_text(String p_title, String p_description, String p_partial, const Callable &p_callback) {
+ GodotJavaWrapper *godot_java = OS_Android::get_singleton()->get_godot_java();
+ ERR_FAIL_NULL_V(godot_java, FAILED);
+ input_dialog_callback = p_callback;
+ return godot_java->show_input_dialog(p_title, p_description, p_partial);
+}
+
+void DisplayServerAndroid::emit_input_dialog_callback(String p_text) {
+ if (input_dialog_callback.is_valid()) {
+ input_dialog_callback.call_deferred(p_text);
+ }
+}
+
TypedArray<Rect2> DisplayServerAndroid::get_display_cutouts() const {
GodotIOJavaWrapper *godot_io_java = OS_Android::get_singleton()->get_godot_io_java();
ERR_FAIL_NULL_V(godot_io_java, Array());
@@ -218,6 +231,14 @@ DisplayServer::ScreenOrientation DisplayServerAndroid::screen_get_orientation(in
return (ScreenOrientation)orientation;
}
+int DisplayServerAndroid::screen_get_internal_current_rotation(int p_screen) const {
+ GodotIOJavaWrapper *godot_io_java = OS_Android::get_singleton()->get_godot_io_java();
+ ERR_FAIL_NULL_V(godot_io_java, 0);
+
+ const int rotation = godot_io_java->get_internal_current_screen_rotation();
+ return rotation;
+}
+
int DisplayServerAndroid::get_screen_count() const {
return 1;
}
@@ -606,12 +627,6 @@ DisplayServerAndroid::DisplayServerAndroid(const String &p_rendering_driver, Dis
native_menu = memnew(NativeMenu);
-#if defined(GLES3_ENABLED)
- if (rendering_driver == "opengl3") {
- RasterizerGLES3::make_current(false);
- }
-#endif
-
#if defined(RD_ENABLED)
rendering_context = nullptr;
rendering_device = nullptr;
@@ -626,19 +641,24 @@ DisplayServerAndroid::DisplayServerAndroid(const String &p_rendering_driver, Dis
if (rendering_context->initialize() != OK) {
memdelete(rendering_context);
rendering_context = nullptr;
+#if defined(GLES3_ENABLED)
bool fallback_to_opengl3 = GLOBAL_GET("rendering/rendering_device/fallback_to_opengl3");
if (fallback_to_opengl3 && rendering_driver != "opengl3") {
WARN_PRINT("Your device seem not to support Vulkan, switching to OpenGL 3.");
rendering_driver = "opengl3";
OS::get_singleton()->set_current_rendering_method("gl_compatibility");
OS::get_singleton()->set_current_rendering_driver_name(rendering_driver);
- } else {
+ } else
+#endif
+ {
ERR_PRINT(vformat("Failed to initialize %s context", rendering_driver));
r_error = ERR_UNAVAILABLE;
return;
}
}
+ }
+ if (rendering_context) {
union {
#ifdef VULKAN_ENABLED
RenderingContextDriverVulkanAndroid::WindowPlatformData vulkan;
@@ -678,6 +698,12 @@ DisplayServerAndroid::DisplayServerAndroid(const String &p_rendering_driver, Dis
}
#endif
+#if defined(GLES3_ENABLED)
+ if (rendering_driver == "opengl3") {
+ RasterizerGLES3::make_current(false);
+ }
+#endif
+
Input::get_singleton()->set_event_dispatch_function(_dispatch_input_events);
r_error = OK;
diff --git a/platform/android/display_server_android.h b/platform/android/display_server_android.h
index 299de52a5b..cab1b503f7 100644
--- a/platform/android/display_server_android.h
+++ b/platform/android/display_server_android.h
@@ -89,6 +89,8 @@ class DisplayServerAndroid : public DisplayServer {
Callable system_theme_changed;
+ Callable input_dialog_callback;
+
void _window_callback(const Callable &p_callable, const Variant &p_arg, bool p_deferred = false) const;
static void _dispatch_input_events(const Ref<InputEvent> &p_event);
@@ -118,6 +120,9 @@ public:
virtual String clipboard_get() const override;
virtual bool clipboard_has() const override;
+ virtual Error dialog_input_text(String p_title, String p_description, String p_partial, const Callable &p_callback) override;
+ void emit_input_dialog_callback(String p_text);
+
virtual TypedArray<Rect2> get_display_cutouts() const override;
virtual Rect2i get_display_safe_area() const override;
@@ -126,6 +131,7 @@ public:
virtual void screen_set_orientation(ScreenOrientation p_orientation, int p_screen = SCREEN_OF_MAIN_WINDOW) override;
virtual ScreenOrientation screen_get_orientation(int p_screen = SCREEN_OF_MAIN_WINDOW) const override;
+ virtual int screen_get_internal_current_rotation(int p_screen) const override;
virtual int get_screen_count() const override;
virtual int get_primary_screen() const override;
diff --git a/platform/android/java/lib/res/values/dimens.xml b/platform/android/java/lib/res/values/dimens.xml
index 9034dbbcc1..287d1c8920 100644
--- a/platform/android/java/lib/res/values/dimens.xml
+++ b/platform/android/java/lib/res/values/dimens.xml
@@ -1,4 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="text_edit_height">48dp</dimen>
+ <dimen name="input_dialog_padding_horizontal">10dp</dimen>
+ <dimen name="input_dialog_padding_vertical">5dp</dimen>
</resources>
diff --git a/platform/android/java/lib/res/values/strings.xml b/platform/android/java/lib/res/values/strings.xml
index 03752e092e..e44addadd0 100644
--- a/platform/android/java/lib/res/values/strings.xml
+++ b/platform/android/java/lib/res/values/strings.xml
@@ -55,4 +55,7 @@
<string name="kilobytes_per_second">%1$s KB/s</string>
<string name="time_remaining">Time remaining: %1$s</string>
<string name="time_remaining_notification">%1$s left</string>
+
+ <!-- Labels for the dialog action buttons -->
+ <string name="dialog_ok">OK</string>
</resources>
diff --git a/platform/android/java/lib/src/org/godotengine/godot/Godot.kt b/platform/android/java/lib/src/org/godotengine/godot/Godot.kt
index d20c5c90db..508c0a30ce 100644
--- a/platform/android/java/lib/src/org/godotengine/godot/Godot.kt
+++ b/platform/android/java/lib/src/org/godotengine/godot/Godot.kt
@@ -46,6 +46,7 @@ import android.os.*
import android.util.Log
import android.util.TypedValue
import android.view.*
+import android.widget.EditText
import android.widget.FrameLayout
import androidx.annotation.Keep
import androidx.annotation.StringRes
@@ -83,6 +84,7 @@ import java.util.*
import java.util.concurrent.atomic.AtomicBoolean
import java.util.concurrent.atomic.AtomicReference
+
/**
* Core component used to interface with the native layer of the engine.
*
@@ -479,12 +481,17 @@ class Godot(private val context: Context) {
// ...add to FrameLayout
containerLayout?.addView(editText)
renderView = if (usesVulkan()) {
- if (!meetsVulkanRequirements(activity.packageManager)) {
+ if (meetsVulkanRequirements(activity.packageManager)) {
+ GodotVulkanRenderView(host, this, godotInputHandler)
+ } else if (canFallbackToOpenGL()) {
+ // Fallback to OpenGl.
+ GodotGLRenderView(host, this, godotInputHandler, xrMode, useDebugOpengl)
+ } else {
throw IllegalStateException(activity.getString(R.string.error_missing_vulkan_requirements_message))
}
- GodotVulkanRenderView(host, this, godotInputHandler)
+
} else {
- // Fallback to openGl
+ // Fallback to OpenGl.
GodotGLRenderView(host, this, godotInputHandler, xrMode, useDebugOpengl)
}
@@ -774,7 +781,7 @@ class Godot(private val context: Context) {
val builder = AlertDialog.Builder(activity)
builder.setMessage(message).setTitle(title)
builder.setPositiveButton(
- "OK"
+ R.string.dialog_ok
) { dialog: DialogInterface, id: Int ->
okCallback?.run()
dialog.cancel()
@@ -819,6 +826,13 @@ class Godot(private val context: Context) {
}
/**
+ * Returns true if can fallback to OpenGL.
+ */
+ private fun canFallbackToOpenGL(): Boolean {
+ return java.lang.Boolean.parseBoolean(GodotLib.getGlobal("rendering/rendering_device/fallback_to_opengl3"))
+ }
+
+ /**
* Returns true if the device meets the base requirements for Vulkan support, false otherwise.
*/
private fun meetsVulkanRequirements(packageManager: PackageManager?): Boolean {
@@ -879,6 +893,31 @@ class Godot(private val context: Context) {
}
/**
+ * Popup a dialog to input text.
+ */
+ @Keep
+ private fun showInputDialog(title: String, message: String, existingText: String) {
+ val activity: Activity = getActivity() ?: return
+ val inputField = EditText(activity)
+ val paddingHorizontal = activity.resources.getDimensionPixelSize(R.dimen.input_dialog_padding_horizontal)
+ val paddingVertical = activity.resources.getDimensionPixelSize(R.dimen.input_dialog_padding_vertical)
+ inputField.setPadding(paddingHorizontal, paddingVertical, paddingHorizontal, paddingVertical)
+ inputField.setText(existingText)
+ runOnUiThread {
+ val builder = AlertDialog.Builder(activity)
+ builder.setMessage(message).setTitle(title).setView(inputField)
+ builder.setPositiveButton(R.string.dialog_ok) {
+ dialog: DialogInterface, id: Int ->
+ GodotLib.inputDialogCallback(inputField.text.toString())
+ dialog.dismiss()
+ }
+ val dialog = builder.create()
+ dialog.show()
+ }
+ }
+
+
+ /**
* Destroys the Godot Engine and kill the process it's running in.
*/
@JvmOverloads
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 542c93d4e2..44102c5d9c 100644
--- a/platform/android/java/lib/src/org/godotengine/godot/GodotIO.java
+++ b/platform/android/java/lib/src/org/godotengine/godot/GodotIO.java
@@ -49,6 +49,7 @@ import android.util.DisplayMetrics;
import android.util.Log;
import android.view.Display;
import android.view.DisplayCutout;
+import android.view.Surface;
import android.view.WindowInsets;
import androidx.core.content.FileProvider;
@@ -297,6 +298,28 @@ public class GodotIO {
}
}
+ /**
+ This function is used by DisplayServer::screen_get_internal_current_rotation (C++)
+ and is used to implement a performance optimization in devices that do not offer
+ a HW rotator.
+ @return
+ Rotation in degrees, in multiples of 90°
+ */
+ public int getInternalCurrentScreenRotation() {
+ int rotation = activity.getWindowManager().getDefaultDisplay().getRotation();
+
+ switch (rotation) {
+ case Surface.ROTATION_90:
+ return 90;
+ case Surface.ROTATION_180:
+ return 180;
+ case Surface.ROTATION_270:
+ return 270;
+ default:
+ return 0;
+ }
+ }
+
public void setEdit(GodotEditText _edit) {
edit = _edit;
}
diff --git a/platform/android/java/lib/src/org/godotengine/godot/GodotLib.java b/platform/android/java/lib/src/org/godotengine/godot/GodotLib.java
index a6b02a96bd..b7adc96196 100644
--- a/platform/android/java/lib/src/org/godotengine/godot/GodotLib.java
+++ b/platform/android/java/lib/src/org/godotengine/godot/GodotLib.java
@@ -227,6 +227,11 @@ public class GodotLib {
public static native void onNightModeChanged();
/**
+ * Invoked on the input dialog submitted.
+ */
+ public static native void inputDialogCallback(String p_text);
+
+ /**
* Invoked on the GL thread to configure the height of the virtual keyboard.
*/
public static native void setVirtualKeyboardHeight(int p_height);
diff --git a/platform/android/java_godot_io_wrapper.cpp b/platform/android/java_godot_io_wrapper.cpp
index 651b80e902..a43ad40188 100644
--- a/platform/android/java_godot_io_wrapper.cpp
+++ b/platform/android/java_godot_io_wrapper.cpp
@@ -68,6 +68,7 @@ GodotIOJavaWrapper::GodotIOJavaWrapper(JNIEnv *p_env, jobject p_godot_io_instanc
_has_hardware_keyboard = p_env->GetMethodID(cls, "hasHardwareKeyboard", "()Z");
_set_screen_orientation = p_env->GetMethodID(cls, "setScreenOrientation", "(I)V");
_get_screen_orientation = p_env->GetMethodID(cls, "getScreenOrientation", "()I");
+ _get_internal_current_screen_rotation = p_env->GetMethodID(cls, "getInternalCurrentScreenRotation", "()I");
_get_system_dir = p_env->GetMethodID(cls, "getSystemDir", "(IZ)Ljava/lang/String;");
}
}
@@ -269,6 +270,16 @@ int GodotIOJavaWrapper::get_screen_orientation() {
}
}
+int GodotIOJavaWrapper::get_internal_current_screen_rotation() {
+ if (_get_internal_current_screen_rotation) {
+ JNIEnv *env = get_jni_env();
+ ERR_FAIL_NULL_V(env, 0);
+ return env->CallIntMethod(godot_io_instance, _get_internal_current_screen_rotation);
+ } else {
+ return 0;
+ }
+}
+
String GodotIOJavaWrapper::get_system_dir(int p_dir, bool p_shared_storage) {
if (_get_system_dir) {
JNIEnv *env = get_jni_env();
diff --git a/platform/android/java_godot_io_wrapper.h b/platform/android/java_godot_io_wrapper.h
index 7aa2967dce..61e2694d02 100644
--- a/platform/android/java_godot_io_wrapper.h
+++ b/platform/android/java_godot_io_wrapper.h
@@ -63,6 +63,7 @@ private:
jmethodID _has_hardware_keyboard = 0;
jmethodID _set_screen_orientation = 0;
jmethodID _get_screen_orientation = 0;
+ jmethodID _get_internal_current_screen_rotation = 0;
jmethodID _get_system_dir = 0;
public:
@@ -90,6 +91,7 @@ public:
void set_vk_height(int p_height);
void set_screen_orientation(int p_orient);
int get_screen_orientation();
+ int get_internal_current_screen_rotation();
String get_system_dir(int p_dir, bool p_shared_storage);
};
diff --git a/platform/android/java_godot_lib_jni.cpp b/platform/android/java_godot_lib_jni.cpp
index b57d46b4a2..5c51c191ed 100644
--- a/platform/android/java_godot_lib_jni.cpp
+++ b/platform/android/java_godot_lib_jni.cpp
@@ -542,6 +542,14 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_onNightModeChanged(JN
}
}
+JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_inputDialogCallback(JNIEnv *env, jclass clazz, jstring p_text) {
+ DisplayServerAndroid *ds = (DisplayServerAndroid *)DisplayServer::get_singleton();
+ if (ds) {
+ String text = jstring_to_string(p_text, env);
+ ds->emit_input_dialog_callback(text);
+ }
+}
+
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_requestPermissionResult(JNIEnv *env, jclass clazz, jstring p_permission, jboolean p_result) {
String permission = jstring_to_string(p_permission, env);
if (permission == "android.permission.RECORD_AUDIO" && p_result) {
diff --git a/platform/android/java_godot_lib_jni.h b/platform/android/java_godot_lib_jni.h
index a8666a0911..de7c628a8d 100644
--- a/platform/android/java_godot_lib_jni.h
+++ b/platform/android/java_godot_lib_jni.h
@@ -69,6 +69,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_calldeferred(JNIEnv *
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_setVirtualKeyboardHeight(JNIEnv *env, jclass clazz, jint p_height);
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_requestPermissionResult(JNIEnv *env, jclass clazz, jstring p_permission, jboolean p_result);
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_onNightModeChanged(JNIEnv *env, jclass clazz);
+JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_inputDialogCallback(JNIEnv *env, jclass clazz, jstring p_text);
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_onRendererResumed(JNIEnv *env, jclass clazz);
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_onRendererPaused(JNIEnv *env, jclass clazz);
JNIEXPORT jboolean JNICALL Java_org_godotengine_godot_GodotLib_shouldDispatchInputToRenderThread(JNIEnv *env, jclass clazz);
diff --git a/platform/android/java_godot_wrapper.cpp b/platform/android/java_godot_wrapper.cpp
index bb7804888e..ac4bfdac1f 100644
--- a/platform/android/java_godot_wrapper.cpp
+++ b/platform/android/java_godot_wrapper.cpp
@@ -69,6 +69,7 @@ GodotJavaWrapper::GodotJavaWrapper(JNIEnv *p_env, jobject p_activity, jobject p_
_get_clipboard = p_env->GetMethodID(godot_class, "getClipboard", "()Ljava/lang/String;");
_set_clipboard = p_env->GetMethodID(godot_class, "setClipboard", "(Ljava/lang/String;)V");
_has_clipboard = p_env->GetMethodID(godot_class, "hasClipboard", "()Z");
+ _show_input_dialog = p_env->GetMethodID(godot_class, "showInputDialog", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V");
_request_permission = p_env->GetMethodID(godot_class, "requestPermission", "(Ljava/lang/String;)Z");
_request_permissions = p_env->GetMethodID(godot_class, "requestPermissions", "()Z");
_get_granted_permissions = p_env->GetMethodID(godot_class, "getGrantedPermissions", "()[Ljava/lang/String;");
@@ -270,6 +271,23 @@ bool GodotJavaWrapper::has_clipboard() {
}
}
+Error GodotJavaWrapper::show_input_dialog(const String &p_title, const String &p_message, const String &p_existing_text) {
+ if (_show_input_dialog) {
+ JNIEnv *env = get_jni_env();
+ ERR_FAIL_NULL_V(env, ERR_UNCONFIGURED);
+ jstring jStrTitle = env->NewStringUTF(p_title.utf8().get_data());
+ jstring jStrMessage = env->NewStringUTF(p_message.utf8().get_data());
+ jstring jStrExistingText = env->NewStringUTF(p_existing_text.utf8().get_data());
+ env->CallVoidMethod(godot_instance, _show_input_dialog, jStrTitle, jStrMessage, jStrExistingText);
+ env->DeleteLocalRef(jStrTitle);
+ env->DeleteLocalRef(jStrMessage);
+ env->DeleteLocalRef(jStrExistingText);
+ return OK;
+ } else {
+ return ERR_UNCONFIGURED;
+ }
+}
+
bool GodotJavaWrapper::request_permission(const String &p_name) {
if (_request_permission) {
JNIEnv *env = get_jni_env();
diff --git a/platform/android/java_godot_wrapper.h b/platform/android/java_godot_wrapper.h
index 65e91491f2..ed31499984 100644
--- a/platform/android/java_godot_wrapper.h
+++ b/platform/android/java_godot_wrapper.h
@@ -60,6 +60,7 @@ private:
jmethodID _get_clipboard = nullptr;
jmethodID _set_clipboard = nullptr;
jmethodID _has_clipboard = nullptr;
+ jmethodID _show_input_dialog = nullptr;
jmethodID _request_permission = nullptr;
jmethodID _request_permissions = nullptr;
jmethodID _get_granted_permissions = nullptr;
@@ -105,6 +106,7 @@ public:
void set_clipboard(const String &p_text);
bool has_has_clipboard();
bool has_clipboard();
+ Error show_input_dialog(const String &p_title, const String &p_message, const String &p_existing_text);
bool request_permission(const String &p_name);
bool request_permissions();
Vector<String> get_granted_permissions() const;