-
Notifications
You must be signed in to change notification settings - Fork 107
Poi share link #5113
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
Poi share link #5113
Conversation
… POI_share_link
… POI_share_link
… POI_share_link
Sources/Helpers/ShareLinkItem.swift
Outdated
| let metadata = LPLinkMetadata() | ||
| metadata.originalURL = url | ||
| metadata.url = url | ||
| if let title = title, !title.isEmpty { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
Sources/Helpers/ShareLinkItem.swift
Outdated
| metadata.title = title | ||
| } | ||
|
|
||
| if let icon = icon, icon.size.width > 0, icon.size.height > 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
Sources/Views/OATargetPointView.mm
Outdated
| int zoom = _mapView.zoomLevel; | ||
| NSString *poiName = [self.customController encodedPoiNameForLink];; | ||
| NSString *poiType = [self.customController encodedPoiTypeForLink]; | ||
| NSString *httpUrlString = [self buildSharePoiUrlWithPoiName:poiName poiType:poiType lat:lat lon:lon zoom:zoom]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
urlString
Sources/Views/OATargetPointView.mm
Outdated
| NSString *poiName = [self.customController encodedPoiNameForLink];; | ||
| NSString *poiType = [self.customController encodedPoiTypeForLink]; | ||
| NSString *httpUrlString = [self buildSharePoiUrlWithPoiName:poiName poiType:poiType lat:lat lon:lon zoom:zoom]; | ||
| NSURL *httpUrl = [NSURL URLWithString:httpUrlString]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
url
Sources/AppHost/SceneDelegate.mm
Outdated
| if (amenity == nil) | ||
| return NO; | ||
|
|
||
| OATargetPoint*targetPoint=[_rootViewController.mapPanel.mapViewController.mapLayers.poiLayer getTargetPoint:[amenity syntheticAmenity]]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you run out of spaces on your keyboard? )
|
|
||
| - (NSString *)encodedPoiTypeForLink | ||
| { | ||
| NSString *shareType = @""; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
up
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implemented in OAPOIViewController since it complies with Android.
Methods should also be overridden in OAFavoriteViewController
Support Files/OA-Prefix.pch
Outdated
| #define kLastMapUsedTime @"kLastMapUsedTime" | ||
|
|
||
| #define kShareLinkTemplate @"https://osmand.net/map?pin=%.6f,%.6f#%d/%.4f/%.4f\nThe location was shared with you by OsmAnd" | ||
| #define kSharePoiBaseUrl @"https://osmand.net/map/poi/" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use static NSString * const
| for (OAPOI *amenity in amenities) | ||
| { | ||
| if (amenity.obfId > 0) | ||
| if (amenity.obfId != 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i saw a similar change somewhere by @nnngrach. We need to check if there’s a conflict
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't find an identical check in the project.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sources/AppHost/SceneDelegate.mm
Outdated
| OAFavoriteItem *point = [OAFavoritesHelper getVisibleFavByLat:lat lon:lon]; | ||
| if (point && [name isEqualToString:[point getName]]) | ||
| { | ||
| OATargetPoint*targetPoint = [_rootViewController.mapPanel.mapViewController.mapLayers.favoritesLayer getTargetPoint:point]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
up
Sources/AppHost/SceneDelegate.mm
Outdated
| return NO; | ||
| } | ||
|
|
||
| - (BOOL)handleIncomingMapPoiURL:(NSURL *)url |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There shouldn’t be any link-parsing code in the SceneDelegate class. All parsing should be moved to the DeepLinkParser class
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to introduce the following structure:
@objcMembers
final class DeepLinkManager: NSObject {
static let shared = DeepLinkManager()
private let deepLinkParser = DeepLinkParser()
func handleDeepLink(url: URL) -> Bool {
deepLinkParser.parseDeepLink(url)
}
}
This logic should be moved into DeepLinkParser:
return [self handleIncomingFileURL:url]
|| [self handleIncomingActionsURL:url]
|| [self handleIncomingNavigationURL:url]
|| [self handleIncomingSetPinOnMapURL:url]
|| [self handleIncomingMoveMapToLocationURL:url]
|| [self handleIncomingOpenLocationMenuURL:url]
|| [self handleIncomingTileSourceURL:url]
|| [self handleIncomingOsmAndCloudURL:url];
Sources/Helpers/OAFavoritesBridge.h
Outdated
|
|
||
| #import <Foundation/Foundation.h> | ||
|
|
||
| @class OAFavoriteItem; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
Sources/POI/OAPOI.mm
Outdated
| if (wikidata.length == 0) | ||
| return @""; | ||
|
|
||
| if ([wikidata hasPrefix:@"Q"] || [wikidata hasPrefix:@"q"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unichar firstChar = [wikidata characterAtIndex:0];
if (firstChar == 'Q' || firstChar == 'q') {}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or use lowercase for wikidata
Sources/AppHost/SceneDelegate.mm
Outdated
|
|
||
| - (BOOL)handleIncomingSetPinOnMapURL:(NSURL *)url | ||
| { | ||
| if ([DeepLinkParser handleIncomingMapPoiURL:url rootViewController:_rootViewController]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can move all this logic into DeepLinkParser
Sources/AppHost/SceneDelegate.mm
Outdated
|
|
||
| if ([OAUtilities isOsmAndSite:url] && [OAUtilities isPathPrefix:url pathPrefix:@"/map/poi"]) | ||
| { | ||
| __weak __typeof(self) weakSelf = self; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactor to the following pattern:
__weak typeof(self) weakSelf = self;
dispatch_async(dispatch_get_main_queue(), ^{
[weakSelf someMethod];
});
|
|
||
| #import <Foundation/Foundation.h> | ||
|
|
||
| @class OARootViewController, OATargetPoint; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use NS_ASSUME_NONNULL_
Sources/POI/DeepLinkParser.swift
Outdated
| } | ||
|
|
||
| let startLatLon: CLLocation? = { | ||
| guard let startParam = startLatLonParam, !startParam.isEmpty else { return nil } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
Sources/POI/DeepLinkParser.swift
Outdated
| } | ||
|
|
||
| let appMode = OAApplicationMode.value(ofStringKey: appModeKeyParam, def: nil) | ||
| if let key = appModeKeyParam, !key.isEmpty, appMode == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|| ?
Sources/POI/DeepLinkParser.swift
Outdated
| let vc = rootViewController.navigationController?.visibleViewController | ||
| if let verificationVC = vc as? OACloudAccountVerificationViewController { | ||
| let isValidToken: Bool = { | ||
| guard let token = tokenParam else { return false } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
Sources/POI/DeepLinkParser.swift
Outdated
| return BackupUtils.isTokenValid(token) | ||
| }() | ||
|
|
||
| if isValidToken, let token = tokenParam { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
| return rootViewController.handleIncomingURL(url) | ||
| } | ||
|
|
||
| private func handleIncomingActionsURL(_ url: URL, rootViewController: OARootViewController?) -> Bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You lost the example URL. It needs to be migrated as well
… POI_share_link # Conflicts: # Sources/OsmAnd Maps-Bridging-Header.h
No description provided.