Merge pull request #6030 from milchakov/std_migration_jni
Std migration jni
This commit is contained in:
commit
42efb105af
33 changed files with 188 additions and 175 deletions
|
@ -10,14 +10,14 @@
|
|||
#include "base/assert.hpp"
|
||||
#include "base/logging.hpp"
|
||||
|
||||
#include "std/string.hpp"
|
||||
#include <string>
|
||||
|
||||
using namespace my;
|
||||
|
||||
// @todo(vbykoianko) Probably it's worth thinking about output of the function to make the result of
|
||||
// the tests more readable.
|
||||
// @todo(vbykoianko) It's necessary display the test name in the android log.
|
||||
static void AndroidLogMessage(LogLevel l, SrcPoint const & src, string const & s)
|
||||
static void AndroidLogMessage(LogLevel l, SrcPoint const & src, std::string const & s)
|
||||
{
|
||||
android_LogPriority pr = ANDROID_LOG_SILENT;
|
||||
|
||||
|
@ -30,11 +30,11 @@ static void AndroidLogMessage(LogLevel l, SrcPoint const & src, string const & s
|
|||
case LCRITICAL: pr = ANDROID_LOG_FATAL; break;
|
||||
}
|
||||
|
||||
string const out = DebugPrint(src) + " " + s;
|
||||
std::string const out = DebugPrint(src) + " " + s;
|
||||
__android_log_write(pr, " MapsMeTests ", out.c_str());
|
||||
}
|
||||
|
||||
static void AndroidAssertMessage(SrcPoint const & src, string const & s)
|
||||
static void AndroidAssertMessage(SrcPoint const & src, std::string const & s)
|
||||
{
|
||||
#if defined(MWM_LOG_TO_FILE)
|
||||
AndroidLogToFile(LERROR, src, s);
|
||||
|
@ -96,7 +96,7 @@ namespace android_tests
|
|||
return false;
|
||||
}
|
||||
|
||||
static string GetApkPath(ANativeActivity * activity, JNIEnv * env)
|
||||
static std::string GetApkPath(ANativeActivity * activity, JNIEnv * env)
|
||||
{
|
||||
ASSERT(activity, ());
|
||||
ASSERT(env, ());
|
||||
|
@ -113,7 +113,7 @@ namespace android_tests
|
|||
return res;
|
||||
}
|
||||
|
||||
static string GetSdcardPath(ANativeActivity * activity, JNIEnv * env)
|
||||
static std::string GetSdcardPath(ANativeActivity * activity, JNIEnv * env)
|
||||
{
|
||||
ASSERT(activity, ());
|
||||
ASSERT(env, ());
|
||||
|
@ -139,7 +139,7 @@ namespace android_tests
|
|||
return res;
|
||||
}
|
||||
|
||||
static string GetPackageName(ANativeActivity * activity, JNIEnv * env)
|
||||
static std::string GetPackageName(ANativeActivity * activity, JNIEnv * env)
|
||||
{
|
||||
ASSERT(activity, ());
|
||||
ASSERT(env, ());
|
||||
|
@ -162,13 +162,13 @@ namespace android_tests
|
|||
void Initialize(ANativeActivity * activity, JNIEnv * env)
|
||||
{
|
||||
LOG(LINFO, ("Platform::Initialize()"));
|
||||
string apkPath = android_tests::GetApkPath(activity, env);
|
||||
std::string apkPath = android_tests::GetApkPath(activity, env);
|
||||
LOG(LINFO, ("Apk path FromJNI: ", apkPath.c_str()));
|
||||
|
||||
string sdcardPath = android_tests::GetSdcardPath(activity, env);
|
||||
std::string sdcardPath = android_tests::GetSdcardPath(activity, env);
|
||||
LOG(LINFO, ("Sdcard path FromJNI: ", sdcardPath.c_str()));
|
||||
|
||||
string packageName = android_tests::GetPackageName(activity, env);
|
||||
std::string packageName = android_tests::GetPackageName(activity, env);
|
||||
LOG(LINFO, ("Package name FromJNI: ", packageName.c_str()));
|
||||
|
||||
m_writableDir = sdcardPath + "/MapsWithMe/";
|
||||
|
@ -180,12 +180,12 @@ namespace android_tests
|
|||
}
|
||||
|
||||
/// get storage path without ending "/MapsWithMe/"
|
||||
string GetStoragePathPrefix() const
|
||||
std::string GetStoragePathPrefix() const
|
||||
{
|
||||
return string("/sdcard");
|
||||
return std::string("/sdcard");
|
||||
}
|
||||
/// assign storage path (should contain ending "/MapsWithMe/")
|
||||
void SetStoragePath(string const & path) {}
|
||||
void SetStoragePath(std::string const & path) {}
|
||||
|
||||
bool HasAvailableSpaceForWriting(uint64_t size) const{ return true; }
|
||||
|
||||
|
@ -202,7 +202,7 @@ Platform & GetPlatform()
|
|||
return android_tests::Platform::Instance();
|
||||
}
|
||||
|
||||
string GetAndroidSystemLanguage()
|
||||
std::string GetAndroidSystemLanguage()
|
||||
{
|
||||
return "en_US";
|
||||
}
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
#include "base/assert.hpp"
|
||||
#include "base/exception.hpp"
|
||||
#include "base/logging.hpp"
|
||||
#include "std/vector.hpp"
|
||||
|
||||
#include <vector>
|
||||
|
||||
static JavaVM * g_jvm = 0;
|
||||
extern JavaVM * GetJVM()
|
||||
|
@ -118,9 +119,9 @@ jclass GetGlobalClassRef(JNIEnv * env, char const * sig)
|
|||
return static_cast<jclass>(env->NewGlobalRef(klass));
|
||||
}
|
||||
|
||||
string ToNativeString(JNIEnv * env, jstring str)
|
||||
std::string ToNativeString(JNIEnv * env, jstring str)
|
||||
{
|
||||
string result;
|
||||
std::string result;
|
||||
char const * utfBuffer = env->GetStringUTFChars(str, 0);
|
||||
if (utfBuffer)
|
||||
{
|
||||
|
@ -130,12 +131,12 @@ string ToNativeString(JNIEnv * env, jstring str)
|
|||
return result;
|
||||
}
|
||||
|
||||
string ToNativeString(JNIEnv * env, jbyteArray const & bytes)
|
||||
std::string ToNativeString(JNIEnv * env, jbyteArray const & bytes)
|
||||
{
|
||||
int const len = env->GetArrayLength(bytes);
|
||||
vector<char> buffer(len);
|
||||
std::vector<char> buffer(len);
|
||||
env->GetByteArrayRegion(bytes, 0, len, reinterpret_cast<jbyte *>(buffer.data()));
|
||||
return string(buffer.data(), len);
|
||||
return std::string(buffer.data(), len);
|
||||
}
|
||||
|
||||
jstring ToJavaString(JNIEnv * env, char const * s)
|
||||
|
@ -143,10 +144,10 @@ jstring ToJavaString(JNIEnv * env, char const * s)
|
|||
return env->NewStringUTF(s);
|
||||
}
|
||||
|
||||
jobjectArray ToJavaStringArray(JNIEnv * env, vector<string> const & src)
|
||||
jobjectArray ToJavaStringArray(JNIEnv * env, std::vector<std::string> const & src)
|
||||
{
|
||||
return ToJavaArray(env, GetStringClass(env), src,
|
||||
[](JNIEnv * env, string const & item)
|
||||
[](JNIEnv * env, std::string const & item)
|
||||
{
|
||||
return ToJavaString(env, item.c_str());
|
||||
});
|
||||
|
@ -171,14 +172,14 @@ struct global_ref_deleter
|
|||
}
|
||||
};
|
||||
|
||||
shared_ptr<jobject> make_global_ref(jobject obj)
|
||||
std::shared_ptr<jobject> make_global_ref(jobject obj)
|
||||
{
|
||||
jobject * ref = new jobject;
|
||||
*ref = GetEnv()->NewGlobalRef(obj);
|
||||
return shared_ptr<jobject>(ref, global_ref_deleter());
|
||||
return std::shared_ptr<jobject>(ref, global_ref_deleter());
|
||||
}
|
||||
|
||||
string ToNativeString(JNIEnv * env, const jthrowable & e)
|
||||
std::string ToNativeString(JNIEnv * env, const jthrowable & e)
|
||||
{
|
||||
jni::TScopedLocalClassRef logClassRef(env, env->FindClass("android/util/Log"));
|
||||
ASSERT(logClassRef.get(), ());
|
||||
|
@ -204,7 +205,7 @@ bool HandleJavaException(JNIEnv * env)
|
|||
return false;
|
||||
}
|
||||
|
||||
string DescribeException()
|
||||
std::string DescribeException()
|
||||
{
|
||||
JNIEnv * env = GetEnv();
|
||||
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
|
||||
#include "geometry/point2d.hpp"
|
||||
|
||||
#include "std/string.hpp"
|
||||
#include "std/shared_ptr.hpp"
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
extern jclass g_mapObjectClazz;
|
||||
extern jclass g_bookmarkClazz;
|
||||
|
@ -32,12 +32,12 @@ jmethodID GetConstructorID(JNIEnv * env, jclass clazz, char const * signature);
|
|||
// Result value should be DeleteGlobalRef`ed by caller
|
||||
jclass GetGlobalClassRef(JNIEnv * env, char const * s);
|
||||
|
||||
string ToNativeString(JNIEnv * env, jstring str);
|
||||
std::string ToNativeString(JNIEnv * env, jstring str);
|
||||
// Converts UTF-8 array to native UTF-8 string. Result differs from simple GetStringUTFChars call for characters greater than U+10000,
|
||||
// since jni uses modified UTF (MUTF-8) for strings.
|
||||
string ToNativeString(JNIEnv * env, jbyteArray const & utfBytes);
|
||||
std::string ToNativeString(JNIEnv * env, jbyteArray const & utfBytes);
|
||||
jstring ToJavaString(JNIEnv * env, char const * s);
|
||||
inline jstring ToJavaString(JNIEnv * env, string const & s)
|
||||
inline jstring ToJavaString(JNIEnv * env, std::string const & s)
|
||||
{
|
||||
return ToJavaString(env, s.c_str());
|
||||
}
|
||||
|
@ -45,10 +45,10 @@ inline jstring ToJavaString(JNIEnv * env, string const & s)
|
|||
jclass GetStringClass(JNIEnv * env);
|
||||
char const * GetStringClassName();
|
||||
|
||||
string DescribeException();
|
||||
std::string DescribeException();
|
||||
bool HandleJavaException(JNIEnv * env);
|
||||
|
||||
shared_ptr<jobject> make_global_ref(jobject obj);
|
||||
std::shared_ptr<jobject> make_global_ref(jobject obj);
|
||||
using TScopedLocalRef = ScopedLocalRef<jobject>;
|
||||
using TScopedLocalClassRef = ScopedLocalRef<jclass>;
|
||||
using TScopedLocalObjectArrayRef = ScopedLocalRef<jobjectArray>;
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace jni
|
|||
|
||||
using namespace my;
|
||||
|
||||
void AndroidMessage(LogLevel level, SrcPoint const & src, string const & s)
|
||||
void AndroidMessage(LogLevel level, SrcPoint const & src, std::string const & s)
|
||||
{
|
||||
android_LogPriority pr = ANDROID_LOG_SILENT;
|
||||
|
||||
|
@ -37,20 +37,20 @@ void AndroidMessage(LogLevel level, SrcPoint const & src, string const & s)
|
|||
static jmethodID const logCoreMsgMethod = jni::GetStaticMethodID(env.get(), g_loggerFactoryClazz,
|
||||
"logCoreMessage", "(ILjava/lang/String;)V");
|
||||
|
||||
string const out = DebugPrint(src) + " " + s;
|
||||
std::string const out = DebugPrint(src) + " " + s;
|
||||
jni::TScopedLocalRef msg(env.get(), jni::ToJavaString(env.get(), out));
|
||||
env->CallStaticVoidMethod(g_loggerFactoryClazz, logCoreMsgMethod, pr, msg.get());
|
||||
if (g_crashlytics)
|
||||
g_crashlytics->log(g_crashlytics, out.c_str());
|
||||
}
|
||||
|
||||
void AndroidLogMessage(LogLevel level, SrcPoint const & src, string const & s)
|
||||
void AndroidLogMessage(LogLevel level, SrcPoint const & src, std::string const & s)
|
||||
{
|
||||
AndroidMessage(level, src, s);
|
||||
CHECK_LESS(level, g_LogAbortLevel, ("Abort. Log level is too serious", level));
|
||||
}
|
||||
|
||||
void AndroidAssertMessage(SrcPoint const & src, string const & s)
|
||||
void AndroidAssertMessage(SrcPoint const & src, std::string const & s)
|
||||
{
|
||||
AndroidMessage(LCRITICAL, src, s);
|
||||
#ifdef DEBUG
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#include "graphics/opengl/gl_render_context.hpp"
|
||||
|
||||
#include "std/shared_ptr.hpp"
|
||||
#include <memory>
|
||||
|
||||
namespace android
|
||||
{
|
||||
|
|
|
@ -16,13 +16,13 @@
|
|||
|
||||
#include "com/mapswithme/core/jni_helper.hpp"
|
||||
|
||||
#include "std/vector.hpp"
|
||||
#include "std/string.hpp"
|
||||
#include "std/bind.hpp"
|
||||
#include "std/shared_ptr.hpp"
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
using namespace downloader;
|
||||
using namespace std::placeholders;
|
||||
|
||||
/// Special error codes to notify GUI about free space
|
||||
//@{
|
||||
|
@ -37,19 +37,19 @@ using namespace downloader;
|
|||
|
||||
struct FileToDownload
|
||||
{
|
||||
vector<string> m_urls;
|
||||
string m_fileName;
|
||||
string m_pathOnSdcard;
|
||||
std::vector<std::string> m_urls;
|
||||
std::string m_fileName;
|
||||
std::string m_pathOnSdcard;
|
||||
uint64_t m_fileSize;
|
||||
};
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
static vector<FileToDownload> g_filesToDownload;
|
||||
static std::vector<FileToDownload> g_filesToDownload;
|
||||
static int g_totalDownloadedBytes;
|
||||
static int g_totalBytesToDownload;
|
||||
static shared_ptr<HttpRequest> g_currentRequest;
|
||||
static std::shared_ptr<HttpRequest> g_currentRequest;
|
||||
|
||||
} // namespace
|
||||
|
||||
|
@ -57,7 +57,7 @@ extern "C"
|
|||
{
|
||||
using TCallback = HttpRequest::CallbackT;
|
||||
|
||||
static int HasSpaceForFiles(Platform & pl, string const & sdcardPath, size_t fileSize)
|
||||
static int HasSpaceForFiles(Platform & pl, std::string const & sdcardPath, size_t fileSize)
|
||||
{
|
||||
switch (pl.GetWritableStorageStatus(fileSize))
|
||||
{
|
||||
|
@ -73,7 +73,7 @@ extern "C"
|
|||
}
|
||||
|
||||
// Check if we need to download mandatory resource file.
|
||||
static bool NeedToDownload(Platform & pl, string const & name, int size)
|
||||
static bool NeedToDownload(Platform & pl, std::string const & name, int size)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -99,12 +99,12 @@ extern "C"
|
|||
g_totalDownloadedBytes = 0;
|
||||
|
||||
Platform & pl = GetPlatform();
|
||||
string const path = pl.WritableDir();
|
||||
std::string const path = pl.WritableDir();
|
||||
|
||||
ReaderStreamBuf buffer(pl.GetReader(EXTERNAL_RESOURCES_FILE));
|
||||
istream in(&buffer);
|
||||
|
||||
string name;
|
||||
std::string name;
|
||||
int size;
|
||||
while (true)
|
||||
{
|
||||
|
@ -141,7 +141,7 @@ extern "C"
|
|||
return res;
|
||||
}
|
||||
|
||||
static void DownloadFileFinished(shared_ptr<jobject> obj, HttpRequest const & req)
|
||||
static void DownloadFileFinished(std::shared_ptr<jobject> obj, HttpRequest const & req)
|
||||
{
|
||||
HttpRequest::StatusT const status = req.Status();
|
||||
ASSERT_NOT_EQUAL(status, HttpRequest::EInProgress, ());
|
||||
|
@ -169,7 +169,7 @@ extern "C"
|
|||
env->CallVoidMethod(*obj, methodID, errorCode);
|
||||
}
|
||||
|
||||
static void DownloadFileProgress(shared_ptr<jobject> listener, HttpRequest const & req)
|
||||
static void DownloadFileProgress(std::shared_ptr<jobject> listener, HttpRequest const & req)
|
||||
{
|
||||
FileToDownload & curFile = g_filesToDownload.back();
|
||||
|
||||
|
@ -206,11 +206,11 @@ extern "C"
|
|||
|
||||
LOG(LDEBUG, ("downloading", curFile.m_fileName, "sized", curFile.m_fileSize, "bytes"));
|
||||
|
||||
TCallback onFinish(bind(&DownloadFileFinished, jni::make_global_ref(listener), _1));
|
||||
TCallback onProgress(bind(&DownloadFileProgress, jni::make_global_ref(listener), _1));
|
||||
TCallback onFinish(std::bind(&DownloadFileFinished, jni::make_global_ref(listener), _1));
|
||||
TCallback onProgress(std::bind(&DownloadFileProgress, jni::make_global_ref(listener), _1));
|
||||
|
||||
g_currentRequest.reset(HttpRequest::PostJson(GetPlatform().ResourcesMetaServerUrl(), curFile.m_fileName,
|
||||
bind(&DownloadURLListFinished, _1, onFinish, onProgress)));
|
||||
std::bind(&DownloadURLListFinished, _1, onFinish, onProgress)));
|
||||
return ERR_FILE_IN_PROGRESS;
|
||||
}
|
||||
|
||||
|
|
|
@ -37,6 +37,9 @@
|
|||
#include "base/math.hpp"
|
||||
#include "base/sunrise_sunset.hpp"
|
||||
|
||||
using namespace std;
|
||||
using namespace std::placeholders;
|
||||
|
||||
android::Framework * g_framework = 0;
|
||||
|
||||
namespace platform
|
||||
|
|
|
@ -21,11 +21,10 @@
|
|||
|
||||
#include "indexer/map_style.hpp"
|
||||
|
||||
#include "std/map.hpp"
|
||||
#include "std/mutex.hpp"
|
||||
#include "std/shared_ptr.hpp"
|
||||
#include "std/unique_ptr.hpp"
|
||||
#include "std/cstdint.hpp"
|
||||
#include <cstdint>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
|
||||
namespace search
|
||||
{
|
||||
|
@ -43,11 +42,11 @@ namespace android
|
|||
math::LowPassVector<float, 3> m_sensors[2];
|
||||
double m_lastCompass;
|
||||
|
||||
string m_searchQuery;
|
||||
std::string m_searchQuery;
|
||||
|
||||
bool m_isContextDestroyed;
|
||||
|
||||
map<gui::EWidget, gui::Position> m_guiPositions;
|
||||
std::map<gui::EWidget, gui::Position> m_guiPositions;
|
||||
|
||||
void TrafficStateChanged(TrafficManager::TrafficState state);
|
||||
|
||||
|
@ -111,7 +110,7 @@ namespace android
|
|||
void Touch(int action, Finger const & f1, Finger const & f2, uint8_t maskedPointer);
|
||||
|
||||
bool Search(search::EverywhereSearchParams const & params);
|
||||
string GetLastSearchQuery() { return m_searchQuery; }
|
||||
std::string GetLastSearchQuery() { return m_searchQuery; }
|
||||
void ClearLastSearchQuery() { m_searchQuery.clear(); }
|
||||
|
||||
void AddLocalMaps();
|
||||
|
@ -119,7 +118,7 @@ namespace android
|
|||
|
||||
m2::PointD GetViewportCenter() const;
|
||||
|
||||
void AddString(string const & name, string const & value);
|
||||
void AddString(std::string const & name, std::string const & value);
|
||||
|
||||
void Scale(::Framework::EScaleMode mode);
|
||||
void Scale(m2::PointD const & centerPt, int targetZoom, bool animate);
|
||||
|
@ -131,11 +130,11 @@ namespace android
|
|||
|
||||
bool IsDownloadingActive();
|
||||
|
||||
bool ShowMapForURL(string const & url);
|
||||
bool ShowMapForURL(std::string const & url);
|
||||
|
||||
void DeactivatePopup();
|
||||
|
||||
string GetOutdatedCountriesString();
|
||||
std::string GetOutdatedCountriesString();
|
||||
|
||||
void ShowTrack(int category, int track);
|
||||
|
||||
|
@ -162,10 +161,10 @@ namespace android
|
|||
void SetPlacePageInfo(place_page::Info const & info);
|
||||
place_page::Info & GetPlacePageInfo();
|
||||
void RequestBookingMinPrice(JNIEnv * env, jobject policy,
|
||||
string const & hotelId, string const & currency,
|
||||
std::string const & hotelId, std::string const & currency,
|
||||
booking::GetMinPriceCallback const & callback);
|
||||
void RequestBookingInfo(JNIEnv * env, jobject policy,
|
||||
string const & hotelId, string const & lang,
|
||||
std::string const & hotelId, std::string const & lang,
|
||||
booking::GetHotelInfoCallback const & callback);
|
||||
|
||||
bool HasSpaceForMigration();
|
||||
|
@ -180,7 +179,7 @@ namespace android
|
|||
uint64_t RequestUberProducts(JNIEnv * env, jobject policy, ms::LatLon const & from,
|
||||
ms::LatLon const & to, uber::ProductsCallback const & callback,
|
||||
uber::ErrorCallback const & errorCallback);
|
||||
static uber::RideRequestLinks GetUberLinks(string const & productId, ms::LatLon const & from, ms::LatLon const & to);
|
||||
static uber::RideRequestLinks GetUberLinks(std::string const & productId, ms::LatLon const & from, ms::LatLon const & to);
|
||||
|
||||
int ToDoAfterUpdate() const;
|
||||
};
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
extern "C"
|
||||
{
|
||||
|
||||
static void LocationStateModeChanged(location::EMyPositionMode mode, shared_ptr<jobject> const & listener)
|
||||
static void LocationStateModeChanged(location::EMyPositionMode mode, std::shared_ptr<jobject> const & listener)
|
||||
{
|
||||
g_framework->OnMyPositionModeChanged(mode);
|
||||
|
||||
|
@ -33,7 +33,8 @@ Java_com_mapswithme_maps_location_LocationState_nativeGetMode(JNIEnv * env, jcla
|
|||
JNIEXPORT void JNICALL
|
||||
Java_com_mapswithme_maps_location_LocationState_nativeSetListener(JNIEnv * env, jclass clazz, jobject listener)
|
||||
{
|
||||
g_framework->SetMyPositionModeListener(bind(&LocationStateModeChanged, _1, jni::make_global_ref(listener)));
|
||||
g_framework->SetMyPositionModeListener(std::bind(&LocationStateModeChanged, std::placeholders::_1,
|
||||
jni::make_global_ref(listener)));
|
||||
}
|
||||
|
||||
// public static void nativeRemoveListener();
|
||||
|
|
|
@ -12,9 +12,11 @@
|
|||
#include "platform/local_country_file_utils.hpp"
|
||||
#include "platform/mwm_version.hpp"
|
||||
|
||||
#include "std/bind.hpp"
|
||||
#include "std/shared_ptr.hpp"
|
||||
#include "std/unordered_map.hpp"
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
|
||||
using namespace std::placeholders;
|
||||
|
||||
namespace
|
||||
{
|
||||
|
@ -204,8 +206,8 @@ Java_com_mapswithme_maps_downloader_MapManager_nativeMigrate(JNIEnv * env, jclas
|
|||
|
||||
g_migrationListener = env->NewGlobalRef(listener);
|
||||
|
||||
TCountryId id = g_framework->PreMigrate(position, bind(&MigrationStatusChangedCallback, _1, keepOldMaps),
|
||||
bind(&MigrationProgressCallback, _1, _2));
|
||||
TCountryId id = g_framework->PreMigrate(position, std::bind(&MigrationStatusChangedCallback, _1, keepOldMaps),
|
||||
std::bind(&MigrationProgressCallback, _1, _2));
|
||||
if (id != kInvalidCountryId)
|
||||
{
|
||||
NodeAttrs attrs;
|
||||
|
@ -533,7 +535,7 @@ Java_com_mapswithme_maps_downloader_MapManager_nativeDelete(JNIEnv * env, jclass
|
|||
EndBatchingCallbacks(env);
|
||||
}
|
||||
|
||||
static void StatusChangedCallback(shared_ptr<jobject> const & listenerRef, TCountryId const & countryId)
|
||||
static void StatusChangedCallback(std::shared_ptr<jobject> const & listenerRef, TCountryId const & countryId)
|
||||
{
|
||||
NodeStatuses ns;
|
||||
GetStorage().GetNodeStatuses(countryId, ns);
|
||||
|
@ -545,7 +547,7 @@ static void StatusChangedCallback(shared_ptr<jobject> const & listenerRef, TCoun
|
|||
EndBatchingCallbacks(jni::GetEnv());
|
||||
}
|
||||
|
||||
static void ProgressChangedCallback(shared_ptr<jobject> const & listenerRef, TCountryId const & countryId, TLocalAndRemoteSize const & sizes)
|
||||
static void ProgressChangedCallback(std::shared_ptr<jobject> const & listenerRef, TCountryId const & countryId, TLocalAndRemoteSize const & sizes)
|
||||
{
|
||||
JNIEnv * env = jni::GetEnv();
|
||||
|
||||
|
@ -558,8 +560,8 @@ JNIEXPORT jint JNICALL
|
|||
Java_com_mapswithme_maps_downloader_MapManager_nativeSubscribe(JNIEnv * env, jclass clazz, jobject listener)
|
||||
{
|
||||
PrepareClassRefs(env);
|
||||
return GetStorage().Subscribe(bind(&StatusChangedCallback, jni::make_global_ref(listener), _1),
|
||||
bind(&ProgressChangedCallback, jni::make_global_ref(listener), _1, _2));
|
||||
return GetStorage().Subscribe(std::bind(&StatusChangedCallback, jni::make_global_ref(listener), _1),
|
||||
std::bind(&ProgressChangedCallback, jni::make_global_ref(listener), _1, _2));
|
||||
}
|
||||
|
||||
// static void nativeUnsubscribe(int slot);
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include <vector>
|
||||
|
||||
using namespace std;
|
||||
using namespace std::placeholders;
|
||||
using search::Result;
|
||||
using search::Results;
|
||||
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
#include "map/place_page_info.hpp"
|
||||
#include "partners_api/booking_api.hpp"
|
||||
|
||||
#include "std/bind.hpp"
|
||||
#include "std/chrono.hpp"
|
||||
#include <chrono>
|
||||
#include <functional>
|
||||
|
||||
namespace
|
||||
{
|
||||
|
@ -26,7 +26,7 @@ jmethodID g_hotelInfoConstructor;
|
|||
jmethodID g_sponsoredClassConstructor;
|
||||
jmethodID g_priceCallback;
|
||||
jmethodID g_infoCallback;
|
||||
string g_lastRequestedHotelId;
|
||||
std::string g_lastRequestedHotelId;
|
||||
|
||||
void PrepareClassRefs(JNIEnv * env, jclass sponsoredClass)
|
||||
{
|
||||
|
@ -98,7 +98,7 @@ jobjectArray ToReviewsArray(JNIEnv * env, vector<HotelReview> const & reviews)
|
|||
[](JNIEnv * env, HotelReview const & item) {
|
||||
return env->NewObject(
|
||||
g_reviewClass, g_reviewConstructor,
|
||||
time_point_cast<milliseconds>(item.m_date).time_since_epoch().count(),
|
||||
std::chrono::time_point_cast<std::chrono::milliseconds>(item.m_date).time_since_epoch().count(),
|
||||
item.m_score, jni::ToJavaString(env, item.m_author),
|
||||
jni::ToJavaString(env, item.m_pros), jni::ToJavaString(env, item.m_cons));
|
||||
});
|
||||
|
@ -132,13 +132,13 @@ JNIEXPORT void JNICALL Java_com_mapswithme_maps_widget_placepage_Sponsored_nativ
|
|||
{
|
||||
PrepareClassRefs(env, clazz);
|
||||
|
||||
string const hotelId = jni::ToNativeString(env, id);
|
||||
std::string const hotelId = jni::ToNativeString(env, id);
|
||||
g_lastRequestedHotelId = hotelId;
|
||||
|
||||
string const code = jni::ToNativeString(env, currencyCode);
|
||||
std::string const code = jni::ToNativeString(env, currencyCode);
|
||||
|
||||
g_framework->RequestBookingMinPrice(env, policy, hotelId, code,
|
||||
[](string const & hotelId, string const & price, string const & currency) {
|
||||
[](std::string const & hotelId, std::string const & price, std::string const & currency) {
|
||||
GetPlatform().RunOnGuiThread([hotelId, price, currency]() {
|
||||
if (g_lastRequestedHotelId != hotelId)
|
||||
return;
|
||||
|
@ -156,10 +156,10 @@ JNIEXPORT void JNICALL Java_com_mapswithme_maps_widget_placepage_Sponsored_nativ
|
|||
{
|
||||
PrepareClassRefs(env, clazz);
|
||||
|
||||
string const hotelId = jni::ToNativeString(env, id);
|
||||
std::string const hotelId = jni::ToNativeString(env, id);
|
||||
g_lastRequestedHotelId = hotelId;
|
||||
|
||||
string code = jni::ToNativeString(env, locale);
|
||||
std::string code = jni::ToNativeString(env, locale);
|
||||
|
||||
if (code.size() > 2) // 2 - number of characters in country code
|
||||
code.resize(2);
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#include "map/gps_tracker.hpp"
|
||||
|
||||
#include "std/chrono.hpp"
|
||||
#include <chrono>
|
||||
|
||||
namespace
|
||||
{
|
||||
|
@ -38,7 +38,7 @@ extern "C"
|
|||
JNIEXPORT void JNICALL
|
||||
Java_com_mapswithme_maps_location_TrackRecorder_nativeSetDuration(JNIEnv * env, jclass clazz, jint durationHours)
|
||||
{
|
||||
GpsTracker::Instance().SetDuration(hours(durationHours));
|
||||
GpsTracker::Instance().SetDuration(std::chrono::hours(durationHours));
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
extern "C"
|
||||
{
|
||||
static void TrafficStateChanged(TrafficManager::TrafficState state, shared_ptr<jobject> const & listener)
|
||||
static void TrafficStateChanged(TrafficManager::TrafficState state, std::shared_ptr<jobject> const & listener)
|
||||
{
|
||||
JNIEnv * env = jni::GetEnv();
|
||||
env->CallVoidMethod(*listener, jni::GetMethodID(env, *listener, "onTrafficStateChanged", "(I)V"), static_cast<jint>(state));
|
||||
|
@ -16,7 +16,7 @@ JNIEXPORT void JNICALL
|
|||
Java_com_mapswithme_maps_traffic_TrafficState_nativeSetListener(JNIEnv * env, jclass clazz, jobject listener)
|
||||
{
|
||||
CHECK(g_framework, ("Framework isn't created yet!"));
|
||||
g_framework->SetTrafficStateListener(bind(&TrafficStateChanged, _1, jni::make_global_ref(listener)));
|
||||
g_framework->SetTrafficStateListener(std::bind(&TrafficStateChanged, std::placeholders::_1, jni::make_global_ref(listener)));
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
|
|
|
@ -27,7 +27,7 @@ void InjectMetadata(JNIEnv * env, jclass const clazz, jobject const mapObject, f
|
|||
}
|
||||
}
|
||||
|
||||
jobject CreateBanner(JNIEnv * env, string const & id, jint type)
|
||||
jobject CreateBanner(JNIEnv * env, std::string const & id, jint type)
|
||||
{
|
||||
static jmethodID const bannerCtorId =
|
||||
jni::GetConstructorID(env, g_bannerClazz, "(Ljava/lang/String;I)V");
|
||||
|
@ -35,11 +35,11 @@ jobject CreateBanner(JNIEnv * env, string const & id, jint type)
|
|||
return env->NewObject(g_bannerClazz, bannerCtorId, jni::ToJavaString(env, id), type);
|
||||
}
|
||||
|
||||
jobject CreateMapObject(JNIEnv * env, int mapObjectType, string const & title,
|
||||
string const & secondaryTitle, string const & subtitle, double lat,
|
||||
double lon, string const & address, Metadata const & metadata,
|
||||
string const & apiId, jobjectArray jbanners, bool isReachableByTaxi,
|
||||
string const & bookingSearchUrl, jobject const & localAdInfo)
|
||||
jobject CreateMapObject(JNIEnv * env, int mapObjectType, std::string const & title,
|
||||
std::string const & secondaryTitle, std::string const & subtitle, double lat,
|
||||
double lon, std::string const & address, Metadata const & metadata,
|
||||
std::string const & apiId, jobjectArray jbanners, bool isReachableByTaxi,
|
||||
std::string const & bookingSearchUrl, jobject const & localAdInfo)
|
||||
{
|
||||
// public MapObject(@MapObjectType int mapObjectType, String title, String secondaryTitle,
|
||||
// String subtitle, double lat, double lon, String address, String apiId,
|
||||
|
|
|
@ -28,7 +28,7 @@ static constexpr int kSearch = 4;
|
|||
// Fills mapobject's metadata.
|
||||
void InjectMetadata(JNIEnv * env, jclass clazz, jobject const mapObject, feature::Metadata const & metadata);
|
||||
|
||||
jobject CreateMapObject(JNIEnv * env, int mapObjectType, string const & title, string const & subtitle,
|
||||
jobject CreateMapObject(JNIEnv * env, int mapObjectType, std::string const & title, std::string const & subtitle,
|
||||
double lat, double lon, feature::Metadata const & metadata);
|
||||
|
||||
jobject CreateMapObject(JNIEnv * env, place_page::Info const & info);
|
||||
|
|
|
@ -106,7 +106,7 @@ Java_com_mapswithme_maps_bookmarks_data_BookmarkCategory_nativeGetTrack(
|
|||
|
||||
ASSERT(nTrack, ("Track must not be null with index:)", bmkId));
|
||||
|
||||
string formattedLength;
|
||||
std::string formattedLength;
|
||||
measurement_utils::FormatDistance(nTrack->GetLengthMeters(), formattedLength);
|
||||
|
||||
dp::Color nColor = nTrack->GetColor(0);
|
||||
|
|
|
@ -91,7 +91,7 @@ Java_com_mapswithme_maps_bookmarks_data_BookmarkManager_nativeSaveToKmzFile(
|
|||
BookmarkCategory * pCat = frm()->GetBmCategory(catID);
|
||||
if (pCat)
|
||||
{
|
||||
string const name = pCat->GetName();
|
||||
std::string const name = pCat->GetName();
|
||||
if (CreateZipFromPathDeflatedAndDefaultCompression(pCat->GetFileName(), ToNativeString(env, tmpPath) + name + ".kmz"))
|
||||
return ToJavaString(env, name);
|
||||
}
|
||||
|
@ -123,8 +123,8 @@ Java_com_mapswithme_maps_bookmarks_data_BookmarkManager_getLastEditedCategory(
|
|||
JNIEXPORT jstring JNICALL
|
||||
Java_com_mapswithme_maps_bookmarks_data_BookmarkManager_nativeGenerateUniqueFileName(JNIEnv * env, jclass thiz, jstring jBaseName)
|
||||
{
|
||||
string baseName = ToNativeString(env, jBaseName);
|
||||
string bookmarkFileName = BookmarkCategory::GenerateUniqueFileName(GetPlatform().SettingsDir(), baseName);
|
||||
std::string baseName = ToNativeString(env, jBaseName);
|
||||
std::string bookmarkFileName = BookmarkCategory::GenerateUniqueFileName(GetPlatform().SettingsDir(), baseName);
|
||||
return ToJavaString(env, bookmarkFileName);
|
||||
}
|
||||
|
||||
|
|
|
@ -13,14 +13,15 @@
|
|||
#include "indexer/editable_map_object.hpp"
|
||||
#include "indexer/osm_editor.hpp"
|
||||
|
||||
#include "std/algorithm.hpp"
|
||||
#include "std/set.hpp"
|
||||
#include "std/target_os.hpp"
|
||||
#include "std/vector.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
||||
namespace
|
||||
{
|
||||
using TCuisine = pair<string, string>;
|
||||
using TCuisine = std::pair<std::string, std::string>;
|
||||
osm::EditableMapObject g_editableMapObject;
|
||||
|
||||
jclass g_featureCategoryClazz;
|
||||
|
@ -458,7 +459,7 @@ Java_com_mapswithme_maps_editor_Editor_nativeRollbackMapObject(JNIEnv * env, jcl
|
|||
JNIEXPORT jobjectArray JNICALL
|
||||
Java_com_mapswithme_maps_editor_Editor_nativeGetAllFeatureCategories(JNIEnv * env, jclass clazz, jstring jLang)
|
||||
{
|
||||
string const & lang = jni::ToNativeString(env, jLang);
|
||||
std::string const & lang = jni::ToNativeString(env, jLang);
|
||||
GetFeatureCategories().AddLanguage(lang);
|
||||
return jni::ToJavaArray(env, g_featureCategoryClazz,
|
||||
GetFeatureCategories().GetAllCategoryNames(lang),
|
||||
|
@ -468,7 +469,7 @@ Java_com_mapswithme_maps_editor_Editor_nativeGetAllFeatureCategories(JNIEnv * en
|
|||
JNIEXPORT jobjectArray JNICALL
|
||||
Java_com_mapswithme_maps_editor_Editor_nativeSearchFeatureCategories(JNIEnv * env, jclass clazz, jstring query, jstring jLang)
|
||||
{
|
||||
string const & lang = jni::ToNativeString(env, jLang);
|
||||
std::string const & lang = jni::ToNativeString(env, jLang);
|
||||
GetFeatureCategories().AddLanguage(lang);
|
||||
return jni::ToJavaArray(env, g_featureCategoryClazz,
|
||||
GetFeatureCategories().Search(jni::ToNativeString(env, query), lang),
|
||||
|
@ -479,7 +480,7 @@ JNIEXPORT jobjectArray JNICALL
|
|||
Java_com_mapswithme_maps_editor_Editor_nativeGetCuisines(JNIEnv * env, jclass clazz)
|
||||
{
|
||||
osm::TAllCuisines const & cuisines = osm::Cuisines::Instance().AllSupportedCuisines();
|
||||
vector<string> keys;
|
||||
std::vector<std::string> keys;
|
||||
keys.reserve(cuisines.size());
|
||||
for (TCuisine const & cuisine : cuisines)
|
||||
keys.push_back(cuisine.first);
|
||||
|
@ -496,11 +497,11 @@ JNIEXPORT jobjectArray JNICALL
|
|||
Java_com_mapswithme_maps_editor_Editor_nativeTranslateCuisines(JNIEnv * env, jclass clazz, jobjectArray jKeys)
|
||||
{
|
||||
int const length = env->GetArrayLength(jKeys);
|
||||
vector<string> translations;
|
||||
std::vector<std::string> translations;
|
||||
translations.reserve(length);
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
string const & key = jni::ToNativeString(env, (jstring) env->GetObjectArrayElement(jKeys, i));
|
||||
std::string const & key = jni::ToNativeString(env, (jstring) env->GetObjectArrayElement(jKeys, i));
|
||||
translations.push_back(osm::Cuisines::Instance().Translate(key));
|
||||
}
|
||||
return jni::ToJavaStringArray(env, translations);
|
||||
|
@ -510,7 +511,7 @@ JNIEXPORT void JNICALL
|
|||
Java_com_mapswithme_maps_editor_Editor_nativeSetSelectedCuisines(JNIEnv * env, jclass clazz, jobjectArray jKeys)
|
||||
{
|
||||
int const length = env->GetArrayLength(jKeys);
|
||||
vector<string> cuisines;
|
||||
std::vector<std::string> cuisines;
|
||||
cuisines.reserve(length);
|
||||
for (int i = 0; i < length; i++)
|
||||
cuisines.push_back(jni::ToNativeString(env, (jstring) env->GetObjectArrayElement(jKeys, i)));
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
|
||||
#include "base/logging.hpp"
|
||||
|
||||
#include "std/algorithm.hpp"
|
||||
#include "std/set.hpp"
|
||||
#include "std/vector.hpp"
|
||||
#include <algorithm>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
||||
#include "3party/opening_hours/opening_hours.hpp"
|
||||
|
||||
|
@ -72,10 +72,10 @@ jobject JavaTimetable(JNIEnv * env, jobject workingHours, jobject closedHours, b
|
|||
jobject JavaTimetable(JNIEnv * env, TimeTable const & tt)
|
||||
{
|
||||
auto const excludeSpans = tt.GetExcludeTime();
|
||||
set<Weekday> weekdays = tt.GetOpeningDays();
|
||||
vector<int> weekdaysVector;
|
||||
std::set<Weekday> weekdays = tt.GetOpeningDays();
|
||||
std::vector<int> weekdaysVector;
|
||||
weekdaysVector.reserve(weekdays.size());
|
||||
transform(weekdays.begin(), weekdays.end(), back_inserter(weekdaysVector), [](Weekday weekday)
|
||||
std::transform(weekdays.begin(), weekdays.end(), std::back_inserter(weekdaysVector), [](Weekday weekday)
|
||||
{
|
||||
return static_cast<int>(weekday);
|
||||
});
|
||||
|
@ -283,7 +283,7 @@ JNIEXPORT jobjectArray JNICALL
|
|||
Java_com_mapswithme_maps_editor_OpeningHours_nativeTimetablesFromString(JNIEnv * env, jclass clazz, jstring jSource)
|
||||
{
|
||||
TimeTableSet tts;
|
||||
string const source = jni::ToNativeString(env, jSource);
|
||||
std::string const source = jni::ToNativeString(env, jSource);
|
||||
if (!source.empty() && MakeTimeTableSet(OpeningHours(source), tts))
|
||||
return JavaTimetables(env, tts);
|
||||
|
||||
|
@ -294,7 +294,7 @@ JNIEXPORT jstring JNICALL
|
|||
Java_com_mapswithme_maps_editor_OpeningHours_nativeTimetablesToString(JNIEnv * env, jclass clazz, jobjectArray jTts)
|
||||
{
|
||||
TimeTableSet tts = NativeTimetableSet(env, jTts);
|
||||
stringstream sstr;
|
||||
std::stringstream sstr;
|
||||
sstr << MakeOpeningHours(tts).GetRule();
|
||||
return jni::ToJavaString(env, sstr.str());
|
||||
}
|
||||
|
|
|
@ -129,7 +129,7 @@ Java_com_mapswithme_maps_editor_OsmOAuth_nativeUpdateOsmUserStats(JNIEnv * env,
|
|||
// static void onUserStatsUpdated(UserStats stats)
|
||||
static jmethodID const listenerId = jni::GetStaticMethodID(env, osmAuthClazz, "onUserStatsUpdated", "(Lcom/mapswithme/maps/editor/data/UserStats;)V");
|
||||
|
||||
string const username = jni::ToNativeString(env, jUsername);
|
||||
std::string const username = jni::ToNativeString(env, jUsername);
|
||||
auto const policy = forceUpdate ? editor::UserStatsLoader::UpdatePolicy::Force
|
||||
: editor::UserStatsLoader::UpdatePolicy::Lazy;
|
||||
g_framework->NativeFramework()->UpdateUserStats(username, policy, [username]()
|
||||
|
@ -138,7 +138,7 @@ Java_com_mapswithme_maps_editor_OsmOAuth_nativeUpdateOsmUserStats(JNIEnv * env,
|
|||
if (!userStats.IsValid())
|
||||
return;
|
||||
int32_t count, rank;
|
||||
string levelUp;
|
||||
std::string levelUp;
|
||||
userStats.GetChangesCount(count);
|
||||
userStats.GetRank(rank);
|
||||
userStats.GetLevelUpRequiredFeat(levelUp);
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
#include "drape/oglcontext.hpp"
|
||||
|
||||
#include <GLES2/gl2.h>
|
||||
#include <EGL/egl.h>
|
||||
#include <GLES2/gl2.h>
|
||||
|
||||
namespace android
|
||||
{
|
||||
|
|
|
@ -4,11 +4,11 @@
|
|||
#include "base/assert.hpp"
|
||||
#include "base/logging.hpp"
|
||||
|
||||
#include "std/algorithm.hpp"
|
||||
#include <algorithm>
|
||||
|
||||
#include <EGL/egl.h>
|
||||
#include <android/native_window_jni.h>
|
||||
#include <android/native_window.h>
|
||||
#include <android/native_window_jni.h>
|
||||
|
||||
namespace android
|
||||
{
|
||||
|
@ -241,7 +241,7 @@ bool AndroidOGLContextFactory::createWindowSurface()
|
|||
}
|
||||
ASSERT(count > 0, ("Didn't find any configs."));
|
||||
|
||||
sort(&configs[0], &configs[count], ConfigComparator(m_display));
|
||||
std::sort(&configs[0], &configs[count], ConfigComparator(m_display));
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
EGLConfig currentConfig = configs[i];
|
||||
|
|
|
@ -10,12 +10,12 @@ private:
|
|||
jobject m_self;
|
||||
|
||||
public:
|
||||
HttpThread(string const & url,
|
||||
HttpThread(std::string const & url,
|
||||
downloader::IHttpThreadCallback & cb,
|
||||
int64_t beg,
|
||||
int64_t end,
|
||||
int64_t expectedFileSize,
|
||||
string const & pb)
|
||||
std::string const & pb)
|
||||
{
|
||||
JNIEnv * env = jni::GetEnv();
|
||||
|
||||
|
@ -26,7 +26,7 @@ public:
|
|||
static jmethodID const startMethodId = env->GetMethodID(klass, "start", "()V");
|
||||
|
||||
// User id is always the same, so do not waste time on every chunk call
|
||||
static string const uniqueUserId = GetPlatform().UniqueClientId();
|
||||
static std::string const uniqueUserId = GetPlatform().UniqueClientId();
|
||||
|
||||
jni::TScopedLocalByteArrayRef postBody(env, nullptr);
|
||||
size_t const postBodySize = pb.size();
|
||||
|
@ -64,12 +64,12 @@ public:
|
|||
|
||||
namespace downloader
|
||||
{
|
||||
HttpThread * CreateNativeHttpThread(string const & url,
|
||||
HttpThread * CreateNativeHttpThread(std::string const & url,
|
||||
downloader::IHttpThreadCallback & cb,
|
||||
int64_t beg,
|
||||
int64_t end,
|
||||
int64_t size,
|
||||
string const & pb)
|
||||
std::string const & pb)
|
||||
{
|
||||
return new HttpThread(url, cb, beg, end, size, pb);
|
||||
}
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
#include "base/logging.hpp"
|
||||
#include "base/string_utils.hpp"
|
||||
|
||||
#include "std/string.hpp"
|
||||
#include <string>
|
||||
|
||||
string ReplaceDeprecatedLanguageCode(string const & lang)
|
||||
std::string ReplaceDeprecatedLanguageCode(std::string const & lang)
|
||||
{
|
||||
// in* -> id
|
||||
// iw* -> he
|
||||
|
@ -22,7 +22,7 @@ string ReplaceDeprecatedLanguageCode(string const & lang)
|
|||
}
|
||||
|
||||
/// This function is called from native c++ code
|
||||
string GetAndroidSystemLanguage()
|
||||
std::string GetAndroidSystemLanguage()
|
||||
{
|
||||
static char const * DEFAULT_LANG = "en";
|
||||
|
||||
|
@ -40,7 +40,7 @@ string GetAndroidSystemLanguage()
|
|||
jni::TScopedLocalRef localeInstance(env, env->CallStaticObjectMethod(localeClass, localeGetDefaultId));
|
||||
jni::TScopedLocalRef langString(env, env->CallObjectMethod(localeInstance.get(), localeToStringId));
|
||||
|
||||
string res = jni::ToNativeString(env, (jstring) langString.get());
|
||||
std::string res = jni::ToNativeString(env, (jstring) langString.get());
|
||||
if (res.empty())
|
||||
res = DEFAULT_LANG;
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#include "../core/jni_helper.hpp"
|
||||
|
||||
#include "std/string.hpp"
|
||||
#include <string>
|
||||
|
||||
/// More details about deprecated language codes http://developer.android.com/reference/java/util/Locale.html
|
||||
string ReplaceDeprecatedLanguageCode(string const & language);
|
||||
std::string ReplaceDeprecatedLanguageCode(std::string const & language);
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
#include "Platform.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
void MarketingService::SendPushWooshTag(string const & tag)
|
||||
{
|
||||
SendPushWooshTag(tag, vector<string>{"1"});
|
||||
|
|
|
@ -7,24 +7,24 @@
|
|||
#include "base/logging.hpp"
|
||||
#include "base/stl_add.hpp"
|
||||
|
||||
#include "std/algorithm.hpp"
|
||||
#include <algorithm>
|
||||
|
||||
|
||||
string Platform::UniqueClientId() const
|
||||
std::string Platform::UniqueClientId() const
|
||||
{
|
||||
JNIEnv * env = jni::GetEnv();
|
||||
static jmethodID const getInstallationId = jni::GetStaticMethodID(env, g_utilsClazz, "getInstallationId",
|
||||
"()Ljava/lang/String;");
|
||||
static jstring const installationId = (jstring)env->CallStaticObjectMethod(g_utilsClazz, getInstallationId);
|
||||
static string const result = jni::ToNativeString(env, installationId);
|
||||
static std::string const result = jni::ToNativeString(env, installationId);
|
||||
return result;
|
||||
}
|
||||
|
||||
string Platform::GetMemoryInfo() const
|
||||
std::string Platform::GetMemoryInfo() const
|
||||
{
|
||||
JNIEnv * env = jni::GetEnv();
|
||||
if (env == nullptr)
|
||||
return string();
|
||||
return std::string();
|
||||
|
||||
static shared_ptr<jobject> classMemLogging = jni::make_global_ref(env->FindClass("com/mapswithme/util/log/MemLogging"));
|
||||
ASSERT(classMemLogging, ());
|
||||
|
@ -69,8 +69,8 @@ namespace android
|
|||
m_sendPushWooshTagsMethod = env->GetMethodID(functorProcessClass, "sendPushWooshTags", "(Ljava/lang/String;[Ljava/lang/String;)V");
|
||||
m_myTrackerTrackMethod = env->GetStaticMethodID(g_myTrackerClazz, "trackEvent", "(Ljava/lang/String;)V");
|
||||
|
||||
string const flavor = jni::ToNativeString(env, flavorName);
|
||||
string const build = jni::ToNativeString(env, buildType);
|
||||
std::string const flavor = jni::ToNativeString(env, flavorName);
|
||||
std::string const build = jni::ToNativeString(env, buildType);
|
||||
LOG(LINFO, ("Flavor name:", flavor));
|
||||
LOG(LINFO, ("Build type name:", build));
|
||||
|
||||
|
@ -88,7 +88,7 @@ namespace android
|
|||
m_tmpDir = jni::ToNativeString(env, tmpPath);
|
||||
m_writableDir = jni::ToNativeString(env, storagePath);
|
||||
|
||||
string const obbPath = jni::ToNativeString(env, obbGooglePath);
|
||||
std::string const obbPath = jni::ToNativeString(env, obbGooglePath);
|
||||
Platform::FilesList files;
|
||||
GetFilesByExt(obbPath, ".obb", files);
|
||||
m_extResFiles.clear();
|
||||
|
@ -116,7 +116,7 @@ namespace android
|
|||
{
|
||||
}
|
||||
|
||||
string Platform::GetStoragePathPrefix() const
|
||||
std::string Platform::GetStoragePathPrefix() const
|
||||
{
|
||||
size_t const count = m_writableDir.size();
|
||||
ASSERT_GREATER ( count, 2, () );
|
||||
|
@ -127,14 +127,14 @@ namespace android
|
|||
return m_writableDir.substr(0, i);
|
||||
}
|
||||
|
||||
void Platform::SetWritableDir(string const & dir)
|
||||
void Platform::SetWritableDir(std::string const & dir)
|
||||
{
|
||||
m_writableDir = dir;
|
||||
settings::Set("StoragePath", m_writableDir);
|
||||
LOG(LINFO, ("Writable path = ", m_writableDir));
|
||||
}
|
||||
|
||||
void Platform::SetSettingsDir(string const & dir)
|
||||
void Platform::SetSettingsDir(std::string const & dir)
|
||||
{
|
||||
m_settingsDir = dir;
|
||||
LOG(LINFO, ("Settings path = ", m_settingsDir));
|
||||
|
@ -158,7 +158,7 @@ namespace android
|
|||
jni::GetEnv()->CallVoidMethod(m_functorProcessObject, m_functorProcessMethod, reinterpret_cast<jlong>(functor));
|
||||
}
|
||||
|
||||
void Platform::SendPushWooshTag(string const & tag, vector<string> const & values)
|
||||
void Platform::SendPushWooshTag(std::string const & tag, std::vector<std::string> const & values)
|
||||
{
|
||||
if (values.empty())
|
||||
return;
|
||||
|
@ -169,10 +169,10 @@ namespace android
|
|||
jni::TScopedLocalObjectArrayRef(env, jni::ToJavaStringArray(env, values)).get());
|
||||
}
|
||||
|
||||
void Platform::SendMarketingEvent(string const & tag, map<string, string> const & params)
|
||||
void Platform::SendMarketingEvent(std::string const & tag, std::map<std::string, std::string> const & params)
|
||||
{
|
||||
JNIEnv * env = jni::GetEnv();
|
||||
string eventData = tag;
|
||||
std::string eventData = tag;
|
||||
for (auto const & item : params)
|
||||
eventData.append("_" + item.first + "_" + item.second);
|
||||
|
||||
|
|
|
@ -21,16 +21,16 @@ namespace android
|
|||
void OnExternalStorageStatusChanged(bool isAvailable);
|
||||
|
||||
/// get storage path without ending "/MapsWithMe/"
|
||||
string GetStoragePathPrefix() const;
|
||||
std::string GetStoragePathPrefix() const;
|
||||
/// assign storage path (should contain ending "/MapsWithMe/")
|
||||
void SetWritableDir(string const & dir);
|
||||
void SetSettingsDir(string const & dir);
|
||||
void SetWritableDir(std::string const & dir);
|
||||
void SetSettingsDir(std::string const & dir);
|
||||
|
||||
bool HasAvailableSpaceForWriting(uint64_t size) const;
|
||||
void RunOnGuiThread(TFunctor const & fn);
|
||||
|
||||
void SendPushWooshTag(string const & tag, vector<string> const & values);
|
||||
void SendMarketingEvent(string const & tag, map<string, string> const & params);
|
||||
void SendPushWooshTag(std::string const & tag, std::vector<std::string> const & values);
|
||||
void SendMarketingEvent(std::string const & tag, std::map<std::string, std::string> const & params);
|
||||
|
||||
static Platform & Instance();
|
||||
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
#include "../core/jni_helper.hpp"
|
||||
|
||||
#include "platform/socket.hpp"
|
||||
|
||||
#include "base/logging.hpp"
|
||||
#include "base/stl_add.hpp"
|
||||
|
||||
namespace platform
|
||||
{
|
||||
|
@ -23,7 +26,7 @@ public:
|
|||
env->DeleteGlobalRef(m_self);
|
||||
}
|
||||
|
||||
bool Open(string const & host, uint16_t port)
|
||||
bool Open(std::string const & host, uint16_t port)
|
||||
{
|
||||
JNIEnv * env = jni::GetEnv();
|
||||
static jmethodID const openMethod =
|
||||
|
@ -83,5 +86,5 @@ private:
|
|||
jobject m_self;
|
||||
};
|
||||
|
||||
unique_ptr<Socket> CreateSocket() { return make_unique<SocketImpl>(); }
|
||||
std::unique_ptr<Socket> CreateSocket() { return my::make_unique<SocketImpl>(); }
|
||||
}
|
||||
|
|
|
@ -76,7 +76,7 @@ extern "C"
|
|||
JNIEXPORT jstring JNICALL
|
||||
Java_com_mapswithme_util_Config_nativeGetString(JNIEnv * env, jclass thiz, jstring name, jstring defaultValue)
|
||||
{
|
||||
string value;
|
||||
std::string value;
|
||||
if (settings::Get(jni::ToNativeString(env, name), value))
|
||||
return jni::ToJavaString(env, value);
|
||||
|
||||
|
|
|
@ -33,8 +33,8 @@ SOFTWARE.
|
|||
#include "base/exception.hpp"
|
||||
#include "base/logging.hpp"
|
||||
|
||||
#include "std/string.hpp"
|
||||
#include "std/unordered_map.hpp"
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
DECLARE_EXCEPTION(JniException, RootException);
|
||||
|
||||
|
@ -57,7 +57,7 @@ jfieldID GetHttpParamsFieldId(ScopedEnv & env, const char * name,
|
|||
}
|
||||
|
||||
// Set string value to HttpClient.Params object, throws JniException and
|
||||
void SetString(ScopedEnv & env, jobject params, jfieldID const fieldId, string const & value)
|
||||
void SetString(ScopedEnv & env, jobject params, jfieldID const fieldId, std::string const & value)
|
||||
{
|
||||
if (value.empty())
|
||||
return;
|
||||
|
@ -76,7 +76,7 @@ void SetBoolean(ScopedEnv & env, jobject params, jfieldID const fieldId, bool co
|
|||
}
|
||||
|
||||
// Get string value from HttpClient.Params object, throws JniException.
|
||||
void GetString(ScopedEnv & env, jobject const params, jfieldID const fieldId, string & result)
|
||||
void GetString(ScopedEnv & env, jobject const params, jfieldID const fieldId, std::string & result)
|
||||
{
|
||||
jni::ScopedLocalRef<jstring> const wrappedValue(
|
||||
env.get(), static_cast<jstring>(env->GetObjectField(params, fieldId)));
|
||||
|
@ -92,7 +92,7 @@ void GetInt(ScopedEnv & env, jobject const params, jfieldID const fieldId, int &
|
|||
}
|
||||
|
||||
void SetHeaders(ScopedEnv & env, jobject const params,
|
||||
unordered_map<string, string> const & headers)
|
||||
std::unordered_map<std::string, std::string> const & headers)
|
||||
{
|
||||
if (headers.empty())
|
||||
return;
|
||||
|
@ -104,7 +104,7 @@ void SetHeaders(ScopedEnv & env, jobject const params,
|
|||
|
||||
RethrowOnJniException(env);
|
||||
|
||||
using HeaderPair = unordered_map<string, string>::value_type;
|
||||
using HeaderPair = std::unordered_map<std::string, std::string>::value_type;
|
||||
env->CallVoidMethod(
|
||||
params, setHeaders,
|
||||
jni::ToJavaArray(env.get(), g_httpHeaderClazz, headers, [](JNIEnv * env,
|
||||
|
@ -116,7 +116,7 @@ void SetHeaders(ScopedEnv & env, jobject const params,
|
|||
RethrowOnJniException(env);
|
||||
}
|
||||
|
||||
void LoadHeaders(ScopedEnv & env, jobject const params, unordered_map<string, string> & headers)
|
||||
void LoadHeaders(ScopedEnv & env, jobject const params, std::unordered_map<std::string, std::string> & headers)
|
||||
{
|
||||
static jmethodID const getHeaders =
|
||||
env->GetMethodID(g_httpParamsClazz, "getHeaders", "()[Ljava/lang/Object;");
|
||||
|
@ -162,7 +162,7 @@ public:
|
|||
{"httpResponseCode", GetHttpParamsFieldId(env, "httpResponseCode", "I")}};
|
||||
}
|
||||
|
||||
jfieldID GetId(string const & fieldName) const
|
||||
jfieldID GetId(std::string const & fieldName) const
|
||||
{
|
||||
auto const it = m_fieldIds.find(fieldName);
|
||||
CHECK(it != m_fieldIds.end(), ("Incorrect field name:", fieldName));
|
||||
|
@ -170,7 +170,7 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
unordered_map<string, jfieldID> m_fieldIds;
|
||||
std::unordered_map<std::string, jfieldID> m_fieldIds;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
|
|
|
@ -22,13 +22,13 @@ Java_com_mapswithme_util_StringUtils_nativeContainsNormalized(JNIEnv * env, jcla
|
|||
JNIEXPORT jobjectArray JNICALL
|
||||
Java_com_mapswithme_util_StringUtils_nativeFilterContainsNormalized(JNIEnv * env, jclass thiz, jobjectArray src, jstring jSubstr)
|
||||
{
|
||||
string substr = jni::ToNativeString(env, jSubstr);
|
||||
std::string substr = jni::ToNativeString(env, jSubstr);
|
||||
int const length = env->GetArrayLength(src);
|
||||
std::vector<string> filtered;
|
||||
std::vector<std::string> filtered;
|
||||
filtered.reserve(length);
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
string str = jni::ToNativeString(env, (jstring) env->GetObjectArrayElement(src, i));
|
||||
std::string str = jni::ToNativeString(env, (jstring) env->GetObjectArrayElement(src, i));
|
||||
if (search::ContainsNormalized(str, substr))
|
||||
filtered.push_back(str);
|
||||
}
|
||||
|
|
Reference in a new issue