forked from organicmaps/organicmaps
[android] Added passing user lang as key word in Mopub request
This commit is contained in:
parent
8906f0b7c9
commit
9d30ce501b
4 changed files with 21 additions and 1 deletions
|
@ -81,6 +81,7 @@ set(
|
|||
com/mapswithme/platform/SocketImpl.cpp
|
||||
com/mapswithme/util/Config.cpp
|
||||
com/mapswithme/util/HttpClient.cpp
|
||||
com/mapswithme/util/Language.cpp
|
||||
com/mapswithme/util/LoggerFactory.cpp
|
||||
com/mapswithme/util/NetworkPolicy.cpp
|
||||
com/mapswithme/util/StringUtils.cpp
|
||||
|
|
12
android/jni/com/mapswithme/util/Language.cpp
Normal file
12
android/jni/com/mapswithme/util/Language.cpp
Normal file
|
@ -0,0 +1,12 @@
|
|||
#include "android/jni/com/mapswithme/core/jni_helper.hpp"
|
||||
#include "platform/preferred_languages.hpp"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_com_mapswithme_util_Language_nativeNormalize(JNIEnv *env, jclass type, jstring lang)
|
||||
{
|
||||
std::string locale = languages::Normalize(jni::ToNativeString(env, lang));
|
||||
return jni::ToJavaString(env, locale);
|
||||
}
|
||||
}
|
|
@ -10,6 +10,7 @@ import android.view.View;
|
|||
import android.view.ViewGroup;
|
||||
|
||||
import com.mapswithme.maps.location.LocationHelper;
|
||||
import com.mapswithme.util.Language;
|
||||
import com.mapswithme.util.log.Logger;
|
||||
import com.mapswithme.util.log.LoggerFactory;
|
||||
import com.mopub.nativeads.BaseNativeAd;
|
||||
|
@ -57,11 +58,14 @@ class MopubNativeDownloader extends CachingNativeAdLoader
|
|||
RequestParameters.NativeAdAsset.TEXT,
|
||||
RequestParameters.NativeAdAsset.CALL_TO_ACTION_TEXT,
|
||||
RequestParameters.NativeAdAsset.ICON_IMAGE);
|
||||
requestParameters.desiredAssets(assetsSet);
|
||||
|
||||
Location l = LocationHelper.INSTANCE.getSavedLocation();
|
||||
if (l != null)
|
||||
requestParameters.location(l);
|
||||
requestParameters.desiredAssets(assetsSet);
|
||||
|
||||
String locale = Language.nativeNormalize(Language.getDefaultLocale());
|
||||
requestParameters.keywords("user_lang:" + locale);
|
||||
|
||||
nativeAd.makeRequest(requestParameters.build());
|
||||
}
|
||||
|
|
|
@ -53,4 +53,7 @@ public class Language
|
|||
|
||||
return locale;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public static native String nativeNormalize(@NonNull String locale);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue