From e0fdc8467292d77b0ddaeb9e474fcb8e3b8d3a2b Mon Sep 17 00:00:00 2001 From: Dmitry Yunitsky Date: Sun, 10 Aug 2014 16:48:57 +0300 Subject: [PATCH] Lite maps transfer fix. --- android/jni/com/mapswithme/maps/MapStorage.cpp | 7 +++++++ android/src/com/mapswithme/maps/MWMActivity.java | 10 +--------- android/src/com/mapswithme/maps/MapStorage.java | 1 + .../mapswithme/maps/settings/StoragePathManager.java | 6 +++++- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/android/jni/com/mapswithme/maps/MapStorage.cpp b/android/jni/com/mapswithme/maps/MapStorage.cpp index fccab8515f..cd39d25624 100644 --- a/android/jni/com/mapswithme/maps/MapStorage.cpp +++ b/android/jni/com/mapswithme/maps/MapStorage.cpp @@ -1,6 +1,7 @@ #include "MapStorage.hpp" #include "Framework.hpp" +#include "../../../../../coding/internal/file_data.hpp" extern "C" { @@ -161,6 +162,12 @@ extern "C" env->SetObjectArrayElement(ret, i, env->NewStringUTF(v[i].c_str())); return ret; } + + JNIEXPORT jboolean JNICALL + Java_com_mapswithme_maps_MapStorage_nativeMoveFile(JNIEnv * env, jobject thiz, jstring oldFile, jstring newFile) + { + return my::RenameFileX(jni::ToNativeString(env, oldFile), jni::ToNativeString(env, newFile)); + } } namespace storage diff --git a/android/src/com/mapswithme/maps/MWMActivity.java b/android/src/com/mapswithme/maps/MWMActivity.java index 24766fff3d..3fa61dd4d1 100644 --- a/android/src/com/mapswithme/maps/MWMActivity.java +++ b/android/src/com/mapswithme/maps/MWMActivity.java @@ -96,7 +96,6 @@ public class MWMActivity extends NvEventQueueActivity private static final String IS_KML_MOVED = "KmlBeenMoved"; private static final String IS_KITKAT_MIGRATION_COMPLETED = "KitKatMigrationCompleted"; - private static final String ARE_LITE_MAPS_MOVED = "MapsMovedFromLite"; public static Intent createShowMapIntent(Context context, Index index, boolean doAutoDownload) { @@ -403,18 +402,12 @@ public class MWMActivity extends NvEventQueueActivity */ private void checkLiteMapsInPro() { - final boolean areLiteMapsMoved = MWMApplication.get().nativeGetBoolean(ARE_LITE_MAPS_MOVED, false); - - if (!areLiteMapsMoved && - Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && mApplication.isProVersion() && (Utils.isAppInstalled(Constants.Package.MWM_LITE_PACKAGE) || Utils.isAppInstalled(Constants.Package.MWM_SAMSUNG_PACKAGE))) { if (!mPathManager.containsLiteMapsOnSdcard()) - { - MWMApplication.get().nativeSetBoolean(ARE_LITE_MAPS_MOVED, true); return; - } mPathManager.moveMapsLiteToPro(this, new SetStoragePathListener() @@ -422,7 +415,6 @@ public class MWMActivity extends NvEventQueueActivity @Override public void moveFilesFinished(String newPath) { - mApplication.nativeSetBoolean(ARE_LITE_MAPS_MOVED, true); ShowAlertDlg(R.string.move_lite_maps_to_pro_ok); } diff --git a/android/src/com/mapswithme/maps/MapStorage.java b/android/src/com/mapswithme/maps/MapStorage.java index 359d670528..22f19697d5 100644 --- a/android/src/com/mapswithme/maps/MapStorage.java +++ b/android/src/com/mapswithme/maps/MapStorage.java @@ -160,6 +160,7 @@ public class MapStorage private native String[] nativeGetMapsWithoutSearch(); + public static native boolean nativeMoveFile(String oldFile, String newFile); public MapStorage() { diff --git a/android/src/com/mapswithme/maps/settings/StoragePathManager.java b/android/src/com/mapswithme/maps/settings/StoragePathManager.java index ae69e94eaa..42ec28d509 100644 --- a/android/src/com/mapswithme/maps/settings/StoragePathManager.java +++ b/android/src/com/mapswithme/maps/settings/StoragePathManager.java @@ -16,6 +16,7 @@ import android.util.Log; import com.mapswithme.maps.Framework; import com.mapswithme.maps.MWMApplication; +import com.mapswithme.maps.MapStorage; import com.mapswithme.maps.R; import com.mapswithme.util.Constants; import com.mapswithme.util.Utils; @@ -429,7 +430,10 @@ public class StoragePathManager try { for (File moveFile : internalFiles) - copyFile(moveFile, new File(fullNewPath + moveFile.getName())); + { + if (!MapStorage.nativeMoveFile(moveFile.getAbsolutePath(), fullNewPath + moveFile.getName())) + copyFile(moveFile, new File(fullNewPath + moveFile.getName())); + } } catch (IOException e) { for (File moveFile : internalFiles)