diff --git a/iphone/Maps/Classes/MWMBasePlacePageView.mm b/iphone/Maps/Classes/MWMBasePlacePageView.mm index 5cb1881ad5..8dbddcb18b 100644 --- a/iphone/Maps/Classes/MWMBasePlacePageView.mm +++ b/iphone/Maps/Classes/MWMBasePlacePageView.mm @@ -669,7 +669,7 @@ using namespace storage; case MWMPlacePageCellTypeAddBusinessButton: case MWMPlacePageCellTypeAddPlaceButton: case MWMPlacePageCellTypeBookingMore: - [static_cast(cell) config:self.ownerPlacePage forType:cellType]; + [static_cast(cell) config:self.ownerPlacePage.manager forType:cellType]; break; default: { diff --git a/iphone/Maps/Classes/MWMPlacePage.h b/iphone/Maps/Classes/MWMPlacePage.h index 9e723f1a14..ac4ae5b5f5 100644 --- a/iphone/Maps/Classes/MWMPlacePage.h +++ b/iphone/Maps/Classes/MWMPlacePage.h @@ -25,10 +25,6 @@ - (void)addBookmark; - (void)removeBookmark; - (void)editBookmark; -- (void)editPlace; -- (void)addBusiness; -- (void)addPlace; -- (void)bookingMore; - (void)reloadBookmark; - (void)addPlacePageShadowToView:(UIView *)view offset:(CGSize)offset; diff --git a/iphone/Maps/Classes/MWMPlacePage.mm b/iphone/Maps/Classes/MWMPlacePage.mm index c04d9c7e47..772906428c 100644 --- a/iphone/Maps/Classes/MWMPlacePage.mm +++ b/iphone/Maps/Classes/MWMPlacePage.mm @@ -99,27 +99,6 @@ extern NSString * const kPP2BookmarkEditingIPADSegue = @"PP2BookmarkEditingIPAD" self.actionBar.isBookmark = NO; } -- (void)editPlace -{ - [self.manager editPlace]; -} - -- (void)addBusiness -{ - [self.manager addBusiness]; -} - -- (void)addPlace -{ - [self.manager addPlace]; -} - -- (void)bookingMore -{ - MapViewController * vc = MapsAppDelegate.theApp.mapViewController; - [vc openUrl:[NSURL URLWithString:[self.manager.entity getCellValue:MWMPlacePageCellTypeBookingMore]]]; -} - - (void)addPlacePageShadowToView:(UIView *)view offset:(CGSize)offset { CALayer * layer = view.layer; diff --git a/iphone/Maps/Classes/MWMPlacePageActionBar.mm b/iphone/Maps/Classes/MWMPlacePageActionBar.mm index a63af2ac3b..6ddffb6e3b 100644 --- a/iphone/Maps/Classes/MWMPlacePageActionBar.mm +++ b/iphone/Maps/Classes/MWMPlacePageActionBar.mm @@ -174,7 +174,7 @@ NSString * const kPlacePageActionBarNibName = @"PlacePageActionBar"; [self.placePageManager apiBack]; break; case EButton::Booking: - [self.placePageManager book]; + [self.placePageManager book:NO]; break; case EButton::Call: [self.placePageManager call]; diff --git a/iphone/Maps/Classes/MWMPlacePageButtonCell.h b/iphone/Maps/Classes/MWMPlacePageButtonCell.h index 2999e0a3eb..e8007704d8 100644 --- a/iphone/Maps/Classes/MWMPlacePageButtonCell.h +++ b/iphone/Maps/Classes/MWMPlacePageButtonCell.h @@ -1,10 +1,10 @@ #import "MWMTableViewCell.h" #import "MWMPlacePageEntity.h" -@class MWMPlacePage; +@class MWMPlacePageViewManager; @interface MWMPlacePageButtonCell : MWMTableViewCell -- (void)config:(MWMPlacePage *)placePage forType:(MWMPlacePageCellType)type; +- (void)config:(MWMPlacePageViewManager *)manager forType:(MWMPlacePageCellType)type; @end diff --git a/iphone/Maps/Classes/MWMPlacePageButtonCell.mm b/iphone/Maps/Classes/MWMPlacePageButtonCell.mm index 3afe4f3485..8c36325521 100644 --- a/iphone/Maps/Classes/MWMPlacePageButtonCell.mm +++ b/iphone/Maps/Classes/MWMPlacePageButtonCell.mm @@ -1,15 +1,10 @@ -#import "LocationManager.h" -#import "MapsAppDelegate.h" -#import "MWMPlacePage.h" #import "MWMPlacePageButtonCell.h" -#import "MWMPlacePageEntity.h" #import "MWMPlacePageViewManager.h" -#import "Statistics.h" #import "UIColor+MapsMeColor.h" @interface MWMPlacePageButtonCell () -@property (weak, nonatomic) MWMPlacePage * placePage; +@property (weak, nonatomic) MWMPlacePageViewManager * manager; @property (weak, nonatomic) IBOutlet UIButton * titleButton; @property (nonatomic) MWMPlacePageCellType type; @@ -17,9 +12,9 @@ @implementation MWMPlacePageButtonCell -- (void)config:(MWMPlacePage *)placePage forType:(MWMPlacePageCellType)type +- (void)config:(MWMPlacePageViewManager *)manager forType:(MWMPlacePageCellType)type { - self.placePage = placePage; + self.manager = manager; switch (type) { case MWMPlacePageCellTypeAddBusinessButton: @@ -46,39 +41,17 @@ switch (self.type) { case MWMPlacePageCellTypeEditButton: - [Statistics logEvent:kStatEventName(kStatPlacePage, kStatEdit)]; - [self.placePage editPlace]; + [self.manager editPlace]; break; case MWMPlacePageCellTypeAddBusinessButton: - [Statistics logEvent:kStatEditorAddClick withParameters:@{kStatValue : kStatPlacePage}]; - [self.placePage addBusiness]; + [self.manager addBusiness]; break; case MWMPlacePageCellTypeAddPlaceButton: - [Statistics logEvent:kStatEditorAddClick withParameters:@{kStatValue : kStatPlacePageNonBuilding}]; - [self.placePage addPlace]; + [self.manager addPlace]; break; case MWMPlacePageCellTypeBookingMore: - { - NSMutableDictionary * stat = [@{kStatProvider : kStatBooking} mutableCopy]; - LocationManager * lm = MapsAppDelegate.theApp.locationManager; - if (lm.lastLocationIsValid) - { - CLLocation * loc = lm.lastLocation; - stat[kStatLat] = @(loc.coordinate.latitude); - stat[kStatLon] = @(loc.coordinate.longitude); - } - else - { - stat[kStatLat] = @0; - stat[kStatLon] = @0; - } - MWMPlacePageEntity * en = self.placePage.manager.entity; - auto const latLon = en.latlon; - stat[kStatHotel] = @{kStatName : en.title, kStatLat : @(latLon.lat), kStatLon : @(latLon.lon)}; - [Statistics logEvent:kPlacePageHotelDetails withParameters:stat]; - [self.placePage bookingMore]; + [self.manager book:YES]; break; - } default: NSAssert(false, @"Incorrect cell type!"); break; diff --git a/iphone/Maps/Classes/MWMPlacePageEntity.h b/iphone/Maps/Classes/MWMPlacePageEntity.h index 547e7245ff..c97d79ad9a 100644 --- a/iphone/Maps/Classes/MWMPlacePageEntity.h +++ b/iphone/Maps/Classes/MWMPlacePageEntity.h @@ -63,6 +63,7 @@ using MWMPlacePageCellTypeValueMap = map; - (ms::LatLon)latlon; - (m2::PointD const &)mercator; - (NSString *)apiURL; +- (NSURL *)bookingUrl; - (string)titleForNewBookmark; - (instancetype)initWithInfo:(place_page::Info const &)info; diff --git a/iphone/Maps/Classes/MWMPlacePageEntity.mm b/iphone/Maps/Classes/MWMPlacePageEntity.mm index 945bbfa53f..5f5603fd0d 100644 --- a/iphone/Maps/Classes/MWMPlacePageEntity.mm +++ b/iphone/Maps/Classes/MWMPlacePageEntity.mm @@ -26,11 +26,10 @@ void putFields(NSUInteger eTypeValue, NSUInteger ppValue) gMetaFieldsMap[ppValue] = eTypeValue; } -void initFieldsMap(BOOL isBooking) +void initFieldsMap() { - auto const websiteType = isBooking ? MWMPlacePageCellTypeBookingMore : MWMPlacePageCellTypeWebsite; putFields(Metadata::FMD_URL, MWMPlacePageCellTypeURL); - putFields(Metadata::FMD_WEBSITE, websiteType); + putFields(Metadata::FMD_WEBSITE, MWMPlacePageCellTypeWebsite); putFields(Metadata::FMD_PHONE_NUMBER, MWMPlacePageCellTypePhoneNumber); putFields(Metadata::FMD_OPEN_HOURS, MWMPlacePageCellTypeOpenHours); putFields(Metadata::FMD_EMAIL, MWMPlacePageCellTypeEmail); @@ -40,7 +39,7 @@ void initFieldsMap(BOOL isBooking) ASSERT_EQUAL(gMetaFieldsMap[Metadata::FMD_URL], MWMPlacePageCellTypeURL, ()); ASSERT_EQUAL(gMetaFieldsMap[MWMPlacePageCellTypeURL], Metadata::FMD_URL, ()); - ASSERT_EQUAL(gMetaFieldsMap[Metadata::FMD_WEBSITE], websiteType, ()); + ASSERT_EQUAL(gMetaFieldsMap[Metadata::FMD_WEBSITE], MWMPlacePageCellTypeWebsite, ()); ASSERT_EQUAL(gMetaFieldsMap[MWMPlacePageCellTypeWebsite], Metadata::FMD_WEBSITE, ()); ASSERT_EQUAL(gMetaFieldsMap[Metadata::FMD_POSTCODE], MWMPlacePageCellTypePostcode, ()); ASSERT_EQUAL(gMetaFieldsMap[MWMPlacePageCellTypePostcode], Metadata::FMD_POSTCODE, ()); @@ -60,7 +59,7 @@ void initFieldsMap(BOOL isBooking) if (self) { m_info = info; - initFieldsMap(info.IsSponsoredHotel()); + initFieldsMap(); [self config]; } return self; @@ -167,7 +166,7 @@ void initFieldsMap(BOOL isBooking) case MWMPlacePageCellTypeWebsite: return m_info.IsSponsoredHotel() ? nil : [self getDefaultField:cellType]; case MWMPlacePageCellTypeBookingMore: - return m_info.IsSponsoredHotel() ? [self getDefaultField:cellType] : nil; + return m_info.IsSponsoredHotel() ? @(m_info.GetSponsoredDescriptionUrl().c_str()) : nil; default: return [self getDefaultField:cellType]; } @@ -180,6 +179,12 @@ void initFieldsMap(BOOL isBooking) return haveField ? @(it->second.c_str()) : nil; } +- (NSURL *)bookingUrl +{ + auto const & url = m_info.GetSponsoredBookingUrl(); + return url.empty() ? nil : [NSURL URLWithString:@(url.c_str())]; +} + - (place_page::Info const &)info { return m_info; diff --git a/iphone/Maps/Classes/MWMPlacePageViewManager.h b/iphone/Maps/Classes/MWMPlacePageViewManager.h index 8446b4430a..db4e7a8537 100644 --- a/iphone/Maps/Classes/MWMPlacePageViewManager.h +++ b/iphone/Maps/Classes/MWMPlacePageViewManager.h @@ -29,7 +29,7 @@ - (void)addPlace; - (void)addBookmark; - (void)removeBookmark; -- (void)book; +- (void)book:(BOOL)isDecription; - (void)call; - (void)apiBack; - (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)orientation; diff --git a/iphone/Maps/Classes/MWMPlacePageViewManager.mm b/iphone/Maps/Classes/MWMPlacePageViewManager.mm index 7a73c3a193..f670bedd3d 100644 --- a/iphone/Maps/Classes/MWMPlacePageViewManager.mm +++ b/iphone/Maps/Classes/MWMPlacePageViewManager.mm @@ -246,7 +246,7 @@ extern NSString * const kBookmarksChangedNotification; anchorView:self.placePage.actionBar.shareAnchor]; } -- (void)book +- (void)book:(BOOL)isDescription { NSMutableDictionary * stat = [@{kStatProvider : kStatBooking} mutableCopy]; LocationManager * lm = MapsAppDelegate.theApp.locationManager; @@ -264,11 +264,10 @@ extern NSString * const kBookmarksChangedNotification; MWMPlacePageEntity * en = self.entity; auto const latLon = en.latlon; stat[kStatHotel] = @{kStatName : en.title, kStatLat : @(latLon.lat), kStatLon : @(latLon.lon)}; - [Statistics logEvent:kPlacePageHotelBook withParameters:stat]; + [Statistics logEvent:isDescription ? kPlacePageHotelDetails : kPlacePageHotelBook withParameters:stat]; UIViewController * vc = static_cast(MapsAppDelegate.theApp.mapViewController); - NSString * urlString = [self.entity getCellValue:MWMPlacePageCellTypeBookingMore]; - NSAssert(urlString, @"Booking url can't be nil!"); - NSURL * url = [NSURL URLWithString:urlString]; + NSURL * url = isDescription ? self.entity.bookingUrl : [NSURL URLWithString:[self.entity getCellValue:MWMPlacePageCellTypeBookingMore]]; + NSAssert(url, @"Booking url can't be nil!"); [vc openUrl:url]; } @@ -289,16 +288,19 @@ extern NSString * const kBookmarksChangedNotification; - (void)editPlace { + [Statistics logEvent:kStatEventName(kStatPlacePage, kStatEdit)]; [(MapViewController *)self.ownerViewController openEditor]; } - (void)addBusiness { + [Statistics logEvent:kStatEditorAddClick withParameters:@{kStatValue : kStatPlacePage}]; [self.delegate addPlace:YES hasPoint:NO point:m2::PointD()]; } - (void)addPlace { + [Statistics logEvent:kStatEditorAddClick withParameters:@{kStatValue : kStatPlacePageNonBuilding}]; [self.delegate addPlace:NO hasPoint:YES point:self.entity.mercator]; }