summaryrefslogtreecommitdiffstats
path: root/platform/android/java
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2024-06-13 17:19:27 +0200
committerRémi Verschelde <rverschelde@gmail.com>2024-06-13 17:19:27 +0200
commitde8a05f4470a506066e9fe1530fa40a9407a5709 (patch)
tree6a0edfd538b451cd965c2cc1709a9132ba3a5930 /platform/android/java
parente988c1a682c9c9eb6407dc59bf6b52bd8f09277a (diff)
parentf20e21a6d6b91fee2106be2fea5f794cfed7578f (diff)
downloadredot-engine-de8a05f4470a506066e9fe1530fa40a9407a5709.tar.gz
Merge pull request #92965 from m4gr3d/fix_splash_screen
Update the Android splash screen logic
Diffstat (limited to 'platform/android/java')
-rw-r--r--platform/android/java/app/build.gradle1
-rw-r--r--platform/android/java/app/config.gradle3
-rw-r--r--platform/android/java/app/res/drawable-nodpi/splash.pngbin14766 -> 0 bytes
-rw-r--r--platform/android/java/app/res/drawable-nodpi/splash_bg_color.pngbin1360 -> 0 bytes
-rw-r--r--platform/android/java/app/res/drawable/splash_drawable.xml12
-rw-r--r--platform/android/java/app/res/values/themes.xml15
-rw-r--r--platform/android/java/app/src/com/godot/game/GodotApp.java4
-rw-r--r--platform/android/java/editor/build.gradle8
-rw-r--r--platform/android/java/editor/src/debug/res/values/strings.xml4
-rw-r--r--platform/android/java/editor/src/dev/res/values/strings.xml4
-rw-r--r--platform/android/java/editor/src/main/AndroidManifest.xml46
-rw-r--r--platform/android/java/editor/src/main/java/org/godotengine/editor/GodotEditor.kt15
-rw-r--r--platform/android/java/editor/src/main/java/org/godotengine/editor/GodotGame.kt3
-rw-r--r--platform/android/java/editor/src/main/res/layout/godot_editor_layout.xml25
-rw-r--r--platform/android/java/editor/src/main/res/values/strings.xml2
-rw-r--r--platform/android/java/editor/src/main/res/values/themes.xml6
-rw-r--r--platform/android/java/lib/src/org/godotengine/godot/GodotActivity.kt6
17 files changed, 107 insertions, 47 deletions
diff --git a/platform/android/java/app/build.gradle b/platform/android/java/app/build.gradle
index bde6a93c86..01d5d9ef92 100644
--- a/platform/android/java/app/build.gradle
+++ b/platform/android/java/app/build.gradle
@@ -32,6 +32,7 @@ configurations {
dependencies {
implementation "androidx.fragment:fragment:$versions.fragmentVersion"
+ implementation "androidx.core:core-splashscreen:$versions.splashscreenVersion"
if (rootProject.findProject(":lib")) {
implementation project(":lib")
diff --git a/platform/android/java/app/config.gradle b/platform/android/java/app/config.gradle
index c404af34d8..01759a1b2f 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/app/res/drawable-nodpi/splash.png b/platform/android/java/app/res/drawable-nodpi/splash.png
deleted file mode 100644
index 7bddd4325a..0000000000
--- a/platform/android/java/app/res/drawable-nodpi/splash.png
+++ /dev/null
Binary files differ
diff --git a/platform/android/java/app/res/drawable-nodpi/splash_bg_color.png b/platform/android/java/app/res/drawable-nodpi/splash_bg_color.png
deleted file mode 100644
index 004b6fd508..0000000000
--- a/platform/android/java/app/res/drawable-nodpi/splash_bg_color.png
+++ /dev/null
Binary files differ
diff --git a/platform/android/java/app/res/drawable/splash_drawable.xml b/platform/android/java/app/res/drawable/splash_drawable.xml
deleted file mode 100644
index 30627b998c..0000000000
--- a/platform/android/java/app/res/drawable/splash_drawable.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
-
- <item android:drawable="@drawable/splash_bg_color" />
-
- <item>
- <bitmap
- android:gravity="center"
- android:filter="false"
- android:src="@drawable/splash" />
- </item>
-</layer-list>
diff --git a/platform/android/java/app/res/values/themes.xml b/platform/android/java/app/res/values/themes.xml
index d64b50ca45..3ab8401928 100644
--- a/platform/android/java/app/res/values/themes.xml
+++ b/platform/android/java/app/res/values/themes.xml
@@ -3,8 +3,17 @@
<style name="GodotAppMainTheme" parent="@android:style/Theme.Black.NoTitleBar"/>
- <style name="GodotAppSplashTheme" parent="@android:style/Theme.Black.NoTitleBar.Fullscreen">
- <item name="android:windowBackground">@drawable/splash_drawable</item>
- <item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
+ <style name="GodotAppSplashTheme" parent="Theme.SplashScreen">
+ <!-- Set the splash screen background, animated icon, and animation
+ duration. -->
+ <item name="android:windowSplashScreenBackground">@mipmap/icon_background</item>
+
+ <!-- Use windowSplashScreenAnimatedIcon to add a drawable or an animated
+ drawable. One of these is required. -->
+ <item name="windowSplashScreenAnimatedIcon">@mipmap/icon_foreground</item>
+
+ <!-- Set the theme of the Activity that directly follows your splash
+ screen. This is required. -->
+ <item name="postSplashScreenTheme">@style/GodotAppMainTheme</item>
</style>
</resources>
diff --git a/platform/android/java/app/src/com/godot/game/GodotApp.java b/platform/android/java/app/src/com/godot/game/GodotApp.java
index 9142d767b4..22e617f6e7 100644
--- a/platform/android/java/app/src/com/godot/game/GodotApp.java
+++ b/platform/android/java/app/src/com/godot/game/GodotApp.java
@@ -34,6 +34,8 @@ import org.godotengine.godot.GodotActivity;
import android.os.Bundle;
+import androidx.core.splashscreen.SplashScreen;
+
/**
* Template activity for Godot Android builds.
* Feel free to extend and modify this class for your custom logic.
@@ -41,7 +43,7 @@ import android.os.Bundle;
public class GodotApp extends GodotActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
- setTheme(R.style.GodotAppMainTheme);
+ SplashScreen.installSplashScreen(this);
super.onCreate(savedInstanceState);
}
}
diff --git a/platform/android/java/editor/build.gradle b/platform/android/java/editor/build.gradle
index c5ef086152..55fe2a22fe 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 09ee2d77e1..0000000000
--- a/platform/android/java/editor/src/debug/res/values/strings.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<resources>
- <string name="godot_editor_name_string">Godot Editor 4 (debug)</string>
-</resources>
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 215f2c7d0a..0000000000
--- a/platform/android/java/editor/src/dev/res/values/strings.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<resources>
- <string name="godot_editor_name_string">Godot Editor 4 (dev)</string>
-</resources>
diff --git a/platform/android/java/editor/src/main/AndroidManifest.xml b/platform/android/java/editor/src/main/AndroidManifest.xml
index f646ef3f51..c7d14a3f49 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" />
- <uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"
+ <uses-permission
+ android:name="android.permission.MANAGE_EXTERNAL_STORAGE"
tools:ignore="ScopedStorage" />
- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
- android:maxSdkVersion="29"/>
- <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"
- android:maxSdkVersion="29"/>
+ <uses-permission
+ android:name="android.permission.WRITE_EXTERNAL_STORAGE"
+ android:maxSdkVersion="29" />
+ <uses-permission
+ android:name="android.permission.READ_EXTERNAL_STORAGE"
+ android:maxSdkVersion="29" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.VIBRATE" />
@@ -26,39 +29,44 @@
<application
android:allowBackup="false"
android:icon="@mipmap/icon"
- android:label="@string/godot_editor_name_string"
- tools:ignore="GoogleAppIndexingWarning"
- android:theme="@style/GodotEditorTheme"
- android:requestLegacyExternalStorage="true">
+ android:label="${editorAppName}${editorBuildSuffix}"
+ android:requestLegacyExternalStorage="true"
+ android:theme="@style/GodotEditorSplashScreenTheme"
+ tools:ignore="GoogleAppIndexingWarning">
+ <profileable
+ android:shell="true"
+ android:enabled="true"
+ tools:targetApi="29" />
<activity
android:name=".GodotEditor"
android:configChanges="orientation|keyboardHidden|screenSize|smallestScreenSize|density|keyboard|navigation|screenLayout|uiMode"
+ android:exported="true"
android:launchMode="singleTask"
- android:screenOrientation="userLandscape"
- android:exported="true">
- <layout android:defaultHeight="@dimen/editor_default_window_height"
- android:defaultWidth="@dimen/editor_default_window_width" />
+ android:screenOrientation="userLandscape">
+ <layout
+ android:defaultWidth="@dimen/editor_default_window_width"
+ android:defaultHeight="@dimen/editor_default_window_height" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
+
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
-
<activity
android:name=".GodotGame"
android:configChanges="orientation|keyboardHidden|screenSize|smallestScreenSize|density|keyboard|navigation|screenLayout|uiMode"
+ android:exported="false"
android:label="@string/godot_project_name_string"
- android:process=":GodotGame"
android:launchMode="singleTask"
- android:exported="false"
+ android:process=":GodotGame"
android:screenOrientation="userLandscape">
- <layout android:defaultHeight="@dimen/editor_default_window_height"
- android:defaultWidth="@dimen/editor_default_window_width" />
+ <layout
+ android:defaultWidth="@dimen/editor_default_window_width"
+ android:defaultHeight="@dimen/editor_default_window_height" />
</activity>
-
</application>
</manifest>
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 52acd63674..5515347bd6 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<String>()
+ 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 aa4d02b5b2..8e4e089211 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 0000000000..431a468f29
--- /dev/null
+++ b/platform/android/java/editor/src/main/res/layout/godot_editor_layout.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<androidx.constraintlayout.widget.ConstraintLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ xmlns:app="http://schemas.android.com/apk/res-auto">
+
+ <FrameLayout
+ android:id="@+id/godot_fragment_container"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+
+ <ProgressBar
+ style="@android:style/Widget.Holo.ProgressBar.Large"
+ android:id="@+id/editor_loading_indicator"
+ android:layout_width="80dp"
+ android:layout_height="80dp"
+ android:indeterminate="true"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintVertical_bias="0.80"/>
+
+</androidx.constraintlayout.widget.ConstraintLayout>
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 216d02d9c7..909711ab18 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 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
- <string name="godot_editor_name_string">Godot Editor 4</string>
-
<string name="denied_storage_permission_error_msg">Missing storage access permission!</string>
</resources>
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 fda04d6dc7..2b352247db 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 @@
<resources>
<style name="GodotEditorTheme" parent="@android:style/Theme.Black.NoTitleBar.Fullscreen">
</style>
+
+ <style name="GodotEditorSplashScreenTheme" parent="Theme.SplashScreen.IconBackground">
+ <!-- Set the theme of the Activity that directly follows your splash
+ screen. This is required. -->
+ <item name="postSplashScreenTheme">@style/GodotEditorTheme</item>
+ </style>
</resources>
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 7b8fad8952..4c5e857b7a 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()