Merge remote-tracking branch 'origin/sasha_pasha_branch' into sasha_pasha_branch

This commit is contained in:
Alexander Sytnyk 2017-08-15 12:18:34 +03:00
commit e460e2ba2c
9 changed files with 59 additions and 30 deletions

View file

@ -119,7 +119,7 @@
android:background="?attr/bg_card"
android:gravity="center_vertical"
android:padding="8dp"
android:text="@string/add_route_point"
android:text="@string/add_route_points"
android:textColor="?android:attr/textColorPrimary"
osmand:typeface="@string/font_roboto_medium"/>

View file

@ -115,7 +115,7 @@
android:background="?attr/bg_card"
android:gravity="center_vertical"
android:padding="8dp"
android:text="@string/add_route_point"
android:text="@string/add_route_points"
android:textColor="?android:attr/textColorPrimary"
osmand:typeface="@string/font_roboto_medium"/>

View file

@ -2668,7 +2668,7 @@
<string name="shared_string_action_name">Action name</string>
<string name="mappilary_no_internet_desc">You need internet to view photos from Mapillary</string>
<string name="retry">Retry</string>
<string name="add_route_point">Add Route Point</string>
<string name="add_route_points">Add Route Points</string>
<string name="add_waypoint">Add Waypoint</string>
<string name="add_line">Add Line</string>
<string name="save_gpx_waypoint">Save GPX Waypoint</string>

View file

@ -909,6 +909,16 @@ public class GPXUtilities {
modifiedTime = System.currentTimeMillis();
}
public void addRtePts(List<WptPt> points) {
if (routes.size() == 0) {
routes.add(new Route());
}
Route currentRoute = routes.get(routes.size() - 1);
currentRoute.points.addAll(points);
modifiedTime = System.currentTimeMillis();
}
public void updateWptPt(WptPt pt, double lat, double lon, long time, String description, String name, String category, int color) {
int index = points.indexOf(pt);

View file

@ -16,6 +16,7 @@ import net.osmand.AndroidUtils;
import net.osmand.data.LatLon;
import net.osmand.data.PointDescription;
import net.osmand.data.QuadRect;
import net.osmand.plus.activities.TrackActivity.NewGpxLine.LineType;
import net.osmand.plus.GPXDatabase.GpxDataItem;
import net.osmand.plus.GPXUtilities;
import net.osmand.plus.GPXUtilities.GPXFile;
@ -112,10 +113,10 @@ public class TrackActivity extends TabActivity {
}
}
public void addLine() {
public void addLine(LineType lineType) {
GPXFile gpxFile = getGpx();
QuadRect rect = getRect();
NewGpxLine newGpxLine = new NewGpxLine(gpxFile, rect);
NewGpxLine newGpxLine = new NewGpxLine(gpxFile, rect, lineType);
WptPt pointToShow = gpxFile != null ? gpxFile.findPointToShow() : null;
if (pointToShow != null) {
LatLon location = new LatLon(pointToShow.getLatitude(), pointToShow.getLongitude());
@ -407,12 +408,16 @@ public class TrackActivity extends TabActivity {
}
public static class NewGpxLine {
public enum LineType { SEGMENT, ROUTE_POINTS }
private GPXFile gpxFile;
private QuadRect rect;
private LineType lineType;
public NewGpxLine(GPXFile gpxFile, QuadRect rect) {
public NewGpxLine(GPXFile gpxFile, QuadRect rect, LineType lineType) {
this.gpxFile = gpxFile;
this.rect = rect;
this.lineType = lineType;
}
public GPXFile getGpxFile() {
@ -422,5 +427,9 @@ public class TrackActivity extends TabActivity {
public QuadRect getRect() {
return rect;
}
public LineType getLineType() {
return lineType;
}
}
}

View file

@ -40,6 +40,7 @@ import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.TrackActivity;
import net.osmand.plus.activities.TrackActivity.NewGpxLine;
import net.osmand.plus.activities.TrackActivity.NewGpxLine.LineType;
import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.helpers.GpxUiHelper;
import net.osmand.plus.measurementtool.adapter.MeasurementToolAdapter;
@ -198,9 +199,9 @@ public class MeasurementToolFragment extends Fragment {
}
@Override
public void saveAsNewSegmentOnClick() {
public void addToGpxOnClick() {
if (measurementLayer.getPointsCount() > 0) {
saveAsNewSegment(mapActivity);
addToGpx(mapActivity);
} else {
Toast.makeText(mapActivity, getString(R.string.none_point_error), Toast.LENGTH_SHORT).show();
}
@ -332,7 +333,7 @@ public class MeasurementToolFragment extends Fragment {
@Override
public void onClick(View v) {
if (measurementLayer.getPointsCount() > 0) {
saveAsNewSegment(mapActivity);
addToGpx(mapActivity);
} else {
Toast.makeText(mapActivity, getString(R.string.none_point_error), Toast.LENGTH_SHORT).show();
}
@ -729,11 +730,12 @@ public class MeasurementToolFragment extends Fragment {
}
}
private void saveAsNewSegment(MapActivity mapActivity) {
private void addToGpx(MapActivity mapActivity) {
GPXFile gpx = newGpxLine.getGpxFile();
SelectedGpxFile selectedGpxFile = mapActivity.getMyApplication().getSelectedGpxHelper().getSelectedFileByPath(gpx.path);
boolean showOnMap = selectedGpxFile != null;
saveExistingGpx(gpx, showOnMap);
LineType lineType = newGpxLine.getLineType();
saveExistingGpx(gpx, showOnMap, lineType);
}
private void saveAsGpxOnClick(MapActivity mapActivity) {
@ -803,14 +805,14 @@ public class MeasurementToolFragment extends Fragment {
}
private void saveNewGpx(File dir, String fileName, boolean checked) {
saveGpx(dir, fileName, checked, null, false);
saveGpx(dir, fileName, checked, null, false, null);
}
private void saveExistingGpx(GPXFile gpx, boolean showOnMap) {
saveGpx(null, null, showOnMap, gpx, true);
private void saveExistingGpx(GPXFile gpx, boolean showOnMap, LineType lineType) {
saveGpx(null, null, showOnMap, gpx, true, lineType);
}
private void saveGpx(final File dir, final String fileName, final boolean showOnMap, final GPXFile gpx, final boolean openTrackActivity) {
private void saveGpx(final File dir, final String fileName, final boolean showOnMap, final GPXFile gpx, final boolean openTrackActivity, final LineType lineType) {
new AsyncTask<Void, Void, String>() {
private ProgressDialog progressDialog;
@ -855,16 +857,25 @@ public class MeasurementToolFragment extends Fragment {
toSave = new File(gpx.path);
if (measurementLayer != null) {
List<WptPt> points = measurementLayer.getMeasurementPoints();
switch (lineType) {
case SEGMENT:
gpx.addTrkSegment(points);
break;
case ROUTE_POINTS:
gpx.addRtePts(points);
break;
}
}
if (activity != null) {
String res = GPXUtilities.writeGpxFile(toSave, gpx, activity.getMyApplication());
if (showOnMap) {
SelectedGpxFile sf = activity.getMyApplication().getSelectedGpxHelper().selectGpxFile(gpx, true, false);
if (sf != null) {
if (lineType == LineType.SEGMENT) {
sf.processPoints();
}
}
}
return res;
}
}

View file

@ -106,7 +106,7 @@ public class OptionsBottomSheetDialogFragment extends BottomSheetDialogFragment
@Override
public void onClick(View view) {
if (listener != null) {
listener.saveAsNewSegmentOnClick();
listener.addToGpxOnClick();
}
dismiss();
}
@ -168,7 +168,7 @@ public class OptionsBottomSheetDialogFragment extends BottomSheetDialogFragment
void snapToRoadOnCLick();
void saveAsNewSegmentOnClick();
void addToGpxOnClick();
void saveAsNewTrackOnClick();

View file

@ -35,6 +35,7 @@ import net.osmand.AndroidUtils;
import net.osmand.data.FavouritePoint;
import net.osmand.data.LatLon;
import net.osmand.data.PointDescription;
import net.osmand.plus.activities.TrackActivity.NewGpxLine.LineType;
import net.osmand.plus.FavouritesDbHelper;
import net.osmand.plus.GPXDatabase.GpxDataItem;
import net.osmand.plus.GPXUtilities;
@ -163,12 +164,11 @@ public class TrackPointFragment extends OsmandExpandableListFragment {
break;
case R.id.route_text_layout:
case R.id.route_fab:
PointDescription pointRteDescription = new PointDescription(PointDescription.POINT_TYPE_RTE, getString(R.string.add_route_point));
addPoint(pointRteDescription);
addLine(LineType.ROUTE_POINTS);
break;
case R.id.line_text_layout:
case R.id.line_fab:
addLine();
addLine(LineType.SEGMENT);
break;
}
}
@ -216,8 +216,8 @@ public class TrackPointFragment extends OsmandExpandableListFragment {
getTrackActivity().addPoint(pointDescription);
}
private void addLine() {
getTrackActivity().addLine();
private void addLine(LineType lineType) {
getTrackActivity().addLine(lineType);
}
private void openMenu() {

View file

@ -59,12 +59,12 @@ import net.osmand.data.PointDescription;
import net.osmand.data.QuadRect;
import net.osmand.data.RotatedTileBox;
import net.osmand.data.RotatedTileBox.RotatedTileBoxBuilder;
import net.osmand.plus.activities.TrackActivity.NewGpxLine.LineType;
import net.osmand.plus.GPXDatabase;
import net.osmand.plus.GPXDatabase.GpxDataItem;
import net.osmand.plus.GPXUtilities;
import net.osmand.plus.GPXUtilities.GPXFile;
import net.osmand.plus.GPXUtilities.GPXTrackAnalysis;
import net.osmand.plus.GPXUtilities.Route;
import net.osmand.plus.GPXUtilities.Track;
import net.osmand.plus.GPXUtilities.TrkSegment;
import net.osmand.plus.GPXUtilities.WptPt;
@ -213,12 +213,11 @@ public class TrackSegmentFragment extends OsmAndListFragment {
break;
case R.id.route_text_layout:
case R.id.route_fab:
PointDescription pointRteDescription = new PointDescription(PointDescription.POINT_TYPE_RTE, getString(R.string.add_route_point));
addPoint(pointRteDescription);
addLine(LineType.ROUTE_POINTS);
break;
case R.id.line_text_layout:
case R.id.line_fab:
addLine();
addLine(LineType.SEGMENT);
break;
}
}
@ -286,8 +285,8 @@ public class TrackSegmentFragment extends OsmAndListFragment {
getTrackActivity().addPoint(pointDescription);
}
private void addLine() {
getTrackActivity().addLine();
private void addLine(LineType lineType) {
getTrackActivity().addLine(lineType);
}
private void openMenu() {