diff --git a/OsmAnd/OsmAndCore_androidNativeRelease.aar b/OsmAnd/OsmAndCore_androidNativeRelease.aar new file mode 100644 index 0000000000..20c01affc5 Binary files /dev/null and b/OsmAnd/OsmAndCore_androidNativeRelease.aar differ diff --git a/OsmAnd/src/net/osmand/osm/poi_types.xml b/OsmAnd/src/net/osmand/osm/poi_types.xml new file mode 100644 index 0000000000..abbf8438ed --- /dev/null +++ b/OsmAnd/src/net/osmand/osm/poi_types.xml @@ -0,0 +1,727 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java b/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java index 74053f86c3..904cffc03c 100644 --- a/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java +++ b/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java @@ -324,7 +324,7 @@ public class GpxSelectionHelper { selectedGPXFiles.add(savingTrackHelper.getCurrentTrack()); } } - } catch (JSONException e) { + } catch (Exception e) { app.getSettings().SELECTED_GPX.set(""); e.printStackTrace(); } @@ -337,10 +337,10 @@ public class GpxSelectionHelper { if(s.gpxFile != null && !s.notShowNavigationDialog) { JSONObject obj = new JSONObject(); try { - if(!Algorithms.isEmpty(s.gpxFile.path)) { - obj.put(FILE, s.gpxFile.path); - } else { + if(s.isShowCurrentTrack()) { obj.put(CURRENT_TRACK, true); + } else if(!Algorithms.isEmpty(s.gpxFile.path)) { + obj.put(FILE, s.gpxFile.path); } } catch (JSONException e) { e.printStackTrace(); @@ -410,10 +410,14 @@ public class GpxSelectionHelper { if(gpxFile.tracks.size() > 0) { this.color = gpxFile.tracks.get(0).getColor(0); } + processPoints(); + } + + public void processPoints() { this.processedPointsToDisplay = gpxFile.proccessPoints(); if(this.processedPointsToDisplay.isEmpty()) { this.processedPointsToDisplay = gpxFile.processRoutePoints(); - routePoints = true; + routePoints = !this.processedPointsToDisplay.isEmpty(); } } @@ -437,6 +441,11 @@ public class GpxSelectionHelper { return gpxFile; } + public GPXFile getModifiableGpxFile() { + // call process points after + return gpxFile; + } + public boolean isShowCurrentTrack() { return showCurrentTrack; } diff --git a/OsmAnd/src/net/osmand/plus/OsmandApplication.java b/OsmAnd/src/net/osmand/plus/OsmandApplication.java index daf8f61512..9849d0e834 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandApplication.java +++ b/OsmAnd/src/net/osmand/plus/OsmandApplication.java @@ -592,6 +592,8 @@ public class OsmandApplication extends Application { } catch (RuntimeException e) { warnings.add(e.getMessage()); } + } else { + savingTrackHelper.loadGpxFromDatabase(); } } if(getSettings().SAVE_GLOBAL_TRACK_TO_GPX.get()){ diff --git a/OsmAnd/src/net/osmand/plus/activities/SavingTrackHelper.java b/OsmAnd/src/net/osmand/plus/activities/SavingTrackHelper.java index d2270f93e3..4632d82178 100644 --- a/OsmAnd/src/net/osmand/plus/activities/SavingTrackHelper.java +++ b/OsmAnd/src/net/osmand/plus/activities/SavingTrackHelper.java @@ -373,20 +373,23 @@ public class SavingTrackHelper extends SQLiteOpenHelper { assert track.segments.size() == points.size(); if (points.size() == 0 || newSegment) { points.add(new ArrayList()); + } + if(track.segments.size() == 0 || newSegment) { track.segments.add(new TrkSegment()); } if (pt != null) { int ind = points.size() - 1; List last = points.get(ind); last.add(pt); - track.segments.get(ind).points.add(pt); + TrkSegment lt = track.segments.get(track.segments.size() - 1); + lt.points.add(pt); } } public void insertPointData(double lat, double lon, long time, String description) { final WptPt pt = new WptPt(lat, lon, time, Double.NaN, 0, Double.NaN); pt.name = description; - currentTrack.getGpxFile().points.add(pt); + currentTrack.getModifiableGpxFile().points.add(pt); execWithClose(updatePointsScript, new Object[] { lat, lon, time, description }); } @@ -402,7 +405,16 @@ public class SavingTrackHelper extends SQLiteOpenHelper { } } } - + + public void loadGpxFromDatabase(){ + Map files = collectRecordedData(); + for (Map.Entry entry : files.entrySet()){ + currentTrack.getModifiableGpxFile().points.addAll(entry.getValue().points); + currentTrack.getModifiableGpxFile().tracks.addAll(entry.getValue().tracks); + } + currentTrack.processPoints(); + } + public boolean getIsRecording() { return isRecording; } diff --git a/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java b/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java index 36258a409e..eb3ea19cf5 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java @@ -141,7 +141,8 @@ public class GpxUiHelper { if(showCurrentGpx){ allGpxList.add(0, activity.getString(R.string.show_current_gpx_title)); } - final ContextMenuAdapter adapter = createGpxContextMenuAdapter(activity, allGpxList, selectedGpxList, multipleChoice); + final ContextMenuAdapter adapter = createGpxContextMenuAdapter(activity, allGpxList, selectedGpxList, multipleChoice, + showCurrentGpx); return createDialog(activity, showCurrentGpx, multipleChoice, callbackWithObject, allGpxList, adapter); } @@ -161,14 +162,16 @@ public class GpxUiHelper { list.add(0, activity.getString(R.string.show_current_gpx_title)); } - final ContextMenuAdapter adapter = createGpxContextMenuAdapter(activity, list, null, multipleChoice); + final ContextMenuAdapter adapter = createGpxContextMenuAdapter(activity, list, null, multipleChoice, + showCurrentGpx); return createDialog(activity, showCurrentGpx, multipleChoice, callbackWithObject, list, adapter); } return null; } private static ContextMenuAdapter createGpxContextMenuAdapter(Activity activity, List allGpxList, - List selectedGpxList, boolean multipleChoice) { + List selectedGpxList, boolean multipleChoice, + boolean showCurrentTrack) { final ContextMenuAdapter adapter = new ContextMenuAdapter(activity); //element position in adapter int i = 0; @@ -184,17 +187,28 @@ public class GpxUiHelper { //if there's some selected files - need to mark them as selected if (selectedGpxList != null) { - for (String file : selectedGpxList) { - if (file.endsWith(fileName)) { - adapter.setSelection(i, 1); - break; - } - } + updateSelection(selectedGpxList, showCurrentTrack, adapter, i, fileName); } i++; } return adapter; } + + protected static void updateSelection(List selectedGpxList, boolean showCurrentTrack, + final ContextMenuAdapter adapter, int i, String fileName) { + if(i == 0 && showCurrentTrack) { + if(selectedGpxList.contains("")) { + adapter.setSelection(i, 1); + } + } else { + for (String file : selectedGpxList) { + if (file.endsWith(fileName)) { + adapter.setSelection(i, 1); + break; + } + } + } + } private static void setDescripionInDialog(final ArrayAdapter adapter, final ContextMenuAdapter cmAdapter, Activity activity, final File dir, String filename, final int position) {