diff options
-rw-r--r-- | .travis.yml | 3 | ||||
-rw-r--r-- | editor/import/resource_importer_scene.cpp | 66 | ||||
-rw-r--r-- | editor/import/resource_importer_scene.h | 2 | ||||
-rw-r--r-- | platform/android/SCsub | 9 | ||||
-rw-r--r-- | platform/android/detect.py | 20 | ||||
-rw-r--r-- | platform/android/java/AndroidManifest.xml | 87 | ||||
-rw-r--r-- | platform/android/java/build.gradle | 138 | ||||
-rw-r--r-- | platform/android/java/src/org/godotengine/godot/Godot.java | 10 |
8 files changed, 194 insertions, 141 deletions
diff --git a/.travis.yml b/.travis.yml index 305544d821..a763fa5376 100644 --- a/.travis.yml +++ b/.travis.yml @@ -135,8 +135,7 @@ script: - if [ "$STATIC_CHECKS" = "yes" ]; then sh ./misc/travis/clang-format.sh; else - scons -j2 CC=$CC CXX=$CXX platform=$PLATFORM tools=$TOOLS target=$TARGET $OPTIONS $EXTRA_ARGS; - + scons -j2 CC=$CC CXX=$CXX platform=$PLATFORM tools=$TOOLS target=$TARGET $OPTIONS $EXTRA_ARGS && if [ "$TEST_PROJECT" = "yes" ]; then git clone --depth 1 "https://github.com/godotengine/godot-tests.git"; sed -i "s:custom_template/release=\"\":custom_template/release=\"$(readlink -e bin/godot_server.x11.opt.tools.64)\":" godot-tests/tests/project_export/export_presets.cfg; diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp index 8e6a56a929..64994e21b0 100644 --- a/editor/import/resource_importer_scene.cpp +++ b/editor/import/resource_importer_scene.cpp @@ -960,7 +960,7 @@ void ResourceImporterScene::_find_meshes(Node *p_node, Map<Ref<ArrayMesh>, Trans } } -void ResourceImporterScene::_make_external_resources(Node *p_node, const String &p_base_path, bool p_make_animations, bool p_keep_animations, bool p_make_materials, bool p_keep_materials, bool p_make_meshes, Map<Ref<Animation>, Ref<Animation> > &p_animations, Map<Ref<Material>, Ref<Material> > &p_materials, Map<Ref<ArrayMesh>, Ref<ArrayMesh> > &p_meshes) { +void ResourceImporterScene::_make_external_resources(Node *p_node, const String &p_base_path, bool p_make_animations, bool p_animations_as_text, bool p_keep_animations, bool p_make_materials, bool p_materials_as_text, bool p_keep_materials, bool p_make_meshes, bool p_meshes_as_text, Map<Ref<Animation>, Ref<Animation> > &p_animations, Map<Ref<Material>, Ref<Material> > &p_materials, Map<Ref<ArrayMesh>, Ref<ArrayMesh> > &p_meshes) { List<PropertyInfo> pi; @@ -982,7 +982,14 @@ void ResourceImporterScene::_make_external_resources(Node *p_node, const String anim->track_set_imported(i, true); } - String ext_name = p_base_path.plus_file(_make_extname(E->get()) + ".anim"); + String ext_name; + + if (p_animations_as_text) { + ext_name = p_base_path.plus_file(_make_extname(E->get()) + ".tres"); + } else { + ext_name = p_base_path.plus_file(_make_extname(E->get()) + ".anim"); + } + if (FileAccess::exists(ext_name) && p_keep_animations) { //try to keep custom animation tracks Ref<Animation> old_anim = ResourceLoader::load(ext_name, "Animation", true); @@ -1017,7 +1024,14 @@ void ResourceImporterScene::_make_external_resources(Node *p_node, const String if (!p_materials.has(mat)) { - String ext_name = p_base_path.plus_file(_make_extname(mat->get_name()) + ".material"); + String ext_name; + + if (p_materials_as_text) { + ext_name = p_base_path.plus_file(_make_extname(mat->get_name()) + ".tres"); + } else { + ext_name = p_base_path.plus_file(_make_extname(mat->get_name()) + ".material"); + } + if (p_keep_materials && FileAccess::exists(ext_name)) { //if exists, use it p_materials[mat] = ResourceLoader::load(ext_name); @@ -1045,7 +1059,13 @@ void ResourceImporterScene::_make_external_resources(Node *p_node, const String if (!p_meshes.has(mesh)) { //meshes are always overwritten, keeping them is not practical - String ext_name = p_base_path.plus_file(_make_extname(mesh->get_name()) + ".mesh"); + String ext_name; + + if (p_meshes_as_text) { + ext_name = p_base_path.plus_file(_make_extname(mesh->get_name()) + ".tres"); + } else { + ext_name = p_base_path.plus_file(_make_extname(mesh->get_name()) + ".mesh"); + } ResourceSaver::save(ext_name, mesh, ResourceSaver::FLAG_CHANGE_PATH); p_meshes[mesh] = ResourceLoader::load(ext_name); @@ -1067,9 +1087,14 @@ void ResourceImporterScene::_make_external_resources(Node *p_node, const String continue; if (!p_materials.has(mat)) { + String ext_name; + + if (p_materials_as_text) { + ext_name = p_base_path.plus_file(_make_extname(mat->get_name()) + ".tres"); + } else { + ext_name = p_base_path.plus_file(_make_extname(mat->get_name()) + ".material"); + } - String ext_name = p_base_path.plus_file(_make_extname(mat->get_name()) + ".material"); - ; if (p_keep_materials && FileAccess::exists(ext_name)) { //if exists, use it p_materials[mat] = ResourceLoader::load(ext_name); @@ -1086,7 +1111,15 @@ void ResourceImporterScene::_make_external_resources(Node *p_node, const String //re-save the mesh since a material is now assigned if (p_make_meshes) { - String ext_name = p_base_path.plus_file(_make_extname(mesh->get_name()) + ".mesh"); + + String ext_name; + + if (p_meshes_as_text) { + ext_name = p_base_path.plus_file(_make_extname(mesh->get_name()) + ".tres"); + } else { + ext_name = p_base_path.plus_file(_make_extname(mesh->get_name()) + ".mesh"); + } + ResourceSaver::save(ext_name, mesh, ResourceSaver::FLAG_CHANGE_PATH); p_meshes[mesh] = ResourceLoader::load(ext_name); } @@ -1105,7 +1138,7 @@ void ResourceImporterScene::_make_external_resources(Node *p_node, const String for (int i = 0; i < p_node->get_child_count(); i++) { - _make_external_resources(p_node->get_child(i), p_base_path, p_make_animations, p_keep_animations, p_make_materials, p_keep_materials, p_make_meshes, p_animations, p_materials, p_meshes); + _make_external_resources(p_node->get_child(i), p_base_path, p_make_animations, p_animations_as_text, p_keep_animations, p_make_materials, p_materials_as_text, p_keep_materials, p_make_meshes, p_meshes_as_text, p_animations, p_materials, p_meshes); } } @@ -1134,18 +1167,18 @@ void ResourceImporterScene::get_import_options(List<ImportOption> *r_options, in r_options->push_back(ImportOption(PropertyInfo(Variant::STRING, "nodes/custom_script", PROPERTY_HINT_FILE, script_ext_hint), "")); r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "nodes/storage", PROPERTY_HINT_ENUM, "Single Scene,Instanced Sub-Scenes"), scenes_out ? 1 : 0)); r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "materials/location", PROPERTY_HINT_ENUM, "Node,Mesh"), (meshes_out || materials_out) ? 1 : 0)); - r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "materials/storage", PROPERTY_HINT_ENUM, "Built-In,Files", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), materials_out ? 1 : 0)); + r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "materials/storage", PROPERTY_HINT_ENUM, "Built-In,Files (.material),Files (.tres)", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), materials_out ? 1 : 0)); r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "materials/keep_on_reimport"), materials_out)); r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "meshes/compress"), true)); r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "meshes/ensure_tangents"), true)); - r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "meshes/storage", PROPERTY_HINT_ENUM, "Built-In,Files"), meshes_out ? 1 : 0)); + r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "meshes/storage", PROPERTY_HINT_ENUM, "Built-In,Files (.mesh),Files (.tres)"), meshes_out ? 1 : 0)); r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "meshes/light_baking", PROPERTY_HINT_ENUM, "Disabled,Enable,Gen Lightmaps", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), 0)); r_options->push_back(ImportOption(PropertyInfo(Variant::REAL, "meshes/lightmap_texel_size", PROPERTY_HINT_RANGE, "0.001,100,0.001"), 0.1)); r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "external_files/store_in_subdir"), false)); r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "animation/import", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), true)); r_options->push_back(ImportOption(PropertyInfo(Variant::REAL, "animation/fps", PROPERTY_HINT_RANGE, "1,120,1"), 15)); r_options->push_back(ImportOption(PropertyInfo(Variant::STRING, "animation/filter_script", PROPERTY_HINT_MULTILINE_TEXT), "")); - r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "animation/storage", PROPERTY_HINT_ENUM, "Built-In,Files", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), animations_out)); + r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "animation/storage", PROPERTY_HINT_ENUM, "Built-In,Files (.anim),Files (.tres)"), animations_out ? true : false)); r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "animation/keep_custom_tracks"), animations_out)); r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "animation/optimizer/enabled", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), true)); r_options->push_back(ImportOption(PropertyInfo(Variant::REAL, "animation/optimizer/max_linear_error"), 0.05)); @@ -1367,10 +1400,13 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p _filter_tracks(scene, animation_filter); } - bool external_animations = int(p_options["animation/storage"]) == 1; + bool external_animations = int(p_options["animation/storage"]) == 1 || int(p_options["animation/storage"]) == 2; + bool external_animations_as_text = int(p_options["animation/storage"]) == 2; bool keep_custom_tracks = p_options["animation/keep_custom_tracks"]; - bool external_materials = p_options["materials/storage"]; - bool external_meshes = p_options["meshes/storage"]; + bool external_materials = int(p_options["materials/storage"]) == 1 || int(p_options["materials/storage"]) == 2; + bool external_materials_as_text = int(p_options["materials/storage"]) == 2; + bool external_meshes = int(p_options["meshes/storage"]) == 1 || int(p_options["meshes/storage"]) == 2; + bool external_meshes_as_text = int(p_options["meshes/storage"]) == 2; bool external_scenes = int(p_options["nodes/storage"]) == 1; String base_path = p_source_file.get_base_dir(); @@ -1425,7 +1461,7 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p bool keep_materials = bool(p_options["materials/keep_on_reimport"]); - _make_external_resources(scene, base_path, external_animations, keep_custom_tracks, external_materials, keep_materials, external_meshes, anim_map, mat_map, mesh_map); + _make_external_resources(scene, base_path, external_animations, external_animations_as_text, keep_custom_tracks, external_materials, external_materials_as_text, keep_materials, external_meshes, external_meshes_as_text, anim_map, mat_map, mesh_map); } progress.step(TTR("Running Custom Script..."), 2); diff --git a/editor/import/resource_importer_scene.h b/editor/import/resource_importer_scene.h index 498e0f6fb8..ef9a77917f 100644 --- a/editor/import/resource_importer_scene.h +++ b/editor/import/resource_importer_scene.h @@ -144,7 +144,7 @@ public: void _find_meshes(Node *p_node, Map<Ref<ArrayMesh>, Transform> &meshes); - void _make_external_resources(Node *p_node, const String &p_base_path, bool p_make_animations, bool p_keep_animations, bool p_make_materials, bool p_keep_materials, bool p_make_meshes, Map<Ref<Animation>, Ref<Animation> > &p_animations, Map<Ref<Material>, Ref<Material> > &p_materials, Map<Ref<ArrayMesh>, Ref<ArrayMesh> > &p_meshes); + void _make_external_resources(Node *p_node, const String &p_base_path, bool p_make_animations, bool p_animations_as_text, bool p_keep_animations, bool p_make_materials, bool p_materials_as_text, bool p_keep_materials, bool p_make_meshes, bool p_meshes_as_text, Map<Ref<Animation>, Ref<Animation> > &p_animations, Map<Ref<Material>, Ref<Material> > &p_materials, Map<Ref<ArrayMesh>, Ref<ArrayMesh> > &p_meshes); Node *_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh>, List<Ref<Shape> > > &collision_map, LightBakeMode p_light_bake_mode); diff --git a/platform/android/SCsub b/platform/android/SCsub index e355caf0f9..d2f27817c6 100644 --- a/platform/android/SCsub +++ b/platform/android/SCsub @@ -1,12 +1,11 @@ #!/usr/bin/env python -Import('env') - -from distutils.version import LooseVersion from detect import get_ndk_version +from distutils.version import LooseVersion -android_files = [ +Import('env') +android_files = [ 'os_android.cpp', 'file_access_android.cpp', 'audio_driver_opensl.cpp', @@ -18,7 +17,7 @@ android_files = [ 'java_class_wrapper.cpp', 'java_godot_wrapper.cpp', 'java_godot_io_wrapper.cpp', -# 'power_android.cpp' + #'power_android.cpp' ] env_android = env.Clone() diff --git a/platform/android/detect.py b/platform/android/detect.py index 283791f336..8b62360888 100644 --- a/platform/android/detect.py +++ b/platform/android/detect.py @@ -32,14 +32,12 @@ def get_opts(): def get_flags(): - return [ ('tools', False), ] def create(env): - tools = env['TOOLS'] if "mingw" in tools: tools.remove('mingw') @@ -50,7 +48,6 @@ def create(env): def configure(env): - # Workaround for MinGW. See: # http://www.scons.org/wiki/LongCmdLinesOnWin32 if (os.name == "nt"): @@ -90,7 +87,7 @@ def configure(env): env['SPAWN'] = mySpawn - ## Architecture + # Architecture if env['android_arch'] not in ['armv7', 'arm64v8', 'x86', 'x86_64']: env['android_arch'] = 'armv7' @@ -137,14 +134,14 @@ def configure(env): arch_subpath = "arm64-v8a" env.extra_suffix = ".armv8" + env.extra_suffix - ## Build type + # Build type if (env["target"].startswith("release")): - if (env["optimize"] == "speed"): #optimize for speed (default) + if (env["optimize"] == "speed"): # optimize for speed (default) env.Append(LINKFLAGS=['-O2']) env.Append(CCFLAGS=['-O2', '-fomit-frame-pointer']) env.Append(CPPDEFINES=['NDEBUG']) - else: #optimize for size + else: # optimize for size env.Append(CCFLAGS=['-Os']) env.Append(CPPDEFINES=['NDEBUG']) env.Append(LINKFLAGS=['-Os']) @@ -159,7 +156,7 @@ def configure(env): env.Append(CPPDEFINES=['_DEBUG', 'DEBUG_ENABLED', 'DEBUG_MEMORY_ENABLED']) env.Append(CPPFLAGS=['-UNDEBUG']) - ## Compiler configuration + # Compiler configuration env['SHLIBSUFFIX'] = '.so' @@ -204,7 +201,7 @@ def configure(env): common_opts = ['-fno-integrated-as', '-gcc-toolchain', gcc_toolchain_path] - ## Compile flags + # Compile flags env.Append(CPPFLAGS=["-isystem", env["ANDROID_NDK_ROOT"] + "/sources/cxx-stl/llvm-libc++/include"]) env.Append(CPPFLAGS=["-isystem", env["ANDROID_NDK_ROOT"] + "/sources/cxx-stl/llvm-libc++abi/include"]) @@ -259,7 +256,7 @@ def configure(env): env.Append(CCFLAGS=target_opts) env.Append(CCFLAGS=common_opts) - ## Link flags + # Link flags ndk_version = get_ndk_version(env["ANDROID_NDK_ROOT"]) if ndk_version != None and LooseVersion(ndk_version) >= LooseVersion("17.1.4828580"): @@ -268,7 +265,7 @@ def configure(env): env.Append(LINKFLAGS=[env["ANDROID_NDK_ROOT"] + "/sources/cxx-stl/llvm-libc++/libs/" + arch_subpath + "/libandroid_support.a"]) env.Append(LINKFLAGS=['-shared', '--sysroot=' + lib_sysroot, '-Wl,--warn-shared-textrel']) env.Append(LIBPATH=[env["ANDROID_NDK_ROOT"] + "/sources/cxx-stl/llvm-libc++/libs/" + arch_subpath + "/"]) - env.Append(LINKFLAGS=[env["ANDROID_NDK_ROOT"] +"/sources/cxx-stl/llvm-libc++/libs/" + arch_subpath + "/libc++_shared.so"]) + env.Append(LINKFLAGS=[env["ANDROID_NDK_ROOT"] + "/sources/cxx-stl/llvm-libc++/libs/" + arch_subpath + "/libc++_shared.so"]) if env["android_arch"] == "armv7": env.Append(LINKFLAGS='-Wl,--fix-cortex-a8'.split()) @@ -287,6 +284,7 @@ def configure(env): env.Append(CPPDEFINES=['ANDROID_ENABLED', 'UNIX_ENABLED', 'NO_FCNTL']) env.Append(LIBS=['OpenSLES', 'EGL', 'GLESv3', 'GLESv2', 'android', 'log', 'z', 'dl']) + # Return NDK version string in source.properties (adapted from the Chromium project). def get_ndk_version(path): if path is None: diff --git a/platform/android/java/AndroidManifest.xml b/platform/android/java/AndroidManifest.xml index 3152ef12cd..5114aeb8c5 100644 --- a/platform/android/java/AndroidManifest.xml +++ b/platform/android/java/AndroidManifest.xml @@ -1,58 +1,73 @@ <?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="com.godot.game" - android:versionCode="1" - android:versionName="1.0" - android:installLocation="auto" - > -<supports-screens android:smallScreens="true" - android:normalScreens="true" - android:largeScreens="true" - android:xlargeScreens="true"/> - -<!--glEsVersion is modified by the exporter, changing this value here has no effect--> - <uses-feature android:glEsVersion="0x00020000" android:required="true" /> -<!--Adding custom text to manifest is fine, but do it outside the custom user and application BEGIN/END regions, as that gets rewritten--> - -<!--Custom permissions XML added by add-ons. It's recommended to add them from the export preset, though--> + xmlns:tools="http://schemas.android.com/tools" + package="com.godot.game" + android:versionCode="1" + android:versionName="1.0" + android:installLocation="auto" > + + <!-- Adding custom text to the manifest is fine, but do it outside the custom USER and APPLICATION BEGIN/END comments, --> + <!-- as that gets rewritten. --> + + <supports-screens + android:smallScreens="true" + android:normalScreens="true" + android:largeScreens="true" + android:xlargeScreens="true" /> + + <!-- glEsVersion is modified by the exporter, changing this value here has no effect. --> + <uses-feature + android:glEsVersion="0x00020000" + android:required="true" /> + +<!-- Custom user permissions XML added by add-ons. It's recommended to add them from the export preset, though. --> <!--CHUNK_USER_PERMISSIONS_BEGIN--> <!--CHUNK_USER_PERMISSIONS_END--> -<!--Anything in this line after the icon will be erased when doing custom build. If you want to add tags manually, do before it.--> - <application android:label="@string/godot_project_name_string" android:allowBackup="false" tools:ignore="GoogleAppIndexingWarning" android:icon="@drawable/icon"> + <!-- Any tag in this line after android:icon will be erased when doing custom builds. --> + <!-- If you want to add tags manually, do before it. --> + <application + android:label="@string/godot_project_name_string" + android:allowBackup="false" + tools:ignore="GoogleAppIndexingWarning" + android:icon="@drawable/icon" > -<!--The following values are replaced when Godot exports, modifying them here has no effect. Do these changes in the--> -<!--export preset. Adding new ones is fine.--> + <!-- The following metadata values are replaced when Godot exports, modifying them here has no effect. --> + <!-- Do these changes in the export preset. Adding new ones is fine. --> -<!-- XR mode metadata. This is modified by the exporter based on the selected xr mode. DO NOT CHANGE the values here. --> - <meta-data android:name="xr_mode_metadata_name" android:value="xr_mode_metadata_value"/> + <!-- XR mode metadata. This is modified by the exporter based on the selected xr mode. DO NOT CHANGE the values here. --> + <meta-data + android:name="xr_mode_metadata_name" + android:value="xr_mode_metadata_value" /> - <activity android:name="org.godotengine.godot.Godot" - android:label="@string/godot_project_name_string" - android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" - android:launchMode="singleTask" - android:screenOrientation="landscape" - android:configChanges="orientation|keyboardHidden|screenSize|smallestScreenSize|density|keyboard|navigation|screenLayout|uiMode" - android:resizeableActivity="false" - tools:ignore="UnusedAttribute"> + <activity + android:name="org.godotengine.godot.Godot" + android:label="@string/godot_project_name_string" + android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" + android:launchMode="singleTask" + android:screenOrientation="landscape" + android:configChanges="orientation|keyboardHidden|screenSize|smallestScreenSize|density|keyboard|navigation|screenLayout|uiMode" + android:resizeableActivity="false" + tools:ignore="UnusedAttribute" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> - <service android:name="org.godotengine.godot.GodotDownloaderService" /> -<!--Custom application XML added by add-ons--> + <service android:name="org.godotengine.godot.GodotDownloaderService" /> + +<!-- Custom application XML added by add-ons. --> <!--CHUNK_APPLICATION_BEGIN--> <!--CHUNK_APPLICATION_END--> </application> - <instrumentation android:icon="@drawable/icon" - android:label="@string/godot_project_name_string" - android:name="org.godotengine.godot.GodotInstrumentation" - android:targetPackage="org.godotengine.game" /> + <instrumentation + android:icon="@drawable/icon" + android:label="@string/godot_project_name_string" + android:name="org.godotengine.godot.GodotInstrumentation" + android:targetPackage="org.godotengine.game" /> </manifest> diff --git a/platform/android/java/build.gradle b/platform/android/java/build.gradle index 620128fc94..0f8499ba91 100644 --- a/platform/android/java/build.gradle +++ b/platform/android/java/build.gradle @@ -1,113 +1,111 @@ -//Gradle project for Godot Engine Android port. -//Do not modify code between the BEGIN/END sections, as it's autogenerated by add-ons +// Gradle build config for Godot Engine's Android port. +// +// Do not remove/modify comments ending with BEGIN/END, they are used to inject +// addon-specific configuration. buildscript { - repositories { - google() - jcenter() + repositories { + google() + jcenter() //CHUNK_BUILDSCRIPT_REPOSITORIES_BEGIN //CHUNK_BUILDSCRIPT_REPOSITORIES_END - } - dependencies { - classpath 'com.android.tools.build:gradle:3.4.2' + } + dependencies { + classpath 'com.android.tools.build:gradle:3.4.2' //CHUNK_BUILDSCRIPT_DEPENDENCIES_BEGIN //CHUNK_BUILDSCRIPT_DEPENDENCIES_END - } + } } apply plugin: 'com.android.application' allprojects { repositories { - mavenCentral() - google() - jcenter() + mavenCentral() + google() + jcenter() //CHUNK_ALLPROJECTS_REPOSITORIES_BEGIN //CHUNK_ALLPROJECTS_REPOSITORIES_END - } } dependencies { - implementation "com.android.support:support-core-utils:28.0.0" + implementation "com.android.support:support-core-utils:28.0.0" //CHUNK_DEPENDENCIES_BEGIN //CHUNK_DEPENDENCIES_END } android { + compileSdkVersion 28 + buildToolsVersion "28.0.3" + useLibrary 'org.apache.http.legacy' - lintOptions { - abortOnError false - disable 'MissingTranslation','UnusedResources' - } - - compileSdkVersion 28 - buildToolsVersion "28.0.3" - useLibrary 'org.apache.http.legacy' - - packagingOptions { - exclude 'META-INF/LICENSE' - exclude 'META-INF/NOTICE' - } - defaultConfig { - minSdkVersion 18 - targetSdkVersion 28 + defaultConfig { + minSdkVersion 18 + targetSdkVersion 28 //CHUNK_ANDROID_DEFAULTCONFIG_BEGIN //CHUNK_ANDROID_DEFAULTCONFIG_END - } - // Both signing and zip-aligning will be done at export time - buildTypes.all { buildType -> - buildType.zipAlignEnabled false - buildType.signingConfig null - } - sourceSets { - main { - manifest.srcFile 'AndroidManifest.xml' - java.srcDirs = ['src' + } + + lintOptions { + abortOnError false + disable 'MissingTranslation', 'UnusedResources' + } + + packagingOptions { + exclude 'META-INF/LICENSE' + exclude 'META-INF/NOTICE' + } + + // Both signing and zip-aligning will be done at export time + buildTypes.all { buildType -> + buildType.zipAlignEnabled false + buildType.signingConfig null + } + + sourceSets { + main { + manifest.srcFile 'AndroidManifest.xml' + java.srcDirs = [ + 'src' //DIR_SRC_BEGIN //DIR_SRC_END - ] - res.srcDirs = [ - 'res' + ] + res.srcDirs = [ + 'res' //DIR_RES_BEGIN //DIR_RES_END - ] - aidl.srcDirs = [ - 'aidl' + ] + aidl.srcDirs = [ + 'aidl' //DIR_AIDL_BEGIN //DIR_AIDL_END - ] - assets.srcDirs = [ - 'assets' + ] + assets.srcDirs = [ + 'assets' //DIR_ASSETS_BEGIN //DIR_ASSETS_END - - ] - } - debug.jniLibs.srcDirs = [ - 'libs/debug' + ] + } + debug.jniLibs.srcDirs = [ + 'libs/debug' //DIR_JNI_DEBUG_BEGIN //DIR_JNI_DEBUG_END - ] - release.jniLibs.srcDirs = [ - 'libs/release' + ] + release.jniLibs.srcDirs = [ + 'libs/release' //DIR_JNI_RELEASE_BEGIN //DIR_JNI_RELEASE_END - ] - } -// No longer used, as it's not useful for build source template -// applicationVariants.all { variant -> -// variant.outputs.all { output -> -// output.outputFileName = "../../../../../../../bin/android_${variant.name}.apk" -// } -// } + ] + } + // No longer used, as it's not useful for build source template + //applicationVariants.all { variant -> + // variant.outputs.all { output -> + // output.outputFileName = "../../../../../../../bin/android_${variant.name}.apk" + // } + //} } //CHUNK_GLOBAL_BEGIN //CHUNK_GLOBAL_END - - - - - diff --git a/platform/android/java/src/org/godotengine/godot/Godot.java b/platform/android/java/src/org/godotengine/godot/Godot.java index 7f71430805..1b3239777c 100644 --- a/platform/android/java/src/org/godotengine/godot/Godot.java +++ b/platform/android/java/src/org/godotengine/godot/Godot.java @@ -31,6 +31,7 @@ package org.godotengine.godot; import android.Manifest; +import android.annotation.SuppressLint; import android.app.Activity; import android.app.ActivityManager; import android.app.AlertDialog; @@ -56,6 +57,7 @@ import android.os.Build; import android.os.Bundle; import android.os.Environment; import android.os.Messenger; +import android.os.VibrationEffect; import android.os.Vibrator; import android.provider.Settings.Secure; import android.support.annotation.Keep; @@ -325,12 +327,18 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC * Used by the native code (java_godot_wrapper.h) to vibrate the device. * @param durationMs */ + @SuppressLint("MissingPermission") @Keep private void vibrate(int durationMs) { if (requestPermission("VIBRATE")) { Vibrator v = (Vibrator)getSystemService(Context.VIBRATOR_SERVICE); if (v != null) { - v.vibrate(durationMs); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + v.vibrate(VibrationEffect.createOneShot(durationMs, VibrationEffect.DEFAULT_AMPLITUDE)); + } else { + //deprecated in API 26 + v.vibrate(durationMs); + } } } } |