mendhak/gpslogger

[BUG] Can't enter a writable file path above v107 / why no graphical folder seclection?

Closed this issue · 21 comments

Galaxy S10 (And 11)

Since v107, I can't enter a writable file path. I don't want to use the hidden default folder but I can't select a simple folder like "Downloads". Folders on an SD card don't work either, all permissions are granted.
Why do we still have to enter the path manually? For people (like me), who find paths on Android more than confusing, it's a real pain. Why not the standard graphical selection as in every other app?

A long time ago there used to be a graphical folder picker, I can't remember all the reasons now, I had to remove it as it was causing more problems than it was solving, in terms of support, crashes and new Android changes. The idea was to replace it with something compatible with the modern requirements including Scoped Storage.

I never got around to doing it, and the storage restrictions have been piling on, so now I'm lost as to how to provide a workflow that lets users pick a folder and let this app be granted permission to create files in there. My lack of time nowadays isn't helping, though just a few months ago I did finally upgrade to SDK 30 which will help with a reimplementation. That must be related to the restrictions you're seeing as I had to do SDK upgrades in the past few versions.

Oh :o
Didn't know Android's storage/file system is so (unnecessary) complicated :/

A long time ago there used to be a graphical folder picker, I can't remember all the reasons now, I had to remove it as it was causing more problems than it was solving, in terms of support, crashes and new Android changes. The idea was to replace it with something compatible with the modern requirements including Scoped Storage.

@mendhak: maybe you would like to look at Gadgetbridge? They use a modern graphical folder picker.
https://codeberg.org/Freeyourgadget/Gadgetbridge
You will find the folder picker in "Settings -> Export location" (see attached screenshots).
Since I am not a developer, I can not give you the exact location in the Gadgetbrige-sourcecode, but maybe this information is helpful for you.
01
02

One more hint:
GPSlogger asks only for file-access to "mediafiles" (see attched screenshots).
I think this prevents GPSlogger from saving GPX-files outside of its own folder (/storage/emulated/0/Android/data/com.mendhak.gpslogger/files) in Android11. Maybe you should ask for file-access to "all files", so GPSlogger can save to /storage/emulated/0/MyGpxFiles...
03
04

Thank you so much for developig GPSlogger! ❤️

Hey there, in blastrock's pull request the 2nd part should be taken care of, I've been testing it by writing to different paths and it prompts for permission and then the app is able to write to that location. I think you've seen the PR already, I'm just testing it a bit right now.

For the first part, a file picker, I'll have a look at the repo you mentioned. There's also a site, Android Arsenal which has some libraries I could look at for this. https://android-arsenal.com/tag/35?sort=created

I had a look at the GadgetBridge app, and they are picking a specific file via their export feature. You'll notice you can even point directly at Google Drive via that picker, and it'll export to that location.

The problem with using the "built in" directory chooser is this. Accessing paths in newer Android versions no longer returns a directory path, instead you get a result like this from that file/directory chooser:

content://com.android.externalstorage.documents/tree/primary%3AGPSLogger%2FFilesGoHere

Which would be OK but it also requires a new way of writing files, and that new way of writing files doesn't have all the functionality that I've been using so far to write files efficiently.

I've tried looking for some folder pickers which return the internal paths, but many no longer work or don't work with API Level 16. In any case that's a lot of moving parts, that's why a large rewrite required.

So what I'm doing for now is I'll release this permission fix so that it at least lets people write to different paths.

@mendhak Just wanted to let you know that the update didn't resolve the problem on my device

Hey @3Domse3 the version 116 isn't on fdroid yet, that will take about a week to show up. I've only just released its tag I assume you were trying version 115.

Hey @3Domse3 the version 116 isn't on fdroid yet, that will take about a week to show up. I've only just released its tag I assume you were trying version 115.

I always download the apk from Github and install it manually. Inside the app, it says "version 116"

The problem with using the "built in" directory chooser is this. Accessing paths in newer Android versions no longer returns a directory path, instead you get a result like this from that file/directory chooser:
damn, that is much more complicated than I thought... :)

So what I'm doing for now is I'll release this permission fix so that it at least lets people write to different paths.
ok, I think that is the best solution for now! 👍

Hey @3Domse3 the version 116 isn't on fdroid yet, that will take about a week to show up. I've only just released its tag I assume you were trying version 115.

I always download the apk from Github and install it manually. Inside the app, it says "version 116"

Oh no... what path did you enter, and what error did you get?

I tried stuff like /storage/emulated/0/GPSLogger and /storage/emulated/0/Download/ and those worked for me, where previously they didn't.

Did you get prompted for the file manager permission? You should get an error saying that path isn't writable... on the next screen choose to allow file manager. SOmething like that.

I will also test, as soon as it is on F-Droid and let you guys know...

I tried stuff like /storage/emulated/0/GPSLogger and /storage/emulated/0/Download/ and those worked for me, where previously they didn't.

I'm sorry, I thought the new path selector was already in place. Manually entering a path works now for me too :)
Do you know what I need to enter as a path to store on the SD card? I find Android paths quite confusing :/

Do you know what I need to enter as a path to store on the SD card? I find Android paths quite confusing :/

You could use "Material Files" (https://f-droid.org/de/packages/me.zhanghai.android.files/), then browse to the path and click on the "..." -> "Copy Path".

Do you know what I need to enter as a path to store on the SD card? I find Android paths quite confusing :/

You could use "Material Files" (https://f-droid.org/de/packages/me.zhanghai.android.files/), then browse to the path and click on the "..." -> "Copy Path".

Thanks :D

Hi all in this pull request here I'm adding in a directory and file chooser. It's there for the GPSLogger folder path, and the SFTP private key path.

It took a loooooooooooooooooooot of searching and this one was the least troublesome, but I've also had to fork it and add some patches.

I've added some screenshots in that PR. I'll repaste the screenshots here.

First you have to pick the storage:

image

Then the folder picker looks like so:

image

And the file picker looks like so:

image

Hi all in this pull request here I'm adding in a directory and file chooser. It's there for the GPSLogger folder path, and the SFTP private key path.

OMG! Thank you! :D

I will also test, as soon as it is on F-Droid and let you guys know...

@mendhak ok so, because 116 is available on f-droid since a few hours, I've tested it and I was able to save into /storage/emulated/0/GPX 👍 (Android 11)
Thank you!!!

Thanks for update, that's good to hear! FDroid build server had been stuck for a few days, I'd been waiting for it to go through so I could create this prerelease tag.

I think v117 is almost ready just a little bit more testing to do. My struggle has been with the SD Card. I can't write to it in any emulators even if I have the permissions to. It seems like SD Cards are really locked down and it seems on SD cards, you're only allowed to write to the app's own folder but no other place. That is, /storage/XXXX-YYYY/Android/data/com.mendhak.gpslogger/files.

It seems like SD Cards are really locked down and it seems on SD cards, you're only allowed to write to the app's own folder but no other place. That is, /storage/XXXX-

Oh okay :/ Nothing we can do about I guess. I remember, an older version (~v107) was able to write to a choosable folder on my SD card.

Hi all, finally v117 is on F-Droid. The app will now ask for a manage storage permission (on Android 11+) when you choose the 'save to folder' setting. In my emulator testing, only on Android 11+, I was also able to save to SD card. But not on any other OS version.

There's also a graphical folder picker for files and folders so you don't have to type it in anymore. The folder picker is for saving the log location, the file picker is for SFTP private key path.

I'm now going around and closing a bunch of issues related to folder permissions.

Hi all, finally v117 is on F-Droid. The app will now ask for a manage storage permission (on Android 11+) when you choose the 'save to folder' setting. In my emulator testing, only on Android 11+,

Tested with Android 11 on Oneplus 6T and it is working great. 👍
Can not test with SDcard, since my device has no sdcard...