summaryrefslogtreecommitdiffstats
path: root/platform/android
diff options
context:
space:
mode:
authorFredia Huya-Kouadio <fhuya@meta.com>2023-05-30 19:04:38 -0700
committerFredia Huya-Kouadio <fhuya@meta.com>2023-06-07 18:32:52 -0700
commitb2cd6a8a953e5fa3d96d31850bce00969ae0fa03 (patch)
tree836aaff61404dec34db9124ed1108899cea5552a /platform/android
parent72b59325cf7beba7e6e9170cf6023a079fd58672 (diff)
downloadredot-engine-b2cd6a8a953e5fa3d96d31850bce00969ae0fa03.tar.gz
Add setting to control the window used to run the project for the Android editor
The follow options were added to the (new) `run/window_placement/android_window` editor setting: - `Same as Editor`: run the project in the same window as the editor - `Side-by-side with Editor`: run the project in an adjacent window to the editor - `Auto`: choose how to run the project based on the device screen size
Diffstat (limited to 'platform/android')
-rw-r--r--platform/android/java/editor/src/main/java/org/godotengine/editor/GodotEditor.kt33
1 files changed, 31 insertions, 2 deletions
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