forked from organicmaps/organicmaps
[core] google banners in search
This commit is contained in:
parent
5aee1eec68
commit
da2cf12f8e
21 changed files with 103 additions and 25 deletions
|
@ -14,9 +14,10 @@ public final class Banner implements Parcelable
|
|||
private static final int TYPE_FACEBOOK = 1;
|
||||
private static final int TYPE_RB = 2;
|
||||
private static final int TYPE_MOPUB = 3;
|
||||
private static final int TYPE_GOOGLE = 4;
|
||||
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
@IntDef({ TYPE_NONE, TYPE_FACEBOOK, TYPE_RB, TYPE_MOPUB })
|
||||
@IntDef({ TYPE_NONE, TYPE_FACEBOOK, TYPE_RB, TYPE_MOPUB, TYPE_GOOGLE })
|
||||
|
||||
public @interface BannerType {}
|
||||
|
||||
|
@ -68,6 +69,8 @@ public final class Banner implements Parcelable
|
|||
return Providers.MY_TARGET;
|
||||
case TYPE_MOPUB:
|
||||
return Providers.MOPUB;
|
||||
case TYPE_GOOGLE:
|
||||
return Providers.GOOGLE;
|
||||
default:
|
||||
throw new AssertionError("Unsupported banner type: " + mType);
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ class FacebookAdsLoader extends CachingNativeAdLoader implements AdListener
|
|||
private static final String TAG = FacebookAdsLoader.class.getSimpleName();
|
||||
|
||||
FacebookAdsLoader(@Nullable OnAdCacheModifiedListener cacheListener,
|
||||
@Nullable AdTracker tracker)
|
||||
@Nullable AdTracker tracker)
|
||||
{
|
||||
super(tracker, cacheListener);
|
||||
}
|
||||
|
|
|
@ -7,8 +7,8 @@ public class Factory
|
|||
{
|
||||
@NonNull
|
||||
static NativeAdLoader createLoaderForBanner(@NonNull Banner banner,
|
||||
@Nullable OnAdCacheModifiedListener cacheListener,
|
||||
@Nullable AdTracker tracker)
|
||||
@Nullable OnAdCacheModifiedListener cacheListener,
|
||||
@Nullable AdTracker tracker)
|
||||
{
|
||||
String provider = banner.getProvider();
|
||||
switch (provider)
|
||||
|
@ -19,6 +19,8 @@ public class Factory
|
|||
return new MyTargetAdsLoader(cacheListener, tracker);
|
||||
case Providers.MOPUB:
|
||||
return new MopubNativeDownloader(cacheListener, tracker);
|
||||
case Providers.GOOGLE:
|
||||
throw new AssertionError("Not implemented yet");
|
||||
default:
|
||||
throw new AssertionError("Unknown ads provider: " + provider);
|
||||
}
|
||||
|
|
|
@ -6,4 +6,5 @@ class Providers
|
|||
static final String FACEBOOK = "FB";
|
||||
static final String MY_TARGET = "MY_TARGET";
|
||||
static final String MOPUB = "MOPUB";
|
||||
static final String GOOGLE = "GOOGLE";
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ enum BannerType {
|
|||
case facebook(String)
|
||||
case rb(String)
|
||||
case mopub(String)
|
||||
case google(String)
|
||||
|
||||
var banner: Banner? {
|
||||
switch self {
|
||||
|
@ -10,6 +11,7 @@ enum BannerType {
|
|||
case .facebook(let id): return FacebookBanner(bannerID: id)
|
||||
case .rb(let id): return RBBanner(bannerID: id)
|
||||
case .mopub(let id): return MopubBanner(bannerID: id)
|
||||
case .google: return nil
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,6 +21,7 @@ enum BannerType {
|
|||
case .facebook: return .facebook
|
||||
case .rb: return .rb
|
||||
case .mopub: return .mopub
|
||||
case .google: return .google
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -28,6 +31,7 @@ enum BannerType {
|
|||
case .facebook: self = .facebook(id)
|
||||
case .rb: self = .rb(id)
|
||||
case .mopub: self = .mopub(id)
|
||||
case .google: self = .google(id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -39,10 +43,12 @@ extension BannerType: Equatable {
|
|||
case let (.facebook(l), .facebook(r)): return l == r
|
||||
case let (.rb(l), .rb(r)): return l == r
|
||||
case let (.mopub(l), .mopub(r)): return l == r
|
||||
case let (.google(l), .google(r)): return l == r
|
||||
case (.none, _),
|
||||
(.facebook, _),
|
||||
(.rb, _),
|
||||
(.mopub, _): return false
|
||||
(.mopub, _),
|
||||
(.google, _): return false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -54,6 +60,7 @@ extension BannerType: Hashable {
|
|||
case .facebook(let id): return mwmType.hashValue ^ id.hashValue
|
||||
case .rb(let id): return mwmType.hashValue ^ id.hashValue
|
||||
case .mopub(let id): return mwmType.hashValue ^ id.hashValue
|
||||
case .google(let id): return mwmType.hashValue ^ id.hashValue
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,8 @@ typedef NS_ENUM(NSInteger, MWMBannerType) {
|
|||
MWMBannerTypeNone,
|
||||
MWMBannerTypeFacebook,
|
||||
MWMBannerTypeRb,
|
||||
MWMBannerTypeMopub
|
||||
MWMBannerTypeMopub,
|
||||
MWMBannerTypeGoogle
|
||||
};
|
||||
|
||||
@protocol MWMBanner
|
||||
|
|
|
@ -15,6 +15,7 @@ static inline MWMBannerType MatchBannerType(ads::Banner::Type coreType)
|
|||
case ads::Banner::Type::Facebook: return MWMBannerTypeFacebook;
|
||||
case ads::Banner::Type::RB: return MWMBannerTypeRb;
|
||||
case ads::Banner::Type::Mopub: return MWMBannerTypeMopub;
|
||||
case ads::Banner::Type::Google: return MWMBannerTypeGoogle;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -105,6 +105,8 @@ final class AdBanner: UITableViewCell {
|
|||
configRBBanner(ad: ad as! MTRGNativeAd)
|
||||
case .mopub:
|
||||
configMopubBanner(ad: ad as! MopubBanner)
|
||||
case .google:
|
||||
assert(false)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,8 @@ set(
|
|||
cian_api.hpp
|
||||
facebook_ads.cpp
|
||||
facebook_ads.hpp
|
||||
google_ads.cpp
|
||||
google_ads.hpp
|
||||
mopub_ads.cpp
|
||||
mopub_ads.hpp
|
||||
opentable_api.cpp
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "partners_api/ads_engine.hpp"
|
||||
#include "partners_api/facebook_ads.hpp"
|
||||
#include "partners_api/google_ads.hpp"
|
||||
#include "partners_api/mopub_ads.hpp"
|
||||
#include "partners_api/rb_ads.hpp"
|
||||
|
||||
|
@ -17,7 +18,7 @@ Engine::Engine()
|
|||
m_banners.emplace_back(Banner::Type::RB, my::make_unique<Rb>());
|
||||
m_banners.emplace_back(Banner::Type::Mopub, my::make_unique<Mopub>());
|
||||
|
||||
m_searchBanners.emplace_back(Banner::Type::Facebook, my::make_unique<Facebook>());
|
||||
m_searchBanners.emplace_back(Banner::Type::Google, my::make_unique<Google>());
|
||||
}
|
||||
|
||||
bool Engine::HasBanner(feature::TypesHolder const & types,
|
||||
|
|
|
@ -11,7 +11,8 @@ struct Banner
|
|||
None = 0,
|
||||
Facebook = 1,
|
||||
RB = 2,
|
||||
Mopub = 3
|
||||
Mopub = 3,
|
||||
Google = 4
|
||||
};
|
||||
|
||||
Banner() = default;
|
||||
|
@ -29,6 +30,7 @@ inline std::string DebugPrint(Banner::Type type)
|
|||
case Banner::Type::Facebook: return "Facebook";
|
||||
case Banner::Type::RB: return "RB";
|
||||
case Banner::Type::Mopub: return "Mopub";
|
||||
case Banner::Type::Google: return "Google";
|
||||
}
|
||||
}
|
||||
} // namespace ads
|
||||
|
|
|
@ -4,10 +4,8 @@ namespace
|
|||
{
|
||||
#if defined(OMIM_OS_IPHONE)
|
||||
auto const kSingleBannerIdForAllTypes = "185237551520383_1450324925011633";
|
||||
auto const kSearchbannerId = "185237551520383_1453784847998974";
|
||||
#else
|
||||
auto const kSingleBannerIdForAllTypes = "185237551520383_1450325641678228";
|
||||
auto const kSearchbannerId = "185237551520383_1384653791578747";
|
||||
#endif
|
||||
} // namespace
|
||||
|
||||
|
@ -17,14 +15,4 @@ std::string Facebook::GetBannerIdForOtherTypes() const
|
|||
{
|
||||
return kSingleBannerIdForAllTypes;
|
||||
}
|
||||
|
||||
bool Facebook::HasSearchBanner() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string Facebook::GetSearchBannerId() const
|
||||
{
|
||||
return kSearchbannerId;
|
||||
}
|
||||
} // namespace ads
|
||||
|
|
|
@ -12,7 +12,5 @@ public:
|
|||
|
||||
// ContainerBase overrides:
|
||||
std::string GetBannerIdForOtherTypes() const override;
|
||||
bool HasSearchBanner() const override;
|
||||
std::string GetSearchBannerId() const override;
|
||||
};
|
||||
} // namespace ads
|
||||
|
|
23
partners_api/google_ads.cpp
Normal file
23
partners_api/google_ads.cpp
Normal file
|
@ -0,0 +1,23 @@
|
|||
#include "partners_api/google_ads.hpp"
|
||||
|
||||
namespace
|
||||
{
|
||||
#if defined(OMIM_OS_IPHONE)
|
||||
auto const kSearchbannerId = "mobile-app-mapsme";
|
||||
#else
|
||||
auto const kSearchbannerId = "mobile-app-mapsme";
|
||||
#endif
|
||||
} // namespace
|
||||
|
||||
namespace ads
|
||||
{
|
||||
bool Google::HasSearchBanner() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string Google::GetSearchBannerId() const
|
||||
{
|
||||
return kSearchbannerId;
|
||||
}
|
||||
} // namespace ads
|
15
partners_api/google_ads.hpp
Normal file
15
partners_api/google_ads.hpp
Normal file
|
@ -0,0 +1,15 @@
|
|||
#pragma once
|
||||
|
||||
#include "partners_api/ads_base.hpp"
|
||||
|
||||
namespace ads
|
||||
{
|
||||
// Class which matches feature types and facebook banner ids.
|
||||
class Google : public Container
|
||||
{
|
||||
public:
|
||||
// ContainerBase overrides:
|
||||
bool HasSearchBanner() const override;
|
||||
std::string GetSearchBannerId() const override;
|
||||
};
|
||||
} // namespace ads
|
|
@ -14,6 +14,7 @@ SOURCES += \
|
|||
booking_api.cpp \
|
||||
cian_api.cpp \
|
||||
facebook_ads.cpp \
|
||||
google_ads.cpp \
|
||||
mopub_ads.cpp \
|
||||
opentable_api.cpp \
|
||||
rb_ads.cpp \
|
||||
|
@ -31,6 +32,7 @@ HEADERS += \
|
|||
booking_api.hpp \
|
||||
cian_api.hpp \
|
||||
facebook_ads.hpp \
|
||||
google_ads.hpp \
|
||||
mopub_ads.hpp \
|
||||
opentable_api.hpp \
|
||||
rb_ads.hpp \
|
||||
|
|
|
@ -8,6 +8,7 @@ set(
|
|||
booking_tests.cpp
|
||||
cian_tests.cpp
|
||||
facebook_tests.cpp
|
||||
google_tests.cpp
|
||||
mopub_tests.cpp
|
||||
rb_tests.cpp
|
||||
taxi_engine_tests.cpp
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include "partners_api/ads_engine.hpp"
|
||||
#include "partners_api/facebook_ads.hpp"
|
||||
#include "partners_api/google_ads.hpp"
|
||||
#include "partners_api/mopub_ads.hpp"
|
||||
#include "partners_api/rb_ads.hpp"
|
||||
|
||||
|
@ -135,13 +136,13 @@ UNIT_TEST(AdsEngine_Smoke)
|
|||
auto result = engine.GetBanners(holder, {"Russian Federation"}, "ru");
|
||||
TEST(result.empty(), ());
|
||||
}
|
||||
ads::Facebook facebook;
|
||||
ads::Google google;
|
||||
{
|
||||
TEST(engine.HasSearchBanner(), ());
|
||||
auto result = engine.GetSearchBanners();
|
||||
TEST_EQUAL(result.size(), 1, ());
|
||||
TEST_EQUAL(result[0].m_type, ads::Banner::Type::Facebook, ());
|
||||
TEST_EQUAL(result[0].m_bannerId, facebook.GetSearchBannerId(), ());
|
||||
TEST_EQUAL(result[0].m_type, ads::Banner::Type::Google, ());
|
||||
TEST_EQUAL(result[0].m_bannerId, google.GetSearchBannerId(), ());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
11
partners_api/partners_api_tests/google_tests.cpp
Normal file
11
partners_api/partners_api_tests/google_tests.cpp
Normal file
|
@ -0,0 +1,11 @@
|
|||
#include "testing/testing.hpp"
|
||||
|
||||
#include "partners_api/google_ads.hpp"
|
||||
|
||||
UNIT_TEST(Google_BannerInSearch)
|
||||
{
|
||||
ads::Google google;
|
||||
TEST(google.HasSearchBanner(), ());
|
||||
auto result = google.GetSearchBannerId();
|
||||
TEST_EQUAL(result, "dummy", ());
|
||||
}
|
|
@ -30,6 +30,7 @@ SOURCES += \
|
|||
booking_tests.cpp \
|
||||
cian_tests.cpp \
|
||||
facebook_tests.cpp \
|
||||
google_tests.cpp \
|
||||
mopub_tests.cpp \
|
||||
rb_tests.cpp \
|
||||
taxi_engine_tests.cpp \
|
||||
|
|
|
@ -29,6 +29,10 @@
|
|||
3D47B2AF1F14BE94000828D2 /* cian_tests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3D47B2AE1F14BE94000828D2 /* cian_tests.cpp */; };
|
||||
3D47B2B11F14FA14000828D2 /* utils.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 3D47B2B01F14FA14000828D2 /* utils.hpp */; };
|
||||
3D7815761F3A14910068B6AC /* async_gui_thread.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 3D7815751F3A14910068B6AC /* async_gui_thread.hpp */; };
|
||||
3D452AEF1EE6D202009EAB9B /* google_tests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3D452AED1EE6D202009EAB9B /* google_tests.cpp */; };
|
||||
3D452AF01EE6D202009EAB9B /* mopub_tests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3D452AEE1EE6D202009EAB9B /* mopub_tests.cpp */; };
|
||||
3D452AF31EE6D20D009EAB9B /* google_ads.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3D452AF11EE6D20D009EAB9B /* google_ads.cpp */; };
|
||||
3D452AF41EE6D20D009EAB9B /* google_ads.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 3D452AF21EE6D20D009EAB9B /* google_ads.hpp */; };
|
||||
3DBC1C541E4B14920016897F /* facebook_ads.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3DBC1C521E4B14920016897F /* facebook_ads.cpp */; };
|
||||
3DBC1C551E4B14920016897F /* facebook_ads.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 3DBC1C531E4B14920016897F /* facebook_ads.hpp */; };
|
||||
3DFEBF851EF82BEA00317D5C /* viator_api.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3DFEBF831EF82BEA00317D5C /* viator_api.cpp */; };
|
||||
|
@ -85,6 +89,10 @@
|
|||
3D47B2AE1F14BE94000828D2 /* cian_tests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cian_tests.cpp; sourceTree = "<group>"; };
|
||||
3D47B2B01F14FA14000828D2 /* utils.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = utils.hpp; sourceTree = "<group>"; };
|
||||
3D7815751F3A14910068B6AC /* async_gui_thread.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = async_gui_thread.hpp; sourceTree = "<group>"; };
|
||||
3D452AED1EE6D202009EAB9B /* google_tests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = google_tests.cpp; sourceTree = "<group>"; };
|
||||
3D452AEE1EE6D202009EAB9B /* mopub_tests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = mopub_tests.cpp; sourceTree = "<group>"; };
|
||||
3D452AF11EE6D20D009EAB9B /* google_ads.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = google_ads.cpp; sourceTree = "<group>"; };
|
||||
3D452AF21EE6D20D009EAB9B /* google_ads.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = google_ads.hpp; sourceTree = "<group>"; };
|
||||
3DBC1C501E4B14810016897F /* facebook_tests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = facebook_tests.cpp; sourceTree = "<group>"; };
|
||||
3DBC1C521E4B14920016897F /* facebook_ads.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = facebook_ads.cpp; sourceTree = "<group>"; };
|
||||
3DBC1C531E4B14920016897F /* facebook_ads.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = facebook_ads.hpp; sourceTree = "<group>"; };
|
||||
|
@ -185,6 +193,8 @@
|
|||
3DFEBF971EFBFC1500317D5C /* taxi_provider.hpp */,
|
||||
3DFEBF981EFBFC1500317D5C /* yandex_api.cpp */,
|
||||
3DFEBF991EFBFC1500317D5C /* yandex_api.hpp */,
|
||||
3D452AF11EE6D20D009EAB9B /* google_ads.cpp */,
|
||||
3D452AF21EE6D20D009EAB9B /* google_ads.hpp */,
|
||||
3430643A1E9FBCF500DC7665 /* mopub_ads.cpp */,
|
||||
3430643B1E9FBCF500DC7665 /* mopub_ads.hpp */,
|
||||
346E888F1E9D087400D4CE9B /* ads_base.cpp */,
|
||||
|
@ -216,6 +226,8 @@
|
|||
3DFEBF871EF82C1300317D5C /* viator_tests.cpp */,
|
||||
3DFEBFA01EFBFC2300317D5C /* taxi_engine_tests.cpp */,
|
||||
3DFEBFA11EFBFC2300317D5C /* yandex_tests.cpp */,
|
||||
3D452AED1EE6D202009EAB9B /* google_tests.cpp */,
|
||||
3D452AEE1EE6D202009EAB9B /* mopub_tests.cpp */,
|
||||
346E889D1E9D088200D4CE9B /* ads_engine_tests.cpp */,
|
||||
346E889E1E9D088200D4CE9B /* rb_tests.cpp */,
|
||||
3DBC1C501E4B14810016897F /* facebook_tests.cpp */,
|
||||
|
@ -261,6 +273,7 @@
|
|||
3D47B29D1F054C89000828D2 /* taxi_places.hpp in Headers */,
|
||||
3D7815761F3A14910068B6AC /* async_gui_thread.hpp in Headers */,
|
||||
F67E75261DB8F06F00D6741F /* opentable_api.hpp in Headers */,
|
||||
3D452AF41EE6D20D009EAB9B /* google_ads.hpp in Headers */,
|
||||
F6B536411DA520E40067EEA5 /* booking_api.hpp in Headers */,
|
||||
3430643D1E9FBCF500DC7665 /* mopub_ads.hpp in Headers */,
|
||||
3D47B2B11F14FA14000828D2 /* utils.hpp in Headers */,
|
||||
|
@ -369,6 +382,8 @@
|
|||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
3DFEBFA41EFBFC2300317D5C /* yandex_tests.cpp in Sources */,
|
||||
3D452AEF1EE6D202009EAB9B /* google_tests.cpp in Sources */,
|
||||
3D452AF01EE6D202009EAB9B /* mopub_tests.cpp in Sources */,
|
||||
3430643C1E9FBCF500DC7665 /* mopub_ads.cpp in Sources */,
|
||||
346E88961E9D087400D4CE9B /* ads_base.cpp in Sources */,
|
||||
3DFEBF891EF82C1300317D5C /* viator_tests.cpp in Sources */,
|
||||
|
@ -379,6 +394,7 @@
|
|||
346E889B1E9D087400D4CE9B /* rb_ads.cpp in Sources */,
|
||||
3DBC1C541E4B14920016897F /* facebook_ads.cpp in Sources */,
|
||||
3D47B2AF1F14BE94000828D2 /* cian_tests.cpp in Sources */,
|
||||
3D452AF31EE6D20D009EAB9B /* google_ads.cpp in Sources */,
|
||||
346E88981E9D087400D4CE9B /* ads_engine.cpp in Sources */,
|
||||
3D47B29B1F054C89000828D2 /* taxi_countries.cpp in Sources */,
|
||||
F67E75251DB8F06F00D6741F /* opentable_api.cpp in Sources */,
|
||||
|
|
Loading…
Add table
Reference in a new issue