Skip to content

Example App: Sharing the Geo JSON file #21

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

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions GeoTrackKitExample/GeoTrackKitExample/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,45 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>LSItemContentTypes</key>
<array>
<string>com.icolasoft.GeoTrackKit.track.file</string>
</array>
<key>CFBundleTypeExtensions</key>
<array>
<string></string>
</array>
<key>CFBundleTypeName</key>
<string>Track File</string>
<key>LSHandlerRank</key>
<string>Owner</string>
</dict>
</array>
<key>UTExportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeDescription</key>
<string>GeoTrackKit Track File</string>
<key>UTTypeConformsTo</key>
<array>
<string>public.data</string>
</array>
<key>UTTypeIdentifier</key>
<string>com.icolasoft.GeoTrackKit.track.file</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<string>gtj</string>
<key>public.mime-type</key>
<string>application/geotrack-json</string>
</dict>
</dict>
</array>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ private extension TrackMapViewController {
}
let documentsFolder = try FileManager.default.url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: true)
let fileName = model.track.name.trackNameToFileSystemName
let fileUrl = documentsFolder.appendingPathComponent("\(fileName).json")
let fileUrl = documentsFolder.appendingPathComponent("\(fileName).gtj")
do {
try jsonString.write(to: fileUrl, atomically: false, encoding: .utf8)
} catch {
Expand Down Expand Up @@ -164,7 +164,7 @@ private extension TrackMapViewController {
let dialog = UIAlertController(title: "Share", message: "How would you like to share?", preferredStyle: .actionSheet)

dialog.addAction(UIAlertAction(title: "JSON", style: .default) { [weak self] _ in
self?.shareJsonFile()
self?.shareGeoTrackJsonFile()
dialog.dismiss(animated: true)
})
dialog.addAction(UIAlertAction(title: "GPX", style: .default) { [weak self] _ in
Expand All @@ -185,8 +185,8 @@ private extension TrackMapViewController {
present(activityVC, animated: true, completion: nil)
}

/// Shares the track as a JSON file
func shareJsonFile() {
/// Shares the track as a GeoTrack-JSON file
func shareGeoTrackJsonFile() {
guard let trackWrittenToJsonFile = trackWrittenToJsonFile else {
return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ class TrackListTableViewController: UITableViewController {
guard let track = load(trackUrl: tracks[indexPath.row]) else {
return
}
if track.track.name.isEmpty {
track.track.name = tracks[indexPath.row].filenameNoExtension ?? ""
}


// swiftlint:disable:next force_cast
let mapVC = UIStoryboard(name: "TrackView", bundle: nil).instantiateViewController(withIdentifier: "TrackMapViewController") as! TrackMapViewController
mapVC.useDemoTrack = false
Expand Down