feat: support folder selection from other apps via Storage Access Framework - #202
Open
alvaroemtnez wants to merge 5 commits into
Open
alvaroemtnez wants to merge 5 commits into
alvaroemtnez wants to merge 5 commits into
Conversation
Contributor
|
@zerox80 ^ |
Contributor
|
ill take a look |
zerox80
suggested changes
Aug 10, 2026
Author
|
Thanks for taking the time to check it! I'll have a look between next week and the other and try to solve everything :) |
alvaroemtnez
force-pushed
the
improvement/saf_folder_selection
branch
from
September 16, 2026 09:08
d46f077 to
2cdda93
Compare
…k, include a toggle to pretend to be local storage and solve COLUMN_FLAGS being declared twice in RootCursor.kt
…ulti-threaded file creation
alvaroemtnez
force-pushed
the
improvement/saf_folder_selection
branch
from
September 16, 2026 09:13
2cdda93 to
f65b9c6
Compare
Author
|
Sorry it took this long to get to review it. I just pushed the proposed changes:
Hope I didn't miss anything else, I don't know the codebase that well yet and I run my OpenCloud instance only for myself and my family (and so, I didn't think of those cases and setups with multiple spaces per user, concurrent uploads with duplicated names, etc). PS: the force pushes were because I accidentally merged your latest commits instead of rebasing :( fixed though, the PR has 5 commits: 2 from before, and one with every suggested change. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
OpenCloud has a correct implementation to select its locations from the system files app via the Storage Access Framework. However, as stated in #99 and #45, selecting a folder from an app was not supported, as the
ACTION_OPEN_DOCUMENT_TREEintent of the Android Storage Access Framework (SAF) needed to be implemented.This PR adds support for that intent, and also, as some apps filter the SAF locations and allow only local storage (which OpenCloud can be, if a folder is selected as "available offline", so filtering it makes no sense but hardcoding it as local storage doesn't either), adds a toggle in the Advanced section of settings to pretend to be so, by adding the FLAG_LOCAL_ONLY flag, as other apps like RSAF do, and the corresponding translations for the settings item.
As granting an app access to a location in OpenCloud can mean that the app in question does multiple concurrent operations, light changes have been made, replacing
fileToUploadsingleton with ConcurrentHashMap and UUIDs to support multi-threaded file creation.Code changes
isChildDocumentfunction override toopencloudApp/src/main/java/eu/opencloud/android/presentation/documentsprovider/DocumentsStorageProvider.ktto implement the ACTION_OPEN_DOCUMENT_TREE intent.opencloudApp/src/main/java/eu/opencloud/android/presentation/documentsprovider/DocumentsStorageProvider.kt, minor changes to use ConcurrentHashMap and random UUIDs for a more robust upload queue.addRootfunction inopencloudApp/src/main/java/eu/opencloud/android/presentation/documentsprovider/cursors/RootCursor.ktto pass a boolean to enable pretending to be local storage.opencloudApp/src/main/res/xml/settings_advanced.xmlandopencloudApp/src/main/java/eu/opencloud/android/presentation/settings/advanced/SettingsAdvancedFragment.kt)Limitations
content://eu.opencloud.documents/tree/[ID], where[ID]is an integer defining the directory or file in the internal app tree. As far as I know, displaying the full URI that the user sees in their cloud web UI would require deep and breaking changes (which would probably not be worth, at the moment).AI use
LLMs (Gemini) were used for assistance in code generation and for the translations. All generated code was reviewed and tested and can be easily audited.