Description
This issue is to enable organice running as a native Android app to provide access to local files.
IOs should be added later, but is out of scope for this (I don't know IOs).
Workflow should be like this:
- User opens the native file picker dialog to choose a directory where org files live
- (optional) organice will store that location for future use
- organice will read and write org files to that location - the same flow as for web
I believe native android with local storage is achievable.
There is prior work on organice develop
branch.
It uses capacitor-js to build a native Android version of organice.
organice runs in a web view and should be able to access native Android (and IOs) filesystem API's via capacitor plugins.
I tried to implement the code with some success using https://github.com/ionic-team/capacitor-plugins/tree/main/filesystem plugin and https://github.com/capawesome-team/capacitor-file-picker .
I managed to create and read files but not control exactly where to put them and also did not manage to use the right native open file dialog (use SD card or other providers) .
I talked with one friend who is familiar with Android dev and also did some checking and I published my findings as comments on
- feat(file-picker): add
pickDirectory(...)
method capawesome-team/capacitor-plugins#16 - feat: On Android I can't select files on SD card - I see only Photos and Google drive capawesome-team/capacitor-file-picker#60
I think the easiest solution for us long term would be to implement our own capacitor plugin with and API specific to organice.
I believe the Android Java code will be easy to maintain and port to something else then capacitor if there is ever the need.
Also the API surface is small.
The downside of this approach is that the IOs interface should be developed separately (by someone who knows this part)
Related issues:
- Create a plugin: https://capacitorjs.com/docs/plugins/creating-plugins
- Android API's to use https://developer.android.com/guide/topics/providers/document-provider
- Android storage client example code: https://github.com/android/storage-samples/blob/main/StorageClient/Application/src/main/java/com/example/android/storageclient/StorageClientFragment.java
- Provide access to local files - filesystem backend - use web File API #921
- Local File System Adapter #752
- Allow syncing to local filesystem / new sync target #730
- Full offline support #399