1
0
mirror of https://github.com/godotengine/godot.git synced 2025-12-02 16:48:55 +00:00

Android: Implement support for native dialog

This adds support for DisplayServer::dialog_show() on Android, aligning it with the functionality already available on macOS and Windows.
This commit is contained in:
Anish Mishra
2025-01-03 09:24:38 +05:30
parent bdf625bd54
commit cb9ee099ac
14 changed files with 347 additions and 37 deletions

View File

@@ -70,7 +70,7 @@ bool DisplayServerAndroid::has_feature(Feature p_feature) const {
//case FEATURE_IME:
case FEATURE_MOUSE:
//case FEATURE_MOUSE_WARP:
//case FEATURE_NATIVE_DIALOG:
case FEATURE_NATIVE_DIALOG:
case FEATURE_NATIVE_DIALOG_INPUT:
case FEATURE_NATIVE_DIALOG_FILE:
//case FEATURE_NATIVE_DIALOG_FILE_EXTRA:
@@ -177,6 +177,19 @@ bool DisplayServerAndroid::clipboard_has() const {
}
}
Error DisplayServerAndroid::dialog_show(String p_title, String p_description, Vector<String> p_buttons, const Callable &p_callback) {
GodotJavaWrapper *godot_java = OS_Android::get_singleton()->get_godot_java();
ERR_FAIL_NULL_V(godot_java, FAILED);
dialog_callback = p_callback;
return godot_java->show_dialog(p_title, p_description, p_buttons);
}
void DisplayServerAndroid::emit_dialog_callback(int p_button_index) {
if (dialog_callback.is_valid()) {
dialog_callback.call_deferred(p_button_index);
}
}
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);