diff --git a/android/jni/com/mapswithme/core/jni_helper.cpp b/android/jni/com/mapswithme/core/jni_helper.cpp index b023b8aa39..90e087150d 100644 --- a/android/jni/com/mapswithme/core/jni_helper.cpp +++ b/android/jni/com/mapswithme/core/jni_helper.cpp @@ -10,7 +10,6 @@ void InitNVEvent(JavaVM * jvm); extern "C" { - JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM * jvm, void *) { @@ -27,7 +26,6 @@ extern "C" { g_jvm = 0; } - } // extern "C" @@ -44,8 +42,9 @@ namespace jni return mid; } - string ToString(JNIEnv * env, jstring str) + string ToString(jstring str) { + JNIEnv * env = GetEnv(); string result; char const * utfBuffer = env->GetStringUTFChars(str, 0); if (utfBuffer) diff --git a/android/jni/com/mapswithme/core/jni_helper.hpp b/android/jni/com/mapswithme/core/jni_helper.hpp index 48b33374dc..1fad23ea92 100644 --- a/android/jni/com/mapswithme/core/jni_helper.hpp +++ b/android/jni/com/mapswithme/core/jni_helper.hpp @@ -11,7 +11,7 @@ namespace jni // "()V" - void function returning void; // "(Ljava/lang/String;)V" - String function returning void; jmethodID GetJavaMethodID(JNIEnv * env, jobject obj, char const * fn, char const * sig); - string ToString(JNIEnv * env, jstring str); + string ToString(jstring str); JNIEnv * GetEnv(); JavaVM * GetJVM(); diff --git a/android/jni/com/mapswithme/maps/DownloadResourcesActivity.cpp b/android/jni/com/mapswithme/maps/DownloadResourcesActivity.cpp index fa320c0ec4..e9001646da 100644 --- a/android/jni/com/mapswithme/maps/DownloadResourcesActivity.cpp +++ b/android/jni/com/mapswithme/maps/DownloadResourcesActivity.cpp @@ -11,6 +11,8 @@ #include "../../../../../coding/zip_reader.hpp" #include "../../../../../coding/url_encode.hpp" +#include "../../../../../coding/reader_streambuf.hpp" +#include "../../../../../coding/internal/file_data.hpp" #include "../../../../../platform/platform.hpp" #include "../../../../../platform/http_request.hpp" @@ -68,26 +70,14 @@ extern "C" Java_com_mapswithme_maps_DownloadResourcesActivity_nativeGetBytesToDownload(JNIEnv * env, jobject thiz, jstring apkPath, jstring sdcardPath) { - { - char const * strApkPath = env->GetStringUTFChars(apkPath, 0); - if (!strApkPath) - return ERR_NOT_ENOUGH_MEMORY; - g_apkPath = strApkPath; - env->ReleaseStringUTFChars(apkPath, strApkPath); - - char const * strSdcardPath = env->GetStringUTFChars(sdcardPath, 0); - if (!strSdcardPath) - return ERR_NOT_ENOUGH_MEMORY; - g_sdcardPath = strSdcardPath; - env->ReleaseStringUTFChars(sdcardPath, strSdcardPath); - } + g_apkPath = jni::ToString(apkPath); + g_sdcardPath = jni::ToString(sdcardPath); jint totalBytesToDownload = 0; - string buffer; - ReaderPtr(GetPlatform().GetReader("external_resources.txt")).ReadAsString(buffer); + ReaderStreamBuf buffer(GetPlatform().GetReader("external_resources.txt")); - stringstream in(buffer); + istream in(&buffer); string name; int size; @@ -144,7 +134,7 @@ extern "C" { int errorCode = 0; - CHECK(req.Status() != downloader::HttpRequest::EInProgress, ("should be either Completed or Failed")); + ASSERT(req.Status() != downloader::HttpRequest::EInProgress, ("should be either Completed or Failed")); switch (req.Status()) { @@ -158,7 +148,7 @@ extern "C" FileToDownload & curFile = g_filesToDownload.back(); - LOG(LINFO, ("finished downloading", curFile.m_fileName, "sized", curFile.m_fileSize, "bytes")); + LOG(LDEBUG, ("finished downloading", curFile.m_fileName, "sized", curFile.m_fileSize, "bytes")); /// slight hack, check manually for Maps extension and AddMap accordingly if (curFile.m_fileName.find(".mwm") != string::npos) @@ -169,26 +159,26 @@ extern "C" g_totalDownloadedBytes += curFile.m_fileSize; - LOG(LINFO, ("totalDownloadedBytes:", g_totalDownloadedBytes)); + LOG(LDEBUG, ("totalDownloadedBytes:", g_totalDownloadedBytes)); g_filesToDownload.pop_back(); JNIEnv * env = jni::GetEnv(); jmethodID onFinishMethod = env->GetMethodID(env->GetObjectClass(*obj.get()), "onDownloadFinished", "(I)V"); - CHECK(onFinishMethod, ("Not existing method: void onDownloadFinished(int)")); + ASSERT(onFinishMethod, ("Not existing method: void onDownloadFinished(int)")); env->CallVoidMethod(*obj.get(), onFinishMethod, errorCode); } void DownloadFileProgress(shared_ptr obj, downloader::HttpRequest & req) { - LOG(LINFO, (req.Progress().first, "bytes for", g_filesToDownload.back().m_fileName, "was downloaded")); + LOG(LDEBUG, (req.Progress().first, "bytes for", g_filesToDownload.back().m_fileName, "was downloaded")); JNIEnv * env = jni::GetEnv(); jmethodID onProgressMethod = env->GetMethodID(env->GetObjectClass(*obj.get()), "onDownloadProgress", "(IIII)V"); - CHECK(onProgressMethod, ("Not existing method: void onDownloadProgress(int, int, int, int)")); + ASSERT(onProgressMethod, ("Not existing method: void onDownloadProgress(int, int, int, int)")); FileToDownload & curFile = g_filesToDownload.back(); @@ -212,7 +202,7 @@ extern "C" { FileToDownload & curFile = g_filesToDownload.back(); - LOG(LINFO, ("finished URL list download for", curFile.m_fileName)); + LOG(LDEBUG, ("finished URL list download for", curFile.m_fileName)); downloader::ParseServerList(req.Data(), curFile.m_urls); @@ -221,7 +211,7 @@ extern "C" curFile.m_urls[i] = curFile.m_urls[i] + OMIM_OS_NAME "/" + strings::to_string(g_framework->Storage().GetCurrentVersion()) + "/" + UrlEncode(curFile.m_fileName); - LOG(LINFO, (curFile.m_urls[i])); + LOG(LDEBUG, (curFile.m_urls[i])); } downloader::HttpRequest::GetFile(curFile.m_urls, @@ -262,20 +252,8 @@ extern "C" Java_com_mapswithme_maps_DownloadResourcesActivity_nativeMoveMaps(JNIEnv * env, jobject thiz, jstring fromPath, jstring toPath) { - string from, to; - { - char const * strFrom = env->GetStringUTFChars(fromPath, 0); - if (!strFrom) - return; - from = strFrom; - env->ReleaseStringUTFChars(fromPath, strFrom); - - char const * strTo = env->GetStringUTFChars(toPath, 0); - if (!strTo) - return; - to = strTo; - env->ReleaseStringUTFChars(toPath, strTo); - } + string from = jni::ToString(fromPath); + string to = jni::ToString(toPath); Platform & pl = GetPlatform(); Platform::FilesList files; @@ -283,8 +261,8 @@ extern "C" pl.GetFilesInDir(from, "*" DATA_FILE_EXTENSION, files); for (size_t i = 0; i < files.size(); ++i) { - LOG(LINFO, (from + files[i], to + files[i])); - rename((from + files[i]).c_str(), (to + files[i]).c_str()); + LOG(LDEBUG, ("moving map from:", from + files[i], ", to:", to + files[i])); + my::RenameFileX((from + files[i]).c_str(), (to + files[i]).c_str()); } // Delete not finished *.downloading files @@ -292,7 +270,7 @@ extern "C" pl.GetFilesInDir(from, "*" DOWNLOADING_FILE_EXTENSION, files); pl.GetFilesInDir(from, "*" RESUME_FILE_EXTENSION, files); for (size_t i = 0; i < files.size(); ++i) - remove((from + files[i]).c_str()); + my::DeleteFileX((from + files[i]).c_str()); } JNIEXPORT jstring JNICALL diff --git a/android/jni/com/mapswithme/maps/MWMApplication.cpp b/android/jni/com/mapswithme/maps/MWMApplication.cpp index a5f47d8d64..295904bf19 100644 --- a/android/jni/com/mapswithme/maps/MWMApplication.cpp +++ b/android/jni/com/mapswithme/maps/MWMApplication.cpp @@ -33,6 +33,6 @@ extern "C" if (!g_framework) g_framework = new android::Framework(); - g_framework->SetEmptyModelMessage(jni::ToString(env, emptyModelMessage)); + g_framework->SetEmptyModelMessage(jni::ToString(emptyModelMessage)); } } diff --git a/android/jni/com/mapswithme/maps/MapStorage.cpp b/android/jni/com/mapswithme/maps/MapStorage.cpp index ac811cd7fa..8be71f8fdb 100644 --- a/android/jni/com/mapswithme/maps/MapStorage.cpp +++ b/android/jni/com/mapswithme/maps/MapStorage.cpp @@ -35,12 +35,12 @@ extern "C" int country() const { - return jni::GetEnv()->GetIntField(*m_self.get(), m_groupID); + return jni::GetEnv()->GetIntField(*m_self.get(), m_countryID); } int region() const { - return jni::GetEnv()->GetIntField(*m_self.get(), m_groupID); + return jni::GetEnv()->GetIntField(*m_self.get(), m_regionID); } storage::TIndex const toNative() const @@ -50,15 +50,15 @@ extern "C" static jobject toJava(storage::TIndex const & idx) { - LOG(LINFO, ("constructing Java Index object from ", idx.m_group, idx.m_country, idx.m_region)); + LOG(LDEBUG, ("constructing Java Index object from ", idx.m_group, idx.m_country, idx.m_region)); JNIEnv * env = jni::GetEnv(); jclass klass = env->FindClass("com/mapswithme/maps/MapStorage$Index"); - CHECK(klass, ("Can't find java class com/mapswithme/maps/MapStorage$Index")); + ASSERT(klass, ("Can't find java class com/mapswithme/maps/MapStorage$Index")); jmethodID methodId = env->GetMethodID(klass, "", "(III)V"); - CHECK(methodId, ("Can't find java constructor in com/mapswithme/maps/MapStorage$Index")); + ASSERT(methodId, ("Can't find java constructor in com/mapswithme/maps/MapStorage$Index")); return env->NewObject(klass, methodId, idx.m_group, idx.m_country, idx.m_region); } diff --git a/android/jni/com/mapswithme/platform/Platform.cpp b/android/jni/com/mapswithme/platform/Platform.cpp index 5b5af670eb..48a962bd8f 100644 --- a/android/jni/com/mapswithme/platform/Platform.cpp +++ b/android/jni/com/mapswithme/platform/Platform.cpp @@ -12,10 +12,8 @@ class Platform::PlatformImpl { public: - PlatformImpl() - { - m_preCachingDepth = 3; - } + PlatformImpl() : m_preCachingDepth(3) + {} size_t m_preCachingDepth; }; @@ -87,12 +85,12 @@ namespace android m_impl = new PlatformImpl(); - m_resourcesDir = jni::ToString(env, apkPath); - m_writableDir = jni::ToString(env, storagePath); - m_settingsDir = jni::ToString(env, settingsPath); + m_resourcesDir = jni::ToString(apkPath); + m_writableDir = jni::ToString(storagePath); + m_settingsDir = jni::ToString(settingsPath); - m_localTmpPath = jni::ToString(env, tmpPath); - m_externalTmpPath = jni::ToString(env, extTmpPath); + m_localTmpPath = jni::ToString(tmpPath); + m_externalTmpPath = jni::ToString(extTmpPath); // By default use external temporary folder m_tmpDir = m_externalTmpPath; diff --git a/android/res/layout/download_resources.xml b/android/res/layout/download_resources.xml index 57c88308ee..5e99bcafa0 100644 --- a/android/res/layout/download_resources.xml +++ b/android/res/layout/download_resources.xml @@ -51,7 +51,7 @@ android:layout_gravity="center" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:text="Download" + android:text="@string/download" android:onClick="onDownloadClicked" /> @@ -64,7 +64,7 @@ android:layout_gravity="center" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:text="Cancel" + android:text="@string/cancel" android:onClick="onCancelClicked" android:visibility="gone" /> @@ -88,7 +88,7 @@ android:textSize="12sp" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:text="Try Again" + android:text="@string/try_again" android:onClick="onTryAgainClicked" android:visibility="gone" /> @@ -119,7 +119,7 @@ android:id="@+id/download_country_checkbox" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:text="@string/download_country" + android:text="@string/download_country_ask" android:visibility="gone" /> diff --git a/android/res/values-de/strings.xml b/android/res/values-de/strings.xml index 1e80991180..8e4ad31a22 100644 --- a/android/res/values-de/strings.xml +++ b/android/res/values-de/strings.xml @@ -23,4 +23,5 @@ Um die Karte dieses Ortes\nherunterzuladen, berühren Sie\n bitte die Taste in der unteren\n Hälfte des Bildschirms Das Programm braucht OpenGL um funktionnieren zu können. Leider wird ihr Gerät nicht unterschtüzt. Karte + Herunterladen diff --git a/android/res/values-es/strings.xml b/android/res/values-es/strings.xml index d1479a7ac7..b88bf02cd9 100644 --- a/android/res/values-es/strings.xml +++ b/android/res/values-es/strings.xml @@ -24,4 +24,5 @@ Un hardware aceleró OpenGL se requiere. Desgraciadamente, el dispositivo móvil no es compatible. Carga de MapsWithMe... Mapa + Descargar diff --git a/android/res/values-fr/strings.xml b/android/res/values-fr/strings.xml index 87ef44a891..1f35ec3f3a 100644 --- a/android/res/values-fr/strings.xml +++ b/android/res/values-fr/strings.xml @@ -24,4 +24,5 @@ Le programme a besoin d`OpenGL pour travailler. Votre appareil n`est pas appuyé maleuresement. Chargement MapsWithMe... Carte + Charger diff --git a/android/res/values-ru/strings.xml b/android/res/values-ru/strings.xml index 04b5253141..577c35380d 100644 --- a/android/res/values-ru/strings.xml +++ b/android/res/values-ru/strings.xml @@ -32,7 +32,11 @@ Для загрузки %2$s нужно %1$s свободного места Карта Для запуска программы нужно загрузить\n %1$.3f%2$s необходимых ресурсов. - Загрузить ? Получаем местоположение Перейти на карту + Пока загружается %s \nвы можете пользоваться приложением. + Загрузить %d? + Загрузить + Отменить + Попробовать еще раз diff --git a/android/res/values/strings.xml b/android/res/values/strings.xml index b149d12d92..e4bb5ef019 100644 --- a/android/res/values/strings.xml +++ b/android/res/values/strings.xml @@ -32,8 +32,11 @@ Please free %1$s on your device first in order to download %2$s Map Program needs to download \n%1$.1f%2$s of mandatory resources. - Download %s? - Getting current position Go to map + Downloading %s. You can now\n"proceed to the map. + Download %s? + Download + Cancel + Try again diff --git a/android/src/com/mapswithme/maps/DownloadResourcesActivity.java b/android/src/com/mapswithme/maps/DownloadResourcesActivity.java index acbd28b0db..faff745cb3 100644 --- a/android/src/com/mapswithme/maps/DownloadResourcesActivity.java +++ b/android/src/com/mapswithme/maps/DownloadResourcesActivity.java @@ -82,7 +82,7 @@ public class DownloadResourcesActivity extends Activity implements LocationServi private void setDownloadMessage(int bytesToDownload) { - Log.w(TAG, "prepareFilesDownload, bytesToDownload:" + bytesToDownload); + Log.d(TAG, "prepareFilesDownload, bytesToDownload:" + bytesToDownload); if (bytesToDownload < 1024 * 1024) mMsgView.setText(String.format(getString(R.string.download_resources), @@ -181,13 +181,13 @@ public class DownloadResourcesActivity extends Activity implements LocationServi enableAutomaticStandby(); if (result == ERR_NO_MORE_FILES) { - Log.w(TAG, "finished files download"); + Log.i(TAG, "finished files download"); if (mHasLocation && mDownloadCountryCheckBox.isChecked()) { mDownloadCountryCheckBox.setVisibility(View.GONE); - mMsgView.setText("Downloading " + mCountryName + ". You can now\n" + - "proceed to the map"); + mMsgView.setText(String.format(getString(R.string.downloading_country_can_proceed), + mCountryName)); MapStorage.Index idx = mMapStorage.findIndexByName(mCountryName); @@ -281,7 +281,7 @@ public class DownloadResourcesActivity extends Activity implements LocationServi public void onDownloadProgress(int currentTotal, int currentProgress, int globalTotal, int globalProgress) { - Log.w(TAG, "curTotal:" + currentTotal + ", curProgress:" + currentProgress + Log.d(TAG, "curTotal:" + currentTotal + ", curProgress:" + currentProgress + ", glbTotal:" + globalTotal + ", glbProgress:" + globalProgress); if (mProgress != null) @@ -322,18 +322,18 @@ public class DownloadResourcesActivity extends Activity implements LocationServi CheckBox checkBox = (CheckBox)findViewById(R.id.download_country_checkbox); - Log.w(TAG, "Location : " + lat + ", " + lon); + Log.i(TAG, "Searching for country name at location lat=" + lat + ", lon=" + lon); checkBox.setVisibility(View.VISIBLE); mCountryName = nativeGetCountryName(lat, lon); mHasLocation = true; - checkBox.setText(String.format(getString(R.string.download_country), mCountryName)); + checkBox.setText(String.format(getString(R.string.download_country_ask), mCountryName)); mLocationService.stopUpdate(this); mLocationService = null; } - Log.w(TAG, "tryCount:" + mLocationsCount); + Log.d(TAG, "tryCount:" + mLocationsCount); ++mLocationsCount; } } diff --git a/platform/platform_android.cpp b/platform/platform_android.cpp index 64b8620223..5d7987de64 100644 --- a/platform/platform_android.cpp +++ b/platform/platform_android.cpp @@ -108,7 +108,7 @@ string Platform::DeviceName() const void Platform::GetFontNames(FilesList & res) const { - LOG(LINFO, ("searching for font in", WritableDir())); + LOG(LDEBUG, ("searching for fonts in:", WritableDir())); GetFilesInDir(WritableDir(), "*.ttf", res); sort(res.begin(), res.end()); }