From 3f299e92551e79c95970b1250b18f22374391706 Mon Sep 17 00:00:00 2001 From: Fredia Huya-Kouadio Date: Mon, 4 Apr 2022 00:22:02 -0700 Subject: [PATCH] Update `resize` settings: - Unlock resizing for the Godot Editor - Add an option to specify whether a game is resizeable for the Godot template --- platform/android/export/export_plugin.cpp | 6 ++++++ platform/android/export/gradle_export_util.cpp | 8 +++++--- .../android/java/editor/src/main/AndroidManifest.xml | 9 +++------ platform/android/java_godot_io_wrapper.cpp | 3 +++ 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/platform/android/export/export_plugin.cpp b/platform/android/export/export_plugin.cpp index df3693ba61b..69ae8ed74ca 100644 --- a/platform/android/export/export_plugin.cpp +++ b/platform/android/export/export_plugin.cpp @@ -863,6 +863,7 @@ void EditorExportPlatformAndroid::_fix_manifest(const Ref &p bool classify_as_game = p_preset->get("package/classify_as_game"); bool retain_data_on_uninstall = p_preset->get("package/retain_data_on_uninstall"); bool exclude_from_recents = p_preset->get("package/exclude_from_recents"); + bool is_resizeable = p_preset->get("screen/is_resizeable"); Vector perms; // Write permissions into the perms variable. @@ -980,6 +981,10 @@ void EditorExportPlatformAndroid::_fix_manifest(const Ref &p encode_uint32(exclude_from_recents, &p_manifest.write[iofs + 16]); } + if (tname == "activity" && attrname == "resizeableActivity") { + encode_uint32(is_resizeable, &p_manifest.write[iofs + 16]); + } + if (tname == "supports-screens") { if (attrname == "smallScreens") { encode_uint32(screen_support_small ? 0xFFFFFFFF : 0, &p_manifest.write[iofs + 16]); @@ -1733,6 +1738,7 @@ void EditorExportPlatformAndroid::get_export_options(List *r_optio r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "screen/support_normal"), true)); r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "screen/support_large"), true)); r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "screen/support_xlarge"), true)); + r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "screen/is_resizeable"), false)); r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "user_data_backup/allow"), false)); diff --git a/platform/android/export/gradle_export_util.cpp b/platform/android/export/gradle_export_util.cpp index ab915a5f855..c4cf82de6c0 100644 --- a/platform/android/export/gradle_export_util.cpp +++ b/platform/android/export/gradle_export_util.cpp @@ -253,11 +253,13 @@ String _get_activity_tag(const Ref &p_preset) { String orientation = _get_android_orientation_label(DisplayServer::ScreenOrientation(int(GLOBAL_GET("display/window/handheld/orientation")))); String manifest_activity_text = vformat( " \n", + "android:screenOrientation=\"%s\" " + "android:resizeableActivity=\"%s\">\n", bool_to_string(p_preset->get("package/exclude_from_recents")), - orientation); + orientation, + bool_to_string(p_preset->get("screen/is_resizeable"))); if (uses_xr) { manifest_activity_text += " \n"; } else { diff --git a/platform/android/java/editor/src/main/AndroidManifest.xml b/platform/android/java/editor/src/main/AndroidManifest.xml index 0708ffa32f4..bae075d9291 100644 --- a/platform/android/java/editor/src/main/AndroidManifest.xml +++ b/platform/android/java/editor/src/main/AndroidManifest.xml @@ -29,8 +29,7 @@ android:name=".GodotProjectManager" android:configChanges="orientation|keyboardHidden|screenSize|smallestScreenSize|density|keyboard|navigation|screenLayout|uiMode" android:launchMode="singleTask" - android:resizeableActivity="false" - android:screenOrientation="landscape" + android:screenOrientation="userLandscape" android:exported="true" android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" android:process=":GodotProjectManager"> @@ -46,8 +45,7 @@ android:configChanges="orientation|keyboardHidden|screenSize|smallestScreenSize|density|keyboard|navigation|screenLayout|uiMode" android:process=":GodotEditor" android:launchMode="singleTask" - android:resizeableActivity="false" - android:screenOrientation="landscape" + android:screenOrientation="userLandscape" android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"> @@ -57,8 +55,7 @@ android:label="@string/godot_project_name_string" android:process=":GodotGame" android:launchMode="singleTask" - android:resizeableActivity="false" - android:screenOrientation="landscape" + android:screenOrientation="userLandscape" android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"> diff --git a/platform/android/java_godot_io_wrapper.cpp b/platform/android/java_godot_io_wrapper.cpp index d6e3ad90b1c..a5698f4efc3 100644 --- a/platform/android/java_godot_io_wrapper.cpp +++ b/platform/android/java_godot_io_wrapper.cpp @@ -198,11 +198,14 @@ void GodotIOJavaWrapper::hide_vk() { } void GodotIOJavaWrapper::set_screen_orientation(int p_orient) { + // The Godot Android Editor sets its own orientation via its AndroidManifest +#ifndef TOOLS_ENABLED if (_set_screen_orientation) { JNIEnv *env = get_jni_env(); ERR_FAIL_COND(env == nullptr); env->CallVoidMethod(godot_io_instance, _set_screen_orientation, p_orient); } +#endif } int GodotIOJavaWrapper::get_screen_orientation() {