Is there any reason why AI2 is redirecting the ImagePicker to the ASD for Android ≥ 10? @ewpatton
Kodular (rightly) doesn’t do that (after the new Fenix update). Because even under targetSdkVersion = 30, the app still has unrestricted (read) access to media files in the external storage (of course with READ permission).
It has always been the case that the ImagePicker has copied the selected image to an area associated with App Inventor. Historically, that has been /sdcard/AppInventor, but with the recent changes to the file system access by Google, starting in Android 10 it copies to the app specific directory instead.
Yes, but what sense should it make that the image is saved in the ASD after every pick. In addition, if the same image is selected several times, a new image is created in the ASD after each opening (.AfterPicking), so that the memory is superfluously filled.
In addition, no image can be selected from the ASD with the ImagePicker (at least not under Android 11). The user would probably like to know which image he / she has accessed from which location. The ASD path and the image name generated there does not say anything about it.
So I think this (historical) approach might be reconsidered.
This assumes that the images on disk are not going to change between subsequent invocations of the image picker, which is too strong of an assumption in the general case. Technically, it might even be possible (although highly unlikely) that an image could change between when it is picked and when App Inventor copies it to App Inventor's working directory. This behavior ensures that for the average App Inventor user once they've picked an image it will remain and be available for them to manipulate.
This is an unfortunate side effect of Google's rule changes. The goal is that eventually people could write to the shared storage so that the picker would be able to use those images.
Yes, of course, but even with this it is not possible to select an image from the ASD.
However, I have found a way via an extension with which images (files) can also be picked from the ASD with targetSdk = 30.
Is there any way to write (save) → non-media files e.g. to /Documents or /Download (targetSDK=30, without MANAGE_EXTERNAL_STORAGE permission)? Probably not, but I'm not 100% sure.
I definitely agree that the storage requirements are confusing. I'll have to run some tests on Android 9, 10, and 11 to better understand exactly what's going on here.
I don't understand how that can be Evan - the ASD should be accessible by the App, so we should provide App Inventor Users with a picker for images stored in the ASD.
But the actual behaviour should be to allow user to pick files from whole storage and not only from ASD, because ASD is only accessible to that particular app.
Yes, but neither the ImagePicker nor the Activity starter can access the ASD, at least as far as I know (and certainly not under Android 11). If you've found a way, show us.
As already said, I found a way to select (pick) the ASD directly with the help of an extension.
Maybe not an elegant method but as we know that files inside ASD can be accessed through File Manager extensions so list files and let user choose from it.But then you will have to rely completely on the 'custom' file picker.
I see a lot of apps using this kind of file picker, so that they don't rely on Android version completely.
Yes, of course, it is possible to list all files or those of a certain type. But this is definitely not a user-friendly method. It should therefore be possible in principle to select (pick) the ASD in order to be able to select any file and any subfolder from there.
Like this (with an extension, tested on Android 11, APK, also tested with targetSdk=30):
I don't think that is possible with your FileTools or @Taifun's TaifunFile extension. You'll need at least one more extension. Otherwise show your approach.
The ImagePicker is implemented using an intent to launch the ACTION_PICK intent, which typically launches another application. That application won't necessarily be privy to the private data of the App Inventor app specific directory. This is where the breakdown occurs. I think the eventual goal will be to use the "Shared" scope to write to the shared directories so that apps would integrate correctly with tools like the ImagePicker. I'll have to double check, but I believe that the Camera and Camcorder components will still result in media in the DCIM folder, which would allow access to the ImagePicker, but components like Canvas will not since they don't save to the shared directories.