From 49154d7ea7b7424945c86fc7dd22036505ca2ad9 Mon Sep 17 00:00:00 2001 From: "r.kuznetsov" Date: Tue, 8 Aug 2017 18:59:52 +0300 Subject: [PATCH] Added deleting saved route points. --- android/jni/com/mapswithme/maps/Framework.cpp | 6 ++++++ android/src/com/mapswithme/maps/Framework.java | 1 + map/routing_manager.cpp | 8 ++++++++ map/routing_manager.hpp | 2 ++ 4 files changed, 17 insertions(+) diff --git a/android/jni/com/mapswithme/maps/Framework.cpp b/android/jni/com/mapswithme/maps/Framework.cpp index 7b1c256dd9..cbb5643d1d 100644 --- a/android/jni/com/mapswithme/maps/Framework.cpp +++ b/android/jni/com/mapswithme/maps/Framework.cpp @@ -1450,4 +1450,10 @@ Java_com_mapswithme_maps_Framework_nativeSaveRoutePoints() { frm()->GetRoutingManager().SaveRoutePoints(); } + +JNIEXPORT void JNICALL +Java_com_mapswithme_maps_Framework_nativeDeleteSavedRoutePoints() +{ + frm()->GetRoutingManager().DeleteSavedRoutePoints(); +} } // extern "C" diff --git a/android/src/com/mapswithme/maps/Framework.java b/android/src/com/mapswithme/maps/Framework.java index 80c7b1df32..ec7f236c5c 100644 --- a/android/src/com/mapswithme/maps/Framework.java +++ b/android/src/com/mapswithme/maps/Framework.java @@ -352,4 +352,5 @@ public class Framework public static native boolean nativeHasSavedRoutePoints(); public static native boolean nativeLoadRoutePoints(); public static native void nativeSaveRoutePoints(); + public static native void nativeDeleteSavedRoutePoints(); } diff --git a/map/routing_manager.cpp b/map/routing_manager.cpp index 3bd61cb45f..8910b1bf03 100644 --- a/map/routing_manager.cpp +++ b/map/routing_manager.cpp @@ -1060,3 +1060,11 @@ void RoutingManager::SaveRoutePoints() const LOG(LWARNING, ("Saving road points failed:", ex.Msg())); } } + +void RoutingManager::DeleteSavedRoutePoints() +{ + if (!HasSavedRoutePoints()) + return; + auto const fileName = GetPlatform().SettingsPathForFile(kRoutePointsFile); + FileWriter::DeleteFileX(fileName); +} diff --git a/map/routing_manager.hpp b/map/routing_manager.hpp index 55056c3e2a..38bf06caac 100644 --- a/map/routing_manager.hpp +++ b/map/routing_manager.hpp @@ -228,6 +228,8 @@ public: bool LoadRoutePoints(); /// \brief It saves route points to file. void SaveRoutePoints() const; + /// \brief It deletes file with saved route points if it exists. + void DeleteSavedRoutePoints(); private: void InsertRoute(routing::Route const & route);