Hi, I am exploring the mobile-App of Joplin
and seen some similar issues in android
and this one also
I think there is no problem with @react-native-file-picker , problem is the Storage Permission.
File -picker behaves bit different in every android version , in some versions it asks for permission before going to pick file but in other(like android 10) it is not ask for storage permission for only file picker.
in my case- I use OnePlus6 (android 10) , as the guideline of Android, we don't have to ask permission for android default system file picker, but if we want to pick file from other built in apps (like Gallery etc...) then we need granted permission to access storage
People generally use gallery for pick photos.
I recreate this issue in android 9,10 and 11.
let see what happens when I recreate this issue in android 10
and after clicked on ok it did't ask me for storage permission.
then i went in app info and manually allowed storage permission and then it successfully attached photo in note.
in any case Joplin did not crash.
but it can crash in older version of androids.
so , we can resolve this issue by adding runtime storage permission in Note.js file it generalizes for all device, when user click on attach file it first verify the storage permission before going forward!!! this way we don't have to depend on file picker to ask permission.
Did a quick test but could not reproduce the error, though I may have granted the permissions earlier.
In any case, I think the correct way to do this is to use URI permissions, this way Joplin does not need to request anything to read the file. To do this however it must read the data via the ContentResolver rather than trying to read it as a file on storage.
So in summary: yes, requesting storage permissions will work (until Android 11, I think) but it's not the best way.
if u want to recreate issue go to app setting and deny media and files permission.(this issue is not in all androids)
you are right , in latest android 12 and 11, we must use ContentResolver API to Retrieve data it makes Joplin more data secure app, no additional permission needed. and for older android Sdks we can Add Permission check.
currently I don't know how to retrieve data by URI with Native APIs . but I worked on a project in past in which I use Media Store and Content Resolver APIs in android to Retrieve music files and there thumbnail(using bitmap decode).
Please also tell me about Search in Joplin android app, it is working too bad in my android 10.
@Amarpsp10 if you're interested in fixing this looks like the best way forward is to use the copyTo option that you can pass to react-native-document-picker to copy the file to Joplin's cache or files dir.
And then just rename it to whatever is needed for Joplin - since the file will be in Joplin's own dir, renaming it should not require any special access permissions.
@roman_r_m sorry to say, but App is already doing same thing, It copy the chosen file in user data(Joplin's own dir) and then proceed next, means there is another problem, but yeah I learnt working of Document Picker,
@roman_r_m I saw this statement after picking file copy(localFilePath, targetPath);
and here localFilePath is Uri of picked file. and const targetPath = Resource_1.default.fullPath(resource);
where const Resource_1 = require("@joplin/lib/models/Resource");
if you get something please tell
So I have tried to reproduce the issue from your original post and could not (I am using the emulator bundled with Android studio). Even without storage permissions I can share pictures both from the stock gallery app and from a random 3rd party gallery I've installed from apkmirror.
Also tried Android 11 - same result.
I think I know how to fix it but without being able to test my changes I am not sure what I can do here.
have you reproduce issue in your real device with android 10?
because different mobiles have different "Security Patches".
one thing more I saw, if we turn on our Developer options then device reduce its security. and also give some diff results
Yes, looks like most issues are with desktop app, probably because it has more functions. And most issues on mobile seem to be related to sync.
If you prefer working on mobile, there are a few choices still: