Skip to content

Commit 90ba13b

Browse files
committed
Merge pull request godotengine#109528 from syntaxerror247/drive-selection-issue
Fix drive selection issue on Android
2 parents 583f3bf + 5bcf9a5 commit 90ba13b

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

doc/classes/DirAccess.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@
181181
<return type="int" />
182182
<description>
183183
On Windows, returns the number of drives (partitions) mounted on the current filesystem.
184-
On macOS, returns the number of mounted volumes.
184+
On macOS and Android, returns the number of mounted volumes.
185185
On Linux, returns the number of mounted volumes and GTK 3 bookmarks.
186186
On other platforms, the method returns 0.
187187
</description>
@@ -193,6 +193,7 @@
193193
On Windows, returns the name of the drive (partition) passed as an argument (e.g. [code]C:[/code]).
194194
On macOS, returns the path to the mounted volume passed as an argument.
195195
On Linux, returns the path to the mounted volume or GTK 3 bookmark passed as an argument.
196+
On Android (API level 30+), returns the path to the mounted volume as an argument.
196197
On other platforms, or if the requested drive does not exist, the method returns an empty String.
197198
</description>
198199
</method>

platform/android/java/lib/src/org/godotengine/godot/io/directory/FilesystemDirectoryAccess.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,11 @@ internal class FilesystemDirectoryAccess(private val context: Context, private v
159159
}
160160

161161
val storageVolume = storageManager.storageVolumes[drive]
162-
return storageVolume.getDescription(context)
162+
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
163+
storageVolume.directory?.absolutePath ?: ""
164+
} else {
165+
""
166+
}
163167
}
164168

165169
override fun makeDir(dir: String): Boolean {

scene/gui/file_dialog.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1362,7 +1362,7 @@ void FileDialog::set_access(Access p_access) {
13621362
case ACCESS_FILESYSTEM: {
13631363
dir_access = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
13641364
#ifdef ANDROID_ENABLED
1365-
set_root_subfolder(OS::get_singleton()->get_system_dir(OS::SYSTEM_DIR_DESKTOP));
1365+
set_current_dir(OS::get_singleton()->get_system_dir(OS::SYSTEM_DIR_DESKTOP));
13661366
#endif
13671367
} break;
13681368
case ACCESS_RESOURCES: {

0 commit comments

Comments
 (0)