diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml
index e8a55d9f3e..75bf679593 100644
--- a/OsmAnd/res/values/strings.xml
+++ b/OsmAnd/res/values/strings.xml
@@ -11,6 +11,7 @@
Thx - Hardy
-->
+ Attach to the roads
Nearest point
Start of the track
Point of the track to navigate
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/RoutePreferencesMenu.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/RoutePreferencesMenu.java
index 78d1c75f32..7775d91119 100644
--- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/RoutePreferencesMenu.java
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/RoutePreferencesMenu.java
@@ -34,7 +34,7 @@ import net.osmand.plus.helpers.FileNameTranslationHelper;
import net.osmand.plus.helpers.GpxUiHelper;
import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper;
import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.AvoidRoadsRoutingParameter;
-import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.FollowTrackRoutingParameter;
+import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.GpxLocalRoutingParameter;
import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.InterruptMusicRoutingParameter;
import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.LocalRoutingParameter;
import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.LocalRoutingParameterGroup;
@@ -163,7 +163,7 @@ public class RoutePreferencesMenu {
btn.performClick();
} else if (obj instanceof AvoidRoadsRoutingParameter) {
routingOptionsHelper.selectRestrictedRoads(mapActivity);
- } else if (obj instanceof FollowTrackRoutingParameter) {
+ } else if (obj instanceof GpxLocalRoutingParameter) {
showOptionsMenu((TextView) view.findViewById(R.id.description));
} else {
CheckBox ch = (CheckBox) view.findViewById(R.id.toggle_item);
@@ -287,7 +287,7 @@ public class RoutePreferencesMenu {
return v;
}
- if (parameter instanceof FollowTrackRoutingParameter) {
+ if (parameter instanceof GpxLocalRoutingParameter) {
View v = mapActivity.getLayoutInflater().inflate(R.layout.plan_route_gpx, null);
AndroidUtils.setListItemBackground(mapActivity, v, nightMode);
AndroidUtils.setTextPrimaryColor(mapActivity, (TextView) v.findViewById(R.id.title), nightMode);
diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java
index c673c81d2f..2e64c1b3ec 100644
--- a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java
+++ b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java
@@ -418,7 +418,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
if (editingCtx.getPointsCount() > 0) {
if (newGpxData != null && newGpxData.getActionType() == ActionType.EDIT_SEGMENT
&& editingCtx.isInSnapToRoadMode()) {
- openSaveAsNewTrackMenu(mapActivity);
+ openSaveAsNewTrackMenu(mapActivity);
} else {
if (newGpxData == null) {
final File dir = mapActivity.getMyApplication().getAppPath(IndexConstants.GPX_INDEX_DIR);
@@ -687,10 +687,10 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
}
}
- @Override
- public void saveAsNewTrackOnClick() {
- openSaveAsNewTrackMenu(getMapActivity());
- }
+ @Override
+ public void saveAsNewTrackOnClick() {
+ openSaveAsNewTrackMenu(getMapActivity());
+ }
@Override
public void addToTheTrackOnClick() {
diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/FollowTrackFragment.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/FollowTrackFragment.java
index 70da3d5ed8..16d2b2dbbf 100644
--- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/FollowTrackFragment.java
+++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/FollowTrackFragment.java
@@ -43,6 +43,7 @@ import net.osmand.plus.measurementtool.NewGpxData;
import net.osmand.plus.measurementtool.NewGpxData.ActionType;
import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.LocalRoutingParameter;
import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.OtherLocalRoutingParameter;
+import net.osmand.plus.routepreparationmenu.cards.AttachTrackToRoadsCard;
import net.osmand.plus.routepreparationmenu.cards.BaseCard;
import net.osmand.plus.routepreparationmenu.cards.BaseCard.CardListener;
import net.osmand.plus.routepreparationmenu.cards.ImportTrackCard;
@@ -207,6 +208,11 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca
reverseTrackCard.setListener(this);
cardsContainer.addView(reverseTrackCard.build(mapActivity));
}
+ if (!gpxFile.hasRtePt()) {
+ AttachTrackToRoadsCard attachTrackCard = new AttachTrackToRoadsCard(mapActivity);
+ attachTrackCard.setListener(this);
+ cardsContainer.addView(attachTrackCard.build(mapActivity));
+ }
if (!rparams.isUseIntermediatePointsRTE()) {
setupNavigateOptionsCard(rparams);
}
diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java
index 344a9d04aa..5a567eda38 100644
--- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java
+++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java
@@ -2119,8 +2119,8 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
GPXRouteParamsBuilder routeParamsBuilder = app.getRoutingHelper().getCurrentGPXRoute();
if (routeParamsBuilder != null) {
- String description = new File(routeParamsBuilder.getFile().path).getName();
- toText.setText(description);
+ String fileName = new File(routeParamsBuilder.getFile().path).getName();
+ toText.setText(GpxUiHelper.getGpxTitle(fileName));
toTitle.setText(R.string.follow_track);
} else {
TargetPointsHelper targets = app.getTargetPointsHelper();
diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/RouteOptionsBottomSheet.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/RouteOptionsBottomSheet.java
index 9fe5ffcc51..c6d3df05ca 100644
--- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/RouteOptionsBottomSheet.java
+++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/RouteOptionsBottomSheet.java
@@ -39,7 +39,7 @@ import net.osmand.plus.helpers.GpxUiHelper;
import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.AvoidPTTypesRoutingParameter;
import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.AvoidRoadsRoutingParameter;
import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.DividerItem;
-import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.FollowTrackRoutingParameter;
+import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.GpxLocalRoutingParameter;
import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.LocalRoutingParameter;
import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.LocalRoutingParameterGroup;
import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.MuteSoundRoutingParameter;
@@ -122,7 +122,7 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
items.add(createAvoidPTTypesItem(optionsItem));
} else if (optionsItem instanceof AvoidRoadsRoutingParameter) {
items.add(createAvoidRoadsItem(optionsItem));
- } else if (optionsItem instanceof FollowTrackRoutingParameter) {
+ } else if (optionsItem instanceof GpxLocalRoutingParameter) {
items.add(createGpxRoutingItem(optionsItem));
} else if (optionsItem instanceof TimeConditionalRoutingItem) {
items.add(createTimeConditionalRoutingItem(optionsItem));
@@ -576,11 +576,13 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
DividerItem.KEY,
AvoidRoadsRoutingParameter.KEY,
ShowAlongTheRouteItem.KEY,
+ DividerItem.KEY,
+ GpxLocalRoutingParameter.KEY,
+ DividerItem.KEY,
GeneralRouter.ALLOW_PRIVATE,
GeneralRouter.USE_SHORTEST_WAY,
TimeConditionalRoutingItem.KEY,
DividerItem.KEY,
- FollowTrackRoutingParameter.KEY,
OtherSettingsRoutingParameter.KEY,
RouteSimulationItem.KEY),
@@ -591,9 +593,9 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
GeneralRouter.ALLOW_MOTORWAYS,
AvoidRoadsRoutingParameter.KEY,
ShowAlongTheRouteItem.KEY,
+ GpxLocalRoutingParameter.KEY,
TimeConditionalRoutingItem.KEY,
DividerItem.KEY,
- FollowTrackRoutingParameter.KEY,
OtherSettingsRoutingParameter.KEY,
RouteSimulationItem.KEY),
@@ -602,9 +604,9 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
DividerItem.KEY,
AvoidRoadsRoutingParameter.KEY,
ShowAlongTheRouteItem.KEY,
+ GpxLocalRoutingParameter.KEY,
TimeConditionalRoutingItem.KEY,
DividerItem.KEY,
- FollowTrackRoutingParameter.KEY,
OtherSettingsRoutingParameter.KEY,
RouteSimulationItem.KEY),
@@ -620,9 +622,9 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
DividerItem.KEY,
AvoidRoadsRoutingParameter.KEY,
ShowAlongTheRouteItem.KEY,
+ GpxLocalRoutingParameter.KEY,
TimeConditionalRoutingItem.KEY,
DividerItem.KEY,
- FollowTrackRoutingParameter.KEY,
OtherSettingsRoutingParameter.KEY,
RouteSimulationItem.KEY),
@@ -630,7 +632,7 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
DividerItem.KEY,
ShowAlongTheRouteItem.KEY,
DividerItem.KEY,
- FollowTrackRoutingParameter.KEY,
+ GpxLocalRoutingParameter.KEY,
OtherSettingsRoutingParameter.KEY,
RouteSimulationItem.KEY),
@@ -638,7 +640,7 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
DividerItem.KEY,
ShowAlongTheRouteItem.KEY,
DividerItem.KEY,
- FollowTrackRoutingParameter.KEY,
+ GpxLocalRoutingParameter.KEY,
OtherSettingsRoutingParameter.KEY,
RouteSimulationItem.KEY);
diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/RoutingOptionsHelper.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/RoutingOptionsHelper.java
index 980c94a207..546b600c7b 100644
--- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/RoutingOptionsHelper.java
+++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/RoutingOptionsHelper.java
@@ -17,7 +17,6 @@ import androidx.appcompat.widget.AppCompatCheckedTextView;
import androidx.core.content.ContextCompat;
import net.osmand.CallbackWithObject;
-import net.osmand.GPXUtilities;
import net.osmand.IndexConstants;
import net.osmand.Location;
import net.osmand.data.LatLon;
@@ -392,8 +391,8 @@ public class RoutingOptionsHelper {
return new AvoidPTTypesRoutingParameter();
case AvoidRoadsRoutingParameter.KEY:
return new AvoidRoadsRoutingParameter();
- case FollowTrackRoutingParameter.KEY:
- return new FollowTrackRoutingParameter();
+ case GpxLocalRoutingParameter.KEY:
+ return new GpxLocalRoutingParameter();
case TimeConditionalRoutingItem.KEY:
return new TimeConditionalRoutingItem();
case OtherSettingsRoutingParameter.KEY:
@@ -440,7 +439,7 @@ public class RoutingOptionsHelper {
list.add(2, new InterruptMusicRoutingParameter());
list.add(3, new AvoidRoadsRoutingParameter());
list.add(4, new TimeConditionalRoutingItem());
- list.add(new FollowTrackRoutingParameter());
+ list.add(new GpxLocalRoutingParameter());
list.add(new OtherSettingsRoutingParameter());
return list;
}
@@ -891,8 +890,7 @@ public class RoutingOptionsHelper {
}
}
-
- public static class FollowTrackRoutingParameter extends LocalRoutingParameter {
+ public static class GpxLocalRoutingParameter extends LocalRoutingParameter {
public static final String KEY = "FollowTrackRoutingParameter";
@@ -904,7 +902,7 @@ public class RoutingOptionsHelper {
return false;
}
- public FollowTrackRoutingParameter() {
+ public GpxLocalRoutingParameter() {
super(null);
}
diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/AttachTrackToRoadsCard.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/AttachTrackToRoadsCard.java
new file mode 100644
index 0000000000..e90d38b84a
--- /dev/null
+++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/AttachTrackToRoadsCard.java
@@ -0,0 +1,42 @@
+package net.osmand.plus.routepreparationmenu.cards;
+
+import android.view.View;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import androidx.annotation.NonNull;
+
+import net.osmand.plus.R;
+import net.osmand.plus.activities.MapActivity;
+
+
+public class AttachTrackToRoadsCard extends BaseCard {
+
+ public AttachTrackToRoadsCard(@NonNull MapActivity mapActivity) {
+ super(mapActivity);
+ }
+
+ @Override
+ public int getCardLayoutId() {
+ return R.layout.bottom_sheet_item_simple;
+ }
+
+ @Override
+ protected void updateContent() {
+ TextView titleTv = view.findViewById(R.id.title);
+ titleTv.setText(R.string.attach_to_the_roads);
+
+ ImageView icon = view.findViewById(R.id.icon);
+ icon.setImageDrawable(getContentIcon(R.drawable.ic_action_snap_to_road));
+
+ view.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ CardListener listener = getListener();
+ if (listener != null) {
+ listener.onCardPressed(AttachTrackToRoadsCard.this);
+ }
+ }
+ });
+ }
+}
\ No newline at end of file
diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/ReverseTrackCard.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/ReverseTrackCard.java
index bad2388654..dd6bd2d673 100644
--- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/ReverseTrackCard.java
+++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/ReverseTrackCard.java
@@ -38,8 +38,6 @@ public class ReverseTrackCard extends BaseCard {
compoundButton.setChecked(parameter.isSelected(app.getSettings()));
UiUtilities.setupCompoundButton(nightMode, getActiveColor(), compoundButton);
- int minHeight = app.getResources().getDimensionPixelSize(R.dimen.route_info_list_text_padding);
- view.setMinimumHeight(minHeight);
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/TrackEditCard.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/TrackEditCard.java
index 550992f96f..556ebe4caa 100644
--- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/TrackEditCard.java
+++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/TrackEditCard.java
@@ -3,7 +3,6 @@ package net.osmand.plus.routepreparationmenu.cards;
import android.graphics.drawable.ColorDrawable;
import android.view.View;
import android.widget.ImageButton;
-import android.widget.ImageView;
import android.widget.LinearLayout;
import net.osmand.AndroidUtils;
@@ -51,18 +50,11 @@ public class TrackEditCard extends BaseCard {
@Override
protected void updateContent() {
- int minCardHeight = app.getResources().getDimensionPixelSize(R.dimen.setting_list_item_large_height);
- int listContentPadding = app.getResources().getDimensionPixelSize(R.dimen.list_content_padding);
-
String fileName = Algorithms.getFileWithoutDirs(gpxInfo.getFileName());
String title = GpxUiHelper.getGpxTitle(fileName);
GpxDataItem dataItem = getDataItem(gpxInfo);
GpxUiHelper.updateGpxInfoView(view, title, gpxInfo, dataItem, false, app);
- ImageView trackIcon = view.findViewById(R.id.icon);
- trackIcon.setImageDrawable(getActiveIcon(R.drawable.ic_action_polygom_dark));
- trackIcon.setVisibility(View.VISIBLE);
-
ImageButton editButton = view.findViewById(R.id.show_on_map);
editButton.setVisibility(View.VISIBLE);
editButton.setImageDrawable(getContentIcon(R.drawable.ic_action_edit_dark));
@@ -76,6 +68,9 @@ public class TrackEditCard extends BaseCard {
}
});
+ int minCardHeight = app.getResources().getDimensionPixelSize(R.dimen.setting_list_item_large_height);
+ int listContentPadding = app.getResources().getDimensionPixelSize(R.dimen.list_content_padding);
+
LinearLayout container = view.findViewById(R.id.container);
container.setMinimumHeight(minCardHeight);
AndroidUtils.setPadding(container, listContentPadding, 0, 0, 0);