zhanghai / MaterialFiles

Material Design file manager for Android
https://play.google.com/store/apps/details?id=me.zhanghai.android.files
GNU General Public License v3.0
6.07k stars 410 forks source link

Extract generic file managment code into a library #1100

Closed Skaldebane closed 10 months ago

Skaldebane commented 10 months ago

Hi there! Thanks a lot for this amazing project. I use this all the time personally, and now I found myself coming back here as a developer to see how you implemented detecting storage volumes in a way that works across different API versions, and it definitely looks quite hairy with lots of reflection and workarounds (as expected for Android storage stuff :p)

While I was able to copy some of the code I needed (especially the compat stuff you have around storage) and it worked, I thought that this code could be made into a library that simplifies dealing with the file system, and hiding the complexity from regular app developers who need something that just works™ (in my case, my app is a Font Viewer app with a custom picker, and I found picking from removable media (and just knowing which media is connected) quite hard).

I know this is gonna be extra work for you, so take my suggestion with a grain of salt. I'm ready to help with such project if it ever becomes a reality.

And thanks a lot for your amazing work!

zhanghai commented 10 months ago

Why do you need generic file management in a font viewer? Seems to me regular apps should just use Intent.ACTION_OPEN_DOCUMENT. See also https://developer.android.com/training/data-storage/shared/documents-files#open-file .

Skaldebane commented 10 months ago

@zhanghai Indeed that's what I was using, but support for fonts' mime types is really horrible in the built-in pickers (sometimes it works, sometimes not, etc...), and it's just bad UX for users with a lot of font files. My built-in file picker shows previews of the fonts directly there, and a highly requested feature is for me to automatically scan storage for font files and show them to users in a "library" of sorts, with automatic grouping, filtering, sorting, and search by font family, type, and other metadata... and users want this all to work with removable media (e.g. SD Card).

Skaldebane commented 10 months ago

Mmm, just explaining it to you gave me a better idea, by requesting permissions to a folder (or group of folders) where users store their fonts, including anything in their SD Card 🤔

zhanghai commented 10 months ago

Mmm, just explaining it to you gave me a better idea, by requesting permissions to a folder (or group of folders) where users store their fonts, including anything in their SD Card 🤔

Yes this should be the direction for the future, and apps like music players are also doing it since the Android 10 update. Non-file-management apps are no longer supposed to get full storage access or even storage permission. Apps are also no longer supposed to build a file manager/picker into each one of them. If the system picker is bad, then it should be improved, and now we have Mainline which can update DocumentsUI.