diff --git a/Sources/Controllers/DashboardOnMap/MapSettings/MapSettingsGpxViewController.swift b/Sources/Controllers/DashboardOnMap/MapSettings/MapSettingsGpxViewController.swift index b89c0d7037..b51d85caed 100644 --- a/Sources/Controllers/DashboardOnMap/MapSettings/MapSettingsGpxViewController.swift +++ b/Sources/Controllers/DashboardOnMap/MapSettings/MapSettingsGpxViewController.swift @@ -207,7 +207,6 @@ final class MapSettingsGpxViewController: OABaseNavbarSubviewViewController { noVisibleTracksRow.iconTintColor = UIColor.iconColorDefault noVisibleTracksRow.setObj(localizedString("show_all_tracks"), forKey: "buttonTitle") } else { - let visibleGpxFilePaths = settings?.mapSettingVisibleGpx.get() ?? [] let gpxListToShow = isSearchActive ? filteredGpxList : (isShowingVisibleTracks ? visibleGpxList : allGpxList) for gpx in gpxListToShow { let gpxRow = tracksSection.createNewRow() @@ -215,7 +214,7 @@ final class MapSettingsGpxViewController: OABaseNavbarSubviewViewController { gpxRow.title = gpx.gpxFileNameWithoutExtension gpxRow.setObj(gpx, forKey: "gpx") gpxRow.iconName = "ic_custom_trip" - gpxRow.iconTintColor = visibleGpxFilePaths.contains(gpx.gpxFilePath) ? .iconColorActive : .iconColorDisabled + gpxRow.iconTintColor = settings?.isGpxVisible(gpx.gpxFilePath) == true ? .iconColorActive : .iconColorDisabled } } if isShowingVisibleTracks && !recentlyVisibleGpxList.isEmpty && !isSearchActive { @@ -581,7 +580,7 @@ final class MapSettingsGpxViewController: OABaseNavbarSubviewViewController { alert.addAction(UIAlertAction(title: localizedString("shared_string_yes"), style: .default) { [weak self] _ in guard let self else { return } guard let dataItem = track.dataItem else { return } - let isVisible = settings?.mapSettingVisibleGpx.contains(track.gpxFilePath) ?? false + let isVisible = settings?.isGpxVisible(track.gpxFilePath) ?? false if isVisible { settings?.hideGpx([track.gpxFilePath]) } @@ -625,8 +624,8 @@ final class MapSettingsGpxViewController: OABaseNavbarSubviewViewController { } private func loadVisibleTracks() { - guard let visibleGpxFilePaths = settings?.mapSettingVisibleGpx.get() else { return } - visibleGpxList = allGpxList.filter { visibleGpxFilePaths.contains($0.gpxFilePath) } + guard let settings else { return } + visibleGpxList = allGpxList.filter { settings.isGpxVisible($0.gpxFilePath) } isVisibleTracksAvailable = !visibleGpxList.isEmpty selectedGpxTracks = visibleGpxList } @@ -638,10 +637,10 @@ final class MapSettingsGpxViewController: OABaseNavbarSubviewViewController { return } - guard let visibleGpxFilePaths = settings?.mapSettingVisibleGpx.get() else { return } + guard let settings else { return } let previouslyHiddenTrackPaths = UserDefaults.standard.stringArray(forKey: previouslyVisibleTracksKey) ?? [] let recentlyVisibleTracks = allGpxList.filter { - previouslyHiddenTrackPaths.contains($0.gpxFilePath) && !visibleGpxFilePaths.contains($0.gpxFilePath) + previouslyHiddenTrackPaths.contains($0.gpxFilePath) && !settings.isGpxVisible($0.gpxFilePath) } recentlyVisibleGpxList = recentlyVisibleTracks diff --git a/Sources/Controllers/Map/Helpers/OASelectedGPXHelper.mm b/Sources/Controllers/Map/Helpers/OASelectedGPXHelper.mm index e9cae48702..60ca4bc810 100644 --- a/Sources/Controllers/Map/Helpers/OASelectedGPXHelper.mm +++ b/Sources/Controllers/Map/Helpers/OASelectedGPXHelper.mm @@ -98,7 +98,7 @@ - (BOOL)buildGpxList if (_loadingGPXPaths.count > 0) { - [self removeInactiveGpxFiles:mapSettingVisibleGpx]; + [self removeInactiveGpxFiles]; return YES; } @@ -131,12 +131,12 @@ - (BOOL)buildGpxList if (gpxLoadOperations.count > 0) [_operationQueue addOperations:gpxLoadOperations waitUntilFinished:NO]; - [self removeInactiveGpxFiles:mapSettingVisibleGpx]; + [self removeInactiveGpxFiles]; return _loadingGPXPaths.count > 0; } -- (void)removeInactiveGpxFiles:(NSSet *)mapSettingVisibleGpx +- (void)removeInactiveGpxFiles { NSMutableArray *keysToRemove = [NSMutableArray array]; @@ -144,7 +144,7 @@ - (void)removeInactiveGpxFiles:(NSSet *)mapSettingVisibleGpx { NSString *gpxFilePath = [OAUtilities getGpxShortPath:key]; - if (![mapSettingVisibleGpx containsObject:gpxFilePath]) + if (![_settings isGpxVisible:gpxFilePath]) [keysToRemove addObject:key]; } @@ -224,12 +224,12 @@ + (void)renameVisibleTrack:(NSString *)oldPath newPath:(NSString *)newPath { OAAppSettings *settings = OAAppSettings.sharedManager; NSMutableArray *visibleGpx = [NSMutableArray arrayWithArray:settings.mapSettingVisibleGpx.get]; - for (NSString *gpx in settings.mapSettingVisibleGpx.get) + for (NSString *gpx in [settings.mapSettingVisibleGpx get]) { - if ([gpx isEqualToString:oldPath]) + if ([gpx compare:oldPath] == NSOrderedSame) { [visibleGpx removeObject:gpx]; - [visibleGpx addObject:newPath]; + [visibleGpx addObject:newPath.decomposedStringWithCanonicalMapping]; break; } } diff --git a/Sources/Controllers/Map/OAMapViewController.mm b/Sources/Controllers/Map/OAMapViewController.mm index 186b04806f..e12508c3ae 100644 --- a/Sources/Controllers/Map/OAMapViewController.mm +++ b/Sources/Controllers/Map/OAMapViewController.mm @@ -3241,7 +3241,7 @@ - (void) showTempGpxTrack:(NSString *)filePath update:(BOOL)update [self hideRecGpxTrack]; OAAppSettings *settings = [OAAppSettings sharedManager]; - if ([settings.mapSettingVisibleGpx.get containsObject:filePath]) + if ([settings isGpxVisible:filePath]) { [self runWithRenderSync:^{ [_gpxFilesTemp removeAllObjects]; @@ -3291,7 +3291,7 @@ - (void) showTempGpxTrackFromGpxFile:(OASGpxFile *)doc NSString *filePath = doc.path; OAAppSettings *settings = [OAAppSettings sharedManager]; - if ([settings.mapSettingVisibleGpx.get containsObject:filePath]) + if ([settings isGpxVisible:filePath]) { [self runWithRenderSync:^{ [_gpxFilesTemp removeAllObjects]; @@ -3410,7 +3410,7 @@ - (void) keepTempGpxTrackVisible OASGpxDataItem *gpx = [[OAGPXDatabase sharedDb] getGPXItem:tempGpxFilePath]; NSString *path = gpx.file.absolutePath; - if (![[OAAppSettings sharedManager].mapSettingVisibleGpx.get containsObject:tempGpxFilePath]) + if (![[OAAppSettings sharedManager] isGpxVisible:tempGpxFilePath]) { [_selectedGpxHelper addGpxFile:tempGpxFile for:path]; diff --git a/Sources/Controllers/MyPlaces/TracksViewController.swift b/Sources/Controllers/MyPlaces/TracksViewController.swift index f26bad58b9..545f99482b 100644 --- a/Sources/Controllers/MyPlaces/TracksViewController.swift +++ b/Sources/Controllers/MyPlaces/TracksViewController.swift @@ -571,7 +571,7 @@ final class TracksViewController: UITableViewController, OATrackSavingHelperUpda trackRow.setObj(track.gpxFilePath as Any, forKey: pathKey) trackRow.setObj(fileName, forKey: fileNameKey) trackRow.iconName = "ic_custom_trip" - let isVisible = settings.mapSettingVisibleGpx.contains(track.gpxFilePath) + let isVisible = settings.isGpxVisible(track.gpxFilePath) trackRow.setObj(isVisible, forKey: isVisibleKey) trackRow.setObj(trackIconColor(for: track, isVisible: isVisible), forKey: colorKey) trackRow.setObj(TracksSortModeHelper.getTrackDescription(track: track, sortMode: isSearchActive || isSelectionModeInSearch ? sortModeForSearch : sortMode, includeFolderInfo: shouldShowFolderInfo), forKey: trackSortDescrKey) @@ -1198,15 +1198,15 @@ final class TracksViewController: UITableViewController, OATrackSavingHelperUpda if hasSelectedItems() { var tracksToShow: [String] = [] tracksToShow.append(contentsOf: selectedTracks.compactMap { - settings.mapSettingVisibleGpx.contains($0.gpxFilePath) ? nil : $0.gpxFilePath + settings.isGpxVisible($0.gpxFilePath) ? nil : $0.gpxFilePath }) for folderName in selectedFolders { if let folder = currentFolder.getSubFolders().first(where: { $0.getName() == folderName }) { - let folderTracksToShow = folder.getFlattenedTrackItems().compactMap { settings.mapSettingVisibleGpx.contains($0.gpxFilePath) ? nil : $0.gpxFilePath } + let folderTracksToShow = folder.getFlattenedTrackItems().compactMap { settings.isGpxVisible($0.gpxFilePath) ? nil : $0.gpxFilePath } tracksToShow.append(contentsOf: folderTracksToShow) } else if let smartFolder = smartFolderHelper.getSmartFolder(name: folderName) { - let folderTracksToShow = smartFolder.getTrackItems().compactMap { settings.mapSettingVisibleGpx.contains($0.gpxFilePath) ? nil : $0.gpxFilePath } + let folderTracksToShow = smartFolder.getTrackItems().compactMap { settings.isGpxVisible($0.gpxFilePath) ? nil : $0.gpxFilePath } tracksToShow.append(contentsOf: folderTracksToShow) } } @@ -1339,7 +1339,7 @@ final class TracksViewController: UITableViewController, OATrackSavingHelperUpda } for track in self.selectedTracks { - let isVisible = self.settings.mapSettingVisibleGpx.contains(track.gpxFilePath) + let isVisible = self.settings.isGpxVisible(track.gpxFilePath) if isVisible { self.settings.hideGpx([track.gpxFilePath]) } @@ -1751,7 +1751,7 @@ final class TracksViewController: UITableViewController, OATrackSavingHelperUpda updateData() } else { guard let dataItem = trackItem.dataItem else { return } - let isVisible = settings.mapSettingVisibleGpx.contains(trackItem.gpxFilePath) + let isVisible = settings.isGpxVisible(trackItem.gpxFilePath) if isVisible { settings.hideGpx([trackItem.gpxFilePath]) } @@ -1920,7 +1920,11 @@ final class TracksViewController: UITableViewController, OATrackSavingHelperUpda } private func updateRenamedGpx(src: KFile, dest: KFile) { - GpxDbHelper.shared.rename(currentFile: src, newFile: dest) + guard gpxDB.renameCurrentFile(src, newFile: dest) else { + NSLog("updateRenamedGpx -> renameCurrentFile failed") + return + } + handleDeletedGpxFile(gpxFile: src) let trackItem = TrackItem(file: dest) trackItem.dataItem = OAGPXDatabase.sharedDb().getGPXItem(dest.path()) @@ -1928,21 +1932,22 @@ final class TracksViewController: UITableViewController, OATrackSavingHelperUpda } private func renameFolder(newName: String, oldName: String) { + let normalizedNewName = newName.decomposedStringWithCanonicalMapping if let smartFolder = smartFolderHelper.getSmartFolder(name: oldName) { let oldSmartFolderId = smartFolder.getId() - smartFolderHelper.renameSmartFolder(smartFolder: smartFolder, newName: newName) + smartFolderHelper.renameSmartFolder(smartFolder: smartFolder, newName: normalizedNewName) renameSortModeKey(from: oldSmartFolderId, to: smartFolder.getId()) updateData() } guard let trackFolder = getTrackFolderByPath(oldName) else { return } let oldFolderPath = currentFolderAbsolutePath().appendingPathComponent(oldName) - let newFolderPath = currentFolderAbsolutePath().appendingPathComponent(newName) + let newFolderPath = currentFolderAbsolutePath().appendingPathComponent(normalizedNewName) if !FileManager.default.fileExists(atPath: newFolderPath) { let oldDir = KFile(filePath: oldFolderPath) if let parentFile = oldDir.getParentFile() { - let newDir = KFile(file: parentFile, fileName: newName) + let newDir = KFile(file: parentFile, fileName: normalizedNewName) if oldDir.renameTo(toFile: newDir) { trackFolder.setDirFile(dirFile: newDir) trackFolder.resetCachedData() @@ -1990,7 +1995,7 @@ final class TracksViewController: UITableViewController, OATrackSavingHelperUpda gpxDB.removeGpxItem($0, withLocalRemove: false) handleDeletedGpxFile(gpxFile: $0.file) let gpxFilePath = $0.gpxFilePath - let isVisible = settings.mapSettingVisibleGpx.contains(gpxFilePath) + let isVisible = settings.isGpxVisible(gpxFilePath) if isVisible { settings.hideGpx([gpxFilePath]) } @@ -2029,7 +2034,7 @@ final class TracksViewController: UITableViewController, OATrackSavingHelperUpda let newPathCount = oldPath.count let oldPathString = visibleGpx[i] let modifiedString = newPath + oldPathString.dropFirst(newPathCount) - visibleGpx[i] = modifiedString + visibleGpx[i] = modifiedString.decomposedStringWithCanonicalMapping } settings.mapSettingVisibleGpx.set(visibleGpx) } @@ -2509,7 +2514,7 @@ final class TracksViewController: UITableViewController, OATrackSavingHelperUpda guard let self else { return nil } let showOnMapAction = UIAction(title: localizedString("show_all_tracks_on_the_map"), image: .icCustomMapPinOutlined) { [weak self] _ in guard let self else { return } - let tracksToShow = group.getTrackItems().compactMap { $0.gpxFilePath }.filter { !self.settings.mapSettingVisibleGpx.contains($0) } + let tracksToShow = group.getTrackItems().compactMap { $0.gpxFilePath }.filter { !self.settings.isGpxVisible($0) } if !tracksToShow.isEmpty { self.settings.showGpx(tracksToShow, update: true) } diff --git a/Sources/Controllers/RoutePlanning/OARoutePlanningHudViewController.mm b/Sources/Controllers/RoutePlanning/OARoutePlanningHudViewController.mm index 07ccdb8fd2..5fa26acab7 100644 --- a/Sources/Controllers/RoutePlanning/OARoutePlanningHudViewController.mm +++ b/Sources/Controllers/RoutePlanning/OARoutePlanningHudViewController.mm @@ -1226,7 +1226,7 @@ - (void) onGpxSaved:(OASGpxFile *)savedGpxFile outFile:(NSString *)outFile final } OASelectedGPXHelper *helper = OASelectedGPXHelper.instance; NSString *gpxFilePath = [OAUtilities getGpxShortPath:outFile]; - if (gpxFilePath && [_settings.mapSettingVisibleGpx.get containsObject:gpxFilePath]) + if (gpxFilePath && [_settings isGpxVisible:gpxFilePath]) { // Refresh track if visible [_settings hideGpx:@[gpxFilePath] update:YES]; diff --git a/Sources/Controllers/TargetMenu/Search/OAQuickSearchTableController.mm b/Sources/Controllers/TargetMenu/Search/OAQuickSearchTableController.mm index ac464c9dbd..23f8931a11 100644 --- a/Sources/Controllers/TargetMenu/Search/OAQuickSearchTableController.mm +++ b/Sources/Controllers/TargetMenu/Search/OAQuickSearchTableController.mm @@ -682,7 +682,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N } cell.descriptionLabel.text = nil; cell.descriptionLabel.attributedText = [TracksSortModeHelper getTrackDescriptionWithTrack:dataItem sortMode:TracksSortModeLastModified includeFolderInfo:YES]; - BOOL isVisible = [[OAAppSettings sharedManager].mapSettingVisibleGpx.get containsObject:dataItem.gpxFilePath]; + BOOL isVisible = [[OAAppSettings sharedManager] isGpxVisible:dataItem.gpxFilePath]; cell.leftIconView.tintColor = [UIColor colorNamed:isVisible ? ACColorNameIconColorActive : ACColorNameIconColorDefault]; return cell; } diff --git a/Sources/GPX/OAGPXDatabase.h b/Sources/GPX/OAGPXDatabase.h index fc8accd768..8c7c769f7b 100644 --- a/Sources/GPX/OAGPXDatabase.h +++ b/Sources/GPX/OAGPXDatabase.h @@ -47,8 +47,7 @@ typedef NS_ENUM(NSInteger, EOAGPX3DLineVisualizationPositionType) { EOAGPX3DLineVisualizationPositionTypeTopBottom, }; -@class OASGpxTrackAnalysis; -@class OASWptPt, OASGpxDataItem; +@class OASWptPt, OASGpxDataItem, OASKFile, OASGpxTrackAnalysis; NS_ASSUME_NONNULL_BEGIN @@ -62,6 +61,7 @@ NS_ASSUME_NONNULL_BEGIN - (OASGpxDataItem *_Nullable)getGPXItem:(NSString *)filePath; - (BOOL)updateDataItem:(OASGpxDataItem *_Nonnull)item; +- (BOOL)renameCurrentFile:(OASKFile *)currentFile newFile:(OASKFile *)newFile; - (NSArray *)getDataItems; - (OASGpxDataItem *)getGPXItemByFileName:(NSString *)fileName; - (NSString *)getFileDir:(NSString *)filePath; diff --git a/Sources/GPX/OAGPXDatabase.mm b/Sources/GPX/OAGPXDatabase.mm index 90d4ccda41..b22326afa7 100644 --- a/Sources/GPX/OAGPXDatabase.mm +++ b/Sources/GPX/OAGPXDatabase.mm @@ -225,6 +225,33 @@ - (BOOL)updateDataItem:(OASGpxDataItem *)item return [[OASGpxDbHelper shared] updateDataItemItem:item]; } +- (BOOL)renameCurrentFile:(OASKFile *)currentFile newFile:(OASKFile *)newFile +{ + BOOL success = [[OASGpxDbHelper shared] renameCurrentFile:currentFile newFile:newFile]; + if (!success) + return NO; + + NSString *currentPath = currentFile.absolutePath; + NSString *newPath = newFile.absolutePath; + NSString *currentPathKey = currentPath.precomposedStringWithCanonicalMapping; + NSString *newPathKey = newPath.precomposedStringWithCanonicalMapping; + NSMutableArray *itemsToRemove = [NSMutableArray array]; + for (OASGpxDataItem *item in [[OASGpxDbHelper shared] getItems]) + { + NSString *itemPath = item.file.absolutePath; + NSString *itemPathKey = itemPath.precomposedStringWithCanonicalMapping; + BOOL isOldRenamedItem = [itemPathKey isEqualToString:currentPathKey] && ![item.file exists]; + BOOL isDuplicateNewItem = [itemPathKey isEqualToString:newPathKey] && ![itemPath isEqualToString:newPath]; + if (isOldRenamedItem || isDuplicateNewItem) + [itemsToRemove addObject:item]; + } + + for (OASGpxDataItem *item in itemsToRemove) + [[OASGpxDbHelper shared] removeItem:item]; + + return YES; +} + - (NSArray *)getDataItems { return [[OASGpxDbHelper shared] getItems]; diff --git a/Sources/Helpers/OAAppSettings.h b/Sources/Helpers/OAAppSettings.h index 6e116304d3..2f650b28e5 100644 --- a/Sources/Helpers/OAAppSettings.h +++ b/Sources/Helpers/OAAppSettings.h @@ -1321,9 +1321,9 @@ typedef NS_ENUM(NSInteger, EOAWikiDataSourceType) - (BOOL) removeImpassableRoad:(CLLocation *)location; - (void) clearImpassableRoads; +- (BOOL)isGpxVisible:(NSString *)filePath; - (void) showGpx:(NSArray *)filePaths; - (void) showGpx:(NSArray *)filePaths update:(BOOL)update; -- (void) updateGpx:(NSArray *)filePaths; - (void) hideGpx:(NSArray *)filePaths; - (void) hideGpx:(NSArray *)filePaths update:(BOOL)update; - (void) hideRemovedGpx; diff --git a/Sources/Helpers/OAAppSettings.m b/Sources/Helpers/OAAppSettings.m index 2674e2fcfb..0f57bb110d 100644 --- a/Sources/Helpers/OAAppSettings.m +++ b/Sources/Helpers/OAAppSettings.m @@ -7487,15 +7487,35 @@ - (void)setApplicationModePref:(OAApplicationMode *)applicationMode markAsLastUs } } +- (BOOL)isGpxVisible:(NSString *)filePath +{ + for (NSString *visiblePath in _mapSettingVisibleGpx.get) + { + if ([visiblePath compare:filePath] == NSOrderedSame) + return YES; + } + + return NO; +} + - (void) showGpx:(NSArray *)filePaths update:(BOOL)update { BOOL added = NO; NSMutableArray *arr = [NSMutableArray arrayWithArray:_mapSettingVisibleGpx.get]; for (NSString *filePath in filePaths) { - if (![arr containsObject:filePath]) + BOOL containsPath = NO; + for (NSString *visiblePath in arr) + { + if ([visiblePath compare:filePath] == NSOrderedSame) + { + containsPath = YES; + break; + } + } + if (!containsPath) { - [arr addObject:filePath]; + [arr addObject:filePath.decomposedStringWithCanonicalMapping]; added = YES; } } @@ -7515,35 +7535,6 @@ - (void) showGpx:(NSArray *)filePaths [self showGpx:filePaths update:YES]; } -- (void) updateGpx:(NSArray *)filePaths -{ - BOOL added = NO; - BOOL removed = NO; - NSMutableArray *arr = [NSMutableArray arrayWithArray:_mapSettingVisibleGpx.get]; - for (NSString *filePath in filePaths) - { - if (![arr containsObject:filePath]) - { - added = YES; - break; - } - } - for (NSString *visible in arr) - { - if (![filePaths containsObject:visible]) - { - removed = YES; - break; - } - } - - if (added || removed) - { - [self.mapSettingVisibleGpx set:[NSMutableArray arrayWithArray:filePaths]]; - [[[OsmAndApp instance] updateGpxTracksOnMapObservable] notifyEvent]; - } -} - - (void) hideGpx:(NSArray *)filePaths { [self hideGpx:filePaths update:YES]; @@ -7556,10 +7547,13 @@ - (void) hideGpx:(NSArray *)filePaths update:(BOOL)update NSMutableArray *arrToDelete = [NSMutableArray array]; for (NSString *filePath in filePaths) { - if ([arr containsObject:filePath]) + for (NSString *visiblePath in arr) { - [arrToDelete addObject:filePath]; - removed = YES; + if ([visiblePath compare:filePath] == NSOrderedSame) + { + [arrToDelete addObject:visiblePath]; + removed = YES; + } } } [arr removeObjectsInArray:arrToDelete]; @@ -7572,7 +7566,12 @@ - (void) hideGpx:(NSArray *)filePaths update:(BOOL)update - (void) hideRemovedGpx { OsmAndAppInstance app = [OsmAndApp instance]; - NSMutableArray *arr = [NSMutableArray arrayWithArray:_mapSettingVisibleGpx.get]; + NSMutableOrderedSet *visiblePaths = [NSMutableOrderedSet orderedSet]; + for (NSString *path in _mapSettingVisibleGpx.get) + { + [visiblePaths addObject:path.decomposedStringWithCanonicalMapping]; + } + NSMutableArray *arr = [NSMutableArray arrayWithArray:visiblePaths.array]; NSMutableArray *arrToDelete = [NSMutableArray array]; for (NSString *filepath in arr) { diff --git a/Sources/Helpers/OAGPXUIHelper.mm b/Sources/Helpers/OAGPXUIHelper.mm index b7ad64e053..95a53de73e 100644 --- a/Sources/Helpers/OAGPXUIHelper.mm +++ b/Sources/Helpers/OAGPXUIHelper.mm @@ -578,7 +578,7 @@ - (void)copyGPXToNewFolder:(NSString *)newFolderName BOOL result = [trackItem.dataItem.file renameToToFile:newFile]; if (result) { - BOOL renameCurrentFileResult = [[OASGpxDbHelper shared] renameCurrentFile:trackItem.dataItem.file newFile:newFile]; + BOOL renameCurrentFileResult = [gpxDatabase renameCurrentFile:trackItem.dataItem.file newFile:newFile]; if (renameCurrentFileResult) { OASGpxDataItem *gpx = [[OAGPXDatabase sharedDb] getGPXItem:newStoringFullPath]; @@ -627,7 +627,7 @@ - (void)copyGPXToNewFolder:(NSString *)newFolderName } } - if ([OAAppSettings.sharedManager.mapSettingVisibleGpx.get containsObject:oldPath]) + if ([OAAppSettings.sharedManager isGpxVisible:oldPath]) [OAAppSettings.sharedManager showGpx:@[newStoringPath]]; } if (openTrack) @@ -663,7 +663,7 @@ - (void)renameTrack:(OASGpxDataItem *)gpx { NSString *oldFilePath = gpx.gpxFilePath; NSString *oldPath = [OsmAndApp.instance.gpxPath stringByAppendingPathComponent:oldFilePath]; - NSString *newFileName = [newName stringByAppendingPathExtension:@"gpx"]; + NSString *newFileName = [[newName stringByAppendingPathExtension:@"gpx"] decomposedStringWithCanonicalMapping]; NSString *newFilePath = [[gpx.gpxFilePath stringByDeletingLastPathComponent] stringByAppendingPathComponent:newFileName]; // 2023-10-22_11-34_Sun 2.gpx NSString *newPath = [OsmAndApp.instance.gpxPath stringByAppendingPathComponent:newFilePath]; if (![NSFileManager.defaultManager fileExistsAtPath:newPath]) @@ -677,7 +677,7 @@ - (void)renameTrack:(OASGpxDataItem *)gpx NSLog(@"[ERROR] -> OAGPXUIHelper -> renameToFileResult is fail"); return; } - BOOL renameCurrentFileResult = [[OASGpxDbHelper shared] renameCurrentFile:gpx.file newFile:newFile]; + BOOL renameCurrentFileResult = [[OAGPXDatabase sharedDb] renameCurrentFile:gpx.file newFile:newFile]; if (!renameCurrentFileResult) { NSLog(@"[ERROR] -> OAGPXUIHelper -> renameCurrentFileResult is fail"); diff --git a/Sources/Helpers/OAOsmAndContextImpl.mm b/Sources/Helpers/OAOsmAndContextImpl.mm index 6f7fe3c35c..10f8ce3359 100644 --- a/Sources/Helpers/OAOsmAndContextImpl.mm +++ b/Sources/Helpers/OAOsmAndContextImpl.mm @@ -333,7 +333,7 @@ - (OASAltitudeMetrics * _Nullable)getAltitudeMetric __attribute__((swift_name("g - (BOOL)isGpxFileVisiblePath:(NSString *)path __attribute__((swift_name("isGpxFileVisible(path:)"))) { NSString *gpxFilePath = [OAUtilities getGpxShortPath:path]; - return [OAAppSettings.sharedManager.mapSettingVisibleGpx.get containsObject:gpxFilePath]; + return [OAAppSettings.sharedManager isGpxVisible:gpxFilePath]; } - (OASGpxFile *)getSelectedFileByPathPath:(NSString *)path