Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI to export bookmarks as GPX #8137

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

cyber-toad
Copy link
Contributor

@cyber-toad cyber-toad commented May 10, 2024

Once code change are completed I'll create translations & generate strings.
Also iOS changes will be required.
@biodranik WDYT about the implementation?

Signed-off-by: cyber-toad <the.cyber.toad@proton.me>
Signed-off-by: cyber-toad <the.cyber.toad@proton.me>
Signed-off-by: cyber-toad <the.cyber.toad@proton.me>
Signed-off-by: cyber-toad <the.cyber.toad@proton.me>
@@ -83,7 +83,7 @@ std::string GetFileNameForExport(BookmarkManager::KMLDataCollectionPtr::element_
return fileName;
}

BookmarkManager::SharingResult ExportSingleFile(BookmarkManager::KMLDataCollectionPtr::element_type::value_type const & kmlToShare)
BookmarkManager::SharingResult ExportSingleFileKml(BookmarkManager::KMLDataCollectionPtr::element_type::value_type const & kmlToShare)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. What is the value of copy-pasting the code into a new function? Let's extend this one instead and add switch inside.
  2. Let's support exporting KML, KMZ and GPX if it's easy.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Export to GPX doesn't have export zip and cleanup of temporary file, so about half of the code is different. What benefit we have if we put the same code into switch branches - now each function covers specific scenario?
    if we merge them we need to use if several time to adjust logic - and there is a problem to if guard.
  2. I had an idea to add KMZ enum value to distinguish between export of single track (Text) and export all (Kmz). But because we split export/export all by number of collections I removed it for now (until there is no 'Export all to Gpz') because it is misleading now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens with that temporary file? Is it cleaned later by the system somehow?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens with that temporary file? Is it cleaned later by the system somehow?

It works this way:

  1. It creates file like "/data/user/0/app.organicmaps.debug/cache/Route.kml.tmp505640107344"
  2. File is removed by OM code and kmz file is created
  3. It shares file like "/data/user/0/app.organicmaps.debug/cache/Route.kmz"
  4. In Android studio file browser I see folder /data/data/app.organicmaps.debug/cache on my phone after sharing is done with several tracks including the latest one "Route.kmz"

In this folder I see some tracks for previous days also. I was not able to find cleanup code for this folder in OM code, based on this answer https://stackoverflow.com/questions/9942560/when-to-clear-the-cache-dir-in-android application should do some housekeeping for it. But better to check it with our Android experts, I could be wrong. I tried to check this folder for non-debug build of OM that I have on my phone, but unfortunately there is an error

image

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, so we have some temporary files stuck there indefinitely... @rtsisyk @Jean-BaptisteC is there a way to know when a shared file was accessed/read by some other app and can be safely deleted? What Android guidelines say about it?

P.S. It's better to test beta or web flavor for non-debug builds.

@@ -1475,7 +1475,7 @@ UNIT_CLASS_TEST(Runner, ExportAll)
TEST(base::DeleteFileX(indexPath), ());
TEST(base::DeleteFileX(tmpPath), ());
};
bmManager.PrepareFileForSharing(std::move(categories), checker);
bmManager.PrepareFileForSharing(std::move(categories), checker, KmlFileType::Text);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it export KML or KMZ? Previously, it was always KMZ, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As described above, I removed kmz enum value and Text for multiple categories now means Put all to KMZ.

Signed-off-by: cyber-toad <the.cyber.toad@proton.me>
@Jean-BaptisteC
Copy link
Member

FIY, app crash when you press button to export bookmarks :)

@cyber-toad
Copy link
Contributor Author

cyber-toad commented May 12, 2024

FIY, app crash when you press button to export bookmarks :)

Do you mean "Export all" button? I tried different exports and was not able to reproduce, is there a log available? Also do you build from latest source, there was an issue with accidental file removal, but I fixed it couple of days ago.

@cyber-toad
Copy link
Contributor Author

@Jean-BaptisteC could you please help me to reproduce the crash that you mentioned, what are the steps?

Signed-off-by: cyber-toad <the.cyber.toad@proton.me>
Copy link
Member

@biodranik biodranik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kirylkaveryn can you please review and fix failing iOS code? And maybe add iOS buttons to export? :)

@Jean-BaptisteC
Copy link
Member

Do you mean "Export all" button? I tried different exports and was not able to reproduce, is there a log available? Also do you build from latest source, there was an issue with accidental file removal, but I fixed it couple of days ago.

Not able to reproduce crash

@kirylkaveryn
Copy link
Contributor

@cyber-toad I've updated the ios part.
Please, grab the last commit from here.
And add the ios tag for the generation of the string.
https://github.com/organicmaps/organicmaps/tree/ios/gpx-file-export-for-ios

Simulator Screen Recording - iPhone 15 Pro - 2024-05-20 at 18 47 28
Simulator Screen Recording - iPhone 15 Pro - 2024-05-20 at 18 49 02

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants