Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Editor Android Port #36776

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions editor/editor_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,7 @@ void EditorNode::_notification(int p_what) {
get_tree()->get_root()->set_snap_2d_transforms_to_pixel(false);
get_tree()->get_root()->set_snap_2d_vertices_to_pixel(false);
get_tree()->set_auto_accept_quit(false);
get_tree()->set_quit_on_go_back(false);
m4gr3d marked this conversation as resolved.
Show resolved Hide resolved
get_tree()->get_root()->connect("files_dropped", callable_mp(this, &EditorNode::_dropped_files));

command_palette->register_shortcuts_as_command();
Expand Down
3 changes: 2 additions & 1 deletion main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2251,9 +2251,10 @@ bool Main::start() {

bool embed_subwindows = GLOBAL_DEF("display/window/subwindows/embed_subwindows", true);

if (OS::get_singleton()->is_single_window() || (!project_manager && !editor && embed_subwindows)) {
if (OS::get_singleton()->is_single_window() || (!project_manager && !editor && embed_subwindows) || !DisplayServer::get_singleton()->has_feature(DisplayServer::Feature::FEATURE_SUBWINDOWS)) {
sml->get_root()->set_embed_subwindows_hint(true);
}

ResourceLoader::add_custom_loaders();
ResourceSaver::add_custom_savers();

Expand Down
7 changes: 7 additions & 0 deletions platform/android/java/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ dependencies {
// Custom build mode. In this scenario this project is the only one around and the Godot
// library is available through the pre-generated godot-lib.*.aar android archive files.
debugImplementation fileTree(dir: 'libs/debug', include: ['*.jar', '*.aar'])
releaseDebugmIplementation fileTree(dir: 'libs/debug', include: ['*.jar', '*.aar'])
m4gr3d marked this conversation as resolved.
Show resolved Hide resolved
releaseImplementation fileTree(dir: 'libs/release', include: ['*.jar', '*.aar'])
}

Expand All @@ -66,6 +67,7 @@ dependencies {
android {
compileSdkVersion versions.compileSdk
buildToolsVersion versions.buildTools
ndkVersion versions.ndkVersion

compileOptions {
sourceCompatibility versions.javaVersion
Expand Down Expand Up @@ -95,6 +97,10 @@ android {
targetSdkVersion getExportTargetSdkVersion()
}

buildTypes {
release_debug {}
thebestnom marked this conversation as resolved.
Show resolved Hide resolved
m4gr3d marked this conversation as resolved.
Show resolved Hide resolved
}

lintOptions {
abortOnError false
disable 'MissingTranslation', 'UnusedResources'
Expand Down Expand Up @@ -167,6 +173,7 @@ android {
assets.srcDirs = ['assets']
}
debug.jniLibs.srcDirs = ['libs/debug', 'libs/debug/vulkan_validation_layers']
release_debug.jniLibs.srcDirs = ['libs/debug']
release.jniLibs.srcDirs = ['libs/release']
}

Expand Down
5 changes: 4 additions & 1 deletion platform/android/java/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,17 @@ allprojects {

ext {
supportedAbis = ["armv7", "arm64v8", "x86", "x86_64"]
supportedTargets = ["release", "debug"]
supportedTargets = ["release", "release_debug", "debug"]

// Used by gradle to specify which architecture to build for by default when running `./gradlew build`.
// This command is usually used by Android Studio.
// If building manually on the command line, it's recommended to use the
// `./gradlew generateGodotTemplates` build command instead after running the `scons` command.
// The defaultAbi must be one of the {supportedAbis} values.
defaultAbi = "arm64v8"

//default for building on Android Studio so editor would be built as well
tools=true
}

def rootDir = "../../.."
Expand Down
74 changes: 74 additions & 0 deletions platform/android/java/editor/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="org.godotengine.editor"
android:installLocation="auto"
android:versionCode="1"
android:versionName="1.0">

<supports-screens
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:xlargeScreens="true" />

<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"
tools:ignore="ScopedStorage" />
m4gr3d marked this conversation as resolved.
Show resolved Hide resolved

<application
android:allowBackup="false"
android:icon="@mipmap/icon"
android:label="@string/godot_editor_name_string"
tools:ignore="GoogleAppIndexingWarning"
android:requestLegacyExternalStorage="true">
m4gr3d marked this conversation as resolved.
Show resolved Hide resolved

<activity
android:name=".GodotProjects"
android:configChanges="orientation|keyboardHidden|screenSize|smallestScreenSize|density|keyboard|navigation|screenLayout|uiMode"
android:label="@string/godot_editor_name_string"
android:launchMode="singleTask"
android:resizeableActivity="false"
android:screenOrientation="landscape"
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"
android:process=":GodotProject"
tools:ignore="UnusedAttribute">

<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<activity
android:name=".GodotEditor"
android:configChanges="orientation|keyboardHidden|screenSize|smallestScreenSize|density|keyboard|navigation|screenLayout|uiMode"
android:label="@string/godot_project_name_string"
android:process=":GodotEditor"
android:launchMode="singleTask"
android:resizeableActivity="false"
android:screenOrientation="landscape"
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen">
</activity>

<activity
android:name=".GodotGame"
android:configChanges="orientation|keyboardHidden|screenSize|smallestScreenSize|density|keyboard|navigation|screenLayout|uiMode"
android:label="@string/godot_project_name_string"
android:process=":GodotGame"
android:launchMode="singleTask"
android:resizeableActivity="false"
android:screenOrientation="landscape"
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen">
</activity>


</application>

</manifest>
63 changes: 63 additions & 0 deletions platform/android/java/editor/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// Gradle build config for Godot Engine's Android port.
apply plugin: 'com.android.application'

dependencies {
implementation libraries.kotlinStdLib
implementation libraries.androidxFragment
implementation project(":lib")
}

android {
compileSdkVersion versions.compileSdk
buildToolsVersion versions.buildTools
ndkVersion versions.ndkVersion

defaultConfig {
applicationId "org.godotengine.editor"
minSdkVersion versions.minSdk
targetSdkVersion versions.targetSdk
}

compileOptions {
sourceCompatibility versions.javaVersion
targetCompatibility versions.javaVersion
}

buildTypes {
release_debug {}
m4gr3d marked this conversation as resolved.
Show resolved Hide resolved
}

lintOptions {
abortOnError false
disable 'MissingTranslation', 'UnusedResources'
}

packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'

// 'doNotStrip' is enabled for development within Android Studio
if (shouldNotStrip()) {
doNotStrip '**/*.so'
}
m4gr3d marked this conversation as resolved.
Show resolved Hide resolved
}

sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
res.srcDirs = ['res']
aidl.srcDirs = ['aidl']
assets.srcDirs = ['assets']
}
m4gr3d marked this conversation as resolved.
Show resolved Hide resolved
debug.jniLibs.srcDirs = ['libs/debug']
release_debug.jniLibs.srcDirs = ['libs/debug']
release.jniLibs.srcDirs = ['libs/release']
}

applicationVariants.all { variant ->
variant.outputs.all { output ->
output.outputFileName = "android_editor_${variant.name}.apk"
}
}
}
4 changes: 4 additions & 0 deletions platform/android/java/editor/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="godot_editor_name_string">Godot Editor</string>
</resources>
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*************************************************************************/
/* GodotEditor.java */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/

package org.godotengine.editor;

import org.godotengine.godot.FullScreenGodotApp;

public class GodotEditor extends FullScreenGodotApp {
m4gr3d marked this conversation as resolved.
Show resolved Hide resolved
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*************************************************************************/
/* GodotGame.java */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/

package org.godotengine.editor;

import org.godotengine.godot.FullScreenGodotApp;

public class GodotGame extends FullScreenGodotApp {
m4gr3d marked this conversation as resolved.
Show resolved Hide resolved
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*************************************************************************/
/* GodotProjects.java */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/

package org.godotengine.editor;
import org.godotengine.godot.FullScreenGodotApp;

import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.provider.Settings;

/**
* Activity for Godot projects.
*/
public class GodotProjects extends FullScreenGodotApp {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getGodotFragment().requestPermissions();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R && !Environment.isExternalStorageManager()) {
startActivity(new Intent(Settings.ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION));
m4gr3d marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
2 changes: 1 addition & 1 deletion platform/android/java/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ android.useAndroidX=true

# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx4536m
org.gradle.jvmargs=-Xmx8536m
m4gr3d marked this conversation as resolved.
Show resolved Hide resolved

# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
Expand Down
8 changes: 6 additions & 2 deletions platform/android/java/lib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ def pathToRootDir = "../../../../"
android {
compileSdkVersion versions.compileSdk
buildToolsVersion versions.buildTools

ndkVersion versions.ndkVersion

defaultConfig {
Expand All @@ -26,6 +25,10 @@ android {
targetCompatibility versions.javaVersion
}

buildTypes {
release_debug {}
m4gr3d marked this conversation as resolved.
Show resolved Hide resolved
}

lintOptions {
abortOnError false
disable 'MissingTranslation', 'UnusedResources'
Expand All @@ -50,6 +53,7 @@ android {
assets.srcDirs = ['assets']
}
debug.jniLibs.srcDirs = ['libs/debug']
release_debug.jniLibs.srcDirs = ['libs/debug']
release.jniLibs.srcDirs = ['libs/release']
}

Expand Down Expand Up @@ -105,7 +109,7 @@ android {
def taskName = getSconsTaskName(buildType)
tasks.create(name: taskName, type: Exec) {
executable sconsExecutableFile.absolutePath
args "--directory=${pathToRootDir}", "platform=android", "target=${releaseTarget}", "android_arch=${defaultAbi}", "-j" + Runtime.runtime.availableProcessors()
args "tools=${tools}", "--directory=${pathToRootDir}", "platform=android", "target=${releaseTarget}", "android_arch=${defaultAbi}", "-j" + Runtime.runtime.availableProcessors()
m4gr3d marked this conversation as resolved.
Show resolved Hide resolved
}

// Schedule the tasks so the generated libs are present before the aar file is packaged.
Expand Down
Loading