From 0d9302e7b1be470735655337f0183ad04c55b6ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9A=D1=83=D0=B7=D0=BD=D0=B5=D1=86=D0=BE=D0=B2=D0=B0=20?= =?UTF-8?q?=D0=9A=D1=81=D0=B5=D0=BD=D0=B8=D1=8F?= Date: Sat, 19 Aug 2017 11:47:21 +0300 Subject: [PATCH] [Android] Extracted search banner info from JNI --- android/jni/com/mapswithme/maps/Framework.cpp | 9 +++++++ .../src/com/mapswithme/maps/Framework.java | 3 +++ .../mapswithme/maps/ads/GoogleSearchAd.java | 26 +++++++++++++++++++ 3 files changed, 38 insertions(+) create mode 100644 android/src/com/mapswithme/maps/ads/GoogleSearchAd.java 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; } +}