You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-09 12:50:35 +00:00
Android Editor: Disable nomedia file creation for Android 11 (api level 30)
Fixes https://github.com/godotengine/godot/issues/106479 Fixes https://github.com/godotengine/godot/issues/105399
This commit is contained in:
@@ -1069,15 +1069,19 @@ void EditorFileSystem::scan() {
|
||||
if (first_scan) {
|
||||
_first_scan_filesystem();
|
||||
#ifdef ANDROID_ENABLED
|
||||
const String nomedia_file_path = ProjectSettings::get_singleton()->get_resource_path().path_join(".nomedia");
|
||||
if (!FileAccess::exists(nomedia_file_path)) {
|
||||
// Create a .nomedia file to hide assets from media apps on Android.
|
||||
Ref<FileAccess> f = FileAccess::open(nomedia_file_path, FileAccess::WRITE);
|
||||
if (f.is_null()) {
|
||||
// .nomedia isn't so critical.
|
||||
ERR_PRINT("Couldn't create .nomedia in project path.");
|
||||
} else {
|
||||
f->close();
|
||||
// Android 11 has some issues with nomedia files, so it's disabled there. See GH-106479 and GH-105399 for details.
|
||||
String sdk_version = OS::get_singleton()->get_version().get_slicec('.', 0);
|
||||
if (sdk_version != "30") {
|
||||
const String nomedia_file_path = ProjectSettings::get_singleton()->get_resource_path().path_join(".nomedia");
|
||||
if (!FileAccess::exists(nomedia_file_path)) {
|
||||
// Create a .nomedia file to hide assets from media apps on Android.
|
||||
Ref<FileAccess> f = FileAccess::open(nomedia_file_path, FileAccess::WRITE);
|
||||
if (f.is_null()) {
|
||||
// .nomedia isn't so critical.
|
||||
ERR_PRINT("Couldn't create .nomedia in project path.");
|
||||
} else {
|
||||
f->close();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -739,14 +739,18 @@ void ProjectDialog::ok_pressed() {
|
||||
hide();
|
||||
if (mode == MODE_NEW || mode == MODE_IMPORT || mode == MODE_INSTALL) {
|
||||
#ifdef ANDROID_ENABLED
|
||||
// Create a .nomedia file to hide assets from media apps on Android.
|
||||
const String nomedia_file_path = path.path_join(".nomedia");
|
||||
Ref<FileAccess> f2 = FileAccess::open(nomedia_file_path, FileAccess::WRITE);
|
||||
if (f2.is_null()) {
|
||||
// .nomedia isn't so critical.
|
||||
ERR_PRINT("Couldn't create .nomedia in project path.");
|
||||
} else {
|
||||
f2->close();
|
||||
// Android 11 has some issues with nomedia files, so it's disabled there. See GH-106479, GH-105399 for details.
|
||||
String sdk_version = OS::get_singleton()->get_version().get_slicec('.', 0);
|
||||
if (sdk_version != "30") {
|
||||
// Create a .nomedia file to hide assets from media apps on Android.
|
||||
const String nomedia_file_path = path.path_join(".nomedia");
|
||||
Ref<FileAccess> f2 = FileAccess::open(nomedia_file_path, FileAccess::WRITE);
|
||||
if (f2.is_null()) {
|
||||
// .nomedia isn't so critical.
|
||||
ERR_PRINT("Couldn't create .nomedia in project path.");
|
||||
} else {
|
||||
f2->close();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
emit_signal(SNAME("project_created"), path, edit_check_box->is_pressed());
|
||||
|
||||
Reference in New Issue
Block a user