diff --git a/iphone/CoreApi/CoreApi.xcodeproj/project.pbxproj b/iphone/CoreApi/CoreApi.xcodeproj/project.pbxproj index 9c2620b98..e0a62c5ee 100644 --- a/iphone/CoreApi/CoreApi.xcodeproj/project.pbxproj +++ b/iphone/CoreApi/CoreApi.xcodeproj/project.pbxproj @@ -85,6 +85,8 @@ 9974CA2A23DF1968003FE824 /* ElevationProfileData.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9974CA2823DF1968003FE824 /* ElevationProfileData.mm */; }; 9974CA2D23DF197B003FE824 /* ElevationProfileData+Core.h in Headers */ = {isa = PBXBuildFile; fileRef = 9974CA2B23DF197B003FE824 /* ElevationProfileData+Core.h */; }; AC6A585728057EF6003EABAF /* StringUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = AC6A585628057CC1003EABAF /* StringUtils.h */; settings = {ATTRIBUTES = (Public, ); }; }; + CE838D272D9D834F00476DD0 /* PlacePagePhone.h in Headers */ = {isa = PBXBuildFile; fileRef = CE838D252D9D834F00476DD0 /* PlacePagePhone.h */; settings = {ATTRIBUTES = (Public, ); }; }; + CE838D282D9D834F00476DD0 /* PlacePagePhone.m in Sources */ = {isa = PBXBuildFile; fileRef = CE838D262D9D834F00476DD0 /* PlacePagePhone.m */; }; ED0B1FF42CAAE3FF006E31A4 /* DeepLinkInAppFeatureHighlightData.h in Headers */ = {isa = PBXBuildFile; fileRef = ED0B1FF22CAAE3FF006E31A4 /* DeepLinkInAppFeatureHighlightData.h */; settings = {ATTRIBUTES = (Public, ); }; }; ED0B1FF52CAAE3FF006E31A4 /* DeepLinkInAppFeatureHighlightData.mm in Sources */ = {isa = PBXBuildFile; fileRef = ED0B1FF32CAAE3FF006E31A4 /* DeepLinkInAppFeatureHighlightData.mm */; }; ED46DE3A2D09BE21007CACD6 /* PlacePageTrackData.mm in Sources */ = {isa = PBXBuildFile; fileRef = ED46DE382D09BE21007CACD6 /* PlacePageTrackData.mm */; }; @@ -196,6 +198,8 @@ 9974CA2823DF1968003FE824 /* ElevationProfileData.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = ElevationProfileData.mm; sourceTree = ""; }; 9974CA2B23DF197B003FE824 /* ElevationProfileData+Core.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "ElevationProfileData+Core.h"; sourceTree = ""; }; AC6A585628057CC1003EABAF /* StringUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StringUtils.h; sourceTree = ""; }; + CE838D252D9D834F00476DD0 /* PlacePagePhone.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PlacePagePhone.h; sourceTree = ""; }; + CE838D262D9D834F00476DD0 /* PlacePagePhone.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PlacePagePhone.m; sourceTree = ""; }; ED0B1FF22CAAE3FF006E31A4 /* DeepLinkInAppFeatureHighlightData.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DeepLinkInAppFeatureHighlightData.h; sourceTree = ""; }; ED0B1FF32CAAE3FF006E31A4 /* DeepLinkInAppFeatureHighlightData.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = DeepLinkInAppFeatureHighlightData.mm; sourceTree = ""; }; ED46DE372D09BE21007CACD6 /* PlacePageTrackData.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PlacePageTrackData.h; sourceTree = ""; }; @@ -319,6 +323,8 @@ 47942D9A237D927800DEFAE3 /* PlacePageBookmarkData.h */, 47942D9E237D954400DEFAE3 /* PlacePageBookmarkData+Core.h */, 47942D9B237D927800DEFAE3 /* PlacePageBookmarkData.mm */, + CE838D252D9D834F00476DD0 /* PlacePagePhone.h */, + CE838D262D9D834F00476DD0 /* PlacePagePhone.m */, 47942D53237CC3B500DEFAE3 /* PlacePagePreviewData.h */, 47942D54237CC3B500DEFAE3 /* PlacePagePreviewData+Core.h */, 47942D55237CC3B500DEFAE3 /* PlacePagePreviewData.mm */, @@ -537,6 +543,7 @@ ED49D75F2CEFA8C0004AF27E /* Product+Core.h in Headers */, 47942D6E237CC3E800DEFAE3 /* PlacePagePreviewData+Core.h in Headers */, 47942D87237CC55800DEFAE3 /* MWMOpeningHoursCommon.h in Headers */, + CE838D272D9D834F00476DD0 /* PlacePagePhone.h in Headers */, 47942DAB237ED9FE00DEFAE3 /* IOpeningHoursLocalization.h in Headers */, 479F7063234FBC5900011E2E /* MWMCarPlayBookmarkObject.h in Headers */, 47E8163723B188D3008FD836 /* MWMStorage.h in Headers */, @@ -664,6 +671,7 @@ 47F701F0238C86F000D18E95 /* PlacePageButtonsData.mm in Sources */, ED49D7222CED0395004AF27E /* ProductsConfiguration+Core.mm in Sources */, 9940622123EAC57900493D1A /* ElevationHeightPoint.m in Sources */, + CE838D282D9D834F00476DD0 /* PlacePagePhone.m in Sources */, ED965B2A2CDA1C440049E39E /* DateTimeFormatter.swift in Sources */, 47EEAFF42350CEDB005CF316 /* AppInfo.mm in Sources */, 47E8163623B1889C008FD836 /* MWMStorage.mm in Sources */, diff --git a/iphone/CoreApi/CoreApi/CoreApi.h b/iphone/CoreApi/CoreApi/CoreApi.h index efd06f1c5..fc38589b3 100644 --- a/iphone/CoreApi/CoreApi/CoreApi.h +++ b/iphone/CoreApi/CoreApi/CoreApi.h @@ -44,3 +44,4 @@ FOUNDATION_EXPORT const unsigned char CoreApiVersionString[]; #import #import #import +#import diff --git a/iphone/CoreApi/CoreApi/PlacePageData/Common/PlacePageInfoData.h b/iphone/CoreApi/CoreApi/PlacePageData/Common/PlacePageInfoData.h index f457e8896..b7b96ec0d 100644 --- a/iphone/CoreApi/CoreApi/PlacePageData/Common/PlacePageInfoData.h +++ b/iphone/CoreApi/CoreApi/PlacePageData/Common/PlacePageInfoData.h @@ -1,6 +1,7 @@ #import @class OpeningHours; +@class PlacePagePhone; NS_ASSUME_NONNULL_BEGIN @@ -8,8 +9,7 @@ NS_ASSUME_NONNULL_BEGIN @property(nonatomic, readonly, nullable) NSString *openingHoursString; @property(nonatomic, readonly, nullable) OpeningHours *openingHours; -@property(nonatomic, readonly, nullable) NSString *phone; -@property(nonatomic, readonly, nullable) NSURL *phoneUrl; +@property(nonatomic, readonly, nullable) PlacePagePhone *phone; @property(nonatomic, readonly, nullable) NSString *website; @property(nonatomic, readonly, nullable) NSString *wikipedia; @property(nonatomic, readonly, nullable) NSString *wikimediaCommons; diff --git a/iphone/CoreApi/CoreApi/PlacePageData/Common/PlacePageInfoData.mm b/iphone/CoreApi/CoreApi/PlacePageData/Common/PlacePageInfoData.mm index 6781a9347..d168573c9 100644 --- a/iphone/CoreApi/CoreApi/PlacePageData/Common/PlacePageInfoData.mm +++ b/iphone/CoreApi/CoreApi/PlacePageData/Common/PlacePageInfoData.mm @@ -1,6 +1,7 @@ #import "PlacePageInfoData+Core.h" #import "OpeningHours.h" +#import "PlacePagePhone.h" #import @@ -46,12 +47,14 @@ NSString * GetLocalizedMetadataValueString(MapObject::MetadataID metaID, std::st break; case MetadataID::FMD_PHONE_NUMBER: { - _phone = ToNSString(value); - NSString *filteredDigits = [[_phone componentsSeparatedByCharactersInSet: + NSString *phone = ToNSString(value); + NSString *filteredDigits = [[phone componentsSeparatedByCharactersInSet: [[NSCharacterSet decimalDigitCharacterSet] invertedSet]] componentsJoinedByString:@""]; - NSString *resultNumber = [_phone hasPrefix:@"+"] ? [NSString stringWithFormat:@"+%@", filteredDigits] : filteredDigits; - _phoneUrl = [NSURL URLWithString:[NSString stringWithFormat:@"tel://%@", resultNumber]]; + NSString *resultNumber = [phone hasPrefix:@"+"] ? [NSString stringWithFormat:@"+%@", filteredDigits] : filteredDigits; + NSURL *phoneUrl = [NSURL URLWithString:[NSString stringWithFormat:@"tel://%@", resultNumber]]; + + _phone = [PlacePagePhone placePagePhoneWithPhone:phone andURL:phoneUrl]; break; } case MetadataID::FMD_WEBSITE: _website = ToNSString(value); break; diff --git a/iphone/CoreApi/CoreApi/PlacePageData/Common/PlacePagePhone.h b/iphone/CoreApi/CoreApi/PlacePageData/Common/PlacePagePhone.h new file mode 100644 index 000000000..90275d6a8 --- /dev/null +++ b/iphone/CoreApi/CoreApi/PlacePageData/Common/PlacePagePhone.h @@ -0,0 +1,16 @@ +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface PlacePagePhone : NSObject + +/// User-visible string of the phone number. +@property(nonatomic, readonly) NSString *phone; +/// Optional `tel:` URL, which can be used to ask iOS to call the phone number. +@property(nonatomic, readonly, nullable) NSURL *url; + ++ (instancetype)placePagePhoneWithPhone:(NSString *)phone andURL:(nullable NSURL *)url; + +@end + +NS_ASSUME_NONNULL_END diff --git a/iphone/CoreApi/CoreApi/PlacePageData/Common/PlacePagePhone.m b/iphone/CoreApi/CoreApi/PlacePageData/Common/PlacePagePhone.m new file mode 100644 index 000000000..005fa2511 --- /dev/null +++ b/iphone/CoreApi/CoreApi/PlacePageData/Common/PlacePagePhone.m @@ -0,0 +1,18 @@ +#import "PlacePagePhone.h" + +@implementation PlacePagePhone + +- (instancetype)initWithPhone:(NSString *)phone andURL:(nullable NSURL *)url { + self = [super init]; + if (self) { + _phone = phone; + _url = url; + } + return self; +} + ++ (instancetype)placePagePhoneWithPhone:(NSString *)phone andURL:(nullable NSURL *)url { + return [[self alloc] initWithPhone:phone andURL:url]; +} + +@end diff --git a/iphone/Maps/Classes/Share/MWMShareActivityItem.mm b/iphone/Maps/Classes/Share/MWMShareActivityItem.mm index 157aabdb3..1391ec643 100644 --- a/iphone/Maps/Classes/Share/MWMShareActivityItem.mm +++ b/iphone/Maps/Classes/Share/MWMShareActivityItem.mm @@ -4,6 +4,7 @@ #import #import #import +#import #import NSString * httpGe0Url(NSString * shortUrl) @@ -139,7 +140,7 @@ NSString * httpGe0Url(NSString * shortUrl) std::vector strings{self.data.previewData.title, self.data.previewData.subtitle, self.data.previewData.secondarySubtitle, - self.data.infoData.phone, + self.data.infoData.phone.phone, url, ge0Url}; diff --git a/iphone/Maps/UI/PlacePage/Components/PlacePageInfoViewController.swift b/iphone/Maps/UI/PlacePage/Components/PlacePageInfoViewController.swift index 2ccf35d29..7e255bab4 100644 --- a/iphone/Maps/UI/PlacePage/Components/PlacePageInfoViewController.swift +++ b/iphone/Maps/UI/PlacePage/Components/PlacePageInfoViewController.swift @@ -159,17 +159,17 @@ class PlacePageInfoViewController: UIViewController { if let phone = placePageInfoData.phone { var cellStyle: Style = .regular - if let phoneUrl = placePageInfoData.phoneUrl, UIApplication.shared.canOpenURL(phoneUrl) { + if let phoneUrl = phone.url, UIApplication.shared.canOpenURL(phoneUrl) { cellStyle = .link } - phoneView = createInfoItem(phone, + phoneView = createInfoItem(phone.phone, icon: UIImage(named: "ic_placepage_phone_number"), style: cellStyle, tapHandler: { [weak self] in self?.delegate?.didPressCall() }, longPressHandler: { [weak self] in - self?.delegate?.didCopy(phone) + self?.delegate?.didCopy(phone.phone) }) } diff --git a/iphone/Maps/UI/PlacePage/PlacePageManager/MWMPlacePageManager.mm b/iphone/Maps/UI/PlacePage/PlacePageManager/MWMPlacePageManager.mm index ed0589eac..60e3c508c 100644 --- a/iphone/Maps/UI/PlacePage/PlacePageManager/MWMPlacePageManager.mm +++ b/iphone/Maps/UI/PlacePage/PlacePageManager/MWMPlacePageManager.mm @@ -195,8 +195,9 @@ using namespace storage; } - (void)call:(PlacePageData *)data { - if (data.infoData.phoneUrl && [UIApplication.sharedApplication canOpenURL:data.infoData.phoneUrl]) { - [UIApplication.sharedApplication openURL:data.infoData.phoneUrl options:@{} completionHandler:nil]; + NSURL * _Nullable phoneURL = data.infoData.phone.url; + if (phoneURL && [UIApplication.sharedApplication canOpenURL:phoneURL]) { + [UIApplication.sharedApplication openURL:phoneURL options:@{} completionHandler:nil]; } }