diff --git a/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java b/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java
index 6eb20d0f15..5b7feed761 100644
--- a/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java
+++ b/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java
@@ -46,6 +46,8 @@ public class GPXUtilities {
private static final String ICON_NAME_EXTENSION = "icon";
private static final String DEFAULT_ICON_NAME = "special_star";
private static final String BACKGROUND_TYPE_EXTENSION = "background";
+ private static final String PROFILE_TYPE_EXTENSION = "profile";
+ private static final String TRKPT_INDEX_EXTENSION = "trkpt_idx";
private final static String GPX_TIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ss'Z'"; //$NON-NLS-1$
private final static String GPX_TIME_FORMAT_MILLIS = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"; //$NON-NLS-1$
@@ -302,6 +304,26 @@ public class GPXUtilities {
getExtensionsToWrite().put(BACKGROUND_TYPE_EXTENSION, backType);
}
+ public String getProfileType() {
+ return getExtensionsToRead().get(PROFILE_TYPE_EXTENSION);
+ }
+
+ public void setProfileType(String profileType) {
+ getExtensionsToWrite().put(PROFILE_TYPE_EXTENSION, profileType);
+ }
+
+ public int getTrkPtIndex() {
+ try {
+ return Integer.parseInt(getExtensionsToRead().get(TRKPT_INDEX_EXTENSION));
+ }catch(NumberFormatException e){
+ return -1;
+ }
+ }
+
+ public void setTrkPtIndex(int index) {
+ getExtensionsToWrite().put(TRKPT_INDEX_EXTENSION, String.valueOf(index));
+ }
+
@Override
public int hashCode() {
final int prime = 31;
diff --git a/OsmAnd/res/layout-land/fragment_measurement_tool.xml b/OsmAnd/res/layout-land/fragment_measurement_tool.xml
index de02d4e67c..4bcb08756a 100644
--- a/OsmAnd/res/layout-land/fragment_measurement_tool.xml
+++ b/OsmAnd/res/layout-land/fragment_measurement_tool.xml
@@ -163,30 +163,25 @@
android:paddingStart="@dimen/measurement_tool_text_button_padding"
android:text="@string/shared_string_options"
android:textColor="?attr/color_dialog_buttons"
- osmand:textAllCapsCompat="true"
osmand:typeface="@string/font_roboto_medium"/>
@@ -242,6 +236,7 @@
android:paddingRight="@dimen/measurement_tool_button_padding"
android:text="@string/shared_string_apply"
android:textColor="@color/color_white"
+ android:textAllCaps="false"
android:paddingEnd="@dimen/measurement_tool_button_padding"
android:paddingStart="@dimen/measurement_tool_button_padding" />
@@ -304,6 +299,7 @@
android:paddingRight="@dimen/measurement_tool_button_padding"
android:text="@string/shared_string_apply"
android:textColor="?attr/color_dialog_buttons"
+ android:textAllCaps="false"
android:paddingEnd="@dimen/measurement_tool_button_padding"
android:paddingStart="@dimen/measurement_tool_button_padding" />
@@ -316,13 +312,12 @@
android:layout_marginRight="@dimen/measurement_tool_button_margin"
android:layout_marginTop="@dimen/measurement_tool_button_margin"
android:background="?attr/btn_round"
- osmand:drawableLeftCompat="@drawable/ic_action_plus"
- osmand:drawableStartCompat="@drawable/ic_action_plus"
android:minHeight="@dimen/measurement_tool_button_height"
android:paddingLeft="@dimen/measurement_tool_button_padding"
android:paddingRight="@dimen/measurement_tool_button_padding"
android:text="@string/shared_string_add"
android:textColor="@color/color_white"
+ android:textAllCaps="false"
android:paddingStart="@dimen/measurement_tool_button_padding"
android:paddingEnd="@dimen/measurement_tool_button_padding" />
diff --git a/OsmAnd/res/layout/fragment_measurement_tool.xml b/OsmAnd/res/layout/fragment_measurement_tool.xml
index d6f1470ba0..e126e58a29 100644
--- a/OsmAnd/res/layout/fragment_measurement_tool.xml
+++ b/OsmAnd/res/layout/fragment_measurement_tool.xml
@@ -39,10 +39,10 @@
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
- android:layout_marginEnd="@dimen/bottom_sheet_content_margin"
- android:layout_marginLeft="@dimen/bottom_sheet_content_margin"
- android:layout_marginRight="@dimen/bottom_sheet_content_margin"
- android:layout_marginStart="@dimen/bottom_sheet_content_margin"
+ android:layout_marginEnd="@dimen/measurement_tool_text_button_padding"
+ android:layout_marginLeft="@dimen/measurement_tool_text_button_padding"
+ android:layout_marginRight="@dimen/measurement_tool_text_button_padding"
+ android:layout_marginStart="@dimen/measurement_tool_text_button_padding"
android:background="@null"
tools:src="@drawable/ic_action_ruler"/>
@@ -64,11 +64,11 @@
android:id="@+id/measurement_distance_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_centerVertical="true"
+ android:layout_marginTop="@dimen/measurement_tool_button_padding"
android:layout_marginEnd="@dimen/text_margin_small"
- android:layout_marginLeft="@dimen/measurement_tool_text_margin"
+ android:layout_marginLeft="@dimen/measurement_tool_text_button_padding"
android:layout_marginRight="@dimen/text_margin_small"
- android:layout_marginStart="@dimen/measurement_tool_text_margin"
+ android:layout_marginStart="@dimen/measurement_tool_text_button_padding"
android:layout_toEndOf="@id/main_icon"
android:layout_toRightOf="@id/main_icon"
android:textAppearance="@style/TextAppearance.ListItemTitle"
@@ -78,7 +78,7 @@
android:id="@+id/measurement_points_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_centerVertical="true"
+ android:layout_marginTop="@dimen/measurement_tool_button_padding"
android:layout_toEndOf="@id/measurement_distance_text_view"
android:layout_toRightOf="@id/measurement_distance_text_view"
android:textColor="?android:textColorSecondary"
@@ -87,17 +87,15 @@
+ android:textColor="@color/color_distance"
+ android:textSize="@dimen/default_desc_text_size"
+ tools:text=" – 700 m" />
+ android:layout_height="@dimen/measurement_tool_controls_height"
+ android:paddingTop="@dimen/measurement_tool_button_padding_top"
+ android:paddingBottom="@dimen/measurement_tool_button_padding_top"
+ android:paddingLeft="@dimen/measurement_tool_button_margin"
+ android:paddingRight="@dimen/measurement_tool_button_margin">
@@ -261,6 +250,7 @@
android:paddingRight="@dimen/measurement_tool_button_padding"
android:text="@string/shared_string_apply"
android:textColor="@color/color_white"
+ android:textAllCaps="false"
android:paddingEnd="@dimen/measurement_tool_button_padding"
android:paddingStart="@dimen/measurement_tool_button_padding" />
@@ -268,15 +258,12 @@
android:id="@+id/cancel_move_point_button"
android:layout_width="wrap_content"
android:layout_height="match_parent"
+ android:layout_margin="@dimen/measurement_tool_button_margin"
android:background="?attr/selectableItemBackground"
android:gravity="center_vertical"
- android:paddingEnd="12dp"
- android:paddingLeft="16dp"
- android:paddingRight="12dp"
- android:paddingStart="16dp"
+ android:padding="@dimen/measurement_tool_text_button_padding_small"
android:text="@string/shared_string_cancel"
android:textColor="?attr/color_dialog_buttons"
- osmand:textAllCapsCompat="true"
osmand:typeface="@string/font_roboto_medium"/>
@@ -292,15 +279,12 @@
android:id="@+id/cancel_point_before_after_button"
android:layout_width="wrap_content"
android:layout_height="match_parent"
+ android:layout_margin="@dimen/measurement_tool_button_margin"
android:background="?attr/selectableItemBackground"
android:gravity="center_vertical"
- android:paddingEnd="@dimen/measurement_tool_text_button_padding_small"
- android:paddingLeft="@dimen/measurement_tool_text_button_padding"
- android:paddingRight="@dimen/measurement_tool_text_button_padding_small"
- android:paddingStart="@dimen/measurement_tool_text_button_padding"
+ android:padding="@dimen/measurement_tool_text_button_padding_small"
android:text="@string/shared_string_cancel"
android:textColor="?attr/color_dialog_buttons"
- osmand:textAllCapsCompat="true"
osmand:typeface="@string/font_roboto_medium"/>
@@ -334,13 +319,12 @@
android:layout_marginRight="@dimen/measurement_tool_button_margin"
android:layout_marginTop="@dimen/measurement_tool_button_margin"
android:background="?attr/btn_round"
- osmand:drawableLeftCompat="@drawable/ic_action_plus"
- osmand:drawableStartCompat="@drawable/ic_action_plus"
android:minHeight="@dimen/measurement_tool_button_height"
android:paddingLeft="@dimen/measurement_tool_button_padding"
android:paddingRight="@dimen/measurement_tool_button_padding"
android:text="@string/shared_string_add"
android:textColor="@color/color_white"
+ android:textAllCaps="false"
android:paddingEnd="@dimen/measurement_tool_button_padding"
android:paddingStart="@dimen/measurement_tool_button_padding" />
diff --git a/OsmAnd/res/layout/plan_route_toolbar_and_up_down_row.xml b/OsmAnd/res/layout/plan_route_toolbar_and_up_down_row.xml
index 25e86566bc..773f46b403 100644
--- a/OsmAnd/res/layout/plan_route_toolbar_and_up_down_row.xml
+++ b/OsmAnd/res/layout/plan_route_toolbar_and_up_down_row.xml
@@ -1,7 +1,6 @@
+ android:paddingStart="@dimen/content_padding"
+ android:paddingEnd="@dimen/content_padding" />
@@ -63,8 +62,8 @@
android:id="@+id/toolbar_divider"
android:layout_width="wrap_content"
android:layout_height="1dp"
- android:layout_marginLeft="54dp"
- android:layout_marginStart="54dp"
+ android:layout_marginLeft="@dimen/toolbar_inset_start"
+ android:layout_marginStart="@dimen/toolbar_inset_start"
android:visibility="gone"
tools:background="?attr/dashboard_divider"
tools:visibility="visible"/>
@@ -81,7 +80,7 @@
12dp
330dp
48dp
- 78dp
+ 84dp
18dp
24dp
18dp
@@ -88,6 +88,7 @@
24dp
12dp
12dp
+ 15dp
54dp
diff --git a/OsmAnd/res/values/sizes.xml b/OsmAnd/res/values/sizes.xml
index ebefb8942f..1c1a621495 100644
--- a/OsmAnd/res/values/sizes.xml
+++ b/OsmAnd/res/values/sizes.xml
@@ -251,15 +251,16 @@
4dp
8dp
220dp
- 48dp
- 52dp
- 12dp
+ 60dp
+ 56dp
+ 8dp
16dp
- 12dp
+ 6dp
14dp
16dp
8dp
8dp
+ 10dp
36dp
52dp
44dp
@@ -340,6 +341,7 @@
56dp
96dp
72dp
+ 54dp
36dp
80dp
diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml
index 5d733cf83f..1dba39ca31 100644
--- a/OsmAnd/res/values/strings.xml
+++ b/OsmAnd/res/values/strings.xml
@@ -11,6 +11,9 @@
Thx - Hardy
-->
+ Add to a Track
+ Plan a route
+ Route between points
Closed OSM Note
Go-cart
Wheelchair forward
diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java
index 25c1b95601..273d69d831 100644
--- a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java
+++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java
@@ -1,6 +1,5 @@
package net.osmand.plus.activities;
-import android.Manifest;
import android.app.Activity;
import android.app.Dialog;
import android.content.DialogInterface;
@@ -21,7 +20,6 @@ import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
-import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import net.osmand.AndroidUtils;
@@ -425,7 +423,7 @@ public class MapActivityActions implements DialogProvider {
}
adapter.addItem(itemBuilder
- .setTitleId(R.string.measurement_tool, mapActivity)
+ .setTitleId(R.string.plan_a_route, mapActivity)
.setId(MAP_CONTEXT_MENU_MEASURE_DISTANCE)
.setIcon(R.drawable.ic_action_ruler)
.setOrder(MEASURE_DISTANCE_ITEM_ORDER)
@@ -473,7 +471,7 @@ public class MapActivityActions implements DialogProvider {
// new String[]{Manifest.permission.ACCESS_FINE_LOCATION},
// REQUEST_LOCATION_FOR_DIRECTIONS_NAVIGATION_PERMISSION);
//}
- } else if (standardId == R.string.measurement_tool) {
+ } else if (standardId == R.string.plan_a_route) {
mapActivity.getContextMenu().close();
MeasurementToolFragment.showInstance(mapActivity.getSupportFragmentManager(), new LatLon(latitude, longitude));
} else if (standardId == R.string.avoid_road) {
@@ -932,7 +930,7 @@ public class MapActivityActions implements DialogProvider {
}
}).createItem());
- optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.measurement_tool, mapActivity)
+ optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.plan_a_route, mapActivity)
.setId(DRAWER_MEASURE_DISTANCE_ID)
.setIcon(R.drawable.ic_action_ruler)
.setListener(new ItemClickListener() {
diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementEditingContext.java b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementEditingContext.java
index 388cd91d72..27305c989f 100644
--- a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementEditingContext.java
+++ b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementEditingContext.java
@@ -17,6 +17,7 @@ import net.osmand.plus.routing.RouteCalculationParams;
import net.osmand.plus.routing.RouteCalculationResult;
import net.osmand.plus.routing.RoutingHelper;
import net.osmand.router.RouteCalculationProgress;
+import net.osmand.util.MapUtils;
import java.util.ArrayList;
import java.util.Arrays;
@@ -45,6 +46,7 @@ public class MeasurementEditingContext {
private boolean inSnapToRoadMode;
private boolean needUpdateCacheForSnap;
private int calculatedPairs;
+ private int trkptIndex;
private SnapToRoadProgressListener progressListener;
private ApplicationMode snapToRoadAppMode;
private RouteCalculationProgress calculationProgress;
@@ -112,7 +114,7 @@ public class MeasurementEditingContext {
this.progressListener = progressListener;
}
- ApplicationMode getSnapToRoadAppMode() {
+ public ApplicationMode getSnapToRoadAppMode() {
return snapToRoadAppMode;
}
@@ -260,6 +262,54 @@ public class MeasurementEditingContext {
}
}
+ void addPoints() {
+ List points = getNewGpxData().getTrkSegment().points;
+ if (isSnapToRoadTrack()) {
+ List routePoints = getNewGpxData().getGpxFile().getRoutePoints();
+ int prevPointIndex = 0;
+ for (int i = 0; i < routePoints.size() - 1; i++) {
+ Pair pair = new Pair<>(routePoints.get(i), routePoints.get(i + 1));
+ int startIndex = pair.first.getTrkPtIndex();
+ if (startIndex < 0 || startIndex < prevPointIndex || startIndex >= points.size()) {
+ startIndex = findPointIndex(pair.first, points, prevPointIndex);
+ }
+ int endIndex = pair.second.getTrkPtIndex() + 1;
+ if (endIndex < 0 || endIndex < startIndex || endIndex >= points.size()) {
+ endIndex = findPointIndex(pair.second, points, startIndex);
+ }
+ if (startIndex >= 0 && endIndex >= 0) {
+ List cacheSegment = new ArrayList<>();
+ for (int j = startIndex; j < endIndex && j < points.size(); j++) {
+ cacheSegment.add(points.get(j));
+ prevPointIndex = j;
+ }
+ snappedToRoadPoints.put(pair, cacheSegment);
+ }
+ }
+ addPoints(routePoints);
+ } else {
+ addPoints(points);
+ }
+ }
+
+ private int findPointIndex(WptPt point, List points, int firstIndex) {
+ double minDistance = Double.MAX_VALUE;
+ int index = 0;
+ for (int i = Math.max(0, firstIndex); i < points.size(); i++) {
+ double distance = MapUtils.getDistance(point.lat, point.lon, points.get(i).lat, points.get(i).lon);
+ if (distance < minDistance) {
+ minDistance = distance;
+ index = i;
+ }
+ }
+ return index;
+ }
+
+ boolean isSnapToRoadTrack() {
+ return !getNewGpxData().getTrkSegment().points.isEmpty()
+ && !getNewGpxData().getGpxFile().getRoutePoints().isEmpty();
+ }
+
private void updateCacheForSnapIfNeeded(boolean both) {
if (needUpdateCacheForSnap) {
recreateCacheForSnap(beforeCacheForSnap = new TrkSegment(), before);
@@ -342,6 +392,9 @@ public class MeasurementEditingContext {
}
calculatedPairs++;
snappedToRoadPoints.put(currentPair, pts);
+ trkptIndex = currentPair.first.getTrkPtIndex();
+ trkptIndex += pts.size() - 1;
+ currentPair.second.setTrkPtIndex(trkptIndex);
updateCacheForSnapIfNeeded(true);
application.runInUIThread(new Runnable() {
@Override
diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java
index 9cdbbe1037..6a04eb7dd3 100644
--- a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java
+++ b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java
@@ -74,6 +74,7 @@ import net.osmand.plus.measurementtool.command.ReorderPointCommand;
import net.osmand.plus.views.controls.ReorderItemTouchHelperCallback;
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory;
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarController;
+import net.osmand.util.Algorithms;
import java.io.File;
import java.text.MessageFormat;
@@ -220,7 +221,15 @@ public class MeasurementToolFragment extends BaseOsmAndFragment {
mainIcon = (ImageView) mainView.findViewById(R.id.main_icon);
final NewGpxData newGpxData = editingCtx.getNewGpxData();
- if (editingCtx.getNewGpxData() != null) {
+ if (newGpxData != null) {
+ List points = newGpxData.getGpxFile().getRoutePoints();
+ if (!points.isEmpty()) {
+ ApplicationMode snapToRoadAppMode = ApplicationMode
+ .valueOfStringKey(points.get(points.size() - 1).getProfileType(), null);
+ if (snapToRoadAppMode != null) {
+ enableSnapToRoadMode(snapToRoadAppMode);
+ }
+ }
ActionType actionType = newGpxData.getActionType();
if (actionType == ActionType.ADD_SEGMENT || actionType == ActionType.EDIT_SEGMENT) {
mainIcon.setImageDrawable(getActiveIcon(R.drawable.ic_action_polygom_dark));
@@ -467,9 +476,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment {
enterMeasurementMode();
- if (editingCtx.isInSnapToRoadMode()) {
- showSnapToRoadControls();
- }
+ showSnapToRoadControls();
if (newGpxData != null && !gpxPointsAdded) {
ActionType actionType = newGpxData.getActionType();
@@ -560,7 +567,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment {
if (rememberPreviousTitle) {
previousToolBarTitle = toolBarController.getTitle();
}
- toolBarController.setTitle(getString(R.string.snap_to_road));
+ toolBarController.setTitle(getString(R.string.route_between_points));
mapActivity.refreshMap();
SnapToRoadBottomSheetDialogFragment fragment = new SnapToRoadBottomSheetDialogFragment();
fragment.setListener(createSnapToRoadFragmentListener());
@@ -587,6 +594,12 @@ public class MeasurementToolFragment extends BaseOsmAndFragment {
public void addToGpxOnClick() {
if (mapActivity != null && measurementLayer != null) {
if (editingCtx.getPointsCount() > 0) {
+ if (editingCtx.isInSnapToRoadMode()) {
+ editingCtx.getPoints().clear();
+ editingCtx.getPoints().addAll(editingCtx.getBeforePoints());
+ editingCtx.getBeforePoints().clear();
+ editingCtx.getBeforePoints().addAll(editingCtx.getBeforeTrkSegmentLine().points);
+ }
addToGpx(mapActivity);
} else {
Toast.makeText(mapActivity, getString(R.string.none_point_error), Toast.LENGTH_SHORT).show();
@@ -803,14 +816,16 @@ public class MeasurementToolFragment extends BaseOsmAndFragment {
private void showSnapToRoadControls() {
final MapActivity mapActivity = getMapActivity();
final ApplicationMode appMode = editingCtx.getSnapToRoadAppMode();
- if (mapActivity != null && appMode != null) {
- toolBarController.setTopBarSwitchVisible(true);
- toolBarController.setTopBarSwitchChecked(true);
- mainIcon.setImageDrawable(getActiveIcon(R.drawable.ic_action_snap_to_road));
-
+ if (mapActivity != null) {
+ Drawable icon;
+ if (appMode == null) {
+ icon = getActiveIcon(R.drawable.ic_action_split_interval);
+ } else {
+ icon = getIcon(appMode.getIconRes(), appMode.getIconColorInfo().getColor(nightMode));
+ }
ImageButton snapToRoadBtn = (ImageButton) mapActivity.findViewById(R.id.snap_to_road_image_button);
snapToRoadBtn.setBackgroundResource(nightMode ? R.drawable.btn_circle_night : R.drawable.btn_circle);
- snapToRoadBtn.setImageDrawable(getIcon(appMode.getIconRes(), appMode.getIconColorInfo().getColor(nightMode)));
+ snapToRoadBtn.setImageDrawable(icon);
snapToRoadBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
@@ -829,11 +844,18 @@ public class MeasurementToolFragment extends BaseOsmAndFragment {
mainIcon.setImageDrawable(getActiveIcon(R.drawable.ic_action_ruler));
editingCtx.setInSnapToRoadMode(false);
editingCtx.cancelSnapToRoad();
+ hideSnapToRoadIcon();
+ MapActivity mapActivity = getMapActivity();
+ if (mapActivity != null) {
+ mainView.findViewById(R.id.snap_to_road_progress_bar).setVisibility(View.GONE);
+ mapActivity.refreshMap();
+ }
+ }
+
+ private void hideSnapToRoadIcon() {
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
mapActivity.findViewById(R.id.snap_to_road_image_button).setVisibility(View.GONE);
- mainView.findViewById(R.id.snap_to_road_progress_bar).setVisibility(View.GONE);
- mapActivity.refreshMap();
}
}
@@ -851,11 +873,8 @@ public class MeasurementToolFragment extends BaseOsmAndFragment {
private void displaySegmentPoints() {
final MeasurementToolLayer measurementLayer = getMeasurementLayer();
-
- TrkSegment segment = editingCtx.getNewGpxData().getTrkSegment();
- List points = segment.points;
if (measurementLayer != null) {
- editingCtx.addPoints(points);
+ editingCtx.addPoints();
adapter.notifyDataSetChanged();
updateText();
}
@@ -898,6 +917,10 @@ public class MeasurementToolFragment extends BaseOsmAndFragment {
MeasurementToolLayer measurementLayer = getMeasurementLayer();
if (measurementLayer != null) {
WptPt newPoint = measurementLayer.getMovedPointToApply();
+ String profileType = editingCtx.getSnapToRoadAppMode().getStringKey();
+ if (!Algorithms.isEmpty(profileType)) {
+ newPoint.setProfileType(profileType);
+ }
WptPt oldPoint = editingCtx.getOriginalPointToMove();
int position = editingCtx.getSelectedPointPosition();
editingCtx.getCommandManager().execute(new MovePointCommand(measurementLayer, oldPoint, newPoint, position));
@@ -1309,6 +1332,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment {
editingCtx.exportRouteAsGpx(trackName, new MeasurementEditingContext.ExportAsGpxListener() {
@Override
public void onExportAsGpxFinished(GPXFile gpx) {
+ gpx.addRoutePoints(editingCtx.getPoints());
final Exception res = GPXUtilities.writeGpxFile(toSave, gpx);
gpx.path = toSave.getAbsolutePath();
OsmandApplication app = getMyApplication();
@@ -1594,6 +1618,8 @@ public class MeasurementToolFragment extends BaseOsmAndFragment {
}
if (editingCtx.isInSnapToRoadMode()) {
disableSnapToRoadMode();
+ } else {
+ hideSnapToRoadIcon();
}
if (editingCtx.getNewGpxData() != null) {
GPXFile gpx = editingCtx.getNewGpxData().getGpxFile();
diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolLayer.java b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolLayer.java
index bd69a1f094..c937d404ff 100644
--- a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolLayer.java
+++ b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolLayer.java
@@ -10,7 +10,6 @@ import android.graphics.PointF;
import net.osmand.Location;
import net.osmand.data.LatLon;
import net.osmand.data.PointDescription;
-import net.osmand.data.QuadPoint;
import net.osmand.data.RotatedTileBox;
import net.osmand.GPXUtilities.TrkSegment;
import net.osmand.GPXUtilities.WptPt;
@@ -20,6 +19,7 @@ import net.osmand.plus.views.ContextMenuLayer;
import net.osmand.plus.views.OsmandMapLayer;
import net.osmand.plus.views.OsmandMapTileView;
import net.osmand.plus.views.Renderable;
+import net.osmand.util.Algorithms;
import net.osmand.util.MapUtils;
import java.util.ArrayList;
@@ -322,6 +322,10 @@ public class MeasurementToolLayer extends OsmandMapLayer implements ContextMenuL
pt.lon = l.getLongitude();
boolean allowed = editingCtx.getPointsCount() == 0 || !editingCtx.getPoints().get(editingCtx.getPointsCount() - 1).equals(pt);
if (allowed) {
+ String profileType = editingCtx.getSnapToRoadAppMode().getStringKey();
+ if (!Algorithms.isEmpty(profileType)) {
+ pt.setProfileType(profileType);
+ }
editingCtx.addPoint(pt);
return pt;
}
@@ -338,6 +342,10 @@ public class MeasurementToolLayer extends OsmandMapLayer implements ContextMenuL
pressedPointLatLon = null;
boolean allowed = editingCtx.getPointsCount() == 0 || !editingCtx.getPoints().get(editingCtx.getPointsCount() - 1).equals(pt);
if (allowed) {
+ String profileType = editingCtx.getSnapToRoadAppMode().getStringKey();
+ if (!Algorithms.isEmpty(profileType)) {
+ pt.setProfileType(profileType);
+ }
editingCtx.addPoint(pt);
moveMapToLatLon(lat, lon);
return pt;
diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/OptionsBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/measurementtool/OptionsBottomSheetDialogFragment.java
index 9d69604c40..8ac32fa803 100644
--- a/OsmAnd/src/net/osmand/plus/measurementtool/OptionsBottomSheetDialogFragment.java
+++ b/OsmAnd/src/net/osmand/plus/measurementtool/OptionsBottomSheetDialogFragment.java
@@ -6,7 +6,7 @@ import android.view.View;
import net.osmand.plus.R;
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
-import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithCompoundButton;
+import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithDescription;
import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem;
import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerHalfItem;
import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem;
@@ -32,14 +32,11 @@ public class OptionsBottomSheetDialogFragment extends MenuBottomSheetDialogFragm
items.add(new TitleItem(getString(R.string.shared_string_options)));
- BaseBottomSheetItem snapToRoadItem = new BottomSheetItemWithCompoundButton.Builder()
- .setChecked(snapToRoadEnabled)
- .setDescription(getString(snapToRoadEnabled ? R.string.shared_string_on : R.string.shared_string_off))
- .setIcon(snapToRoadEnabled
- ? getActiveIcon(R.drawable.ic_action_snap_to_road)
- : getContentIcon(R.drawable.ic_action_snap_to_road))
- .setTitle(getString(R.string.snap_to_road))
- .setLayoutId(R.layout.bottom_sheet_item_with_descr_and_switch_56dp)
+ BaseBottomSheetItem snapToRoadItem = new BottomSheetItemWithDescription.Builder()
+ .setDescription(getString(R.string.routing_profile_straightline))
+ .setIcon(getContentIcon(R.drawable.ic_action_split_interval))
+ .setTitle(getString(R.string.route_between_points))
+ .setLayoutId(R.layout.bottom_sheet_item_with_descr_56dp)
.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@@ -72,21 +69,7 @@ public class OptionsBottomSheetDialogFragment extends MenuBottomSheetDialogFragm
items.add(saveAsNewSegmentItem);
} else if (addLineMode) {
- BaseBottomSheetItem saveAsNewTrackItem = new SimpleBottomSheetItem.Builder()
- .setIcon(getContentIcon(R.drawable.ic_action_polygom_dark))
- .setTitle(getString(R.string.shared_string_save_as_gpx))
- .setLayoutId(R.layout.bottom_sheet_item_simple)
- .setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- if (listener != null) {
- listener.saveAsNewTrackOnClick();
- }
- dismiss();
- }
- })
- .create();
- items.add(saveAsNewTrackItem);
+ items.add(getSaveAsNewTrackItem());
BaseBottomSheetItem saveAsNewSegmentItem = new SimpleBottomSheetItem.Builder()
.setIcon(getContentIcon(R.drawable.ic_action_polygom_dark))
@@ -104,25 +87,11 @@ public class OptionsBottomSheetDialogFragment extends MenuBottomSheetDialogFragm
.create();
items.add(saveAsNewSegmentItem);
} else {
- BaseBottomSheetItem saveAsNewTrackItem = new SimpleBottomSheetItem.Builder()
- .setIcon(getContentIcon(R.drawable.ic_action_polygom_dark))
- .setTitle(getString(R.string.shared_string_save_as_gpx))
- .setLayoutId(R.layout.bottom_sheet_item_simple)
- .setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- if (listener != null) {
- listener.saveAsNewTrackOnClick();
- }
- dismiss();
- }
- })
- .create();
- items.add(saveAsNewTrackItem);
+ items.add(getSaveAsNewTrackItem());
BaseBottomSheetItem addToTrackItem = new SimpleBottomSheetItem.Builder()
.setIcon(getContentIcon(R.drawable.ic_action_split_interval))
- .setTitle(getString(R.string.add_segment_to_the_track))
+ .setTitle(getString(R.string.add_to_a_track))
.setLayoutId(R.layout.bottom_sheet_item_simple)
.setOnClickListener(new View.OnClickListener() {
@Override
@@ -156,6 +125,23 @@ public class OptionsBottomSheetDialogFragment extends MenuBottomSheetDialogFragm
items.add(clearAllItem);
}
+ private BaseBottomSheetItem getSaveAsNewTrackItem() {
+ return new SimpleBottomSheetItem.Builder()
+ .setIcon(getContentIcon(R.drawable.ic_action_save_to_file))
+ .setTitle(getString(R.string.edit_filter_save_as_menu_item))
+ .setLayoutId(R.layout.bottom_sheet_item_simple)
+ .setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (listener != null) {
+ listener.saveAsNewTrackOnClick();
+ }
+ dismiss();
+ }
+ })
+ .create();
+ }
+
@Override
protected int getDismissButtonTextId() {
return R.string.shared_string_close;