android icon indicating copy to clipboard operation
android copied to clipboard

[Feature request] Implement DocumentsProvider

Open jacopotediosi opened this issue 5 years ago • 5 comments

As a cloud application, Mega should allow access to files through the Android Storage Access Framework (SAF).

For examples and more info, an open letter to Cloud Storage Apps can be found here: https://medium.com/steadfast-innovation/open-letter-to-cloud-storage-apps-on-android-a2d0eb919fc4

I've already tried to implement a DocumentProvider to Mega following these guides, to make a PR and reduce your workload:

  • https://developer.android.com/guide/topics/providers/create-document-provider
  • https://medium.com/androiddevelopers/building-a-documentsprovider-f7f2fb38e86a

But I found some difficulties that I was unable to solve (probably because I don't know enough about the structure of the app and the apis):

  • Whenever a DocumentsProvider is created, megaApi.fastLogin() and megaApi.fetchNodes() must be called, which are blocking tasks and need to be completed before we can respond to queryRoots(), slowing down operations and failing sometimes
  • I was unable to get megaApi.startUnbufferedDownload() to work with ParcelFileDescriptor.AutoCloseOutputStream( ParcelFileDescriptor.createReliablePipe()[1] ): download didn't start and remained in STATE_QUEUED
  • It appears that openDocument() is called by SAF multiple times when opening a single document, causing the same download multiple times

jacopotediosi avatar May 27 '20 21:05 jacopotediosi

This definitely must happen and it has superb benefits. For example, I could choose to backup a KeePass vault and use it on both PC and an Android app without worrying about sync.

iskandergaba avatar Jan 26 '22 00:01 iskandergaba

KeePass

Totally agree. I was searching if that function was written by some third-party and found this topic.

This is shameful 'bump', but I do not see another way to indicate such thing.

↘️ https://developer.android.com/guide/topics/providers/document-provider#overview ⠀↘️ https://developer.android.com/guide/topics/providers/create-document-provider

I am not sure, but DocumentsProvider also would add an option to refer to a remote resource which might auto-download/upgrade to its latest version on open.

Screenshot of folder selection in system picker

patrolez avatar Sep 09 '22 01:09 patrolez