-
-
Notifications
You must be signed in to change notification settings - Fork 97
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
Add support for Android native file dialogs #10983
Comments
I don't see a reason why it should be a separate class, this would be better implemented with the existing FileDialog.use_native_dialog property and DisplayServer.file_dialog_show method |
Dese it work for Android or iOS? |
Currently it only work on desktop platform. I am working on it to implement it for android :) |
Oh, really thanks 🎉 |
The docs say it only works on Linux, Windows, and macOS:
|
I hope it will add soon. |
It is now supported for Android. For iOS see #1123 |
Describe the project you are working on
I am working on enhancing the mobile usability of applications developed with Godot Engine 4.4+ by improving the file handling experience. While Godot provides a FileDialog that works well on desktop platforms, its design and functionality are less intuitive for mobile devices like Android and iOS. On mobile, users expect interactions to be more streamlined and native, such as using the system's file manager for file access.
The goal of this project is to integrate native file access functionality into Godot for Android and iOS platforms. This would allow developers to leverage the platform-specific file managers, resulting in a more seamless and familiar experience for users.
Describe the problem or limitation you are having in your project
The current FileDialog in Godot is designed primarily for desktop platforms and does not translate well to mobile devices. On mobile platforms, the FileDialog is non-intuitive, aesthetically unappealing, and lacks features users expect from a mobile file manager. Additionally, it does not integrate with native mobile file managers, limiting the user's ability to browse and manage files through the OS-standard file system interface.
Key limitations include:
Describe the feature / enhancement and how it helps to overcome the problem or limitation
The feature I am proposing is to integrate native file access for Android and iOS platforms within Godot 4.4+. This means the ability for Godot-based applications to invoke the native file manager on mobile devices, allowing users to browse and select files through a system-native interface.
Benefits of this enhancement:
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
The proposal involves implementing platform-specific code that hooks into Android's
Storage Access Framework
and iOS'sUIDocumentPickerViewController
. Below is a breakdown of how the implementation could work:Android Implementation (Java + Godot GDExtension)
On Android, the
Storage Access Framework (SAF)
can be invoked to present the system file picker.In Godot, we can write a simple GDExtension that will invoke the file picker and return the selected file URI back to the script.
Also see: https://developer.android.com/guide/topics/providers/document-provider
iOS Implementation (Objective-C + GDExtension)
On iOS, we can use
UIDocumentPickerViewController
to access the system file picker.Also see: https://developer.apple.com/documentation/uikit/uidocumentpickerviewcontroller
In GDScript, developers will have access to a new method
open_native_file_dialog()
:If this enhancement will not be used often, can it be worked around with a few lines of script?
No, this enhancement cannot be worked around easily with a few lines of script. While it may be possible to create platform-specific plugins, integrating native file access directly into the Godot core is the only reliable solution for a seamless user experience. Platform-specific features like permission handling, file URI management, and OS-specific quirks require a deeper level of integration that would be difficult to achieve efficiently through scripts or addons.
Is there a reason why this should be core and not an add-on in the asset library?
Yes, this feature should be integrated into the core of Godot, as it deals with fundamental file access on mobile platforms. Integrating it into the core provides the following advantages:
• Cross-platform Consistency: Ensures that file access works consistently across both Android and iOS, without requiring developers to maintain separate plugins.
• Native Integration: Core-level integration ensures full access to native APIs, streamlining permissions and handling OS-level file access features, which are critical for modern mobile applications.
• Improved Maintenance: As mobile platforms evolve, core integration ensures that file access features can be updated and maintained by the Godot development team, keeping up with platform changes and new APIs.
The text was updated successfully, but these errors were encountered: