Fix / refactor save gpx (plan route)
This commit is contained in:
parent
d0a274d877
commit
7907e72781
16 changed files with 261 additions and 196 deletions
|
@ -461,7 +461,21 @@ public class GPXUtilities {
|
||||||
public String pointTypes;
|
public String pointTypes;
|
||||||
public String names;
|
public String names;
|
||||||
|
|
||||||
public StringBundle getStringBundle() {
|
public static RouteSegment fromStringBundle(StringBundle bundle) {
|
||||||
|
RouteSegment s = new RouteSegment();
|
||||||
|
s.id = bundle.getString("id", null);
|
||||||
|
s.length = bundle.getString("length", null);
|
||||||
|
s.segmentTime = bundle.getString("segmentTime", null);
|
||||||
|
s.speed = bundle.getString("speed", null);
|
||||||
|
s.turnType = bundle.getString("turnType", null);
|
||||||
|
s.turnAngle = bundle.getString("turnAngle", null);
|
||||||
|
s.types = bundle.getString("types", null);
|
||||||
|
s.pointTypes = bundle.getString("pointTypes", null);
|
||||||
|
s.names = bundle.getString("names", null);
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StringBundle toStringBundle() {
|
||||||
StringBundle bundle = new StringBundle();
|
StringBundle bundle = new StringBundle();
|
||||||
bundle.putString("id", id);
|
bundle.putString("id", id);
|
||||||
bundle.putString("length", length);
|
bundle.putString("length", length);
|
||||||
|
@ -480,7 +494,14 @@ public class GPXUtilities {
|
||||||
public String tag;
|
public String tag;
|
||||||
public String value;
|
public String value;
|
||||||
|
|
||||||
public StringBundle getStringBundle() {
|
public static RouteType fromStringBundle(StringBundle bundle) {
|
||||||
|
RouteType t = new RouteType();
|
||||||
|
t.tag = bundle.getString("t", null);
|
||||||
|
t.value = bundle.getString("v", null);
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StringBundle toStringBundle() {
|
||||||
StringBundle bundle = new StringBundle();
|
StringBundle bundle = new StringBundle();
|
||||||
bundle.putString("t", tag);
|
bundle.putString("t", tag);
|
||||||
bundle.putString("v", value);
|
bundle.putString("v", value);
|
||||||
|
@ -1834,12 +1855,12 @@ public class GPXUtilities {
|
||||||
StringBundle bundle = new StringBundle();
|
StringBundle bundle = new StringBundle();
|
||||||
List<StringBundle> segmentsBundle = new ArrayList<>();
|
List<StringBundle> segmentsBundle = new ArrayList<>();
|
||||||
for (RouteSegment segment : gpxFile.routeSegments) {
|
for (RouteSegment segment : gpxFile.routeSegments) {
|
||||||
segmentsBundle.add(segment.getStringBundle());
|
segmentsBundle.add(segment.toStringBundle());
|
||||||
}
|
}
|
||||||
bundle.putBundleList("route", "segment", segmentsBundle);
|
bundle.putBundleList("route", "segment", segmentsBundle);
|
||||||
List<StringBundle> typesBundle = new ArrayList<>();
|
List<StringBundle> typesBundle = new ArrayList<>();
|
||||||
for (RouteType routeType : gpxFile.routeTypes) {
|
for (RouteType routeType : gpxFile.routeTypes) {
|
||||||
typesBundle.add(routeType.getStringBundle());
|
typesBundle.add(routeType.toStringBundle());
|
||||||
}
|
}
|
||||||
bundle.putBundleList("types", "type", typesBundle);
|
bundle.putBundleList("types", "type", typesBundle);
|
||||||
StringBundleWriter bundleWriter = new StringBundleXmlWriter(bundle, serializer);
|
StringBundleWriter bundleWriter = new StringBundleXmlWriter(bundle, serializer);
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
package net.osmand.router;
|
package net.osmand.router;
|
||||||
|
|
||||||
|
import net.osmand.GPXUtilities;
|
||||||
import net.osmand.GPXUtilities.GPXExtensionsWriter;
|
import net.osmand.GPXUtilities.GPXExtensionsWriter;
|
||||||
import net.osmand.GPXUtilities.GPXFile;
|
import net.osmand.GPXUtilities.GPXFile;
|
||||||
|
import net.osmand.GPXUtilities.RouteSegment;
|
||||||
|
import net.osmand.GPXUtilities.RouteType;
|
||||||
import net.osmand.GPXUtilities.Track;
|
import net.osmand.GPXUtilities.Track;
|
||||||
import net.osmand.GPXUtilities.TrkSegment;
|
import net.osmand.GPXUtilities.TrkSegment;
|
||||||
import net.osmand.GPXUtilities.WptPt;
|
import net.osmand.GPXUtilities.WptPt;
|
||||||
|
@ -37,8 +40,7 @@ public class RouteExporter {
|
||||||
|
|
||||||
public GPXFile exportRoute() {
|
public GPXFile exportRoute() {
|
||||||
RouteDataResources resources = new RouteDataResources(locations);
|
RouteDataResources resources = new RouteDataResources(locations);
|
||||||
final RouteDataBundle bundle = new RouteDataBundle(resources);
|
List<StringBundle> routeItems = new ArrayList<>();
|
||||||
|
|
||||||
if (!Algorithms.isEmpty(route)) {
|
if (!Algorithms.isEmpty(route)) {
|
||||||
for (RouteSegmentResult sr : route) {
|
for (RouteSegmentResult sr : route) {
|
||||||
sr.collectTypes(resources);
|
sr.collectTypes(resources);
|
||||||
|
@ -47,15 +49,12 @@ public class RouteExporter {
|
||||||
sr.collectNames(resources);
|
sr.collectNames(resources);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<StringBundle> routeItems = new ArrayList<>();
|
|
||||||
for (RouteSegmentResult sr : route) {
|
for (RouteSegmentResult sr : route) {
|
||||||
RouteDataBundle itemBundle = new RouteDataBundle(resources);
|
RouteDataBundle itemBundle = new RouteDataBundle(resources);
|
||||||
sr.writeToBundle(itemBundle);
|
sr.writeToBundle(itemBundle);
|
||||||
routeItems.add(itemBundle);
|
routeItems.add(itemBundle);
|
||||||
}
|
}
|
||||||
bundle.putBundleList("route", "segment", routeItems);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
List<StringBundle> typeList = new ArrayList<>();
|
List<StringBundle> typeList = new ArrayList<>();
|
||||||
Map<RouteTypeRule, Integer> rules = resources.getRules();
|
Map<RouteTypeRule, Integer> rules = resources.getRules();
|
||||||
for (RouteTypeRule rule : rules.keySet()) {
|
for (RouteTypeRule rule : rules.keySet()) {
|
||||||
|
@ -63,7 +62,6 @@ public class RouteExporter {
|
||||||
rule.writeToBundle(typeBundle);
|
rule.writeToBundle(typeBundle);
|
||||||
typeList.add(typeBundle);
|
typeList.add(typeBundle);
|
||||||
}
|
}
|
||||||
bundle.putBundleList("types", "type", typeList);
|
|
||||||
|
|
||||||
GPXFile gpx = new GPXFile(OSMAND_ROUTER_V2);
|
GPXFile gpx = new GPXFile(OSMAND_ROUTER_V2);
|
||||||
Track track = new Track();
|
Track track = new Track();
|
||||||
|
@ -75,7 +73,6 @@ public class RouteExporter {
|
||||||
if (locations == null || locations.isEmpty()) {
|
if (locations == null || locations.isEmpty()) {
|
||||||
return gpx;
|
return gpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < locations.size(); i++) {
|
for (int i = 0; i < locations.size(); i++) {
|
||||||
Location loc = locations.get(i);
|
Location loc = locations.get(i);
|
||||||
WptPt pt = new WptPt();
|
WptPt pt = new WptPt();
|
||||||
|
@ -92,21 +89,22 @@ public class RouteExporter {
|
||||||
}
|
}
|
||||||
trkSegment.points.add(pt);
|
trkSegment.points.add(pt);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (points != null) {
|
if (points != null) {
|
||||||
for (WptPt pt : points) {
|
for (WptPt pt : points) {
|
||||||
gpx.addPoint(pt);
|
gpx.addPoint(pt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GPXExtensionsWriter extensionsWriter = new GPXExtensionsWriter() {
|
List<RouteSegment> routeSegments = new ArrayList<>();
|
||||||
@Override
|
for (StringBundle item : routeItems) {
|
||||||
public void writeExtensions(XmlSerializer serializer) {
|
routeSegments.add(RouteSegment.fromStringBundle(item));
|
||||||
StringBundleWriter bundleWriter = new StringBundleXmlWriter(bundle, serializer);
|
|
||||||
bundleWriter.writeBundle();
|
|
||||||
}
|
}
|
||||||
};
|
gpx.routeSegments = routeSegments;
|
||||||
gpx.setExtensionsWriter(extensionsWriter);
|
List<RouteType> routeTypes = new ArrayList<>();
|
||||||
|
for (StringBundle item : typeList) {
|
||||||
|
routeTypes.add(RouteType.fromStringBundle(item));
|
||||||
|
}
|
||||||
|
gpx.routeTypes = routeTypes;
|
||||||
|
|
||||||
return gpx;
|
return gpx;
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,7 +98,7 @@ public class RouteImporter {
|
||||||
for (RouteSegment segment : gpxFile.routeSegments) {
|
for (RouteSegment segment : gpxFile.routeSegments) {
|
||||||
RouteDataObject object = new RouteDataObject(region);
|
RouteDataObject object = new RouteDataObject(region);
|
||||||
RouteSegmentResult segmentResult = new RouteSegmentResult(object);
|
RouteSegmentResult segmentResult = new RouteSegmentResult(object);
|
||||||
segmentResult.readFromBundle(new RouteDataBundle(resources, segment.getStringBundle()));
|
segmentResult.readFromBundle(new RouteDataBundle(resources, segment.toStringBundle()));
|
||||||
route.add(segmentResult);
|
route.add(segmentResult);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -106,7 +106,7 @@ public class RouteImporter {
|
||||||
private void collectTypes() {
|
private void collectTypes() {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (RouteType routeType : gpxFile.routeTypes) {
|
for (RouteType routeType : gpxFile.routeTypes) {
|
||||||
StringBundle bundle = routeType.getStringBundle();
|
StringBundle bundle = routeType.toStringBundle();
|
||||||
String t = bundle.getString("t", null);
|
String t = bundle.getString("t", null);
|
||||||
String v = bundle.getString("v", null);
|
String v = bundle.getString("v", null);
|
||||||
region.initRouteEncodingRule(i++, t, v);
|
region.initRouteEncodingRule(i++, t, v);
|
||||||
|
|
|
@ -327,6 +327,9 @@ public class RouteSegmentResult implements StringExternalizable<RouteDataBundle>
|
||||||
Location prevLocation = null;
|
Location prevLocation = null;
|
||||||
for (int i = 0; i < length; i++) {
|
for (int i = 0; i < length; i++) {
|
||||||
Location location = resources.getLocation(index);
|
Location location = resources.getLocation(index);
|
||||||
|
if (location == null) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
double dist = 0;
|
double dist = 0;
|
||||||
if (prevLocation != null) {
|
if (prevLocation != null) {
|
||||||
dist = MapUtils.getDistance(prevLocation.getLatitude(), prevLocation.getLongitude(), location.getLatitude(), location.getLongitude());
|
dist = MapUtils.getDistance(prevLocation.getLatitude(), prevLocation.getLongitude(), location.getLatitude(), location.getLongitude());
|
||||||
|
|
|
@ -120,7 +120,7 @@ import net.osmand.plus.mapmarkers.PlanRouteFragment;
|
||||||
import net.osmand.plus.measurementtool.GpxApproximationFragment;
|
import net.osmand.plus.measurementtool.GpxApproximationFragment;
|
||||||
import net.osmand.plus.measurementtool.MeasurementEditingContext;
|
import net.osmand.plus.measurementtool.MeasurementEditingContext;
|
||||||
import net.osmand.plus.measurementtool.MeasurementToolFragment;
|
import net.osmand.plus.measurementtool.MeasurementToolFragment;
|
||||||
import net.osmand.plus.measurementtool.NewGpxData;
|
import net.osmand.plus.measurementtool.GpxData;
|
||||||
import net.osmand.plus.measurementtool.SnapTrackWarningBottomSheet;
|
import net.osmand.plus.measurementtool.SnapTrackWarningBottomSheet;
|
||||||
import net.osmand.plus.quickaction.QuickActionListFragment;
|
import net.osmand.plus.quickaction.QuickActionListFragment;
|
||||||
import net.osmand.plus.render.RendererRegistry;
|
import net.osmand.plus.render.RendererRegistry;
|
||||||
|
@ -1290,12 +1290,12 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
||||||
QuadRect qr = newGpxPoint.getRect();
|
QuadRect qr = newGpxPoint.getRect();
|
||||||
mapView.fitRectToMap(qr.left, qr.right, qr.top, qr.bottom, (int) qr.width(), (int) qr.height(), 0);
|
mapView.fitRectToMap(qr.left, qr.right, qr.top, qr.bottom, (int) qr.width(), (int) qr.height(), 0);
|
||||||
getMapLayers().getContextMenuLayer().enterAddGpxPointMode(newGpxPoint);
|
getMapLayers().getContextMenuLayer().enterAddGpxPointMode(newGpxPoint);
|
||||||
} else if (toShow instanceof NewGpxData) {
|
} else if (toShow instanceof GpxData) {
|
||||||
NewGpxData newGpxData = (NewGpxData) toShow;
|
GpxData gpxData = (GpxData) toShow;
|
||||||
QuadRect qr = newGpxData.getRect();
|
QuadRect qr = gpxData.getRect();
|
||||||
mapView.fitRectToMap(qr.left, qr.right, qr.top, qr.bottom, (int) qr.width(), (int) qr.height(), 0);
|
mapView.fitRectToMap(qr.left, qr.right, qr.top, qr.bottom, (int) qr.width(), (int) qr.height(), 0);
|
||||||
MeasurementEditingContext editingContext = new MeasurementEditingContext();
|
MeasurementEditingContext editingContext = new MeasurementEditingContext();
|
||||||
editingContext.setNewGpxData(newGpxData);
|
editingContext.setGpxData(gpxData);
|
||||||
MeasurementToolFragment.showInstance(getSupportFragmentManager(), editingContext);
|
MeasurementToolFragment.showInstance(getSupportFragmentManager(), editingContext);
|
||||||
} else {
|
} else {
|
||||||
mapContextMenu.show(latLonToShow, mapLabelToShow, toShow);
|
mapContextMenu.show(latLonToShow, mapLabelToShow, toShow);
|
||||||
|
|
|
@ -37,7 +37,7 @@ import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.settings.backend.OsmandSettings;
|
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.mapmarkers.CoordinateInputDialogFragment;
|
import net.osmand.plus.mapmarkers.CoordinateInputDialogFragment;
|
||||||
import net.osmand.plus.measurementtool.NewGpxData;
|
import net.osmand.plus.measurementtool.GpxData;
|
||||||
import net.osmand.plus.myplaces.FavoritesActivity;
|
import net.osmand.plus.myplaces.FavoritesActivity;
|
||||||
import net.osmand.plus.myplaces.SplitSegmentDialogFragment;
|
import net.osmand.plus.myplaces.SplitSegmentDialogFragment;
|
||||||
import net.osmand.plus.myplaces.TrackBitmapDrawer;
|
import net.osmand.plus.myplaces.TrackBitmapDrawer;
|
||||||
|
@ -136,14 +136,14 @@ public class TrackActivity extends TabActivity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addNewGpxData(NewGpxData.ActionType actionType) {
|
public void addNewGpxData(GpxData.ActionType actionType) {
|
||||||
addNewGpxData(actionType, null);
|
addNewGpxData(actionType, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addNewGpxData(NewGpxData.ActionType actionType, TrkSegment segment) {
|
public void addNewGpxData(GpxData.ActionType actionType, TrkSegment segment) {
|
||||||
GPXFile gpxFile = getGpx();
|
GPXFile gpxFile = getGpx();
|
||||||
QuadRect rect = getRect();
|
QuadRect rect = getRect();
|
||||||
NewGpxData newGpxData = new NewGpxData(gpxFile, rect, actionType, segment);
|
GpxData gpxData = new GpxData(gpxFile, rect, actionType, segment);
|
||||||
WptPt pointToShow = gpxFile != null ? gpxFile.findPointToShow() : null;
|
WptPt pointToShow = gpxFile != null ? gpxFile.findPointToShow() : null;
|
||||||
if (pointToShow != null) {
|
if (pointToShow != null) {
|
||||||
LatLon location = new LatLon(pointToShow.getLatitude(), pointToShow.getLongitude());
|
LatLon location = new LatLon(pointToShow.getLatitude(), pointToShow.getLongitude());
|
||||||
|
@ -152,7 +152,7 @@ public class TrackActivity extends TabActivity {
|
||||||
settings.getLastKnownMapZoom(),
|
settings.getLastKnownMapZoom(),
|
||||||
new PointDescription(PointDescription.POINT_TYPE_WPT, getString(R.string.add_line)),
|
new PointDescription(PointDescription.POINT_TYPE_WPT, getString(R.string.add_line)),
|
||||||
false,
|
false,
|
||||||
newGpxData
|
gpxData
|
||||||
);
|
);
|
||||||
|
|
||||||
MapActivity.launchMapActivityMoveToTop(this);
|
MapActivity.launchMapActivityMoveToTop(this);
|
||||||
|
|
|
@ -4,7 +4,7 @@ import net.osmand.GPXUtilities.GPXFile;
|
||||||
import net.osmand.GPXUtilities.TrkSegment;
|
import net.osmand.GPXUtilities.TrkSegment;
|
||||||
import net.osmand.data.QuadRect;
|
import net.osmand.data.QuadRect;
|
||||||
|
|
||||||
public class NewGpxData {
|
public class GpxData {
|
||||||
|
|
||||||
public enum ActionType {
|
public enum ActionType {
|
||||||
ADD_SEGMENT,
|
ADD_SEGMENT,
|
||||||
|
@ -18,7 +18,7 @@ public class NewGpxData {
|
||||||
private QuadRect rect;
|
private QuadRect rect;
|
||||||
private ActionType actionType;
|
private ActionType actionType;
|
||||||
|
|
||||||
public NewGpxData(GPXFile gpxFile, QuadRect rect, ActionType actionType, TrkSegment trkSegment) {
|
public GpxData(GPXFile gpxFile, QuadRect rect, ActionType actionType, TrkSegment trkSegment) {
|
||||||
this.gpxFile = gpxFile;
|
this.gpxFile = gpxFile;
|
||||||
this.rect = rect;
|
this.rect = rect;
|
||||||
this.actionType = actionType;
|
this.actionType = actionType;
|
|
@ -39,7 +39,6 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
import static net.osmand.plus.measurementtool.MeasurementEditingContext.CalculationMode.NEXT_SEGMENT;
|
|
||||||
import static net.osmand.plus.measurementtool.MeasurementEditingContext.CalculationMode.WHOLE_TRACK;
|
import static net.osmand.plus.measurementtool.MeasurementEditingContext.CalculationMode.WHOLE_TRACK;
|
||||||
|
|
||||||
public class MeasurementEditingContext {
|
public class MeasurementEditingContext {
|
||||||
|
@ -54,7 +53,7 @@ public class MeasurementEditingContext {
|
||||||
private final TrkSegment after = new TrkSegment();
|
private final TrkSegment after = new TrkSegment();
|
||||||
private TrkSegment afterCacheForSnap;
|
private TrkSegment afterCacheForSnap;
|
||||||
|
|
||||||
private NewGpxData newGpxData;
|
private GpxData gpxData;
|
||||||
|
|
||||||
private int selectedPointPosition = -1;
|
private int selectedPointPosition = -1;
|
||||||
private WptPt originalPointToMove;
|
private WptPt originalPointToMove;
|
||||||
|
@ -139,6 +138,14 @@ public class MeasurementEditingContext {
|
||||||
return commandManager;
|
return commandManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasChanges() {
|
||||||
|
return commandManager.hasChanges();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setChangesSaved() {
|
||||||
|
commandManager.resetChangesCounter();
|
||||||
|
}
|
||||||
|
|
||||||
boolean isInAddPointMode() {
|
boolean isInAddPointMode() {
|
||||||
return inAddPointMode;
|
return inAddPointMode;
|
||||||
}
|
}
|
||||||
|
@ -167,20 +174,21 @@ public class MeasurementEditingContext {
|
||||||
this.inAddPointMode = inAddPointMode;
|
this.inAddPointMode = inAddPointMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
NewGpxData getNewGpxData() {
|
@Nullable
|
||||||
return newGpxData;
|
GpxData getGpxData() {
|
||||||
|
return gpxData;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isNewData() {
|
public boolean isNewData() {
|
||||||
return newGpxData == null;
|
return gpxData == null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNewGpxData(NewGpxData newGpxData) {
|
public void setGpxData(GpxData gpxData) {
|
||||||
this.newGpxData = newGpxData;
|
this.gpxData = gpxData;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasRoutePoints() {
|
public boolean hasRoutePoints() {
|
||||||
return newGpxData != null && newGpxData.getGpxFile() != null && newGpxData.getGpxFile().hasRtePt();
|
return gpxData != null && gpxData.getGpxFile() != null && gpxData.getGpxFile().hasRtePt();
|
||||||
}
|
}
|
||||||
|
|
||||||
public CalculationMode getCalculationMode() {
|
public CalculationMode getCalculationMode() {
|
||||||
|
@ -390,15 +398,15 @@ public class MeasurementEditingContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
void addPoints() {
|
void addPoints() {
|
||||||
NewGpxData newGpxData = getNewGpxData();
|
GpxData gpxData = getGpxData();
|
||||||
if (newGpxData == null || newGpxData.getTrkSegment() == null || Algorithms.isEmpty(newGpxData.getTrkSegment().points)) {
|
if (gpxData == null || gpxData.getTrkSegment() == null || Algorithms.isEmpty(gpxData.getTrkSegment().points)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
List<WptPt> points = newGpxData.getTrkSegment().points;
|
List<WptPt> points = gpxData.getTrkSegment().points;
|
||||||
if (isTrackSnappedToRoad()) {
|
if (isTrackSnappedToRoad()) {
|
||||||
RouteImporter routeImporter = new RouteImporter(newGpxData.getGpxFile());
|
RouteImporter routeImporter = new RouteImporter(gpxData.getGpxFile());
|
||||||
List<RouteSegmentResult> segments = routeImporter.importRoute();
|
List<RouteSegmentResult> segments = routeImporter.importRoute();
|
||||||
List<WptPt> routePoints = newGpxData.getGpxFile().getRoutePoints();
|
List<WptPt> routePoints = gpxData.getGpxFile().getRoutePoints();
|
||||||
int prevPointIndex = 0;
|
int prevPointIndex = 0;
|
||||||
for (int i = 0; i < routePoints.size() - 1; i++) {
|
for (int i = 0; i < routePoints.size() - 1; i++) {
|
||||||
Pair<WptPt, WptPt> pair = new Pair<>(routePoints.get(i), routePoints.get(i + 1));
|
Pair<WptPt, WptPt> pair = new Pair<>(routePoints.get(i), routePoints.get(i + 1));
|
||||||
|
@ -504,10 +512,10 @@ public class MeasurementEditingContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean isTrackSnappedToRoad() {
|
boolean isTrackSnappedToRoad() {
|
||||||
NewGpxData newGpxData = getNewGpxData();
|
GpxData gpxData = getGpxData();
|
||||||
return newGpxData != null && newGpxData.getTrkSegment() != null
|
return gpxData != null && gpxData.getTrkSegment() != null
|
||||||
&& !newGpxData.getTrkSegment().points.isEmpty()
|
&& !gpxData.getTrkSegment().points.isEmpty()
|
||||||
&& newGpxData.getGpxFile().hasRoute();
|
&& gpxData.getGpxFile().hasRoute();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateCacheForSnap(boolean both) {
|
private void updateCacheForSnap(boolean both) {
|
||||||
|
|
|
@ -61,7 +61,7 @@ import net.osmand.plus.activities.TrackActivity;
|
||||||
import net.osmand.plus.base.BaseOsmAndFragment;
|
import net.osmand.plus.base.BaseOsmAndFragment;
|
||||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||||
import net.osmand.plus.measurementtool.GpxApproximationFragment.GpxApproximationFragmentListener;
|
import net.osmand.plus.measurementtool.GpxApproximationFragment.GpxApproximationFragmentListener;
|
||||||
import net.osmand.plus.measurementtool.NewGpxData.ActionType;
|
import net.osmand.plus.measurementtool.GpxData.ActionType;
|
||||||
import net.osmand.plus.measurementtool.OptionsBottomSheetDialogFragment.OptionsFragmentListener;
|
import net.osmand.plus.measurementtool.OptionsBottomSheetDialogFragment.OptionsFragmentListener;
|
||||||
import net.osmand.plus.measurementtool.RouteBetweenPointsBottomSheetDialogFragment.RouteBetweenPointsFragmentListener;
|
import net.osmand.plus.measurementtool.RouteBetweenPointsBottomSheetDialogFragment.RouteBetweenPointsFragmentListener;
|
||||||
import net.osmand.plus.measurementtool.SaveAsNewTrackBottomSheetDialogFragment.SaveAsNewTrackFragmentListener;
|
import net.osmand.plus.measurementtool.SaveAsNewTrackBottomSheetDialogFragment.SaveAsNewTrackFragmentListener;
|
||||||
|
@ -83,6 +83,7 @@ import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarControll
|
||||||
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarControllerType;
|
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarControllerType;
|
||||||
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarView;
|
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarView;
|
||||||
import net.osmand.router.RoutePlannerFrontEnd.GpxRouteApproximation;
|
import net.osmand.router.RoutePlannerFrontEnd.GpxRouteApproximation;
|
||||||
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
|
@ -131,11 +132,9 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
private boolean progressBarVisible;
|
private boolean progressBarVisible;
|
||||||
private boolean pointsListOpened;
|
private boolean pointsListOpened;
|
||||||
private boolean planRouteMode = false;
|
private boolean planRouteMode = false;
|
||||||
private Boolean saved;
|
|
||||||
private boolean portrait;
|
private boolean portrait;
|
||||||
private boolean nightMode;
|
private boolean nightMode;
|
||||||
private int cachedMapPosition;
|
private int cachedMapPosition;
|
||||||
private boolean gpxPointsAdded;
|
|
||||||
|
|
||||||
private MeasurementEditingContext editingCtx = new MeasurementEditingContext();
|
private MeasurementEditingContext editingCtx = new MeasurementEditingContext();
|
||||||
|
|
||||||
|
@ -154,7 +153,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
this.initialPoint = initialPoint;
|
this.initialPoint = initialPoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPlanRouteMode(boolean planRouteMode) {
|
private void setPlanRouteMode(boolean planRouteMode) {
|
||||||
this.planRouteMode = planRouteMode;
|
this.planRouteMode = planRouteMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -386,19 +385,6 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
} else {
|
} else {
|
||||||
toolBarController.setBackBtnIconIds(R.drawable.ic_action_remove_dark, R.drawable.ic_action_remove_dark);
|
toolBarController.setBackBtnIconIds(R.drawable.ic_action_remove_dark, R.drawable.ic_action_remove_dark);
|
||||||
}
|
}
|
||||||
final NewGpxData newGpxData = editingCtx.getNewGpxData();
|
|
||||||
if (newGpxData != null) {
|
|
||||||
ActionType actionType = newGpxData.getActionType();
|
|
||||||
if (actionType == ActionType.ADD_ROUTE_POINTS) {
|
|
||||||
toolBarController.setTitle(getString(R.string.add_route_points));
|
|
||||||
} else if (actionType == ActionType.ADD_SEGMENT) {
|
|
||||||
toolBarController.setTitle(getString(R.string.add_line));
|
|
||||||
} else if (actionType == ActionType.EDIT_SEGMENT) {
|
|
||||||
toolBarController.setTitle(getString(R.string.edit_line));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
toolBarController.setTitle(getString(R.string.plan_route));
|
|
||||||
}
|
|
||||||
toolBarController.setOnBackButtonClickListener(new OnClickListener() {
|
toolBarController.setOnBackButtonClickListener(new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
@ -408,27 +394,14 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
toolBarController.setOnSaveViewClickListener(new OnClickListener() {
|
toolBarController.setOnSaveViewClickListener(new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
if (editingCtx.getPointsCount() > 0) {
|
saveChanges(true);
|
||||||
if (newGpxData != null && newGpxData.getActionType() == ActionType.EDIT_SEGMENT) {
|
|
||||||
openSaveAsNewTrackMenu(mapActivity);
|
|
||||||
} else {
|
|
||||||
if (newGpxData == null) {
|
|
||||||
final File dir = mapActivity.getMyApplication().getAppPath(IndexConstants.GPX_INDEX_DIR);
|
|
||||||
String fileName = getSuggestedName(dir) + GPX_FILE_EXT;
|
|
||||||
saveNewGpx(dir, fileName, true, SaveType.ROUTE_POINT, true);
|
|
||||||
} else {
|
|
||||||
addToGpx(mapActivity);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Toast.makeText(mapActivity, getString(R.string.none_point_error), Toast.LENGTH_SHORT).show();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
mapActivity.showTopToolbar(toolBarController);
|
updateToolbar();
|
||||||
|
|
||||||
|
final GpxData gpxData = editingCtx.getGpxData();
|
||||||
adapter = new MeasurementToolAdapter(getMapActivity(), editingCtx.getPoints(),
|
adapter = new MeasurementToolAdapter(getMapActivity(), editingCtx.getPoints(),
|
||||||
newGpxData != null ? newGpxData.getActionType() : null);
|
gpxData != null ? gpxData.getActionType() : null);
|
||||||
if (portrait) {
|
if (portrait) {
|
||||||
pointsRv = mainView.findViewById(R.id.measure_points_recycler_view);
|
pointsRv = mainView.findViewById(R.id.measure_points_recycler_view);
|
||||||
} else {
|
} else {
|
||||||
|
@ -450,7 +423,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
});
|
});
|
||||||
snapToRoadBtn.setVisibility(View.VISIBLE);
|
snapToRoadBtn.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
initMeasurementMode(newGpxData);
|
initMeasurementMode(gpxData);
|
||||||
|
|
||||||
if (savedInstanceState == null) {
|
if (savedInstanceState == null) {
|
||||||
if (editingCtx.isNewData() && planRouteMode) {
|
if (editingCtx.isNewData() && planRouteMode) {
|
||||||
|
@ -464,6 +437,10 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isInEditMode() {
|
||||||
|
return !planRouteMode && !editingCtx.isNewData();
|
||||||
|
}
|
||||||
|
|
||||||
private void updateUndoRedoCommonStuff() {
|
private void updateUndoRedoCommonStuff() {
|
||||||
hidePointsListIfNoPoints();
|
hidePointsListIfNoPoints();
|
||||||
if (editingCtx.getPointsCount() > 0) {
|
if (editingCtx.getPointsCount() > 0) {
|
||||||
|
@ -474,34 +451,34 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
updateSnapToRoadControls();
|
updateSnapToRoadControls();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initMeasurementMode(NewGpxData newGpxData) {
|
private void initMeasurementMode(GpxData gpxData) {
|
||||||
MapActivity mapActivity = getMapActivity();
|
MapActivity mapActivity = getMapActivity();
|
||||||
if (mapActivity != null) {
|
if (mapActivity != null) {
|
||||||
editingCtx.getCommandManager().setMeasurementLayer(mapActivity.getMapLayers().getMeasurementToolLayer());
|
editingCtx.getCommandManager().setMeasurementLayer(mapActivity.getMapLayers().getMeasurementToolLayer());
|
||||||
enterMeasurementMode();
|
enterMeasurementMode();
|
||||||
updateSnapToRoadControls();
|
updateSnapToRoadControls();
|
||||||
if (newGpxData != null && !gpxPointsAdded) {
|
if (gpxData != null) {
|
||||||
List<WptPt> points = newGpxData.getGpxFile().getRoutePoints();
|
List<WptPt> points = gpxData.getGpxFile().getRoutePoints();
|
||||||
if (!points.isEmpty()) {
|
if (!points.isEmpty()) {
|
||||||
ApplicationMode snapToRoadAppMode = ApplicationMode.valueOfStringKey(points.get(points.size() - 1).getProfileType(), null);
|
ApplicationMode snapToRoadAppMode = ApplicationMode.valueOfStringKey(points.get(points.size() - 1).getProfileType(), null);
|
||||||
if (snapToRoadAppMode != null) {
|
if (snapToRoadAppMode != null) {
|
||||||
setAppMode(snapToRoadAppMode);
|
setAppMode(snapToRoadAppMode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ActionType actionType = newGpxData.getActionType();
|
ActionType actionType = gpxData.getActionType();
|
||||||
if (actionType == ActionType.ADD_ROUTE_POINTS) {
|
if (actionType == ActionType.ADD_ROUTE_POINTS) {
|
||||||
displayRoutePoints();
|
displayRoutePoints();
|
||||||
gpxPointsAdded = true;
|
|
||||||
} else if (actionType == ActionType.EDIT_SEGMENT) {
|
} else if (actionType == ActionType.EDIT_SEGMENT) {
|
||||||
displaySegmentPoints();
|
displaySegmentPoints();
|
||||||
gpxPointsAdded = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
if (saved == null) {
|
if (saved == null) {
|
||||||
saved = newGpxData != null
|
saved = gpxData != null
|
||||||
&& (newGpxData.getActionType() == ActionType.ADD_ROUTE_POINTS
|
&& (gpxData.getActionType() == ActionType.ADD_ROUTE_POINTS
|
||||||
|| newGpxData.getActionType() == ActionType.EDIT_SEGMENT);
|
|| gpxData.getActionType() == ActionType.EDIT_SEGMENT);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -579,9 +556,9 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateMainIcon() {
|
private void updateMainIcon() {
|
||||||
NewGpxData newGpxData = editingCtx.getNewGpxData();
|
GpxData gpxData = editingCtx.getGpxData();
|
||||||
if (newGpxData != null) {
|
if (gpxData != null) {
|
||||||
ActionType actionType = newGpxData.getActionType();
|
ActionType actionType = gpxData.getActionType();
|
||||||
if (actionType == ActionType.ADD_SEGMENT || actionType == ActionType.EDIT_SEGMENT) {
|
if (actionType == ActionType.ADD_SEGMENT || actionType == ActionType.EDIT_SEGMENT) {
|
||||||
mainIcon.setImageDrawable(getActiveIcon(R.drawable.ic_action_polygom_dark));
|
mainIcon.setImageDrawable(getActiveIcon(R.drawable.ic_action_polygom_dark));
|
||||||
} else {
|
} else {
|
||||||
|
@ -611,6 +588,24 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void saveChanges(boolean close) {
|
||||||
|
MapActivity mapActivity = getMapActivity();
|
||||||
|
if (mapActivity != null) {
|
||||||
|
if (editingCtx.getPointsCount() > 0) {
|
||||||
|
GpxData gpxData = editingCtx.getGpxData();
|
||||||
|
if (editingCtx.isNewData()) {
|
||||||
|
saveAsGpx(SaveType.ROUTE_POINT);
|
||||||
|
} else if (isInEditMode() && gpxData.getActionType() == ActionType.EDIT_SEGMENT) {
|
||||||
|
openSaveAsNewTrackMenu(mapActivity);
|
||||||
|
} else {
|
||||||
|
addToGpx(mapActivity, close);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Toast.makeText(mapActivity, getString(R.string.none_point_error), Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
||||||
super.onActivityResult(requestCode, resultCode, data);
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
|
@ -663,23 +658,8 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addToGpxOnClick() {
|
public void saveChangesOnClick() {
|
||||||
MapActivity mapActivity = getMapActivity();
|
saveChanges(false);
|
||||||
if (mapActivity != null) {
|
|
||||||
if (editingCtx.getPointsCount() > 0) {
|
|
||||||
editingCtx.getPoints().clear();
|
|
||||||
editingCtx.getPoints().addAll(editingCtx.getBeforePoints());
|
|
||||||
editingCtx.getBeforePoints().clear();
|
|
||||||
editingCtx.getBeforePoints().addAll(editingCtx.getBeforeTrkSegmentLine().points);
|
|
||||||
if (editingCtx.isNewData()) {
|
|
||||||
saveAsGpx(SaveType.ROUTE_POINT);
|
|
||||||
} else {
|
|
||||||
addToGpx(mapActivity);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Toast.makeText(mapActivity, getString(R.string.none_point_error), Toast.LENGTH_SHORT).show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -710,7 +690,6 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
updateUndoRedoButton(false, redoBtn);
|
updateUndoRedoButton(false, redoBtn);
|
||||||
disable(upDownBtn);
|
disable(upDownBtn);
|
||||||
updateDistancePointsText();
|
updateDistancePointsText();
|
||||||
saved = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -783,7 +762,6 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
updateUndoRedoButton(false, redoBtn);
|
updateUndoRedoButton(false, redoBtn);
|
||||||
updateUndoRedoButton(true, undoBtn);
|
updateUndoRedoButton(true, undoBtn);
|
||||||
updateDistancePointsText();
|
updateDistancePointsText();
|
||||||
saved = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -841,7 +819,6 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
@Override
|
@Override
|
||||||
public void openLastEditTrackOnClick(String gpxFileName) {
|
public void openLastEditTrackOnClick(String gpxFileName) {
|
||||||
addNewGpxData(getGpxFile(gpxFileName));
|
addNewGpxData(getGpxFile(gpxFileName));
|
||||||
saved = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -856,7 +833,6 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
@Override
|
@Override
|
||||||
public void selectFileOnCLick(String gpxFileName) {
|
public void selectFileOnCLick(String gpxFileName) {
|
||||||
addNewGpxData(getGpxFile(gpxFileName));
|
addNewGpxData(getGpxFile(gpxFileName));
|
||||||
saved = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -896,7 +872,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
SelectedGpxFile selectedGpxFile = mapActivity.getMyApplication().getSelectedGpxHelper()
|
SelectedGpxFile selectedGpxFile = mapActivity.getMyApplication().getSelectedGpxHelper()
|
||||||
.getSelectedFileByPath(gpxFile.path);
|
.getSelectedFileByPath(gpxFile.path);
|
||||||
boolean showOnMap = selectedGpxFile != null;
|
boolean showOnMap = selectedGpxFile != null;
|
||||||
saveExistingGpx(gpxFile, showOnMap, ActionType.ADD_SEGMENT, false);
|
saveExistingGpx(gpxFile, showOnMap, ActionType.ADD_SEGMENT, editingCtx.hasRoute() ? SaveType.ROUTE_POINT : SaveType.LINE, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -910,11 +886,10 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
QuadRect rect = gpxFile.getRect();
|
QuadRect rect = gpxFile.getRect();
|
||||||
TrkSegment segment = gpxFile.getNonEmptyTrkSegment();
|
TrkSegment segment = gpxFile.getNonEmptyTrkSegment();
|
||||||
ActionType actionType = segment == null ? ActionType.ADD_ROUTE_POINTS : ActionType.EDIT_SEGMENT;
|
ActionType actionType = segment == null ? ActionType.ADD_ROUTE_POINTS : ActionType.EDIT_SEGMENT;
|
||||||
NewGpxData newGpxData = new NewGpxData(gpxFile, rect, actionType, segment);
|
GpxData gpxData = new GpxData(gpxFile, rect, actionType, segment);
|
||||||
|
editingCtx.setGpxData(gpxData);
|
||||||
editingCtx.setNewGpxData(newGpxData);
|
initMeasurementMode(gpxData);
|
||||||
initMeasurementMode(newGpxData);
|
QuadRect qr = gpxData.getRect();
|
||||||
QuadRect qr = newGpxData.getRect();
|
|
||||||
MapActivity mapActivity = getMapActivity();
|
MapActivity mapActivity = getMapActivity();
|
||||||
if (mapActivity != null) {
|
if (mapActivity != null) {
|
||||||
mapActivity.getMapView().fitRectToMap(qr.left, qr.right, qr.top, qr.bottom,
|
mapActivity.getMapView().fitRectToMap(qr.left, qr.right, qr.top, qr.bottom,
|
||||||
|
@ -929,7 +904,6 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
updateUndoRedoButton(true, undoBtn);
|
updateUndoRedoButton(true, undoBtn);
|
||||||
updateUndoRedoButton(false, redoBtn);
|
updateUndoRedoButton(false, redoBtn);
|
||||||
updateDistancePointsText();
|
updateDistancePointsText();
|
||||||
saved = false;
|
|
||||||
hidePointsListIfNoPoints();
|
hidePointsListIfNoPoints();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -991,7 +965,6 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
updateUndoRedoButton(false, redoBtn);
|
updateUndoRedoButton(false, redoBtn);
|
||||||
updateDistancePointsText();
|
updateDistancePointsText();
|
||||||
mapActivity.refreshMap();
|
mapActivity.refreshMap();
|
||||||
saved = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1042,7 +1015,9 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
|
|
||||||
private void displayRoutePoints() {
|
private void displayRoutePoints() {
|
||||||
MeasurementToolLayer measurementLayer = getMeasurementLayer();
|
MeasurementToolLayer measurementLayer = getMeasurementLayer();
|
||||||
GPXFile gpx = editingCtx.getNewGpxData().getGpxFile();
|
GpxData gpxData = editingCtx.getGpxData();
|
||||||
|
GPXFile gpx = gpxData != null ? gpxData.getGpxFile() : null;
|
||||||
|
if (gpx != null) {
|
||||||
List<WptPt> points = gpx.getRoutePoints();
|
List<WptPt> points = gpx.getRoutePoints();
|
||||||
if (measurementLayer != null) {
|
if (measurementLayer != null) {
|
||||||
editingCtx.addPoints(points);
|
editingCtx.addPoints(points);
|
||||||
|
@ -1050,6 +1025,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
updateDistancePointsText();
|
updateDistancePointsText();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void displaySegmentPoints() {
|
private void displaySegmentPoints() {
|
||||||
MeasurementToolLayer measurementLayer = getMeasurementLayer();
|
MeasurementToolLayer measurementLayer = getMeasurementLayer();
|
||||||
|
@ -1254,7 +1230,6 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
updateUndoRedoButton(false, redoBtn);
|
updateUndoRedoButton(false, redoBtn);
|
||||||
updateDistancePointsText();
|
updateDistancePointsText();
|
||||||
adapter.notifyDataSetChanged();
|
adapter.notifyDataSetChanged();
|
||||||
saved = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showPointsList() {
|
private void showPointsList() {
|
||||||
|
@ -1340,12 +1315,15 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addToGpx(MapActivity mapActivity) {
|
private void addToGpx(MapActivity mapActivity, boolean close) {
|
||||||
GPXFile gpx = editingCtx.getNewGpxData().getGpxFile();
|
GpxData gpxData = editingCtx.getGpxData();
|
||||||
SelectedGpxFile selectedGpxFile = mapActivity.getMyApplication().getSelectedGpxHelper().getSelectedFileByPath(gpx.path);
|
GPXFile gpx = gpxData != null ? gpxData.getGpxFile() : null;
|
||||||
|
if (gpx != null) {
|
||||||
|
SelectedGpxFile selectedGpxFile =
|
||||||
|
mapActivity.getMyApplication().getSelectedGpxHelper().getSelectedFileByPath(gpx.path);
|
||||||
boolean showOnMap = selectedGpxFile != null;
|
boolean showOnMap = selectedGpxFile != null;
|
||||||
ActionType actionType = editingCtx.getNewGpxData().getActionType();
|
saveExistingGpx(gpx, showOnMap, gpxData.getActionType(), editingCtx.hasRoute() ? SaveType.ROUTE_POINT : SaveType.LINE, close);
|
||||||
saveExistingGpx(gpx, showOnMap, actionType, true);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveAsGpx(final SaveType saveType) {
|
private void saveAsGpx(final SaveType saveType) {
|
||||||
|
@ -1366,7 +1344,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
});
|
});
|
||||||
showOnMapToggle.setChecked(true);
|
showOnMapToggle.setChecked(true);
|
||||||
|
|
||||||
String displayedName = getSuggestedName(dir);
|
String displayedName = getSuggestedFileName(dir);
|
||||||
nameEt.setText(displayedName);
|
nameEt.setText(displayedName);
|
||||||
nameEt.setSelection(displayedName.length());
|
nameEt.setSelection(displayedName.length());
|
||||||
final boolean[] textChanged = new boolean[1];
|
final boolean[] textChanged = new boolean[1];
|
||||||
|
@ -1425,10 +1403,10 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getSuggestedName(File dir) {
|
private String getSuggestedFileName(File dir) {
|
||||||
NewGpxData newGpxData = editingCtx.getNewGpxData();
|
GpxData gpxData = editingCtx.getGpxData();
|
||||||
String displayedName;
|
String displayedName;
|
||||||
if (newGpxData == null) {
|
if (gpxData == null) {
|
||||||
final String suggestedName = new SimpleDateFormat("EEE dd MMM yyyy", Locale.US).format(new Date());
|
final String suggestedName = new SimpleDateFormat("EEE dd MMM yyyy", Locale.US).format(new Date());
|
||||||
displayedName = suggestedName;
|
displayedName = suggestedName;
|
||||||
File fout = new File(dir, suggestedName + GPX_FILE_EXT);
|
File fout = new File(dir, suggestedName + GPX_FILE_EXT);
|
||||||
|
@ -1438,25 +1416,24 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
fout = new File(dir, displayedName + GPX_FILE_EXT);
|
fout = new File(dir, displayedName + GPX_FILE_EXT);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
displayedName = AndroidUtils.trimExtension(new File(newGpxData.getGpxFile().path).getName());
|
displayedName = AndroidUtils.trimExtension(new File(gpxData.getGpxFile().path).getName());
|
||||||
}
|
}
|
||||||
return displayedName;
|
return displayedName;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveNewGpx(File dir, String fileName, boolean showOnMap, SaveType saveType, boolean close) {
|
private void saveNewGpx(File dir, String fileName, boolean showOnMap, SaveType saveType, boolean close) {
|
||||||
saveGpx(dir, fileName, showOnMap, null, false, null, saveType, close);
|
saveGpx(dir, fileName, showOnMap, null, null, saveType, close);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveExistingGpx(GPXFile gpx, boolean showOnMap, ActionType actionType, boolean openTrackActivity) {
|
private void saveExistingGpx(GPXFile gpx, boolean showOnMap, ActionType actionType, SaveType saveType, boolean close) {
|
||||||
saveGpx(null, null, showOnMap, gpx, openTrackActivity, actionType, null, false);
|
saveGpx(null, null, showOnMap, gpx, actionType, saveType, close);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("StaticFieldLeak")
|
@SuppressLint("StaticFieldLeak")
|
||||||
private void saveGpx(final File dir,
|
private void saveGpx(final File dir,
|
||||||
final String fileName,
|
final String fileName,
|
||||||
final boolean showOnMap,
|
final boolean showOnMap,
|
||||||
final GPXFile gpx,
|
final GPXFile gpxFile,
|
||||||
final boolean openTrackActivity,
|
|
||||||
final ActionType actionType,
|
final ActionType actionType,
|
||||||
final SaveType saveType,
|
final SaveType saveType,
|
||||||
final boolean close) {
|
final boolean close) {
|
||||||
|
@ -1487,7 +1464,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
List<WptPt> points = editingCtx.getPoints();
|
List<WptPt> points = editingCtx.getPoints();
|
||||||
TrkSegment before = editingCtx.getBeforeTrkSegmentLine();
|
TrkSegment before = editingCtx.getBeforeTrkSegmentLine();
|
||||||
TrkSegment after = editingCtx.getAfterTrkSegmentLine();
|
TrkSegment after = editingCtx.getAfterTrkSegmentLine();
|
||||||
if (gpx == null) {
|
if (gpxFile == null) {
|
||||||
toSave = new File(dir, fileName);
|
toSave = new File(dir, fileName);
|
||||||
String trackName = fileName.substring(0, fileName.length() - GPX_FILE_EXT.length());
|
String trackName = fileName.substring(0, fileName.length() - GPX_FILE_EXT.length());
|
||||||
GPXFile gpx = new GPXFile(Version.getFullVersion(app));
|
GPXFile gpx = new GPXFile(Version.getFullVersion(app));
|
||||||
|
@ -1517,9 +1494,30 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
} else {
|
} else {
|
||||||
|
GPXFile gpx = gpxFile;
|
||||||
toSave = new File(gpx.path);
|
toSave = new File(gpx.path);
|
||||||
|
String trackName = Algorithms.getFileNameWithoutExtension(toSave);
|
||||||
if (measurementLayer != null) {
|
if (measurementLayer != null) {
|
||||||
if (actionType != null) {
|
if (planRouteMode) {
|
||||||
|
if (saveType == SaveType.LINE) {
|
||||||
|
TrkSegment segment = new TrkSegment();
|
||||||
|
segment.points.addAll(before.points);
|
||||||
|
segment.points.addAll(after.points);
|
||||||
|
Track track = new Track();
|
||||||
|
track.name = trackName;
|
||||||
|
track.segments.add(segment);
|
||||||
|
gpx.tracks.add(track);
|
||||||
|
} else if (saveType == SaveType.ROUTE_POINT) {
|
||||||
|
if (editingCtx.hasRoute()) {
|
||||||
|
GPXFile newGpx = editingCtx.exportRouteAsGpx(trackName);
|
||||||
|
if (newGpx != null) {
|
||||||
|
gpx = newGpx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
gpx.addRoutePoints(points);
|
||||||
|
}
|
||||||
|
} else if (actionType != null) {
|
||||||
|
GpxData gpxData = editingCtx.getGpxData();
|
||||||
switch (actionType) {
|
switch (actionType) {
|
||||||
case ADD_SEGMENT: {
|
case ADD_SEGMENT: {
|
||||||
List<WptPt> snappedPoints = new ArrayList<>();
|
List<WptPt> snappedPoints = new ArrayList<>();
|
||||||
|
@ -1533,18 +1531,22 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case EDIT_SEGMENT: {
|
case EDIT_SEGMENT: {
|
||||||
|
if (gpxData != null) {
|
||||||
TrkSegment segment = new TrkSegment();
|
TrkSegment segment = new TrkSegment();
|
||||||
segment.points.addAll(points);
|
segment.points.addAll(points);
|
||||||
gpx.replaceSegment(editingCtx.getNewGpxData().getTrkSegment(), segment);
|
gpx.replaceSegment(gpxData.getTrkSegment(), segment);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case OVERWRITE_SEGMENT: {
|
case OVERWRITE_SEGMENT: {
|
||||||
|
if (gpxData != null) {
|
||||||
List<WptPt> snappedPoints = new ArrayList<>();
|
List<WptPt> snappedPoints = new ArrayList<>();
|
||||||
snappedPoints.addAll(before.points);
|
snappedPoints.addAll(before.points);
|
||||||
snappedPoints.addAll(after.points);
|
snappedPoints.addAll(after.points);
|
||||||
TrkSegment segment = new TrkSegment();
|
TrkSegment segment = new TrkSegment();
|
||||||
segment.points.addAll(snappedPoints);
|
segment.points.addAll(snappedPoints);
|
||||||
gpx.replaceSegment(editingCtx.getNewGpxData().getTrkSegment(), segment);
|
gpx.replaceSegment(gpxData.getTrkSegment(), segment);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1580,8 +1582,8 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
}
|
}
|
||||||
mapActivity.refreshMap();
|
mapActivity.refreshMap();
|
||||||
if (warning == null) {
|
if (warning == null) {
|
||||||
saved = true;
|
editingCtx.setChangesSaved();
|
||||||
if (openTrackActivity) {
|
if (isInEditMode()) {
|
||||||
dismiss(mapActivity);
|
dismiss(mapActivity);
|
||||||
} else {
|
} else {
|
||||||
if (close) {
|
if (close) {
|
||||||
|
@ -1651,12 +1653,30 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
if (mapActivity == null) {
|
if (mapActivity == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (editingCtx.getPointsCount() > 1) {
|
final GpxData gpxData = editingCtx.getGpxData();
|
||||||
final File dir = mapActivity.getMyApplication().getAppPath(IndexConstants.GPX_INDEX_DIR);
|
String fileName = getSuggestedFileName(mapActivity.getMyApplication().getAppPath(IndexConstants.GPX_INDEX_DIR));
|
||||||
toolBarController.setTitle(getSuggestedName(dir));
|
String actionStr = getString(R.string.plan_route);
|
||||||
toolBarController.setDescription(getString(R.string.plan_route));
|
boolean editMode = isInEditMode();
|
||||||
|
if (editMode) {
|
||||||
|
ActionType actionType = gpxData.getActionType();
|
||||||
|
switch (actionType) {
|
||||||
|
case ADD_ROUTE_POINTS:
|
||||||
|
actionStr = getString(R.string.add_route_points);
|
||||||
|
break;
|
||||||
|
case ADD_SEGMENT:
|
||||||
|
actionStr = getString(R.string.add_line);
|
||||||
|
break;
|
||||||
|
case EDIT_SEGMENT:
|
||||||
|
case OVERWRITE_SEGMENT:
|
||||||
|
actionStr = getString(R.string.edit_line);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!editMode && editingCtx.getPointsCount() > 1) {
|
||||||
|
toolBarController.setTitle(fileName);
|
||||||
|
toolBarController.setDescription(actionStr);
|
||||||
} else {
|
} else {
|
||||||
toolBarController.setTitle(getString(R.string.plan_route));
|
toolBarController.setTitle(actionStr);
|
||||||
toolBarController.setDescription(null);
|
toolBarController.setDescription(null);
|
||||||
}
|
}
|
||||||
mapActivity.showTopToolbar(toolBarController);
|
mapActivity.showTopToolbar(toolBarController);
|
||||||
|
@ -1743,7 +1763,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
hidePointsList();
|
hidePointsList();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (editingCtx.getPointsCount() == 0 || saved) {
|
if (!editingCtx.hasChanges()) {
|
||||||
dismiss(mapActivity);
|
dismiss(mapActivity);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1759,14 +1779,17 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
}
|
}
|
||||||
resetAppMode();
|
resetAppMode();
|
||||||
hideSnapToRoadIcon();
|
hideSnapToRoadIcon();
|
||||||
if (!editingCtx.isNewData() && !planRouteMode) {
|
if (isInEditMode()) {
|
||||||
GPXFile gpx = editingCtx.getNewGpxData().getGpxFile();
|
GpxData gpxData = editingCtx.getGpxData();
|
||||||
|
GPXFile gpx = gpxData != null ? gpxData.getGpxFile() : null;
|
||||||
|
if (gpx != null) {
|
||||||
Intent newIntent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization().getTrackActivity());
|
Intent newIntent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization().getTrackActivity());
|
||||||
newIntent.putExtra(TrackActivity.TRACK_FILE_NAME, gpx.path);
|
newIntent.putExtra(TrackActivity.TRACK_FILE_NAME, gpx.path);
|
||||||
newIntent.putExtra(TrackActivity.OPEN_TRACKS_LIST, true);
|
newIntent.putExtra(TrackActivity.OPEN_TRACKS_LIST, true);
|
||||||
newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||||
startActivity(newIntent);
|
startActivity(newIntent);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
mapActivity.getSupportFragmentManager().beginTransaction().remove(this).commitAllowingStateLoss();
|
mapActivity.getSupportFragmentManager().beginTransaction().remove(this).commitAllowingStateLoss();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// ignore
|
// ignore
|
||||||
|
|
|
@ -89,7 +89,7 @@ public class OptionsBottomSheetDialogFragment extends MenuBottomSheetDialogFragm
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
Fragment fragment = getTargetFragment();
|
Fragment fragment = getTargetFragment();
|
||||||
if (fragment instanceof OptionsFragmentListener) {
|
if (fragment instanceof OptionsFragmentListener) {
|
||||||
((OptionsFragmentListener) fragment).addToGpxOnClick();
|
((OptionsFragmentListener) fragment).saveChangesOnClick();
|
||||||
}
|
}
|
||||||
dismiss();
|
dismiss();
|
||||||
}
|
}
|
||||||
|
@ -189,7 +189,7 @@ public class OptionsBottomSheetDialogFragment extends MenuBottomSheetDialogFragm
|
||||||
|
|
||||||
void snapToRoadOnCLick();
|
void snapToRoadOnCLick();
|
||||||
|
|
||||||
void addToGpxOnClick();
|
void saveChangesOnClick();
|
||||||
|
|
||||||
void saveAsNewTrackOnClick();
|
void saveAsNewTrackOnClick();
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithDescription;
|
||||||
import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem;
|
import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem;
|
||||||
import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleDividerItem;
|
import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleDividerItem;
|
||||||
import net.osmand.plus.helpers.FontCache;
|
import net.osmand.plus.helpers.FontCache;
|
||||||
import net.osmand.plus.measurementtool.NewGpxData.ActionType;
|
import net.osmand.plus.measurementtool.GpxData.ActionType;
|
||||||
import net.osmand.plus.settings.backend.ApplicationMode;
|
import net.osmand.plus.settings.backend.ApplicationMode;
|
||||||
import net.osmand.util.MapUtils;
|
import net.osmand.util.MapUtils;
|
||||||
|
|
||||||
|
@ -224,8 +224,8 @@ public class SelectedPointBottomSheetDialogFragment extends MenuBottomSheetDialo
|
||||||
if (!TextUtils.isEmpty(pointName)) {
|
if (!TextUtils.isEmpty(pointName)) {
|
||||||
return pointName;
|
return pointName;
|
||||||
}
|
}
|
||||||
NewGpxData newGpxData = editingCtx.getNewGpxData();
|
GpxData gpxData = editingCtx.getGpxData();
|
||||||
if (newGpxData != null && newGpxData.getActionType() == ActionType.ADD_ROUTE_POINTS) {
|
if (gpxData != null && gpxData.getActionType() == ActionType.ADD_ROUTE_POINTS) {
|
||||||
return getString(R.string.route_point) + " - " + (pos + 1);
|
return getString(R.string.route_point) + " - " + (pos + 1);
|
||||||
}
|
}
|
||||||
return getString(R.string.plugin_distance_point) + " - " + (pos + 1);
|
return getString(R.string.plugin_distance_point) + " - " + (pos + 1);
|
||||||
|
@ -265,8 +265,8 @@ public class SelectedPointBottomSheetDialogFragment extends MenuBottomSheetDialo
|
||||||
}
|
}
|
||||||
description.append(OsmAndFormatter.getFormattedDistance(dist, mapActivity.getMyApplication()));
|
description.append(OsmAndFormatter.getFormattedDistance(dist, mapActivity.getMyApplication()));
|
||||||
}
|
}
|
||||||
NewGpxData newGpxData = editingCtx.getNewGpxData();
|
GpxData gpxData = editingCtx.getGpxData();
|
||||||
if (newGpxData != null && newGpxData.getActionType() == ActionType.EDIT_SEGMENT) {
|
if (gpxData != null && gpxData.getActionType() == ActionType.EDIT_SEGMENT) {
|
||||||
double elevation = pt.ele;
|
double elevation = pt.ele;
|
||||||
if (!Double.isNaN(elevation)) {
|
if (!Double.isNaN(elevation)) {
|
||||||
description.append(" ").append((getString(R.string.altitude)).substring(0, 1)).append(": ");
|
description.append(" ").append((getString(R.string.altitude)).substring(0, 1)).append(": ");
|
||||||
|
|
|
@ -19,7 +19,7 @@ import net.osmand.plus.OsmAndFormatter;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.UiUtilities;
|
import net.osmand.plus.UiUtilities;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.measurementtool.NewGpxData.ActionType;
|
import net.osmand.plus.measurementtool.GpxData.ActionType;
|
||||||
import net.osmand.plus.views.controls.ReorderItemTouchHelperCallback;
|
import net.osmand.plus.views.controls.ReorderItemTouchHelperCallback;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
|
@ -13,6 +13,16 @@ public class MeasurementCommandManager {
|
||||||
private final Deque<MeasurementModeCommand> undoCommands = new LinkedList<>();
|
private final Deque<MeasurementModeCommand> undoCommands = new LinkedList<>();
|
||||||
private final Deque<MeasurementModeCommand> redoCommands = new LinkedList<>();
|
private final Deque<MeasurementModeCommand> redoCommands = new LinkedList<>();
|
||||||
|
|
||||||
|
private int changesCounter = 0;
|
||||||
|
|
||||||
|
public boolean hasChanges() {
|
||||||
|
return changesCounter != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void resetChangesCounter() {
|
||||||
|
changesCounter = 0;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean canUndo() {
|
public boolean canUndo() {
|
||||||
return undoCommands.size() > 0;
|
return undoCommands.size() > 0;
|
||||||
}
|
}
|
||||||
|
@ -25,6 +35,7 @@ public class MeasurementCommandManager {
|
||||||
if (command.execute()) {
|
if (command.execute()) {
|
||||||
undoCommands.push(command);
|
undoCommands.push(command);
|
||||||
redoCommands.clear();
|
redoCommands.clear();
|
||||||
|
changesCounter++;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -41,6 +52,7 @@ public class MeasurementCommandManager {
|
||||||
MeasurementModeCommand command = undoCommands.pop();
|
MeasurementModeCommand command = undoCommands.pop();
|
||||||
redoCommands.push(command);
|
redoCommands.push(command);
|
||||||
command.undo();
|
command.undo();
|
||||||
|
changesCounter--;
|
||||||
return command.getType();
|
return command.getType();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -52,6 +64,7 @@ public class MeasurementCommandManager {
|
||||||
MeasurementModeCommand command = redoCommands.pop();
|
MeasurementModeCommand command = redoCommands.pop();
|
||||||
undoCommands.push(command);
|
undoCommands.push(command);
|
||||||
command.redo();
|
command.redo();
|
||||||
|
changesCounter++;
|
||||||
return command.getType();
|
return command.getType();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -54,7 +54,7 @@ import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.activities.TrackActivity;
|
import net.osmand.plus.activities.TrackActivity;
|
||||||
import net.osmand.plus.dialogs.GpxAppearanceAdapter;
|
import net.osmand.plus.dialogs.GpxAppearanceAdapter;
|
||||||
import net.osmand.plus.measurementtool.NewGpxData;
|
import net.osmand.plus.measurementtool.GpxData;
|
||||||
import net.osmand.plus.myplaces.TrackBitmapDrawer.TrackBitmapDrawerListener;
|
import net.osmand.plus.myplaces.TrackBitmapDrawer.TrackBitmapDrawerListener;
|
||||||
import net.osmand.plus.settings.backend.OsmandSettings;
|
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||||
import net.osmand.plus.settings.backend.OsmandSettings.CommonPreference;
|
import net.osmand.plus.settings.backend.OsmandSettings.CommonPreference;
|
||||||
|
@ -918,14 +918,14 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addNewGpxData(NewGpxData.ActionType actionType) {
|
public void addNewGpxData(GpxData.ActionType actionType) {
|
||||||
TrackActivity activity = getTrackActivity();
|
TrackActivity activity = getTrackActivity();
|
||||||
if (activity != null) {
|
if (activity != null) {
|
||||||
activity.addNewGpxData(actionType);
|
activity.addNewGpxData(actionType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addNewGpxData(NewGpxData.ActionType actionType, GPXUtilities.TrkSegment segment) {
|
public void addNewGpxData(GpxData.ActionType actionType, GPXUtilities.TrkSegment segment) {
|
||||||
TrackActivity activity = getTrackActivity();
|
TrackActivity activity = getTrackActivity();
|
||||||
if (activity != null) {
|
if (activity != null) {
|
||||||
activity.addNewGpxData(actionType, segment);
|
activity.addNewGpxData(actionType, segment);
|
||||||
|
@ -952,9 +952,9 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener {
|
||||||
new PointDescription(PointDescription.POINT_TYPE_WPT, app.getString(R.string.add_waypoint));
|
new PointDescription(PointDescription.POINT_TYPE_WPT, app.getString(R.string.add_waypoint));
|
||||||
addPoint(pointWptDescription);
|
addPoint(pointWptDescription);
|
||||||
} else if (i == R.id.route_text_layout || i == R.id.route_fab) {
|
} else if (i == R.id.route_text_layout || i == R.id.route_fab) {
|
||||||
addNewGpxData(NewGpxData.ActionType.ADD_ROUTE_POINTS);
|
addNewGpxData(GpxData.ActionType.ADD_ROUTE_POINTS);
|
||||||
} else if (i == R.id.line_text_layout || i == R.id.line_fab) {
|
} else if (i == R.id.line_text_layout || i == R.id.line_fab) {
|
||||||
addNewGpxData(NewGpxData.ActionType.ADD_SEGMENT);
|
addNewGpxData(GpxData.ActionType.ADD_SEGMENT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -65,7 +65,7 @@ import net.osmand.plus.helpers.GpxUiHelper;
|
||||||
import net.osmand.plus.helpers.GpxUiHelper.GPXDataSetAxisType;
|
import net.osmand.plus.helpers.GpxUiHelper.GPXDataSetAxisType;
|
||||||
import net.osmand.plus.helpers.GpxUiHelper.GPXDataSetType;
|
import net.osmand.plus.helpers.GpxUiHelper.GPXDataSetType;
|
||||||
import net.osmand.plus.helpers.GpxUiHelper.OrderedLineDataSet;
|
import net.osmand.plus.helpers.GpxUiHelper.OrderedLineDataSet;
|
||||||
import net.osmand.plus.measurementtool.NewGpxData;
|
import net.osmand.plus.measurementtool.GpxData;
|
||||||
import net.osmand.plus.track.SaveGpxAsyncTask;
|
import net.osmand.plus.track.SaveGpxAsyncTask;
|
||||||
import net.osmand.plus.track.SaveGpxAsyncTask.SaveGpxListener;
|
import net.osmand.plus.track.SaveGpxAsyncTask.SaveGpxListener;
|
||||||
import net.osmand.plus.myplaces.TrackBitmapDrawer.TrackBitmapDrawerListener;
|
import net.osmand.plus.myplaces.TrackBitmapDrawer.TrackBitmapDrawerListener;
|
||||||
|
@ -1026,7 +1026,7 @@ public class TrackSegmentFragment extends OsmAndListFragment implements TrackBit
|
||||||
private void editSegment() {
|
private void editSegment() {
|
||||||
TrkSegment segment = getTrkSegment();
|
TrkSegment segment = getTrkSegment();
|
||||||
if (segment != null && fragmentAdapter != null) {
|
if (segment != null && fragmentAdapter != null) {
|
||||||
fragmentAdapter.addNewGpxData(NewGpxData.ActionType.EDIT_SEGMENT, segment);
|
fragmentAdapter.addNewGpxData(GpxData.ActionType.EDIT_SEGMENT, segment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,8 +42,8 @@ import net.osmand.plus.helpers.ImportHelper;
|
||||||
import net.osmand.plus.helpers.ImportHelper.OnGpxImportCompleteListener;
|
import net.osmand.plus.helpers.ImportHelper.OnGpxImportCompleteListener;
|
||||||
import net.osmand.plus.measurementtool.MeasurementEditingContext;
|
import net.osmand.plus.measurementtool.MeasurementEditingContext;
|
||||||
import net.osmand.plus.measurementtool.MeasurementToolFragment;
|
import net.osmand.plus.measurementtool.MeasurementToolFragment;
|
||||||
import net.osmand.plus.measurementtool.NewGpxData;
|
import net.osmand.plus.measurementtool.GpxData;
|
||||||
import net.osmand.plus.measurementtool.NewGpxData.ActionType;
|
import net.osmand.plus.measurementtool.GpxData.ActionType;
|
||||||
import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.LocalRoutingParameter;
|
import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.LocalRoutingParameter;
|
||||||
import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.OtherLocalRoutingParameter;
|
import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.OtherLocalRoutingParameter;
|
||||||
import net.osmand.plus.routepreparationmenu.cards.AttachTrackToRoadsCard;
|
import net.osmand.plus.routepreparationmenu.cards.AttachTrackToRoadsCard;
|
||||||
|
@ -480,10 +480,9 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca
|
||||||
QuadRect rect = gpxFile.getRect();
|
QuadRect rect = gpxFile.getRect();
|
||||||
TrkSegment segment = gpxFile.getNonEmptyTrkSegment();
|
TrkSegment segment = gpxFile.getNonEmptyTrkSegment();
|
||||||
ActionType actionType = segment == null ? ActionType.ADD_ROUTE_POINTS : ActionType.EDIT_SEGMENT;
|
ActionType actionType = segment == null ? ActionType.ADD_ROUTE_POINTS : ActionType.EDIT_SEGMENT;
|
||||||
NewGpxData newGpxData = new NewGpxData(gpxFile, rect, actionType, segment);
|
GpxData gpxData = new GpxData(gpxFile, rect, actionType, segment);
|
||||||
|
|
||||||
MeasurementEditingContext editingContext = new MeasurementEditingContext();
|
MeasurementEditingContext editingContext = new MeasurementEditingContext();
|
||||||
editingContext.setNewGpxData(newGpxData);
|
editingContext.setGpxData(gpxData);
|
||||||
if (useAppMode) {
|
if (useAppMode) {
|
||||||
editingContext.setAppMode(app.getRoutingHelper().getAppMode());
|
editingContext.setAppMode(app.getRoutingHelper().getAppMode());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue