diff options
Diffstat (limited to 'platform/android')
28 files changed, 116 insertions, 63 deletions
diff --git a/platform/android/SCsub b/platform/android/SCsub index 1f3bbc2350..dfc921cc54 100644 --- a/platform/android/SCsub +++ b/platform/android/SCsub @@ -21,7 +21,7 @@ android_files = [ "android_keys_utils.cpp", "display_server_android.cpp", "plugin/godot_plugin_jni.cpp", - "vulkan/vulkan_context_android.cpp", + "vulkan_context_android.cpp", ] env_android = env.Clone() diff --git a/platform/android/android_keys_utils.h b/platform/android/android_keys_utils.h index bdfaaa3215..5cf5628a8b 100644 --- a/platform/android/android_keys_utils.h +++ b/platform/android/android_keys_utils.h @@ -31,8 +31,9 @@ #ifndef ANDROID_KEYS_UTILS_H #define ANDROID_KEYS_UTILS_H +#include "core/os/keyboard.h" + #include <android/input.h> -#include <core/os/keyboard.h> #define AKEYCODE_MAX 0xFFFF diff --git a/platform/android/api/api.cpp b/platform/android/api/api.cpp index 757ca315a7..60c369951c 100644 --- a/platform/android/api/api.cpp +++ b/platform/android/api/api.cpp @@ -30,10 +30,11 @@ #include "api.h" -#include "core/config/engine.h" #include "java_class_wrapper.h" #include "jni_singleton.h" +#include "core/config/engine.h" + #if !defined(ANDROID_ENABLED) static JavaClassWrapper *java_class_wrapper = nullptr; #endif diff --git a/platform/android/api/jni_singleton.h b/platform/android/api/jni_singleton.h index 455ed259ec..a2d1c08168 100644 --- a/platform/android/api/jni_singleton.h +++ b/platform/android/api/jni_singleton.h @@ -33,8 +33,9 @@ #include "core/config/engine.h" #include "core/variant/variant.h" + #ifdef ANDROID_ENABLED -#include "platform/android/jni_utils.h" +#include "jni_utils.h" #endif class JNISingleton : public Object { diff --git a/platform/android/dir_access_jandroid.cpp b/platform/android/dir_access_jandroid.cpp index 7b41ad87bd..6bd09fe00a 100644 --- a/platform/android/dir_access_jandroid.cpp +++ b/platform/android/dir_access_jandroid.cpp @@ -30,10 +30,11 @@ #include "dir_access_jandroid.h" -#include "core/string/print_string.h" #include "string_android.h" #include "thread_jandroid.h" +#include "core/string/print_string.h" + jobject DirAccessJAndroid::dir_access_handler = nullptr; jclass DirAccessJAndroid::cls = nullptr; jmethodID DirAccessJAndroid::_dir_open = nullptr; diff --git a/platform/android/dir_access_jandroid.h b/platform/android/dir_access_jandroid.h index 05b7d47957..5ee4c85659 100644 --- a/platform/android/dir_access_jandroid.h +++ b/platform/android/dir_access_jandroid.h @@ -31,9 +31,11 @@ #ifndef DIR_ACCESS_JANDROID_H #define DIR_ACCESS_JANDROID_H +#include "java_godot_lib_jni.h" + #include "core/io/dir_access.h" #include "drivers/unix/dir_access_unix.h" -#include "java_godot_lib_jni.h" + #include <stdio.h> /// Android implementation of the DirAccess interface used to provide access to diff --git a/platform/android/display_server_android.cpp b/platform/android/display_server_android.cpp index e07e0e1149..4d9a49c35c 100644 --- a/platform/android/display_server_android.cpp +++ b/platform/android/display_server_android.cpp @@ -30,19 +30,23 @@ #include "display_server_android.h" -#include "core/config/project_settings.h" #include "java_godot_io_wrapper.h" #include "java_godot_wrapper.h" #include "os_android.h" #include "tts_android.h" +#include "core/config/project_settings.h" + #if defined(VULKAN_ENABLED) +#include "vulkan_context_android.h" + #include "drivers/vulkan/rendering_device_vulkan.h" -#include "platform/android/vulkan/vulkan_context_android.h" #include "servers/rendering/renderer_rd/renderer_compositor_rd.h" #endif + #ifdef GLES3_ENABLED #include "drivers/gles3/rasterizer_gles3.h" + #include <EGL/egl.h> #endif diff --git a/platform/android/doc_classes/EditorExportPlatformAndroid.xml b/platform/android/doc_classes/EditorExportPlatformAndroid.xml index 0652ba5c0e..9d68cb78f6 100644 --- a/platform/android/doc_classes/EditorExportPlatformAndroid.xml +++ b/platform/android/doc_classes/EditorExportPlatformAndroid.xml @@ -59,14 +59,17 @@ <member name="keystore/debug" type="String" setter="" getter=""> Path of the debug keystore file. Can be overridden with the environment variable [code]GODOT_ANDROID_KEYSTORE_DEBUG_PATH[/code]. + Fallbacks to [code]EditorSettings.export/android/debug_keystore[/code] if empty. </member> <member name="keystore/debug_password" type="String" setter="" getter=""> Password for the debug keystore file. Can be overridden with the environment variable [code]GODOT_ANDROID_KEYSTORE_DEBUG_PASSWORD[/code]. + Fallbacks to [code]EditorSettings.export/android/debug_keystore_pass[/code] if both it and [member keystore/debug] are empty. </member> <member name="keystore/debug_user" type="String" setter="" getter=""> User name for the debug keystore file. Can be overridden with the environment variable [code]GODOT_ANDROID_KEYSTORE_DEBUG_USER[/code]. + Fallbacks to [code]EditorSettings.export/android/debug_keystore_user[/code] if both it and [member keystore/debug] are empty. </member> <member name="keystore/release" type="String" setter="" getter=""> Path of the release keystore file. @@ -87,7 +90,7 @@ Foreground layer of the application adaptive icon file. </member> <member name="launcher_icons/main_192x192" type="String" setter="" getter=""> - Application icon file. If left empty, project icon is used instead. + Application icon file. If left empty, it will fallback to [member ProjectSettings.application/config/icon]. </member> <member name="package/app_category" type="int" setter="" getter=""> Application category for the Play Store. diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp index 1e048100d1..32b46271fd 100644 --- a/platform/android/export/export.cpp +++ b/platform/android/export/export.cpp @@ -30,10 +30,11 @@ #include "export.h" +#include "export_plugin.h" + #include "core/os/os.h" #include "editor/editor_settings.h" #include "editor/export/editor_export.h" -#include "export_plugin.h" void register_android_exporter_types() { GDREGISTER_VIRTUAL_CLASS(EditorExportPlatformAndroid); diff --git a/platform/android/export/export_plugin.cpp b/platform/android/export/export_plugin.cpp index d8dd453faf..6030239695 100644 --- a/platform/android/export/export_plugin.cpp +++ b/platform/android/export/export_plugin.cpp @@ -30,6 +30,8 @@ #include "export_plugin.h" +#include "../logo_svg.gen.h" +#include "../run_icon_svg.gen.h" #include "gradle_export_util.h" #include "core/config/project_settings.h" @@ -46,8 +48,6 @@ #include "editor/editor_scale.h" #include "editor/editor_settings.h" #include "main/splash.gen.h" -#include "platform/android/logo_svg.gen.h" -#include "platform/android/run_icon_svg.gen.h" #include "modules/modules_enabled.gen.h" // For svg. #ifdef MODULE_SVG_ENABLED @@ -2542,7 +2542,6 @@ Error EditorExportPlatformAndroid::sign_apk(const Ref<EditorExportPreset> &p_pre if (ep.step(vformat(TTR("Signing debug %s..."), export_label), 104)) { return ERR_SKIP; } - } else { keystore = release_keystore; password = release_password; diff --git a/platform/android/export/godot_plugin_config.cpp b/platform/android/export/godot_plugin_config.cpp index 56431c25de..b64cca3254 100644 --- a/platform/android/export/godot_plugin_config.cpp +++ b/platform/android/export/godot_plugin_config.cpp @@ -29,6 +29,7 @@ /**************************************************************************/ #include "godot_plugin_config.h" + /* * Set of prebuilt plugins. * Currently unused, this is just for future reference: diff --git a/platform/android/file_access_android.h b/platform/android/file_access_android.h index b8f45628e5..7ff5c4d117 100644 --- a/platform/android/file_access_android.h +++ b/platform/android/file_access_android.h @@ -32,6 +32,7 @@ #define FILE_ACCESS_ANDROID_H #include "core/io/file_access.h" + #include <android/asset_manager.h> #include <android/log.h> #include <stdio.h> diff --git a/platform/android/file_access_filesystem_jandroid.cpp b/platform/android/file_access_filesystem_jandroid.cpp index ea8459d1ed..a1865fb1d4 100644 --- a/platform/android/file_access_filesystem_jandroid.cpp +++ b/platform/android/file_access_filesystem_jandroid.cpp @@ -30,9 +30,10 @@ #include "file_access_filesystem_jandroid.h" +#include "thread_jandroid.h" + #include "core/os/os.h" #include "core/templates/local_vector.h" -#include "thread_jandroid.h" #include <unistd.h> diff --git a/platform/android/file_access_filesystem_jandroid.h b/platform/android/file_access_filesystem_jandroid.h index 5e74d9de24..739c8a0925 100644 --- a/platform/android/file_access_filesystem_jandroid.h +++ b/platform/android/file_access_filesystem_jandroid.h @@ -31,9 +31,10 @@ #ifndef FILE_ACCESS_FILESYSTEM_JANDROID_H #define FILE_ACCESS_FILESYSTEM_JANDROID_H -#include "core/io/file_access.h" #include "java_godot_lib_jni.h" +#include "core/io/file_access.h" + class FileAccessFilesystemJAndroid : public FileAccess { static jobject file_access_handler; static jclass cls; diff --git a/platform/android/java/editor/src/main/java/org/godotengine/editor/GodotEditor.kt b/platform/android/java/editor/src/main/java/org/godotengine/editor/GodotEditor.kt index ce485afd91..bac9dd4c45 100644 --- a/platform/android/java/editor/src/main/java/org/godotengine/editor/GodotEditor.kt +++ b/platform/android/java/editor/src/main/java/org/godotengine/editor/GodotEditor.kt @@ -76,6 +76,16 @@ open class GodotEditor : FullScreenGodotApp() { private const val PROJECT_MANAGER_ARG = "--project-manager" private const val PROJECT_MANAGER_ARG_SHORT = "-p" private const val PROJECT_MANAGER_PROCESS_NAME_SUFFIX = ":GodotProjectManager" + + /** + * Sets of constants to specify the window to use to run the project. + * + * Should match the values in 'editor/editor_settings.cpp' for the + * 'run/window_placement/android_window' setting. + */ + private const val ANDROID_WINDOW_AUTO = 0 + private const val ANDROID_WINDOW_SAME_AS_EDITOR = 1 + private const val ANDROID_WINDOW_SIDE_BY_SIDE_WITH_EDITOR = 2 } private val commandLineParams = ArrayList<String>() @@ -142,8 +152,7 @@ open class GodotEditor : FullScreenGodotApp() { // Whether we should launch the new godot instance in an adjacent window // https://developer.android.com/reference/android/content/Intent#FLAG_ACTIVITY_LAUNCH_ADJACENT - var launchAdjacent = - Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && (isInMultiWindowMode || isLargeScreen) + var launchAdjacent = shouldGameLaunchAdjacent() for (arg in args) { if (EDITOR_ARG == arg || EDITOR_ARG_SHORT == arg) { @@ -246,6 +255,26 @@ open class GodotEditor : FullScreenGodotApp() { protected open fun enablePanAndScaleGestures() = java.lang.Boolean.parseBoolean(GodotLib.getEditorSetting("interface/touchscreen/enable_pan_and_scale_gestures")) + private fun shouldGameLaunchAdjacent(): Boolean { + return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { + try { + when (Integer.parseInt(GodotLib.getEditorSetting("run/window_placement/android_window"))) { + ANDROID_WINDOW_SAME_AS_EDITOR -> false + ANDROID_WINDOW_SIDE_BY_SIDE_WITH_EDITOR -> true + else -> { + // ANDROID_WINDOW_AUTO + isInMultiWindowMode || isLargeScreen + } + } + } catch (e: NumberFormatException) { + // Fall-back to the 'Auto' behavior + isInMultiWindowMode || isLargeScreen + } + } else { + false + } + } + override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { super.onActivityResult(requestCode, resultCode, data) // Check if we got the MANAGE_EXTERNAL_STORAGE permission diff --git a/platform/android/java/lib/src/org/godotengine/godot/input/GodotGestureHandler.kt b/platform/android/java/lib/src/org/godotengine/godot/input/GodotGestureHandler.kt index e9bc435689..e26c9d39c2 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/input/GodotGestureHandler.kt +++ b/platform/android/java/lib/src/org/godotengine/godot/input/GodotGestureHandler.kt @@ -231,7 +231,7 @@ internal class GodotGestureHandler : SimpleOnGestureListener(), OnScaleGestureLi val x = terminusEvent.x val y = terminusEvent.y - if (terminusEvent.pointerCount >= 2 && panningAndScalingEnabled && !pointerCaptureInProgress) { + if (terminusEvent.pointerCount >= 2 && panningAndScalingEnabled && !pointerCaptureInProgress && !dragInProgress) { GodotLib.pan(x, y, distanceX / 5f, distanceY / 5f) } else if (!scaleInProgress){ dragInProgress = true @@ -241,7 +241,7 @@ internal class GodotGestureHandler : SimpleOnGestureListener(), OnScaleGestureLi } override fun onScale(detector: ScaleGestureDetector): Boolean { - if (!panningAndScalingEnabled || pointerCaptureInProgress) { + if (!panningAndScalingEnabled || pointerCaptureInProgress || dragInProgress) { return false } @@ -256,7 +256,7 @@ internal class GodotGestureHandler : SimpleOnGestureListener(), OnScaleGestureLi } override fun onScaleBegin(detector: ScaleGestureDetector): Boolean { - if (!panningAndScalingEnabled || pointerCaptureInProgress) { + if (!panningAndScalingEnabled || pointerCaptureInProgress || dragInProgress) { return false } scaleInProgress = true diff --git a/platform/android/java_godot_io_wrapper.h b/platform/android/java_godot_io_wrapper.h index 99e29bb53d..c113a13040 100644 --- a/platform/android/java_godot_io_wrapper.h +++ b/platform/android/java_godot_io_wrapper.h @@ -31,12 +31,13 @@ #ifndef JAVA_GODOT_IO_WRAPPER_H #define JAVA_GODOT_IO_WRAPPER_H -#include <android/log.h> -#include <jni.h> +#include "string_android.h" #include "core/math/rect2i.h" #include "core/variant/typed_array.h" -#include "string_android.h" + +#include <android/log.h> +#include <jni.h> // Class that makes functions in java/src/org/godotengine/godot/GodotIO.java callable from C++ class GodotIOJavaWrapper { diff --git a/platform/android/java_godot_lib_jni.cpp b/platform/android/java_godot_lib_jni.cpp index 63435853e9..7c1b6023c7 100644 --- a/platform/android/java_godot_lib_jni.cpp +++ b/platform/android/java_godot_lib_jni.cpp @@ -30,37 +30,36 @@ #include "java_godot_lib_jni.h" -#include "java_godot_io_wrapper.h" -#include "java_godot_wrapper.h" - -#include "android/asset_manager_jni.h" #include "android_input_handler.h" #include "api/java_class_wrapper.h" #include "api/jni_singleton.h" -#include "core/config/engine.h" -#include "core/config/project_settings.h" -#include "core/input/input.h" #include "dir_access_jandroid.h" #include "display_server_android.h" #include "file_access_android.h" #include "file_access_filesystem_jandroid.h" +#include "java_godot_io_wrapper.h" +#include "java_godot_wrapper.h" #include "jni_utils.h" -#include "main/main.h" #include "net_socket_android.h" #include "os_android.h" #include "string_android.h" #include "thread_jandroid.h" #include "tts_android.h" -#include <android/input.h> -#include <unistd.h> - -#include <android/native_window_jni.h> +#include "core/config/engine.h" +#include "core/config/project_settings.h" +#include "core/input/input.h" +#include "main/main.h" #ifdef TOOLS_ENABLED #include "editor/editor_settings.h" #endif +#include <android/asset_manager_jni.h> +#include <android/input.h> +#include <android/native_window_jni.h> +#include <unistd.h> + static JavaClassWrapper *java_class_wrapper = nullptr; static OS_Android *os_android = nullptr; static AndroidInputHandler *input_handler = nullptr; diff --git a/platform/android/java_godot_view_wrapper.h b/platform/android/java_godot_view_wrapper.h index 07742d6bb0..e5b04e4866 100644 --- a/platform/android/java_godot_view_wrapper.h +++ b/platform/android/java_godot_view_wrapper.h @@ -31,12 +31,13 @@ #ifndef JAVA_GODOT_VIEW_WRAPPER_H #define JAVA_GODOT_VIEW_WRAPPER_H +#include "string_android.h" + #include "core/math/vector2.h" + #include <android/log.h> #include <jni.h> -#include "string_android.h" - // Class that makes functions in java/src/org/godotengine/godot/GodotView.java callable from C++ class GodotJavaViewWrapper { private: diff --git a/platform/android/java_godot_wrapper.h b/platform/android/java_godot_wrapper.h index 245ab33dcf..1efdffd71b 100644 --- a/platform/android/java_godot_wrapper.h +++ b/platform/android/java_godot_wrapper.h @@ -31,13 +31,14 @@ #ifndef JAVA_GODOT_WRAPPER_H #define JAVA_GODOT_WRAPPER_H -#include <android/log.h> -#include <jni.h> - -#include "core/templates/list.h" #include "java_godot_view_wrapper.h" #include "string_android.h" +#include "core/templates/list.h" + +#include <android/log.h> +#include <jni.h> + // Class that makes functions in java/src/org/godotengine/godot/Godot.java callable from C++ class GodotJavaWrapper { private: diff --git a/platform/android/jni_utils.h b/platform/android/jni_utils.h index d1a4082ae5..c608f9ebaa 100644 --- a/platform/android/jni_utils.h +++ b/platform/android/jni_utils.h @@ -32,8 +32,10 @@ #define JNI_UTILS_H #include "string_android.h" -#include <core/config/engine.h> -#include <core/variant/variant.h> + +#include "core/config/engine.h" +#include "core/variant/variant.h" + #include <jni.h> struct jvalret { diff --git a/platform/android/os_android.cpp b/platform/android/os_android.cpp index a96dcca3b3..c3a7d70034 100644 --- a/platform/android/os_android.cpp +++ b/platform/android/os_android.cpp @@ -30,25 +30,24 @@ #include "os_android.h" +#include "dir_access_jandroid.h" +#include "display_server_android.h" +#include "file_access_android.h" +#include "file_access_filesystem_jandroid.h" +#include "java_godot_io_wrapper.h" +#include "java_godot_wrapper.h" +#include "net_socket_android.h" + #include "core/config/project_settings.h" #include "drivers/unix/dir_access_unix.h" #include "drivers/unix/file_access_unix.h" #include "main/main.h" -#include "platform/android/display_server_android.h" #include "scene/main/scene_tree.h" #include "servers/rendering_server.h" -#include "dir_access_jandroid.h" -#include "file_access_android.h" -#include "file_access_filesystem_jandroid.h" -#include "net_socket_android.h" - #include <dlfcn.h> #include <sys/system_properties.h> -#include "java_godot_io_wrapper.h" -#include "java_godot_wrapper.h" - const char *OS_Android::ANDROID_EXEC_PATH = "apk"; String _remove_symlink(const String &dir) { diff --git a/platform/android/os_android.h b/platform/android/os_android.h index 99fe501975..abcc412588 100644 --- a/platform/android/os_android.h +++ b/platform/android/os_android.h @@ -32,6 +32,7 @@ #define OS_ANDROID_H #include "audio_driver_opensl.h" + #include "core/os/main_loop.h" #include "drivers/unix/os_unix.h" #include "servers/audio_server.h" diff --git a/platform/android/plugin/godot_plugin_jni.cpp b/platform/android/plugin/godot_plugin_jni.cpp index 843c015d49..5d48c4e248 100644 --- a/platform/android/plugin/godot_plugin_jni.cpp +++ b/platform/android/plugin/godot_plugin_jni.cpp @@ -30,12 +30,13 @@ #include "godot_plugin_jni.h" -#include <core/config/engine.h> -#include <core/config/project_settings.h> -#include <core/error/error_macros.h> -#include <platform/android/api/jni_singleton.h> -#include <platform/android/jni_utils.h> -#include <platform/android/string_android.h> +#include "api/jni_singleton.h" +#include "jni_utils.h" +#include "string_android.h" + +#include "core/config/engine.h" +#include "core/config/project_settings.h" +#include "core/error/error_macros.h" static HashMap<String, JNISingleton *> jni_singletons; diff --git a/platform/android/string_android.h b/platform/android/string_android.h index fe2f2e20a7..3f30b8ec3d 100644 --- a/platform/android/string_android.h +++ b/platform/android/string_android.h @@ -31,8 +31,10 @@ #ifndef STRING_ANDROID_H #define STRING_ANDROID_H -#include "core/string/ustring.h" #include "thread_jandroid.h" + +#include "core/string/ustring.h" + #include <jni.h> /** diff --git a/platform/android/thread_jandroid.cpp b/platform/android/thread_jandroid.cpp index 5051c179ed..9f4140f70f 100644 --- a/platform/android/thread_jandroid.cpp +++ b/platform/android/thread_jandroid.cpp @@ -30,10 +30,10 @@ #include "thread_jandroid.h" -#include <android/log.h> - #include "core/os/thread.h" +#include <android/log.h> + static JavaVM *java_vm = nullptr; static thread_local JNIEnv *env = nullptr; diff --git a/platform/android/vulkan/vulkan_context_android.cpp b/platform/android/vulkan_context_android.cpp index ce4b1b7967..01e6d14438 100644 --- a/platform/android/vulkan/vulkan_context_android.cpp +++ b/platform/android/vulkan_context_android.cpp @@ -28,10 +28,10 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /**************************************************************************/ -#ifdef VULKAN_ENABLED - #include "vulkan_context_android.h" +#ifdef VULKAN_ENABLED + #ifdef USE_VOLK #include <volk.h> #else diff --git a/platform/android/vulkan/vulkan_context_android.h b/platform/android/vulkan_context_android.h index f253149ef6..f253149ef6 100644 --- a/platform/android/vulkan/vulkan_context_android.h +++ b/platform/android/vulkan_context_android.h |