From dd966f5680eac1b068d9492d6dbba572cff54936 Mon Sep 17 00:00:00 2001 From: Fredia Huya-Kouadio Date: Sun, 9 Jun 2024 09:22:45 -0700 Subject: [PATCH] Configure the splash screen for the Android editor --- platform/android/java/app/config.gradle | 3 +- platform/android/java/editor/build.gradle | 8 ++++ .../editor/src/debug/res/values/strings.xml | 4 -- .../editor/src/dev/res/values/strings.xml | 4 -- .../java/editor/src/main/AndroidManifest.xml | 48 +++++++++++-------- .../org/godotengine/editor/GodotEditor.kt | 15 ++++++ .../java/org/godotengine/editor/GodotGame.kt | 3 ++ .../main/res/layout/godot_editor_layout.xml | 25 ++++++++++ .../editor/src/main/res/values/strings.xml | 2 - .../editor/src/main/res/values/themes.xml | 6 +++ .../org/godotengine/godot/GodotActivity.kt | 6 ++- 11 files changed, 92 insertions(+), 32 deletions(-) delete mode 100644 platform/android/java/editor/src/debug/res/values/strings.xml delete mode 100644 platform/android/java/editor/src/dev/res/values/strings.xml create mode 100644 platform/android/java/editor/src/main/res/layout/godot_editor_layout.xml diff --git a/platform/android/java/app/config.gradle b/platform/android/java/app/config.gradle index c404af34d81..01759a1b2fd 100644 --- a/platform/android/java/app/config.gradle +++ b/platform/android/java/app/config.gradle @@ -11,7 +11,8 @@ ext.versions = [ nexusPublishVersion: '1.3.0', javaVersion : JavaVersion.VERSION_17, // Also update 'platform/android/detect.py#get_ndk_version()' when this is updated. - ndkVersion : '23.2.8568313' + ndkVersion : '23.2.8568313', + splashscreenVersion: '1.0.1' ] diff --git a/platform/android/java/editor/build.gradle b/platform/android/java/editor/build.gradle index c5ef0861520..55fe2a22fea 100644 --- a/platform/android/java/editor/build.gradle +++ b/platform/android/java/editor/build.gradle @@ -10,6 +10,8 @@ dependencies { implementation project(":lib") implementation "androidx.window:window:1.2.0" + implementation "androidx.core:core-splashscreen:$versions.splashscreenVersion" + implementation "androidx.constraintlayout:constraintlayout:2.1.4" } ext { @@ -92,6 +94,10 @@ android { targetSdkVersion versions.targetSdk missingDimensionStrategy 'products', 'editor' + manifestPlaceholders += [ + editorAppName: "Godot Editor 4", + editorBuildSuffix: "" + ] } base { @@ -124,11 +130,13 @@ android { dev { initWith debug applicationIdSuffix ".dev" + manifestPlaceholders += [editorBuildSuffix: " (dev)"] } debug { initWith release applicationIdSuffix ".debug" + manifestPlaceholders += [editorBuildSuffix: " (debug)"] signingConfig signingConfigs.debug } diff --git a/platform/android/java/editor/src/debug/res/values/strings.xml b/platform/android/java/editor/src/debug/res/values/strings.xml deleted file mode 100644 index 09ee2d77e19..00000000000 --- a/platform/android/java/editor/src/debug/res/values/strings.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - Godot Editor 4 (debug) - diff --git a/platform/android/java/editor/src/dev/res/values/strings.xml b/platform/android/java/editor/src/dev/res/values/strings.xml deleted file mode 100644 index 215f2c7d0ac..00000000000 --- a/platform/android/java/editor/src/dev/res/values/strings.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - Godot Editor 4 (dev) - diff --git a/platform/android/java/editor/src/main/AndroidManifest.xml b/platform/android/java/editor/src/main/AndroidManifest.xml index f646ef3f51b..c7d14a3f491 100644 --- a/platform/android/java/editor/src/main/AndroidManifest.xml +++ b/platform/android/java/editor/src/main/AndroidManifest.xml @@ -13,12 +13,15 @@ android:glEsVersion="0x00030000" android:required="true" /> - - - + + @@ -26,39 +29,44 @@ + android:label="${editorAppName}${editorBuildSuffix}" + android:requestLegacyExternalStorage="true" + android:theme="@style/GodotEditorSplashScreenTheme" + tools:ignore="GoogleAppIndexingWarning"> + - + android:screenOrientation="userLandscape"> + + - - + - 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 52acd63674b..5515347bd61 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 @@ -38,8 +38,10 @@ import android.content.Intent import android.content.pm.PackageManager import android.os.* import android.util.Log +import android.view.View import android.widget.Toast import androidx.annotation.CallSuper +import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen import androidx.window.layout.WindowMetricsCalculator import org.godotengine.godot.GodotActivity import org.godotengine.godot.GodotLib @@ -88,8 +90,13 @@ open class GodotEditor : GodotActivity() { } private val commandLineParams = ArrayList() + private val editorLoadingIndicator: View? by lazy { findViewById(R.id.editor_loading_indicator) } + + override fun getGodotAppLayout() = R.layout.godot_editor_layout override fun onCreate(savedInstanceState: Bundle?) { + installSplashScreen() + // We exclude certain permissions from the set we request at startup, as they'll be // requested on demand based on use-cases. PermissionsUtil.requestManifestPermissions(this, setOf(Manifest.permission.RECORD_AUDIO)) @@ -121,6 +128,14 @@ open class GodotEditor : GodotActivity() { } } + override fun onGodotMainLoopStarted() { + super.onGodotMainLoopStarted() + runOnUiThread { + // Hide the loading indicator + editorLoadingIndicator?.visibility = View.GONE + } + } + /** * Check for project permissions to enable */ diff --git a/platform/android/java/editor/src/main/java/org/godotengine/editor/GodotGame.kt b/platform/android/java/editor/src/main/java/org/godotengine/editor/GodotGame.kt index aa4d02b5b25..8e4e0892119 100644 --- a/platform/android/java/editor/src/main/java/org/godotengine/editor/GodotGame.kt +++ b/platform/android/java/editor/src/main/java/org/godotengine/editor/GodotGame.kt @@ -34,6 +34,9 @@ package org.godotengine.editor * Drives the 'run project' window of the Godot Editor. */ class GodotGame : GodotEditor() { + + override fun getGodotAppLayout() = org.godotengine.godot.R.layout.godot_app_layout + override fun overrideOrientationRequest() = false override fun enableLongPressGestures() = false diff --git a/platform/android/java/editor/src/main/res/layout/godot_editor_layout.xml b/platform/android/java/editor/src/main/res/layout/godot_editor_layout.xml new file mode 100644 index 00000000000..431a468f290 --- /dev/null +++ b/platform/android/java/editor/src/main/res/layout/godot_editor_layout.xml @@ -0,0 +1,25 @@ + + + + + + + + diff --git a/platform/android/java/editor/src/main/res/values/strings.xml b/platform/android/java/editor/src/main/res/values/strings.xml index 216d02d9c74..909711ab180 100644 --- a/platform/android/java/editor/src/main/res/values/strings.xml +++ b/platform/android/java/editor/src/main/res/values/strings.xml @@ -1,6 +1,4 @@ - Godot Editor 4 - Missing storage access permission! diff --git a/platform/android/java/editor/src/main/res/values/themes.xml b/platform/android/java/editor/src/main/res/values/themes.xml index fda04d6dc7d..2b352247db4 100644 --- a/platform/android/java/editor/src/main/res/values/themes.xml +++ b/platform/android/java/editor/src/main/res/values/themes.xml @@ -2,4 +2,10 @@ + + diff --git a/platform/android/java/lib/src/org/godotengine/godot/GodotActivity.kt b/platform/android/java/lib/src/org/godotengine/godot/GodotActivity.kt index 7b8fad89529..4c5e857b7ac 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/GodotActivity.kt +++ b/platform/android/java/lib/src/org/godotengine/godot/GodotActivity.kt @@ -36,6 +36,7 @@ import android.content.pm.PackageManager import android.os.Bundle import android.util.Log import androidx.annotation.CallSuper +import androidx.annotation.LayoutRes import androidx.fragment.app.FragmentActivity import org.godotengine.godot.utils.PermissionsUtil import org.godotengine.godot.utils.ProcessPhoenix @@ -65,7 +66,7 @@ abstract class GodotActivity : FragmentActivity(), GodotHost { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - setContentView(R.layout.godot_app_layout) + setContentView(getGodotAppLayout()) handleStartIntent(intent, true) @@ -80,6 +81,9 @@ abstract class GodotActivity : FragmentActivity(), GodotHost { } } + @LayoutRes + protected open fun getGodotAppLayout() = R.layout.godot_app_layout + override fun onDestroy() { Log.v(TAG, "Destroying Godot app...") super.onDestroy()