Skip to content

Commit

Permalink
Configure the splash screen for the Android editor
Browse files Browse the repository at this point in the history
  • Loading branch information
m4gr3d committed Jun 10, 2024
1 parent 5833f59 commit dd966f5
Show file tree
Hide file tree
Showing 11 changed files with 91 additions and 31 deletions.
3 changes: 2 additions & 1 deletion platform/android/java/app/config.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'

]

Expand Down
8 changes: 8 additions & 0 deletions platform/android/java/editor/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -92,6 +94,10 @@ android {
targetSdkVersion versions.targetSdk

missingDimensionStrategy 'products', 'editor'
manifestPlaceholders += [
editorAppName: "Godot Editor 4",
editorBuildSuffix: ""
]
}

base {
Expand Down Expand Up @@ -124,11 +130,13 @@ android {
dev {
initWith debug
applicationIdSuffix ".dev"
manifestPlaceholders += [editorBuildSuffix: " (dev)"]
}

debug {
initWith release
applicationIdSuffix ".debug"
manifestPlaceholders += [editorBuildSuffix: " (debug)"]
signingConfig signingConfigs.debug
}

Expand Down
4 changes: 0 additions & 4 deletions platform/android/java/editor/src/debug/res/values/strings.xml

This file was deleted.

4 changes: 0 additions & 4 deletions platform/android/java/editor/src/dev/res/values/strings.xml

This file was deleted.

46 changes: 27 additions & 19 deletions platform/android/java/editor/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,52 +13,60 @@
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" />

<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>
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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>
2 changes: 0 additions & 2 deletions platform/android/java/editor/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -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>
6 changes: 6 additions & 0 deletions platform/android/java/editor/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand All @@ -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()
Expand Down

0 comments on commit dd966f5

Please sign in to comment.