diff --git a/android/jni/com/mapswithme/maps/Framework.cpp b/android/jni/com/mapswithme/maps/Framework.cpp index 87b2bb1b4e..9e2a5f4d33 100644 --- a/android/jni/com/mapswithme/maps/Framework.cpp +++ b/android/jni/com/mapswithme/maps/Framework.cpp @@ -9,6 +9,9 @@ #include "map/chart_generator.hpp" #include "map/user_mark.hpp" +#include "partners_api/ads_engine.hpp" +#include "partners_api/banner.hpp" + #include "search/everywhere_search_params.hpp" #include "storage/storage_helpers.hpp" @@ -1473,4 +1476,10 @@ Java_com_mapswithme_maps_Framework_nativeDeleteSavedRoutePoints() { frm()->GetRoutingManager().DeleteSavedRoutePoints(); } + +JNIEXPORT jobjectArray JNICALL +Java_com_mapswithme_maps_Framework_nativeGetSearchBanners(JNIEnv * env, jclass) +{ + return usermark_helper::ToBannersArray(env, frm()->GetAdsEngine().GetSearchBanners()); +} } // extern "C" diff --git a/android/src/com/mapswithme/maps/Framework.java b/android/src/com/mapswithme/maps/Framework.java index 2c22ab96f9..b9856cf1d0 100644 --- a/android/src/com/mapswithme/maps/Framework.java +++ b/android/src/com/mapswithme/maps/Framework.java @@ -8,6 +8,7 @@ import android.support.annotation.Nullable; import android.support.annotation.Size; import android.support.annotation.UiThread; +import com.mapswithme.maps.ads.Banner; import com.mapswithme.maps.ads.LocalAdInfo; import com.mapswithme.maps.api.ParsedRoutingData; import com.mapswithme.maps.api.ParsedSearchRequest; @@ -367,4 +368,6 @@ public class Framework public static native boolean nativeLoadRoutePoints(); public static native void nativeSaveRoutePoints(); public static native void nativeDeleteSavedRoutePoints(); + + public static native Banner[] nativeGetSearchBanners(); } diff --git a/android/src/com/mapswithme/maps/ads/GoogleSearchAd.java b/android/src/com/mapswithme/maps/ads/GoogleSearchAd.java new file mode 100644 index 0000000000..10e7b2d4ad --- /dev/null +++ b/android/src/com/mapswithme/maps/ads/GoogleSearchAd.java @@ -0,0 +1,26 @@ +package com.mapswithme.maps.ads; + +import com.mapswithme.maps.Framework; + +public class GoogleSearchAd +{ + private String mAdUnitId = ""; + + public GoogleSearchAd() + { + Banner[] banners = Framework.nativeGetSearchBanners(); + if (banners == null) + return; + + for (Banner b : banners) + { + if (b.getProvider().equals(Providers.GOOGLE)) + { + mAdUnitId = b.getId(); + break; + } + } + } + + String getAdUnitId() { return mAdUnitId; } +}