summaryrefslogtreecommitdiffstats
path: root/platform/android/java_godot_lib_jni.cpp
diff options
context:
space:
mode:
authorAnish Mishra <mishragames@gmail.com>2024-10-21 14:47:32 +0530
committerAnish Mishra <mishragames@gmail.com>2024-10-30 14:53:02 +0530
commitb2130efb31c98897a58ebf4de407bff57d3a89b6 (patch)
tree6ff069b80afc29f369dc0c557bc63589af26b491 /platform/android/java_godot_lib_jni.cpp
parent0dfd18c84bf5e44d5c1cb78891a42ae1f8100ea8 (diff)
downloadredot-engine-b2130efb31c98897a58ebf4de407bff57d3a89b6.tar.gz
[Android] Implement native file picker support
Diffstat (limited to 'platform/android/java_godot_lib_jni.cpp')
-rw-r--r--platform/android/java_godot_lib_jni.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/platform/android/java_godot_lib_jni.cpp b/platform/android/java_godot_lib_jni.cpp
index 997534ada3..5c1e78dcc4 100644
--- a/platform/android/java_godot_lib_jni.cpp
+++ b/platform/android/java_godot_lib_jni.cpp
@@ -548,6 +548,22 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_inputDialogCallback(J
}
}
+JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_filePickerCallback(JNIEnv *env, jclass clazz, jboolean p_ok, jobjectArray p_selected_paths) {
+ DisplayServerAndroid *ds = (DisplayServerAndroid *)DisplayServer::get_singleton();
+ if (ds) {
+ Vector<String> selected_paths;
+
+ jint length = env->GetArrayLength(p_selected_paths);
+ for (jint i = 0; i < length; ++i) {
+ jstring java_string = (jstring)env->GetObjectArrayElement(p_selected_paths, i);
+ String path = jstring_to_string(java_string, env);
+ selected_paths.push_back(path);
+ env->DeleteLocalRef(java_string);
+ }
+ ds->emit_file_picker_callback(p_ok, selected_paths);
+ }
+}
+
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) {