From 69750b7912eca5b09c51732b83f91e2fdebf37b4 Mon Sep 17 00:00:00 2001 From: Koen Rabaey Date: Tue, 29 Apr 2014 08:27:43 +0200 Subject: [PATCH] Keep name of imported file when saving gpx track --- .../osmand/plus/activities/MapActivityActions.java | 14 +++++++++++--- .../plus/activities/ShowRouteInfoActivity.java | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java index 21469c6dfa..daf16a041a 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java @@ -297,7 +297,7 @@ public class MapActivityActions implements DialogProvider { mapActivity.showDialog(DIALOG_SAVE_DIRECTIONS); } - public static Dialog createSaveDirections(Activity activity) { + public static Dialog createSaveDirections(Activity activity, RoutingHelper routingHelper) { final OsmandApplication app = ((OsmandApplication) activity.getApplication()); final File fileDir = app.getAppPath(IndexConstants.GPX_INDEX_DIR); final Dialog dlg = new Dialog(activity); @@ -305,7 +305,15 @@ public class MapActivityActions implements DialogProvider { dlg.setContentView(R.layout.save_directions_dialog); final EditText edit = (EditText) dlg.findViewById(R.id.FileNameEdit); - edit.setText("_" + MessageFormat.format("{0,date,yyyy-MM-dd}", new Date()) + "_"); + final GPXRouteParamsBuilder rp = routingHelper.getCurrentGPXRoute(); + final String editText; + if (rp == null || rp.getFile() == null || rp.getFile().path == null) { + editText = "_" + MessageFormat.format("{0,date,yyyy-MM-dd}", new Date()) + "_"; + } else { + editText = new File(rp.getFile().path).getName(); + } + edit.setText(editText); + ((Button) dlg.findViewById(R.id.Save)).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -582,7 +590,7 @@ public class MapActivityActions implements DialogProvider { case DIALOG_RELOAD_TITLE: return createReloadTitleDialog(args); case DIALOG_SAVE_DIRECTIONS: - return createSaveDirections(mapActivity); + return createSaveDirections(mapActivity, mapActivity.getRoutingHelper()); } return OsmAndDialogs.createDialog(id, mapActivity, args); } diff --git a/OsmAnd/src/net/osmand/plus/activities/ShowRouteInfoActivity.java b/OsmAnd/src/net/osmand/plus/activities/ShowRouteInfoActivity.java index deee5540d4..351b07f610 100644 --- a/OsmAnd/src/net/osmand/plus/activities/ShowRouteInfoActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/ShowRouteInfoActivity.java @@ -58,7 +58,7 @@ public class ShowRouteInfoActivity extends OsmandListActivity { @Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == SAVE) { - MapActivityActions.createSaveDirections(ShowRouteInfoActivity.this).show(); + MapActivityActions.createSaveDirections(ShowRouteInfoActivity.this, helper).show(); return true; } return super.onOptionsItemSelected(item);