diff --git a/android/jni/com/mapswithme/maps/Framework.cpp b/android/jni/com/mapswithme/maps/Framework.cpp index 13ad815d3d..b538051948 100644 --- a/android/jni/com/mapswithme/maps/Framework.cpp +++ b/android/jni/com/mapswithme/maps/Framework.cpp @@ -749,6 +749,10 @@ extern "C" case UserMark::Type::POI: { + // TODO(AlexZ): Refactor out passing custom name for shared links. + auto const & cn = static_cast(mark)->GetCustomName(); + if (!cn.empty()) + info.m_name = cn; CallOnPoiActivatedListener(obj, mark->GetPivot(), info, metadata); break; } diff --git a/iphone/Maps/Classes/MWMPlacePageEntity.mm b/iphone/Maps/Classes/MWMPlacePageEntity.mm index 5dcb355600..94637cdc59 100644 --- a/iphone/Maps/Classes/MWMPlacePageEntity.mm +++ b/iphone/Maps/Classes/MWMPlacePageEntity.mm @@ -116,8 +116,11 @@ NSString * mwmToOSMCuisineString(NSString * mwmCuisine) [self configureForMyPosition:static_cast(mark)]; break; case Type::SEARCH: + [self configureWithFeature:mark->GetFeature() andCustomName:nil]; + break; case Type::POI: - [self configureWithFeature:mark->GetFeature()]; + [self configureWithFeature:mark->GetFeature() + andCustomName:@(static_cast(mark)->GetCustomName().c_str())]; break; case Type::BOOKMARK: [self configureForBookmark:mark]; @@ -187,7 +190,7 @@ NSString * mwmToOSMCuisineString(NSString * mwmCuisine) _isHTMLDescription = strings::IsHTML(description); self.bookmarkColor = @(data.GetType().c_str()); - [self configureWithFeature:bookmark->GetFeature()]; + [self configureWithFeature:bookmark->GetFeature() andCustomName:nil]; [self addBookmarkField]; } @@ -208,15 +211,18 @@ NSString * mwmToOSMCuisineString(NSString * mwmCuisine) [self addMetaField:MWMPlacePageCellTypeCoordinate]; } -// feature can be nullptr if user selected any empty area. -- (void)configureWithFeature:(FeatureType const *)feature +- (void)configureWithFeature:(FeatureType const *)feature andCustomName:(NSString *)customName { + // Custom name is used in shared links and should override default feature's name in PP. + self.title = customName; + // feature can be nullptr if user selected any empty area. if (feature) { search::AddressInfo const info = GetFramework().GetFeatureAddressInfo(*feature); feature::Metadata const & metadata = feature->GetMetadata(); NSString * const name = @(info.GetPinName().c_str()); - self.title = name.length > 0 ? name : L(@"dropped_pin"); + if (0 == self.title.length) + self.title = name.length > 0 ? name : L(@"dropped_pin"); self.category = @(info.GetPinType().c_str()); self.address = @(info.FormatAddress().c_str()); diff --git a/map/framework.cpp b/map/framework.cpp index e1c70a7131..f695a2fc7e 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -1620,7 +1620,8 @@ bool Framework::ShowMapForURL(string const & url) { PoiMarkPoint * mark = UserMarkContainer::UserMarkForPoi(); mark->SetPtOrg(point); - // TODO(AlexZ): Do we really have to set custom name here if it's not empty? + // TODO(AlexZ): refactor out interface for passing PP values to UI. + mark->SetCustomName(name); ActivateUserMark(mark, false); } } diff --git a/map/user_mark.cpp b/map/user_mark.cpp index 09752c0180..1a397499c5 100644 --- a/map/user_mark.cpp +++ b/map/user_mark.cpp @@ -156,6 +156,16 @@ void PoiMarkPoint::SetPtOrg(m2::PointD const & ptOrg) m_ptOrg = ptOrg; } +void PoiMarkPoint::SetCustomName(string const & customName) +{ + m_customName = customName; +} + +string const & PoiMarkPoint::GetCustomName() const +{ + return m_customName; +} + MyPositionMarkPoint::MyPositionMarkPoint(UserMarkContainer * container) : PoiMarkPoint(container) { diff --git a/map/user_mark.hpp b/map/user_mark.hpp index 30306a9d02..edbb1a3042 100644 --- a/map/user_mark.hpp +++ b/map/user_mark.hpp @@ -98,6 +98,13 @@ public: unique_ptr Copy() const override; void SetPtOrg(m2::PointD const & ptOrg); + // TODO(AlexZ): Refactor out. Now we need it to pass custom name from shared links. + void SetCustomName(string const & customName); + string const & GetCustomName() const; + +private: + // If present, should override any feature's name for this user mark. + string m_customName; }; class MyPositionMarkPoint : public PoiMarkPoint diff --git a/map/user_mark_container.cpp b/map/user_mark_container.cpp index 98fb0475b9..703ccd290a 100644 --- a/map/user_mark_container.cpp +++ b/map/user_mark_container.cpp @@ -113,6 +113,9 @@ void UserMarkContainer::InitStaticMarks(UserMarkContainer * container) PoiMarkPoint * UserMarkContainer::UserMarkForPoi() { ASSERT(g_selectionUserMark != NULL, ()); + // TODO(AlexZ): Refactor out UserMarks and containers. + // Consider this call as returning "new" PoiMarkPoint, so clear up old "custom name" data. + g_selectionUserMark->SetCustomName(string()); return g_selectionUserMark.get(); }