From 73d013fb9dad6b61912744e6d60d7419d905ca9b Mon Sep 17 00:00:00 2001 From: Roman Kuznetsov Date: Mon, 9 Oct 2017 17:22:13 +0300 Subject: [PATCH] Added a sponsored project Thor (#7216) * Added a sponsored project Thor * Review fixes --- .../mapswithme/maps/widget/placepage/Sponsored.java | 4 +++- .../com/mapswithme/util/statistics/Statistics.java | 4 ++++ indexer/ftypes_matcher.cpp | 11 +++++++++++ indexer/ftypes_matcher.hpp | 8 ++++++++ iphone/Maps/Common/Statistics/StatisticsStrings.h | 1 + iphone/Maps/UI/PlacePage/MWMPlacePageData.h | 1 + iphone/Maps/UI/PlacePage/MWMPlacePageData.mm | 1 + iphone/Maps/UI/PlacePage/MWMPlacePageManager.mm | 2 ++ map/framework.cpp | 9 +++++++++ map/place_page_info.hpp | 3 ++- platform/marketing_service.cpp | 3 ++- platform/marketing_service.hpp | 1 + 12 files changed, 45 insertions(+), 3 deletions(-) diff --git a/android/src/com/mapswithme/maps/widget/placepage/Sponsored.java b/android/src/com/mapswithme/maps/widget/placepage/Sponsored.java index aadb480fba..ab6f2c997f 100644 --- a/android/src/com/mapswithme/maps/widget/placepage/Sponsored.java +++ b/android/src/com/mapswithme/maps/widget/placepage/Sponsored.java @@ -27,9 +27,11 @@ public final class Sponsored public static final int TYPE_GEOCHAT = 3; public static final int TYPE_VIATOR = 4; public static final int TYPE_CIAN = 5; + public static final int TYPE_THOR = 6; @Retention(RetentionPolicy.SOURCE) - @IntDef({ TYPE_NONE, TYPE_BOOKING, TYPE_OPENTABLE, TYPE_GEOCHAT, TYPE_VIATOR, TYPE_CIAN }) + @IntDef({ TYPE_NONE, TYPE_BOOKING, TYPE_OPENTABLE, TYPE_GEOCHAT, + TYPE_VIATOR, TYPE_CIAN, TYPE_THOR }) public @interface SponsoredType {} private static class Price diff --git a/android/src/com/mapswithme/util/statistics/Statistics.java b/android/src/com/mapswithme/util/statistics/Statistics.java index c066e1fceb..a6331db3c4 100644 --- a/android/src/com/mapswithme/util/statistics/Statistics.java +++ b/android/src/com/mapswithme/util/statistics/Statistics.java @@ -87,6 +87,7 @@ import static com.mapswithme.util.statistics.Statistics.ParamValue.GEOCHAT; import static com.mapswithme.util.statistics.Statistics.ParamValue.OPENTABLE; import static com.mapswithme.util.statistics.Statistics.ParamValue.SEARCH_BOOKING_COM; import static com.mapswithme.util.statistics.Statistics.ParamValue.VIATOR; +import static com.mapswithme.util.statistics.Statistics.ParamValue.THOR; public enum Statistics { @@ -346,6 +347,7 @@ public enum Statistics public static final String VIATOR = "Viator.Com"; public static final String GEOCHAT = "Geochat"; public static final String CIAN = "Cian.Ru"; + public static final String THOR = "Thor"; public static final String NO_PRODUCTS = "no_products"; } @@ -781,6 +783,8 @@ public enum Statistics return OPENTABLE; case Sponsored.TYPE_CIAN: return CIAN; + case Sponsored.TYPE_THOR: + return THOR; case Sponsored.TYPE_NONE: return "N/A"; default: diff --git a/indexer/ftypes_matcher.cpp b/indexer/ftypes_matcher.cpp index 4475adc0c6..ae335fc1d9 100644 --- a/indexer/ftypes_matcher.cpp +++ b/indexer/ftypes_matcher.cpp @@ -511,6 +511,17 @@ IsViatorChecker const & IsViatorChecker::Instance() return inst; } +IsThorChecker::IsThorChecker() +{ + m_types.push_back(classif().GetTypeByPath({"sponsored", "thor"})); +} + +IsThorChecker const & IsThorChecker::Instance() +{ + static IsThorChecker const inst; + return inst; +} + IsPublicTransportStopChecker::IsPublicTransportStopChecker() { m_types.push_back(classif().GetTypeByPath({"highway", "bus_stop"})); diff --git a/indexer/ftypes_matcher.hpp b/indexer/ftypes_matcher.hpp index 5378ed6612..5b1143e5d6 100644 --- a/indexer/ftypes_matcher.hpp +++ b/indexer/ftypes_matcher.hpp @@ -234,6 +234,14 @@ public: static IsViatorChecker const & Instance(); }; +class IsThorChecker : public BaseChecker +{ + IsThorChecker(); + +public: + static IsThorChecker const & Instance(); +}; + class IsPublicTransportStopChecker : public BaseChecker { IsPublicTransportStopChecker(); diff --git a/iphone/Maps/Common/Statistics/StatisticsStrings.h b/iphone/Maps/Common/Statistics/StatisticsStrings.h index fdca417af3..3e32df8af2 100644 --- a/iphone/Maps/Common/Statistics/StatisticsStrings.h +++ b/iphone/Maps/Common/Statistics/StatisticsStrings.h @@ -264,6 +264,7 @@ static NSString * const kStatTTSSettings = @"TTS settings"; static NSString * const kStatTable = @"Table"; static NSString * const kStatTags = @"tags"; static NSString * const kStatTaxi = @"Taxi"; +static NSString * const kStatThor = @"Thor"; static NSString * const kStatToLocation = @"to_location"; static NSString * const kStatToMyPosition = @"To my position"; static NSString * const kStatToggleBookmark = @"Toggle bookmark"; diff --git a/iphone/Maps/UI/PlacePage/MWMPlacePageData.h b/iphone/Maps/UI/PlacePage/MWMPlacePageData.h index 56fb70637c..ed5c8d7f12 100644 --- a/iphone/Maps/UI/PlacePage/MWMPlacePageData.h +++ b/iphone/Maps/UI/PlacePage/MWMPlacePageData.h @@ -246,6 +246,7 @@ using CianIsReady = void (^)(NSArray * items); - (BOOL)isOpentable; - (BOOL)isViator; - (BOOL)isCian; +- (BOOL)isThor; - (BOOL)isBookingSearch; - (BOOL)isHTMLDescription; - (BOOL)isMyPosition; diff --git a/iphone/Maps/UI/PlacePage/MWMPlacePageData.mm b/iphone/Maps/UI/PlacePage/MWMPlacePageData.mm index 7f1870c772..4eee96608a 100644 --- a/iphone/Maps/UI/PlacePage/MWMPlacePageData.mm +++ b/iphone/Maps/UI/PlacePage/MWMPlacePageData.mm @@ -765,6 +765,7 @@ using namespace place_page; - (BOOL)isOpentable { return m_info.GetSponsoredType() == SponsoredType::Opentable; } - (BOOL)isViator { return m_info.GetSponsoredType() == SponsoredType::Viator; } - (BOOL)isCian { return m_info.GetSponsoredType() == SponsoredType::Cian; } +- (BOOL)isThor { return m_info.GetSponsoredType() == SponsoredType::Thor; } - (BOOL)isBookingSearch { return !m_info.GetBookingSearchUrl().empty(); } - (BOOL)isMyPosition { return m_info.IsMyPosition(); } - (BOOL)isHTMLDescription { return strings::IsHTML(m_info.GetBookmarkData().GetDescription()); } diff --git a/iphone/Maps/UI/PlacePage/MWMPlacePageManager.mm b/iphone/Maps/UI/PlacePage/MWMPlacePageManager.mm index f5e0affb90..a9626c0800 100644 --- a/iphone/Maps/UI/PlacePage/MWMPlacePageManager.mm +++ b/iphone/Maps/UI/PlacePage/MWMPlacePageManager.mm @@ -252,6 +252,8 @@ void logSponsoredEvent(MWMPlacePageData * data, NSString * eventName) parameters[kStatProvider] = kStatBooking; else if (data.isCian) parameters[kStatProvider] = kStatCian; + else if (data.isThor) + parameters[kStatProvider] = kStatThor; switch (Platform::ConnectionStatus()) { case Platform::EConnectionType::CONNECTION_NONE: diff --git a/map/framework.cpp b/map/framework.cpp index 151fe63715..4d36efeac1 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -906,6 +906,15 @@ void Framework::FillInfoFromFeatureType(FeatureType const & ft, place_page::Info info.SetSponsoredUrl(cian::Api::GetMainPageUrl()); info.SetPreviewIsExtended(); } + else if (ftypes::IsThorChecker::Instance()(ft) && + !info.GetMetadata().Get(feature::Metadata::FMD_RATING).empty()) + { + info.SetSponsoredType(place_page::SponsoredType::Thor); + auto const & url = info.GetMetadata().Get(feature::Metadata::FMD_WEBSITE); + info.SetSponsoredUrl(url); + info.SetSponsoredDescriptionUrl(url); + GetPlatform().GetMarketingService().SendPushWooshTag(marketing::kSponsoredThorDiscovered); + } FillLocalExperts(ft, info); diff --git a/map/place_page_info.hpp b/map/place_page_info.hpp index 9c50ca50d6..d49e04eb5d 100644 --- a/map/place_page_info.hpp +++ b/map/place_page_info.hpp @@ -38,7 +38,8 @@ enum class SponsoredType Opentable, Geochat, Viator, - Cian + Cian, + Thor }; enum class LocalAdsStatus diff --git a/platform/marketing_service.cpp b/platform/marketing_service.cpp index 5b02fa75ea..1ae4538b2a 100644 --- a/platform/marketing_service.cpp +++ b/platform/marketing_service.cpp @@ -22,6 +22,7 @@ char const * const kRoutingTransitDiscovered = "routing_transit_discovered"; char const * const kEditorAddDiscovered = "editor_add_discovered"; char const * const kEditorEditDiscovered = "editor_edit_discovered"; char const * const kTrafficDiscovered = "traffic_discovered"; +char const * const kSponsoredThorDiscovered = "sponsored_thor_discovered"; // Events. char const * const kDownloaderMapActionFinished = "Downloader_Map_action_finished"; @@ -56,7 +57,7 @@ void MarketingService::ProcessFirstLaunch() kEditorAddDiscovered, kEditorEditDiscovered, - kTrafficDiscovered + kTrafficDiscovered, kSponsoredThorDiscovered }; for (auto const & tag : tags) diff --git a/platform/marketing_service.hpp b/platform/marketing_service.hpp index bac4604c80..8bfec5f379 100644 --- a/platform/marketing_service.hpp +++ b/platform/marketing_service.hpp @@ -27,6 +27,7 @@ extern char const * const kRoutingTransitDiscovered; extern char const * const kEditorAddDiscovered; extern char const * const kEditorEditDiscovered; extern char const * const kTrafficDiscovered; +extern char const * const kSponsoredThorDiscovered; // Events. extern char const * const kDownloaderMapActionFinished;