diff --git a/OsmAnd/res/layout/route_steps_main.xml b/OsmAnd/res/layout/route_steps_main.xml index 3faad7fd6e..ab49941f19 100644 --- a/OsmAnd/res/layout/route_steps_main.xml +++ b/OsmAnd/res/layout/route_steps_main.xml @@ -10,12 +10,14 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="10dp" + android:ellipsize="end" android:textSize="20sp"/> diff --git a/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java b/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java index 8d1c07c6e5..ab850098cf 100644 --- a/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java +++ b/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java @@ -261,11 +261,11 @@ public class GpxSelectionHelper { return null; } - public void setGpxFileToDisplay(GPXFile... gpxs) { + public void setGpxFileToDisplay(boolean notShowNavigationDialog, GPXFile... gpxs) { // special case for gpx current route for(GPXFile gpx : gpxs) { boolean show = true; - selectGpxFileImpl(gpx, show); + selectGpxFileImpl(gpx, show, notShowNavigationDialog); } saveCurrentSelections(); } @@ -283,7 +283,7 @@ public class GpxSelectionHelper { p.startTask(getString(R.string.loading_smth, fl.getName()), -1); } GPXFile gpx = GPXUtilities.loadGPXFile(app, fl); - selectGpxFile(gpx, true); + selectGpxFile(gpx, true, false); } else if(obj.has(CURRENT_TRACK)) { selectedGPXFiles.add(savingTrackHelper.getCurrentTrack()); } @@ -298,7 +298,7 @@ public class GpxSelectionHelper { private void saveCurrentSelections() { JSONArray ar = new JSONArray(); for(SelectedGpxFile s : selectedGPXFiles) { - if(s.gpxFile != null) { + if(s.gpxFile != null && !s.notShowNavigationDialog) { JSONObject obj = new JSONObject(); try { if(!Algorithms.isEmpty(s.gpxFile.path)) { @@ -315,11 +315,12 @@ public class GpxSelectionHelper { app.getSettings().SELECTED_GPX.set(ar.toString()); } - private void selectGpxFileImpl(GPXFile gpx, boolean show) { + private void selectGpxFileImpl(GPXFile gpx, boolean show, boolean notShowNavigationDialog) { boolean displayed = false; SelectedGpxFile sf ; if(gpx.showCurrentTrack) { sf = savingTrackHelper.getCurrentTrack(); + sf.notShowNavigationDialog = notShowNavigationDialog; displayed = selectedGPXFiles.contains(sf); } else { sf = getSelectedFileByPath(gpx.path); @@ -327,6 +328,7 @@ public class GpxSelectionHelper { if(show && sf == null) { sf = new SelectedGpxFile(); sf.setGpxFile(gpx); + sf.notShowNavigationDialog = notShowNavigationDialog; } } if(displayed != show) { @@ -338,8 +340,8 @@ public class GpxSelectionHelper { } } - public void selectGpxFile(GPXFile gpx, boolean show) { - selectGpxFileImpl(gpx, show); + public void selectGpxFile(GPXFile gpx, boolean show, boolean showNavigationDialog) { + selectGpxFileImpl(gpx, show, showNavigationDialog); saveCurrentSelections(); } @@ -353,6 +355,8 @@ public class GpxSelectionHelper { public static class SelectedGpxFile { + public boolean notShowNavigationDialog = false; + private boolean showCurrentTrack; private GPXFile gpxFile; private int color; @@ -396,6 +400,7 @@ public class GpxSelectionHelper { public int getColor() { return color; } + } public enum GpxDisplayItemType { diff --git a/OsmAnd/src/net/osmand/plus/OsmandPlugin.java b/OsmAnd/src/net/osmand/plus/OsmandPlugin.java index 29bdc36de1..ecafdaa204 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandPlugin.java +++ b/OsmAnd/src/net/osmand/plus/OsmandPlugin.java @@ -86,7 +86,6 @@ public abstract class OsmandPlugin { if(Version.isRouteNavPluginInlined(app)) { RoutePointsPlugin routePointsPlugin = new RoutePointsPlugin(app); installedPlugins.add(routePointsPlugin); - enablePlugin(app, routePointsPlugin, true); } installPlugin(OSMODROID_PLUGIN_COMPONENT, OsMoDroidPlugin.ID, app, new OsMoDroidPlugin(app)); diff --git a/OsmAnd/src/net/osmand/plus/activities/AvailableGPXFragment.java b/OsmAnd/src/net/osmand/plus/activities/AvailableGPXFragment.java index 8ae0b9d8b3..a093aa5c56 100644 --- a/OsmAnd/src/net/osmand/plus/activities/AvailableGPXFragment.java +++ b/OsmAnd/src/net/osmand/plus/activities/AvailableGPXFragment.java @@ -422,7 +422,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment { if (loc != null) { settings.setMapLocationToShow(loc.lat, loc.lon, settings.getLastKnownMapZoom()); e = false; - getMyApplication().getSelectedGpxHelper().setGpxFileToDisplay(info.gpx); + getMyApplication().getSelectedGpxHelper().setGpxFileToDisplay(false, info.gpx); MapActivity.launchMapActivityMoveToTop(getActivity()); } } @@ -887,7 +887,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment { protected void onProgressUpdate(GpxInfo... values) { for(GpxInfo g : values) { final boolean visible = selectedItems.contains(g); - selectedGpxHelper.selectGpxFile(g.gpx, visible); + selectedGpxHelper.selectGpxFile(g.gpx, visible, false); if(visible && toShow == null) { toShow = g.gpx.findPointToShow(); } diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java index 46539ba479..32ad27f6b0 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java @@ -583,13 +583,15 @@ public class MapActivityActions implements DialogProvider { public void enterRoutePlanningMode(final LatLon from, final String fromName) { List selectedGPXFiles = mapActivity.getMyApplication().getSelectedGpxHelper().getSelectedGPXFiles(); GPXFile gpxFile = null; + boolean notShowDialog = false; for (SelectedGpxFile gs : selectedGPXFiles) { if (!gs.isShowCurrentTrack()) { + notShowDialog = gs.notShowNavigationDialog; gpxFile = gs.getGpxFile(); break; } } - if(gpxFile != null) { + if(gpxFile != null && !notShowDialog) { final GPXFile f = gpxFile; Builder bld = new AlertDialog.Builder(mapActivity); bld.setMessage(R.string.use_displayed_track_for_navigation); diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityLayers.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityLayers.java index c679be499c..90d2e31c40 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivityLayers.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityLayers.java @@ -390,7 +390,7 @@ public class MapActivityLayers { locToShow = g.findPointToShow(); } } - getApplication().getSelectedGpxHelper().setGpxFileToDisplay(result); + getApplication().getSelectedGpxHelper().setGpxFileToDisplay(false, result); if(locToShow != null){ mapView.getAnimatedDraggingThread().startMoving(locToShow.lat, locToShow.lon, mapView.getZoom(), true); diff --git a/OsmAnd/src/net/osmand/plus/helpers/GpxImportHelper.java b/OsmAnd/src/net/osmand/plus/helpers/GpxImportHelper.java index 65b6047bd7..b3edd6f497 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/GpxImportHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/GpxImportHelper.java @@ -282,7 +282,7 @@ public class GpxImportHelper { } private void showGpxOnMap(final GPXUtilities.GPXFile result) { - application.getSelectedGpxHelper().setGpxFileToDisplay(result); + application.getSelectedGpxHelper().setGpxFileToDisplay(false, result); final GPXUtilities.WptPt moveTo = result.findPointToShow(); if (moveTo != null) { mapView.getAnimatedDraggingThread().startMoving(moveTo.lat, moveTo.lon, mapView.getZoom(), true); diff --git a/OsmAnd/src/net/osmand/plus/osmo/OsMoPlugin.java b/OsmAnd/src/net/osmand/plus/osmo/OsMoPlugin.java index a946175272..14f4cca6cf 100644 --- a/OsmAnd/src/net/osmand/plus/osmo/OsMoPlugin.java +++ b/OsmAnd/src/net/osmand/plus/osmo/OsMoPlugin.java @@ -367,7 +367,7 @@ public class OsMoPlugin extends OsmandPlugin implements MonitoringInfoControlSer } if(visible && (changed || makeVisible)) { GPXFile selectGPXFile = GPXUtilities.loadGPXFile(app, f); - app.getSelectedGpxHelper().setGpxFileToDisplay(selectGPXFile); + app.getSelectedGpxHelper().setGpxFileToDisplay(false, selectGPXFile); } } catch (JSONException e) { e.printStackTrace(); diff --git a/OsmAnd/src/net/osmand/plus/routepointsnavigation/RoutePointsActivity.java b/OsmAnd/src/net/osmand/plus/routepointsnavigation/RoutePointsActivity.java index 2dfb8c4b1c..186b83ae36 100644 --- a/OsmAnd/src/net/osmand/plus/routepointsnavigation/RoutePointsActivity.java +++ b/OsmAnd/src/net/osmand/plus/routepointsnavigation/RoutePointsActivity.java @@ -4,6 +4,8 @@ import java.util.ArrayList; import java.util.List; import android.content.Intent; +import android.graphics.Paint; +import android.util.DisplayMetrics; import android.util.TypedValue; import net.osmand.CallbackWithObject; import net.osmand.data.LatLon; @@ -77,7 +79,7 @@ public class RoutePointsActivity extends OsmandListActivity { public boolean processResult(GPXUtilities.GPXFile[] result) { final GPXFile gpx = result[0]; app.getSelectedGpxHelper().clearAllGpxFileToShow(); - app.getSelectedGpxHelper().setGpxFileToDisplay(gpx); + app.getSelectedGpxHelper().setGpxFileToDisplay(true, gpx); plugin.setCurrentRoute(gpx); SelectedRouteGpxFile sgpx = plugin.getCurrentRoute(); if (!sgpx.getCurrentPoints().isEmpty() && @@ -101,6 +103,10 @@ public class RoutePointsActivity extends OsmandListActivity { private void prepareView() { TextView gpxName = (TextView) findViewById(R.id.gpx_name); + TextView visited = (TextView) findViewById(R.id.points_count); + String visitedString = "(" + plugin.getVisitedAllString() + ")"; + visited.setText(visitedString); + SelectedRouteGpxFile route = plugin.getCurrentRoute(); String fileName; if(route != null) { @@ -108,7 +114,23 @@ public class RoutePointsActivity extends OsmandListActivity { } else { fileName = getString(R.string.rp_current_route_not_available); } - SpannableString content = new SpannableString(fileName); + DisplayMetrics displaymetrics = new DisplayMetrics(); + getWindowManager().getDefaultDisplay().getMetrics(displaymetrics); + float screenWight = displaymetrics.widthPixels - visited.getPaint().measureText(visitedString) - 15; + Paint textPaint = gpxName.getPaint(); + String name = fileName; + int i = fileName.length()-1; + for(;;){ + float textSize = textPaint.measureText(name); + if (textSize < screenWight){ + break; + } + name = fileName.substring(0, i); + i--; + } + + + SpannableString content = new SpannableString(name); content.setSpan(new ClickableSpan() { @Override @@ -119,9 +141,6 @@ public class RoutePointsActivity extends OsmandListActivity { gpxName.setText(content); gpxName.setMovementMethod(LinkMovementMethod.getInstance()); - TextView visited = (TextView) findViewById(R.id.points_count); - visited.setText("(" + plugin.getVisitedAllString() + ")"); - adapter = new PointItemAdapter(this, R.layout.route_point_info, route == null ? new ArrayList() : route.getCurrentPoints()); @@ -291,9 +310,7 @@ public class RoutePointsActivity extends OsmandListActivity { return true; } else if (item.getItemId() == NAVIGATE_DIALOG_ID){ app.getSettings().navigateDialog(); - Intent intent = new Intent(this, app.getAppCustomization().getMapActivity()); - intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - startActivity(intent); + finish(); return true; } return super.onOptionsItemSelected(item); diff --git a/OsmAnd/src/net/osmand/plus/routepointsnavigation/RoutePointsPlugin.java b/OsmAnd/src/net/osmand/plus/routepointsnavigation/RoutePointsPlugin.java index bbc6f2aa97..2948fc541d 100644 --- a/OsmAnd/src/net/osmand/plus/routepointsnavigation/RoutePointsPlugin.java +++ b/OsmAnd/src/net/osmand/plus/routepointsnavigation/RoutePointsPlugin.java @@ -99,7 +99,7 @@ public class RoutePointsPlugin extends OsmandPlugin { private void registerWidget(MapActivity activity) { MapInfoLayer mapInfoLayer = activity.getMapLayers().getMapInfoLayer(); if (mapInfoLayer != null) { - routeStepsControl = createRouteStepsInfoControl(activity, mapInfoLayer.getPaintSubText(), mapInfoLayer.getPaintSubText()); + routeStepsControl = createRouteStepsInfoControl(activity, mapInfoLayer.getPaintText(), mapInfoLayer.getPaintSubText()); mapInfoLayer.getMapInfoControls().registerSideWidget(routeStepsControl, R.drawable.widget_signpost, R.string.map_widget_route_points, "route_steps", false, 8); mapInfoLayer.recreateControls(); @@ -195,8 +195,7 @@ public class RoutePointsPlugin extends OsmandPlugin { public String getDistance(RoutePoint rp) { double d = MapUtils.getDistance(rp.getPoint(), getPoint()); - String distance = OsmAndFormatter.getFormattedDistance((float) d, app); - return distance; + return OsmAndFormatter.getFormattedDistance((float) d, app); } public String getTime() { diff --git a/OsmAnd/src/net/osmand/plus/sherpafy/TourViewActivity.java b/OsmAnd/src/net/osmand/plus/sherpafy/TourViewActivity.java index f5482e49c5..e47db1a68b 100644 --- a/OsmAnd/src/net/osmand/plus/sherpafy/TourViewActivity.java +++ b/OsmAnd/src/net/osmand/plus/sherpafy/TourViewActivity.java @@ -391,7 +391,7 @@ public class TourViewActivity extends SherlockFragmentActivity { if (gpx != null && gpx.findPointToShow() != null) { WptPt p = gpx.findPointToShow(); getMyApplication().getSettings().setMapLocationToShow(p.lat, p.lon, 16, null); - getMyApplication().getSelectedGpxHelper().setGpxFileToDisplay(gpx); + getMyApplication().getSelectedGpxHelper().setGpxFileToDisplay(false, gpx); } } } diff --git a/OsmAnd/src/net/osmand/plus/views/controls/MapNavigateControl.java b/OsmAnd/src/net/osmand/plus/views/controls/MapNavigateControl.java index 33b7f971bb..abf516d347 100644 --- a/OsmAnd/src/net/osmand/plus/views/controls/MapNavigateControl.java +++ b/OsmAnd/src/net/osmand/plus/views/controls/MapNavigateControl.java @@ -53,6 +53,9 @@ public class MapNavigateControl extends MapControls { public void startCounter() { OsmandSettings settings = mapActivity.getMyApplication().getSettings(); + if(settings.DELAY_TO_START_NAVIGATION.get() <= 0) { + return; + } if (startCounter <= 0) { startCounter = System.currentTimeMillis() + settings.DELAY_TO_START_NAVIGATION.get() * 1000; delayStart = new Runnable() {