diff --git a/android/src/com/mapswithme/maps/widget/placepage/PlacePageButtons.java b/android/src/com/mapswithme/maps/widget/placepage/PlacePageButtons.java index 7d2b936f29..60fa722fae 100644 --- a/android/src/com/mapswithme/maps/widget/placepage/PlacePageButtons.java +++ b/android/src/com/mapswithme/maps/widget/placepage/PlacePageButtons.java @@ -49,347 +49,202 @@ final class PlacePageButtons @NonNull ButtonType getType(); + + @DrawableRes + int getBackgroundResource(); } enum ButtonType { - PARTNER1, PARTNER3, BOOKING, BOOKING_SEARCH, OPENTABLE, BACK, BOOKMARK, + PARTNER1, PARTNER3, PARTNER4, PARTNER5, PARTNER6, PARTNER7, + PARTNER8, PARTNER9, PARTNER10, PARTNER11, PARTNER12, PARTNER13, + PARTNER14, PARTNER15, PARTNER16, PARTNER17, + BOOKING, BOOKING_SEARCH, OPENTABLE, BACK, BOOKMARK, ROUTE_FROM, ROUTE_TO, ROUTE_ADD, ROUTE_REMOVE, SHARE, MORE, CALL } private enum PartnerItem implements ButtonInterface { - PARTNER1(1) - { - @Override - public int getTitle() - { - return R.string.sponsored_partner1_action; - } - - @Override - public int getIcon() - { - return R.drawable.ic_24px_logo_partner1; - } - - @NonNull - public ButtonType getType() - { - return ButtonType.PARTNER1; - } - }, - - PARTNER3(3) - { - @Override - public int getTitle() - { - return R.string.sponsored_partner3_action; - } - - @Override - public int getIcon() - { - return R.drawable.ic_24px_logo_partner3; - } - - @Override - @NonNull - public ButtonType getType() - { - return ButtonType.PARTNER3; - } - }; + PARTNER1(1, R.string.sponsored_partner1_action, + R.drawable.ic_24px_logo_partner1, R.drawable.button_partner1, ButtonType.PARTNER1), + PARTNER3(3, R.string.sponsored_partner3_action, + R.drawable.ic_24px_logo_partner3, R.drawable.button_partner3, ButtonType.PARTNER3), + PARTNER4(4, R.string.sponsored_partner4_action, + R.drawable.ic_24px_logo_partner4, R.drawable.button_partner4, ButtonType.PARTNER4), + PARTNER5(5, R.string.sponsored_partner5_action, + R.drawable.ic_24px_logo_partner5, R.drawable.button_partner5, ButtonType.PARTNER5), + PARTNER6(6, R.string.sponsored_partner6_action, + R.drawable.ic_24px_logo_partner6, R.drawable.button_partner6, ButtonType.PARTNER6), + PARTNER7(7, R.string.sponsored_partner7_action, + R.drawable.ic_24px_logo_partner7, R.drawable.button_partner7, ButtonType.PARTNER7), + PARTNER8(8, R.string.sponsored_partner8_action, + R.drawable.ic_24px_logo_partner8, R.drawable.button_partner8, ButtonType.PARTNER8), + PARTNER9(9, R.string.sponsored_partner9_action, + R.drawable.ic_24px_logo_partner9, R.drawable.button_partner9, ButtonType.PARTNER9), + PARTNER10(10, R.string.sponsored_partner10_action, + R.drawable.ic_24px_logo_partner10, R.drawable.button_partner10, ButtonType.PARTNER10), + PARTNER11(11, R.string.sponsored_partner11_action, + R.drawable.ic_24px_logo_partner11, R.drawable.button_partner11, ButtonType.PARTNER11), + PARTNER12(12, R.string.sponsored_partner12_action, + R.drawable.ic_24px_logo_partner12, R.drawable.button_partner12, ButtonType.PARTNER12), + PARTNER13(13, R.string.sponsored_partner13_action, + R.drawable.ic_24px_logo_partner13, R.drawable.button_partner13, ButtonType.PARTNER13), + PARTNER14(14, R.string.sponsored_partner14_action, + R.drawable.ic_24px_logo_partner14, R.drawable.button_partner14, ButtonType.PARTNER14), + PARTNER15(15, R.string.sponsored_partner15_action, + R.drawable.ic_24px_logo_partner15, R.drawable.button_partner15, ButtonType.PARTNER15), + PARTNER16(16, R.string.sponsored_partner16_action, + R.drawable.ic_24px_logo_partner16, R.drawable.button_partner16, ButtonType.PARTNER16), + PARTNER17(17, R.string.sponsored_partner17_action, + R.drawable.ic_24px_logo_partner17, R.drawable.button_partner17, ButtonType.PARTNER17); private final int mIndex; + @StringRes + private final int mTitleId; + @DrawableRes + private final int mIconId; + @DrawableRes + private final int mBackgroundId; + @NonNull + private final ButtonType mButtonType; - PartnerItem(int index) + PartnerItem(int index, @StringRes int titleId, @DrawableRes int iconId, + @DrawableRes int backgroundId, @NonNull ButtonType buttonType) { mIndex = index; + mTitleId = titleId; + mIconId = iconId; + mBackgroundId = backgroundId; + mButtonType = buttonType; } public int getIndex() { return mIndex; } + + @StringRes + @Override + public int getTitle() + { + return mTitleId; + } + + @DrawableRes + @Override + public int getIcon() + { + return mIconId; + } + + @NonNull + @Override + public ButtonType getType() + { + return mButtonType; + } + + @DrawableRes + @Override + public int getBackgroundResource() + { + return mBackgroundId; + } } enum Item implements ButtonInterface { - BOOKING + BOOKING(R.string.book_button, R.drawable.ic_booking, ButtonType.BOOKING) { + @DrawableRes @Override - public int getTitle() + public int getBackgroundResource() { - return R.string.book_button; - } - - @Override - public int getIcon() - { - return R.drawable.ic_booking; - } - - @Override - @NonNull - public ButtonType getType() - { - return ButtonType.BOOKING; + return R.drawable.button_booking; } }, - BOOKING_SEARCH + BOOKING_SEARCH(R.string.booking_search, R.drawable.ic_menu_search, ButtonType.BOOKING_SEARCH) { + @DrawableRes @Override - public int getTitle() + public int getBackgroundResource() { - return R.string.booking_search; - } - - @Override - public int getIcon() - { - return R.drawable.ic_menu_search; - } - - @NonNull - @Override - public ButtonType getType() - { - return ButtonType.BOOKING_SEARCH; + return R.drawable.button_booking; } }, - OPENTABLE + OPENTABLE(R.string.book_button, R.drawable.ic_opentable, ButtonType.OPENTABLE) { + @DrawableRes @Override - public int getTitle() + public int getBackgroundResource() { - return R.string.book_button; - } - - @Override - public int getIcon() - { - return R.drawable.ic_opentable; - } - - @NonNull - @Override - public ButtonType getType() - { - return ButtonType.OPENTABLE; + return R.drawable.button_opentable; } }, - BACK - { - @Override - public int getTitle() - { - return R.string.back; - } + BACK(R.string.back, ThemeUtils.getResource(MwmApplication.get(), + android.R.attr.homeAsUpIndicator), ButtonType.BACK), - @Override - public int getIcon() - { - return ThemeUtils.getResource(MwmApplication.get(), android.R.attr.homeAsUpIndicator); - } + BOOKMARK(R.string.bookmark, R.drawable.ic_bookmarks_off, ButtonType.BOOKMARK), - @NonNull - @Override - public ButtonType getType() - { - return ButtonType.BACK; - } - }, + ROUTE_FROM(R.string.p2p_from_here, R.drawable.ic_route_from, ButtonType.ROUTE_FROM), - BOOKMARK - { - @Override - public int getTitle() - { - return R.string.bookmark; - } + ROUTE_TO(R.string.p2p_to_here, R.drawable.ic_route_to, ButtonType.ROUTE_TO), - @Override - public int getIcon() - { - return R.drawable.ic_bookmarks_off; - } + ROUTE_ADD(R.string.placepage_add_stop, R.drawable.ic_route_via, ButtonType.ROUTE_ADD), - @NonNull - @Override - public ButtonType getType() - { - return ButtonType.BOOKMARK; - } - }, + ROUTE_REMOVE(R.string.placepage_remove_stop, R.drawable.ic_route_remove, + ButtonType.ROUTE_REMOVE), - ROUTE_FROM - { - @Override - public int getTitle() - { - return R.string.p2p_from_here; - } - - @Override - public int getIcon() - { - return R.drawable.ic_route_from; - } - - @NonNull - @Override - public ButtonType getType() - { - return ButtonType.ROUTE_FROM; - } - }, - - ROUTE_TO - { - @Override - public int getTitle() - { - return R.string.p2p_to_here; - } - - @Override - public int getIcon() - { - return R.drawable.ic_route_to; - } - - @NonNull - @Override - public ButtonType getType() - { - return ButtonType.ROUTE_TO; - } - }, - - ROUTE_ADD - { - @Override - public int getTitle() - { - return R.string.placepage_add_stop; - } - - @Override - public int getIcon() - { - return R.drawable.ic_route_via; - } - - @NonNull - @Override - public ButtonType getType() - { - return ButtonType.ROUTE_ADD; - } - }, - - ROUTE_REMOVE - { - @Override - public int getTitle() - { - return R.string.placepage_remove_stop; - } - - @Override - public int getIcon() - { - return R.drawable.ic_route_remove; - } - - @NonNull - @Override - public ButtonType getType() - { - return ButtonType.ROUTE_REMOVE; - } - }, - - SHARE - { - @Override - public int getTitle() - { - return R.string.share; - } - - @Override - public int getIcon() - { - return R.drawable.ic_share; - } - - @NonNull - @Override - public ButtonType getType() - { - return ButtonType.SHARE; - } - }, + SHARE(R.string.share, R.drawable.ic_share, ButtonType.SHARE), // Must not be used outside - MORE - { - @Override - public int getTitle() - { - return R.string.placepage_more_button; - } + MORE(R.string.placepage_more_button, R.drawable.bs_ic_more, ButtonType.MORE), - @Override - public int getIcon() - { - return R.drawable.bs_ic_more; - } - - @NonNull - @Override - public ButtonType getType() - { - return ButtonType.MORE; - } - }, - - CALL - { - @Override - public int getTitle() - { - return R.string.placepage_call_button; - } - - @Override - public int getIcon() - { - return R.drawable.ic_place_page_phone; - } - - @NonNull - @Override - public ButtonType getType() - { - return ButtonType.CALL; - } - }; + CALL(R.string.placepage_call_button, R.drawable.ic_place_page_phone, ButtonType.CALL); @StringRes + private final int mTitleId; + + @DrawableRes + private final int mIconId; + + @NonNull + private final ButtonType mButtonType; + + Item(@StringRes int titleId, @DrawableRes int iconId, @NonNull ButtonType buttonType) + { + mTitleId = titleId; + mIconId = iconId; + mButtonType = buttonType; + } + + @StringRes + @Override public int getTitle() { - throw new UnsupportedOperationException("Not supported!"); + return mTitleId; } @DrawableRes + @Override public int getIcon() + { + return mIconId; + } + + @NonNull + @Override + public ButtonType getType() + { + return mButtonType; + } + + @DrawableRes + @Override + public int getBackgroundResource() { throw new UnsupportedOperationException("Not supported!"); } diff --git a/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java b/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java index ed24e5bb36..540500b7df 100644 --- a/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java +++ b/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java @@ -456,27 +456,25 @@ public class PlacePageView extends RelativeLayout switch (item.getType()) { case BOOKING: - frame.setBackgroundResource(R.drawable.button_booking); - color = Color.WHITE; - break; - case BOOKING_SEARCH: - frame.setBackgroundResource(R.drawable.button_booking); - color = Color.WHITE; - break; - case OPENTABLE: - frame.setBackgroundResource(R.drawable.button_opentable); - color = Color.WHITE; - break; - case PARTNER1: - frame.setBackgroundResource(R.drawable.button_partner1); - color = Color.BLACK; - break; - case PARTNER3: - frame.setBackgroundResource(R.drawable.button_partner3); + case PARTNER4: + case PARTNER5: + case PARTNER6: + case PARTNER7: + case PARTNER8: + case PARTNER9: + case PARTNER10: + case PARTNER11: + case PARTNER12: + case PARTNER13: + case PARTNER14: + case PARTNER15: + case PARTNER16: + case PARTNER17: + frame.setBackgroundResource(item.getBackgroundResource()); color = Color.WHITE; break; @@ -583,6 +581,20 @@ public class PlacePageView extends RelativeLayout case OPENTABLE: case PARTNER1: case PARTNER3: + case PARTNER4: + case PARTNER5: + case PARTNER6: + case PARTNER7: + case PARTNER8: + case PARTNER9: + case PARTNER10: + case PARTNER11: + case PARTNER12: + case PARTNER13: + case PARTNER14: + case PARTNER15: + case PARTNER16: + case PARTNER17: onSponsoredClick(true /* book */, false); break; diff --git a/iphone/Maps/Categories/UIColor+MapsMeColor.h b/iphone/Maps/Categories/UIColor+MapsMeColor.h index 6f3ef9a4b5..c7d5ff8b9d 100644 --- a/iphone/Maps/Categories/UIColor+MapsMeColor.h +++ b/iphone/Maps/Categories/UIColor+MapsMeColor.h @@ -48,6 +48,34 @@ + (UIColor *)partner1TextColor; + (UIColor *)partner3Background; + (UIColor *)partner3TextColor; ++ (UIColor *)partner4Background; ++ (UIColor *)partner4TextColor; ++ (UIColor *)partner5Background; ++ (UIColor *)partner5TextColor; ++ (UIColor *)partner6Background; ++ (UIColor *)partner6TextColor; ++ (UIColor *)partner7Background; ++ (UIColor *)partner7TextColor; ++ (UIColor *)partner8Background; ++ (UIColor *)partner8TextColor; ++ (UIColor *)partner9Background; ++ (UIColor *)partner9TextColor; ++ (UIColor *)partner10Background; ++ (UIColor *)partner10TextColor; ++ (UIColor *)partner11Background; ++ (UIColor *)partner11TextColor; ++ (UIColor *)partner12Background; ++ (UIColor *)partner12TextColor; ++ (UIColor *)partner13Background; ++ (UIColor *)partner13TextColor; ++ (UIColor *)partner14Background; ++ (UIColor *)partner14TextColor; ++ (UIColor *)partner15Background; ++ (UIColor *)partner15TextColor; ++ (UIColor *)partner16Background; ++ (UIColor *)partner16TextColor; ++ (UIColor *)partner17Background; ++ (UIColor *)partner17TextColor; + (UIColor *)colorWithName:(NSString *)colorName; diff --git a/iphone/Maps/Categories/UIColor+MapsMeColor.mm b/iphone/Maps/Categories/UIColor+MapsMeColor.mm index da583a796f..b946ad69f1 100644 --- a/iphone/Maps/Categories/UIColor+MapsMeColor.mm +++ b/iphone/Maps/Categories/UIColor+MapsMeColor.mm @@ -355,7 +355,147 @@ UIColor * color(SEL cmd) + (UIColor *)partner3TextColor { - return [UIColor colorWithRed:scaled(255) green:scaled(255) blue:scaled(255) alpha:alpha100]; + return UIColor.whiteColor; +} + ++ (UIColor *)partner4Background +{ + return UIColor.blackColor; +} + ++ (UIColor *)partner4TextColor +{ + return UIColor.whiteColor; +} + ++ (UIColor *)partner5Background +{ + return [UIColor colorWithRed:scaled(0) green:scaled(115) blue:scaled(210) alpha:alpha100]; +} + ++ (UIColor *)partner5TextColor +{ + return UIColor.whiteColor; +} + ++ (UIColor *)partner6Background +{ + return [UIColor colorWithRed:scaled(0) green:scaled(92) blue:scaled(185) alpha:alpha100]; +} + ++ (UIColor *)partner6TextColor +{ + return UIColor.whiteColor; +} + ++ (UIColor *)partner7Background +{ + return [UIColor colorWithRed:scaled(226) green:scaled(67) blue:scaled(7) alpha:alpha100]; +} + ++ (UIColor *)partner7TextColor +{ + return UIColor.whiteColor; +} + ++ (UIColor *)partner8Background +{ + return [UIColor colorWithRed:scaled(141) green:scaled(27) blue:scaled(47) alpha:alpha100]; +} + ++ (UIColor *)partner8TextColor +{ + return UIColor.whiteColor; +} + ++ (UIColor *)partner9Background +{ + return [UIColor colorWithRed:scaled(220) green:scaled(0) blue:scaled(57) alpha:alpha100]; +} + ++ (UIColor *)partner9TextColor +{ + return UIColor.whiteColor; +} + ++ (UIColor *)partner10Background +{ + return [UIColor colorWithRed:scaled(2) green:scaled(81) blue:scaled(152) alpha:alpha100]; +} + ++ (UIColor *)partner10TextColor +{ + return UIColor.whiteColor; +} + ++ (UIColor *)partner11Background +{ + return [UIColor colorWithRed:scaled(165) green:scaled(3) blue:scaled(0) alpha:alpha100]; +} + ++ (UIColor *)partner11TextColor +{ + return UIColor.whiteColor; +} + ++ (UIColor *)partner12Background +{ + return [UIColor colorWithRed:scaled(126) green:scaled(189) blue:scaled(50) alpha:alpha100]; +} + ++ (UIColor *)partner12TextColor +{ + return UIColor.whiteColor; +} + ++ (UIColor *)partner13Background +{ + return [UIColor colorWithRed:scaled(55) green:scaled(37) blue:scaled(43) alpha:alpha100]; +} + ++ (UIColor *)partner13TextColor +{ + return UIColor.whiteColor; +} + ++ (UIColor *)partner14Background +{ + return UIColor.blackColor; +} + ++ (UIColor *)partner14TextColor +{ + return UIColor.whiteColor; +} + ++ (UIColor *)partner15Background +{ + return UIColor.blackColor; +} + ++ (UIColor *)partner15TextColor +{ + return UIColor.whiteColor; +} + ++ (UIColor *)partner16Background +{ + return UIColor.blackColor; +} + ++ (UIColor *)partner16TextColor +{ + return UIColor.whiteColor; +} + ++ (UIColor *)partner17Background +{ + return UIColor.blackColor; +} + ++ (UIColor *)partner17TextColor +{ + return UIColor.whiteColor; } + (UIColor *)bannerBackground diff --git a/map/framework.cpp b/map/framework.cpp index 645c88aa98..c7ebf0e1f4 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -853,9 +853,12 @@ void Framework::FillInfoFromFeatureType(FeatureType const & ft, place_page::Info info.SetSponsoredType(place_page::SponsoredType::Partner); auto const partnerIndex = PartnerChecker::Instance().GetPartnerIndex(ft); info.SetPartnerIndex(partnerIndex); - if (GetPartnerByIndex(partnerIndex).m_hasButton) + auto const & partnerInfo = GetPartnerByIndex(partnerIndex); + if (partnerInfo.m_hasButton) { - auto const & url = info.GetMetadata().Get(feature::Metadata::FMD_BANNER_URL); + auto url = info.GetMetadata().Get(feature::Metadata::FMD_BANNER_URL); + if (url.empty()) + url = partnerInfo.m_defaultBannerUrl; info.SetSponsoredUrl(url); info.SetSponsoredDescriptionUrl(url); } diff --git a/partners_api/partners.cpp b/partners_api/partners.cpp index a252805ff8..db5bc1b1d8 100644 --- a/partners_api/partners.cpp +++ b/partners_api/partners.cpp @@ -13,9 +13,25 @@ #include std::vector const kPartners = { - PartnerInfo(2, "LuggageHero"), - - PartnerInfo(3, "BurgerKing", true /* m_hasButton */) + PartnerInfo(2, "LuggageHero"), + PartnerInfo(3, "BurgerKing", true /* m_hasButton */), + PartnerInfo(4, "Adidas", true /* m_hasButton */), + PartnerInfo(6, "AdidasOriginal", true /* m_hasButton */), + PartnerInfo(7, "AdidasKids", true /* m_hasButton */), + PartnerInfo(8, "CostaCoffee", true /* m_hasButton */, + "https://localads.maps.me/redirects/costa_coffee"), + PartnerInfo(9, "TGIFridays", true /* m_hasButton */, + "https://localads.maps.me/redirects/tgi_fridays"), + PartnerInfo(10, "Sportmaster", true /* m_hasButton */, + "https://localads.maps.me/redirects/sportmaster"), + PartnerInfo(11, "KFC", true /* m_hasButton */), + PartnerInfo(12, "AzbukaVkusa", true /* m_hasButton */, + "https://localads.maps.me/redirects/azbuka_vkusa"), + PartnerInfo(13, "Shokoladnitsa", true /* m_hasButton */), + PartnerInfo(14, "Yakitoriya", true /* m_hasButton */), + PartnerInfo(15, "Menza", true /* m_hasButton */), + PartnerInfo(16, "YanPrimus", true /* m_hasButton */), + PartnerInfo(17, "GinNo", true /* m_hasButton */), }; namespace @@ -25,21 +41,29 @@ PartnerInfo const kFakePartner(kFakePartnerIndex, {}); } // namespace PartnerInfo::PartnerInfo(int partnerIndex, std::string && name, bool hasButton, - std::string && iosBannerPlacementId, std::string && androidBannerPlacementId) + std::string && defaultBannerUrl, + std::string && iosBannerPlacementId, + std::string && androidBannerPlacementId) : m_partnerIndex(partnerIndex) , m_type("partner" + strings::to_string(partnerIndex)) , m_name(std::move(name)) , m_hasButton(hasButton) + , m_defaultBannerUrl(std::move(defaultBannerUrl)) , m_iosBannerPlacementId(std::move(iosBannerPlacementId)) , m_androidBannerPlacementId(std::move(androidBannerPlacementId)) {} +PartnerInfo::PartnerInfo(int partnerIndex, std::string && name, bool hasButton, + std::string && defaultBannerUrl) + : PartnerInfo(partnerIndex, std::move(name), hasButton, std::move(defaultBannerUrl), {}, {}) +{} + PartnerInfo::PartnerInfo(int partnerIndex, std::string && name, bool hasButton) - : PartnerInfo(partnerIndex, std::move(name), hasButton, {}, {}) + : PartnerInfo(partnerIndex, std::move(name), hasButton, {}, {}, {}) {} PartnerInfo::PartnerInfo(int partnerIndex, std::string && name) - : PartnerInfo(partnerIndex, std::move(name), false /* hasButton */) + : PartnerInfo(partnerIndex, std::move(name), false /* hasButton */, {}) {} std::string const & PartnerInfo::GetBannerPlacementId() const diff --git a/partners_api/partners.hpp b/partners_api/partners.hpp index a0c367e0b6..16fbc7e37f 100644 --- a/partners_api/partners.hpp +++ b/partners_api/partners.hpp @@ -10,11 +10,17 @@ struct PartnerInfo std::string const m_type; std::string const m_name; bool const m_hasButton = false; + std::string const m_defaultBannerUrl; std::string const m_iosBannerPlacementId; std::string const m_androidBannerPlacementId; PartnerInfo(int partnerIndex, std::string && name, bool hasButton, - std::string && iosBannerPlacementId, std::string && androidBannerPlacementId); + std::string && defaultBannerUrl, + std::string && iosBannerPlacementId, + std::string && androidBannerPlacementId); + + PartnerInfo(int partnerIndex, std::string && name, bool hasButton, + std::string && defaultBannerUrl); PartnerInfo(int partnerIndex, std::string && name, bool hasButton);