From 0eaecf971ecbc3e6a0e98b4c1664cb385888fc36 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 2 Jul 2014 12:22:15 +0300 Subject: [PATCH 1/8] Fixed bug 119 in Jira. --- OsmAnd/src/net/osmand/plus/activities/AvailableGPXFragment.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/AvailableGPXFragment.java b/OsmAnd/src/net/osmand/plus/activities/AvailableGPXFragment.java index 2a42be6123..193c5d175d 100644 --- a/OsmAnd/src/net/osmand/plus/activities/AvailableGPXFragment.java +++ b/OsmAnd/src/net/osmand/plus/activities/AvailableGPXFragment.java @@ -437,7 +437,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment { } } }; - if (info.gpx != null) { + if(info.gpx != null){ if (info.file == null) { GpxSelectionHelper.SelectedGpxFile selectedGpxFile = selectedGpxHelper.getSelectedCurrentRecordingTrack(); if (selectedGpxFile != null && selectedGpxFile.getGpxFile() == info.gpx) { From 33531a3c6b0f8b691139cb65e61fcf4abd362c03 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 3 Jul 2014 17:44:23 +0300 Subject: [PATCH 2/8] First implementation of map layers dialog change --- OsmAnd/res/layout/list_menu_item.xml | 10 +- OsmAnd/res/layout/list_menu_item_native.xml | 12 ++- .../plus/activities/MapActivityLayers.java | 97 +++++++++++++------ .../net/osmand/plus/helpers/GpxUiHelper.java | 40 +++++++- 4 files changed, 119 insertions(+), 40 deletions(-) diff --git a/OsmAnd/res/layout/list_menu_item.xml b/OsmAnd/res/layout/list_menu_item.xml index 1bc96fbdc0..8b10baea70 100644 --- a/OsmAnd/res/layout/list_menu_item.xml +++ b/OsmAnd/res/layout/list_menu_item.xml @@ -31,18 +31,22 @@ android:textColor="@color/color_black" android:layout_weight="1"/> + android:layout_height="fill_parent" + android:gravity="center_vertical"> + + /> \ No newline at end of file diff --git a/OsmAnd/res/layout/list_menu_item_native.xml b/OsmAnd/res/layout/list_menu_item_native.xml index fa360a2eeb..88d2e16d6f 100644 --- a/OsmAnd/res/layout/list_menu_item_native.xml +++ b/OsmAnd/res/layout/list_menu_item_native.xml @@ -30,17 +30,21 @@ android:layout_weight="1"/> + android:layout_height="fill_parent" + android:gravity="center_vertical"> + + + android:focusable="false" /> \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityLayers.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityLayers.java index c679be499c..ba52b388e8 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivityLayers.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityLayers.java @@ -6,6 +6,7 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map.Entry; +import android.widget.*; import net.osmand.CallbackWithObject; import net.osmand.ResultMatcher; import net.osmand.StateChangedListener; @@ -13,20 +14,12 @@ import net.osmand.access.AccessibleToast; import net.osmand.data.AmenityType; import net.osmand.map.ITileSource; import net.osmand.map.TileSourceManager.TileSourceTemplate; -import net.osmand.plus.ContextMenuAdapter; +import net.osmand.plus.*; import net.osmand.plus.ContextMenuAdapter.Item; import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick; import net.osmand.plus.GPXUtilities.GPXFile; import net.osmand.plus.GPXUtilities.WptPt; -import net.osmand.plus.OsmAndFormatter; -import net.osmand.plus.OsmandApplication; -import net.osmand.plus.OsmandPlugin; -import net.osmand.plus.OsmandSettings; import net.osmand.plus.OsmandSettings.CommonPreference; -import net.osmand.plus.PoiFilter; -import net.osmand.plus.PoiFiltersHelper; -import net.osmand.plus.R; -import net.osmand.plus.SQLiteTileSource; import net.osmand.plus.helpers.GpxUiHelper; import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin; import net.osmand.plus.render.MapVectorLayer; @@ -55,15 +48,8 @@ import android.content.Intent; import android.os.Build; import android.view.View; import android.view.ViewGroup; -import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; -import android.widget.ArrayAdapter; -import android.widget.CheckBox; -import android.widget.CompoundButton; import android.widget.CompoundButton.OnCheckedChangeListener; -import android.widget.ListAdapter; -import android.widget.TextView; -import android.widget.Toast; /** * Object is responsible to maintain layers using by map activity @@ -90,9 +76,11 @@ public class MapActivityLayers { private ContextMenuLayer contextMenuLayer; private MapControlsLayer mapControlsLayer; private DownloadedRegionsLayer downloadedRegionsLayer; + private GpxSelectionHelper gpxSelectionHelper; public MapActivityLayers(MapActivity activity) { this.activity = activity; + gpxSelectionHelper = getApplication().getSelectedGpxHelper(); } public OsmandApplication getApplication(){ @@ -261,7 +249,7 @@ public class MapActivityLayers { getApplication().getSelectedGpxHelper().clearAllGpxFileToShow(); } else { dialog.dismiss(); - showGPXFileLayer(mapView); + showGPXFileLayer(getAlreadySelectedGpx(), mapView); } } else if(itemId == R.string.layer_transport_route){ transportInfoLayer.setVisible(isChecked); @@ -318,8 +306,37 @@ public class MapActivityLayers { public View getView(final int position, View convertView, ViewGroup parent) { // User super class to create the View View v = activity.getLayoutInflater().inflate(layout, null); - TextView tv = (TextView)v.findViewById(R.id.title); - tv.setText(adapter.getItemName(position)); + TextView tv = (TextView)v.findViewById(R.id.title); + tv.setText(adapter.getItemName(position)); + + //if it's gpx or poi layer - need to show settings icon + int specialItemId = adapter.getItemId(position); + if (specialItemId == R.string.layer_poi || specialItemId == R.string.layer_gpx_layer) { + ImageView set = (ImageView) v.findViewById(R.id.icon_settings); + + //setting icon depending on theme + if(light){ + set.setImageResource(R.drawable.ic_action_settings_light); + } else { + set.setImageResource(R.drawable.ic_action_settings_dark); + } + + if (specialItemId == R.string.layer_poi){ + set.setOnClickListener( new View.OnClickListener() { + @Override + public void onClick(View view) { + selectPOIFilterLayer(mapView); + } + }); + } else { + set.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + showGPXFileLayer(getAlreadySelectedGpx(), mapView); + } + }); + } + } //Put the image on the TextView if(adapter.getImageId(position, light) != 0) { @@ -372,37 +389,53 @@ public class MapActivityLayers { }); dlg.show(); } - - public void showGPXFileLayer(final OsmandMapTileView mapView){ + + public void showGPXFileLayer(List files, final OsmandMapTileView mapView) { final OsmandSettings settings = getApplication().getSettings(); - GpxUiHelper.selectGPXFile(activity, true, true, new CallbackWithObject() { + CallbackWithObject callbackWithObject = new CallbackWithObject() { @Override public boolean processResult(GPXFile[] result) { WptPt locToShow = null; - for(GPXFile g : result) { - if(g.showCurrentTrack) { - if(!settings.SAVE_TRACK_TO_GPX.get()){ + for (GPXFile g : result) { + if (g.showCurrentTrack) { + if (!settings.SAVE_TRACK_TO_GPX.get()) { AccessibleToast.makeText(activity, R.string.gpx_monitoring_disabled_warn, Toast.LENGTH_SHORT).show(); - } + } break; - } - if(!g.showCurrentTrack || locToShow == null) { + } + if (!g.showCurrentTrack || locToShow == null) { locToShow = g.findPointToShow(); } } getApplication().getSelectedGpxHelper().setGpxFileToDisplay(result); - if(locToShow != null){ - mapView.getAnimatedDraggingThread().startMoving(locToShow.lat, locToShow.lon, + if (locToShow != null) { + mapView.getAnimatedDraggingThread().startMoving(locToShow.lat, locToShow.lon, mapView.getZoom(), true); } mapView.refreshMap(); return true; } - }); + }; + + if (files == null) { + GpxUiHelper.selectGPXFile(activity, true, true, callbackWithObject); + } else { + GpxUiHelper.selectGPXFile(files, activity, true, true, callbackWithObject); + } } - + private List getAlreadySelectedGpx(){ + if (gpxSelectionHelper == null){ + return null; + } + List selectedGpxFiles = gpxSelectionHelper.getSelectedGPXFiles(); + List files = new ArrayList(); + for (GpxSelectionHelper.SelectedGpxFile file : selectedGpxFiles) { + files.add(file.getGpxFile().path); + } + return files; + } private void selectPOIFilterLayer(final OsmandMapTileView mapView){ diff --git a/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java b/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java index f9a6da583b..202d71c6fe 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java @@ -127,6 +127,44 @@ public class GpxUiHelper { } return description.toString(); } + + public static void selectGPXFile(List list, final Activity activity, + final boolean showCurrentGpx, final boolean multipleChoice, final CallbackWithObject callbackWithObject){ + OsmandApplication app = (OsmandApplication) activity.getApplication(); + final File dir = app.getAppPath(IndexConstants.GPX_INDEX_DIR); + final List allGpxList = getSortedGPXFilenames(dir); + if(allGpxList.isEmpty()){ + AccessibleToast.makeText(activity, R.string.gpx_files_not_found, Toast.LENGTH_LONG).show(); + } + + if(!allGpxList.isEmpty() || showCurrentGpx){ + final ContextMenuAdapter adapter = new ContextMenuAdapter(activity); + if(showCurrentGpx){ + allGpxList.add(0, activity.getString(R.string.show_current_gpx_title)); + } + + //element position in adapter + int i =0; + for(String s : allGpxList) { + String fileName = s; + if (s.endsWith(".gpx")) { + s = s.substring(0, s.length() - ".gpx".length()); + } + s = s.replace('_', ' '); + + adapter.item(s).selected(multipleChoice ? 0 : -1) + .icons(R.drawable.ic_action_info_dark, R.drawable.ic_action_info_light).reg(); + for (String file : list) { + if (file.endsWith(fileName)) { + adapter.setSelection(i, 1); + break; + } + } + i++; + } + createDialog(activity, showCurrentGpx, multipleChoice, callbackWithObject, allGpxList, adapter); + } + } public static void selectGPXFile(final Activity activity, final boolean showCurrentGpx, final boolean multipleChoice, final CallbackWithObject callbackWithObject) { @@ -137,7 +175,7 @@ public class GpxUiHelper { AccessibleToast.makeText(activity, R.string.gpx_files_not_found, Toast.LENGTH_LONG).show(); } if(!list.isEmpty() || showCurrentGpx){ - + final ContextMenuAdapter adapter = new ContextMenuAdapter(activity); if(showCurrentGpx){ list.add(0, activity.getString(R.string.show_current_gpx_title)); From 4d96697618de19b206bbef65a359d29bc753a676 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 3 Jul 2014 18:45:38 +0300 Subject: [PATCH 3/8] updated functionality of settings button --- .../plus/activities/MapActivityLayers.java | 26 ++++++++++++++----- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityLayers.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityLayers.java index ba52b388e8..49ae83ab46 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivityLayers.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityLayers.java @@ -310,28 +310,33 @@ public class MapActivityLayers { tv.setText(adapter.getItemName(position)); //if it's gpx or poi layer - need to show settings icon - int specialItemId = adapter.getItemId(position); - if (specialItemId == R.string.layer_poi || specialItemId == R.string.layer_gpx_layer) { - ImageView set = (ImageView) v.findViewById(R.id.icon_settings); + //need imageview and specialItemId o + final ImageView settingsImage = (ImageView) v.findViewById(R.id.icon_settings); + final int specialItemId = adapter.getItemId(position); + if ((specialItemId == R.string.layer_poi || specialItemId == R.string.layer_gpx_layer) + && adapter.getSelection(position) > 0) { //setting icon depending on theme if(light){ - set.setImageResource(R.drawable.ic_action_settings_light); + settingsImage.setImageResource(R.drawable.ic_action_settings_light); } else { - set.setImageResource(R.drawable.ic_action_settings_dark); + settingsImage.setImageResource(R.drawable.ic_action_settings_dark); } if (specialItemId == R.string.layer_poi){ - set.setOnClickListener( new View.OnClickListener() { + settingsImage.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { selectPOIFilterLayer(mapView); } }); } else { - set.setOnClickListener(new View.OnClickListener() { + settingsImage.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { + if (listener.dialog != null) { + listener.dialog.dismiss(); + } showGPXFileLayer(getAlreadySelectedGpx(), mapView); } }); @@ -355,6 +360,13 @@ public class MapActivityLayers { ch.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + if (specialItemId == R.string.layer_poi){ + if (isChecked){ + settingsImage.setVisibility(View.VISIBLE); + } else { + settingsImage.setVisibility(View.GONE); + } + } listener.onClick(position, isChecked); } }); From ac6dc7081aa8ce889f40f3b32880210c33a69673 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 3 Jul 2014 18:56:07 +0300 Subject: [PATCH 4/8] hotfix to settings button in layout menu --- OsmAnd/res/layout/list_menu_item.xml | 4 +++- OsmAnd/res/layout/list_menu_item_native.xml | 4 +++- OsmAnd/src/net/osmand/plus/activities/MapActivityLayers.java | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/OsmAnd/res/layout/list_menu_item.xml b/OsmAnd/res/layout/list_menu_item.xml index 8b10baea70..59c76e0f15 100644 --- a/OsmAnd/res/layout/list_menu_item.xml +++ b/OsmAnd/res/layout/list_menu_item.xml @@ -37,7 +37,9 @@ + android:gravity="center_vertical" + android:visibility="gone" + android:focusable="false"/> + android:gravity="center_vertical" + android:visibility="gone" + android:focusable="false"/> 0) { + settingsImage.setVisibility(View.VISIBLE); //setting icon depending on theme if(light){ settingsImage.setImageResource(R.drawable.ic_action_settings_light); From 2eb942aa0a1ec7134b49dce3584292503af0f273 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 4 Jul 2014 11:58:41 +0300 Subject: [PATCH 5/8] Created service to find straight route --- .../osmand/plus/routing/RouteProvider.java | 36 ++++++++++++++++--- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java b/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java index 77b1c41e29..ed088077a1 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java +++ b/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java @@ -77,7 +77,7 @@ public class RouteProvider { public enum RouteService { OSMAND("OsmAnd (offline)"), YOURS("YOURS"), ORS("OpenRouteService"), OSRM("OSRM (only car)"), - BROUTER("BRouter (offline)"); + BROUTER("BRouter (offline)"), STRAIGHT("Straight line(offline)"); private final String name; private RouteService(String name){ this.name = name; @@ -324,7 +324,10 @@ public class RouteProvider { res = findORSRoute(params); } else if (params.type == RouteService.OSRM) { res = findOSRMRoute(params); - } else { + } else if (params.type == RouteService.STRAIGHT){ + res = findStraightRoute(params); + } + else { res = new RouteCalculationResult("Selected route service is not available"); } if(log.isInfoEnabled() ){ @@ -344,7 +347,6 @@ public class RouteProvider { return new RouteCalculationResult(null); } - public RouteCalculationResult recalculatePartOfflineRoute(RouteCalculationResult res, RouteCalculationParams params) { RouteCalculationResult rcr = params.previousToRecalculate; List locs = new ArrayList(rcr.getRouteLocations()); @@ -1205,7 +1207,31 @@ public class RouteProvider { } return new RouteCalculationResult(res, null, params, null); } - - + private RouteCalculationResult findStraightRoute(RouteCalculationParams params) { + double[] lats = new double[] { params.start.getLatitude(), params.end.getLatitude() }; + double[] lons = new double[] { params.start.getLongitude(), params.end.getLongitude() }; + List intermediates = params.intermediates; + List dots = new ArrayList(); + //writing start location + Location location = new Location(String.valueOf("start")); + location.setLatitude(lats[0]); + location.setLongitude(lons[0]); + //adding intermediate dots if they exists + if (intermediates != null){ + for(int i =0; i Date: Fri, 4 Jul 2014 13:14:12 +0300 Subject: [PATCH 6/8] Update MapActivityLayers.java --- OsmAnd/src/net/osmand/plus/activities/MapActivityLayers.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityLayers.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityLayers.java index f3f0b7a7ad..8e2d1bfae2 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivityLayers.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityLayers.java @@ -331,7 +331,7 @@ public class MapActivityLayers { selectPOIFilterLayer(mapView); } }); - } else { + } else if (specialItemId == R.string.layer_gpx_layer) { settingsImage.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { From fe68ff3a3c31bf2dd8c687ef6d3c6fa6a5d35c50 Mon Sep 17 00:00:00 2001 From: Bars107 Date: Fri, 4 Jul 2014 13:14:40 +0300 Subject: [PATCH 7/8] Update RouteProvider.java --- OsmAnd/src/net/osmand/plus/routing/RouteProvider.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java b/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java index ed088077a1..c05f4af02d 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java +++ b/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java @@ -77,7 +77,7 @@ public class RouteProvider { public enum RouteService { OSMAND("OsmAnd (offline)"), YOURS("YOURS"), ORS("OpenRouteService"), OSRM("OSRM (only car)"), - BROUTER("BRouter (offline)"), STRAIGHT("Straight line(offline)"); + BROUTER("BRouter (offline)"), STRAIGHT("Straight line"); private final String name; private RouteService(String name){ this.name = name; From 350c5ccc0a6693842d246f32599b89e28b6bd932 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 4 Jul 2014 14:18:44 +0300 Subject: [PATCH 8/8] refactored gpx layers dialog --- .../net/osmand/plus/helpers/GpxUiHelper.java | 69 ++++++++++--------- 1 file changed, 37 insertions(+), 32 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java b/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java index 202d71c6fe..0366481bad 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java @@ -128,7 +128,7 @@ public class GpxUiHelper { return description.toString(); } - public static void selectGPXFile(List list, final Activity activity, + public static void selectGPXFile(List selectedGpxList, final Activity activity, final boolean showCurrentGpx, final boolean multipleChoice, final CallbackWithObject callbackWithObject){ OsmandApplication app = (OsmandApplication) activity.getApplication(); final File dir = app.getAppPath(IndexConstants.GPX_INDEX_DIR); @@ -138,30 +138,10 @@ public class GpxUiHelper { } if(!allGpxList.isEmpty() || showCurrentGpx){ - final ContextMenuAdapter adapter = new ContextMenuAdapter(activity); if(showCurrentGpx){ allGpxList.add(0, activity.getString(R.string.show_current_gpx_title)); } - - //element position in adapter - int i =0; - for(String s : allGpxList) { - String fileName = s; - if (s.endsWith(".gpx")) { - s = s.substring(0, s.length() - ".gpx".length()); - } - s = s.replace('_', ' '); - - adapter.item(s).selected(multipleChoice ? 0 : -1) - .icons(R.drawable.ic_action_info_dark, R.drawable.ic_action_info_light).reg(); - for (String file : list) { - if (file.endsWith(fileName)) { - adapter.setSelection(i, 1); - break; - } - } - i++; - } + final ContextMenuAdapter adapter = createGpxContextMenuAdapter(activity,allGpxList, selectedGpxList, multipleChoice); createDialog(activity, showCurrentGpx, multipleChoice, callbackWithObject, allGpxList, adapter); } } @@ -175,22 +155,42 @@ public class GpxUiHelper { AccessibleToast.makeText(activity, R.string.gpx_files_not_found, Toast.LENGTH_LONG).show(); } if(!list.isEmpty() || showCurrentGpx){ - - final ContextMenuAdapter adapter = new ContextMenuAdapter(activity); if(showCurrentGpx){ list.add(0, activity.getString(R.string.show_current_gpx_title)); } - for(String s : list) { - if (s.endsWith(".gpx")) { - s = s.substring(0, s.length() - ".gpx".length()); - } - s = s.replace('_', ' '); - adapter.item(s).selected(multipleChoice ? 0 : -1) - .icons(R.drawable.ic_action_info_dark, R.drawable.ic_action_info_light).reg(); - } + + final ContextMenuAdapter adapter = createGpxContextMenuAdapter(activity, list, null, multipleChoice); createDialog(activity, showCurrentGpx, multipleChoice, callbackWithObject, list, adapter); } } + + private static ContextMenuAdapter createGpxContextMenuAdapter(Activity activity, List allGpxList, List selectedGpxList, boolean multipleChoice) { + final ContextMenuAdapter adapter = new ContextMenuAdapter(activity); + //element position in adapter + int i = 0; + for (String s : allGpxList) { + String fileName = s; + if (s.endsWith(".gpx")) { + s = s.substring(0, s.length() - ".gpx".length()); + } + s = s.replace('_', ' '); + + adapter.item(s).selected(multipleChoice ? 0 : -1) + .icons(R.drawable.ic_action_info_dark, R.drawable.ic_action_info_light).reg(); + + //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; + } + } + } + i++; + } + return adapter; + } private static void setDescripionInDialog(final ArrayAdapter adapter, final ContextMenuAdapter cmAdapter, Activity activity, final File dir, String filename, final int position) { @@ -290,6 +290,11 @@ public class GpxUiHelper { @Override public void onClick(DialogInterface dialog, int which) { GPXFile currentGPX = null; + //clear all previously selected files before adding new one + OsmandApplication app = (OsmandApplication) activity.getApplication(); + if(app != null && app.getSelectedGpxHelper() != null){ + app.getSelectedGpxHelper().clearAllGpxFileToShow(); + } if (showCurrentGpx && adapter.getSelection(0) > 0) { currentGPX = app.getSavingTrackHelper().getCurrentGpx(); }