zamojski / TowerCollector

The OpenCellID and MLS contributor's app.
Mozilla Public License 2.0
217 stars 27 forks source link

Where is tree? #130

Open jidanni opened 3 years ago

jidanni commented 3 years ago

Screenshot_20210724-132228.jpg Where is this crazy tree directory? Why so much confusion? No other app acts like this.

zamojski commented 3 years ago

This way Android reports the path to the selected primary storage, if you select SD card it will show something similar to /tree/sdcard/TowerCollector. In all cases tree means the root folder, I can delete it from there but still you will need to find primary...

Any example of application that shows the path in the other way but uses the same folder selection method?

jidanni commented 3 years ago

Well all I know is no file was saved. The stock file explorer app uses no such names. But it does have a 'recent' function that scans the disk for new files, and there were none. So no file was saved anywhere.

jidanni commented 3 years ago

Please use paths that, e.g., can be browsed with the chrome browser: file:///sdcard/TowerCollector . The fancy internal names are of no use if other apps can't use them.

jidanni commented 3 years ago

https://stackoverflow.com/questions/29713587/how-to-get-the-real-path-with-action-open-document-tree-intent Please only show real paths to users.

zamojski commented 3 years ago

The recent files shown by file picker works only for Downloads folder, so it you choose to save exported files there you'll see them. Currently Android recommends to use DocumentFile API over older File API. In the file picker you can select any location, switch may be on USB OTG drive, Google Drive and many others which don't have physical path on the phone. See https://stackoverflow.com/a/39577775 . Your link with suggested solution doesn't work in all scenarios and doesn't have compatible license, so I cannot use it.

jidanni commented 3 years ago

All I know is in https://stackoverflow.com/questions/39577708/is-it-possible-to-get-a-regular-file-from-documentfile/39577775#comment66473723_39578621 he wants to see paths with no colons in them, like me.

jidanni commented 3 years ago

I just tested this in the Android shell: $ ls /tree No such file or directory!

That is all the proof you need to show that you are using an internal language that is unusable for users.

It would be okay if there was a symbolic link called that, but that is not the case.

Yes that place exists but it's like you are using German for it instead of English.

You are using a developers' name for a place that is an internal name that should not be shown to users because they cannot use it at all one single bit. So please show the physical name instead of the internal name. Thank you.

jidanni commented 3 years ago

Simply add a step: something like: Instead of print (name), use print (physical (name)).

zamojski commented 3 years ago

I understand what you mean but as I said it's not that easy because not all URIs have a translation to physical files.

jidanni commented 3 years ago

All I know is you used to say /sdcard for many years in Settings. Just go back to using the former method, please.

zamojski commented 3 years ago

That's not possible, the old approach will not work on Android 11+ and will cause my app to be removed from Google Play. If you have doubts read about scoped storage.

jidanni commented 3 years ago

Ah ha! So simply export to the Downloads directory!

https://medium.com/androiddevelopers/android-11-storage-faq-78cefea52b7c

In scoped storage, apps can contribute media files to Media Store collections. Media Store will put the files into well organized folders like DCIM, Movies, Download, and so on based on file type. For all such files, apps can also continue to have access via File APIs as well. The OS maintains a system to attribute an app to each media store file, so apps can read/write files that they originally contributed to the Media Store without needing storage permissions.

jidanni commented 3 years ago

https://medium.com/androiddevelopers/scope-storage-myths-ca6a97d7ff37

zamojski commented 3 years ago

Please read carefully the answer to 'I want to save non-media files, but I don’t want them deleted when my app is uninstalled. Do I need to use SAF?' question. Tower Collector uses SAF to pick a folder where you want to store the files.

You need to also consider that the app runs on older Android versions and keeping different implementations per version makes app maintenance more complicated and error prone. That's why I decided to use SAF because it's supported on all versions.

Take a look on this article: https://betterprogramming.pub/android-scoped-storage-demystified-3024a062ba24

jidanni commented 3 years ago

Okay I have tested it and confirm that on Android 8 tree primary Tower collector equals SD card tower collector. Now what will happen if I upgrade my phone to Android 11? Won't that become a place that you can't write anymore?

jidanni commented 3 years ago

So how can I get ready so there will be no surprises when one day I upgrade my phone? What would be a safe place to pick in the file picker? Shouldn't there be some warning if somebody picks a place that will cause problems later when they upgrade their phone? Should I just pick my downloads directory?

jidanni commented 3 years ago

Okay now I have picked tree primary download. I'm sorry about the punctuation but I'm using voice input.

zamojski commented 3 years ago

Won't that become a place that you can't write anymore?

If the app uses SAF you'll keep the access. But using the older File API on Android versions lower than 10 you'll need to grant permission to wow external storage, even for the Downloads directory.

Personality I don't like the approach to keep all non-media files on the trash named Downloads. I used to often delete all the files there from time to time to cleanup old temporary files downloaded with a web browser. That way I would accidentally delete exported measurements.

Another reason to give users access where to store the files is to let them choose a location where they have more free space available (if they have an SD card).

To summarize, I have nothing against showing physical path on the device, but it may not always create a valid path and you may still see the tree on some devices because there's no direct translation between the two.