[android] Added passing user lang as key word in Mopub request

This commit is contained in:
Александр Зацепин 2018-01-16 18:42:17 +03:00 committed by Ilya Zverev
parent 8906f0b7c9
commit 9d30ce501b
4 changed files with 21 additions and 1 deletions

View file

@ -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

View 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);
}
}

View file

@ -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());
}

View file

@ -53,4 +53,7 @@ public class Language
return locale;
}
@NonNull
public static native String nativeNormalize(@NonNull String locale);
}