Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2017-06-28 10:12:30 +02:00
commit ed7213a55d
3 changed files with 85 additions and 48 deletions

View file

@ -191,9 +191,15 @@ public class TrackDetailsMenu {
} }
} else { } else {
float distance = pos * dataSet.getDivX(); float distance = pos * dataSet.getDivX();
for (WptPt p : segment.points) { double previousSplitDistance = 0;
if (p.distance >= distance) { for (int i = 0; i < segment.points.size(); i++) {
wpt = p; if (i != 0) {
if (segment.points.get(i).distance < segment.points.get(i - 1).distance) {
previousSplitDistance += segment.points.get(i - 1).distance;
}
}
if (previousSplitDistance + segment.points.get(i).distance >= distance) {
wpt = segment.points.get(i);
break; break;
} }
} }
@ -231,18 +237,24 @@ public class TrackDetailsMenu {
} else { } else {
float startDistance = startPos * dataSet.getDivX(); float startDistance = startPos * dataSet.getDivX();
float endDistance = endPos * dataSet.getDivX(); float endDistance = endPos * dataSet.getDivX();
for (WptPt p : segment.points) { double previousSplitDistance = 0;
if (p.distance >= startDistance && p.distance <= endDistance) { for (int i = 0; i < segment.points.size(); i++) {
if (i != 0) {
if (segment.points.get(i).distance < segment.points.get(i - 1).distance) {
previousSplitDistance += segment.points.get(i - 1).distance;
}
}
if (previousSplitDistance + segment.points.get(i).distance >= startDistance && previousSplitDistance + segment.points.get(i).distance <= endDistance) {
if (left == 0 && right == 0) { if (left == 0 && right == 0) {
left = p.getLongitude(); left = segment.points.get(i).getLongitude();
right = p.getLongitude(); right = segment.points.get(i).getLongitude();
top = p.getLatitude(); top = segment.points.get(i).getLatitude();
bottom = p.getLatitude(); bottom = segment.points.get(i).getLatitude();
} else { } else {
left = Math.min(left, p.getLongitude()); left = Math.min(left, segment.points.get(i).getLongitude());
right = Math.max(right, p.getLongitude()); right = Math.max(right, segment.points.get(i).getLongitude());
top = Math.max(top, p.getLatitude()); top = Math.max(top, segment.points.get(i).getLatitude());
bottom = Math.min(bottom, p.getLatitude()); bottom = Math.min(bottom, segment.points.get(i).getLatitude());
} }
} }
} }
@ -287,6 +299,13 @@ public class TrackDetailsMenu {
Highlight[] highlights = chart.getHighlighted(); Highlight[] highlights = chart.getHighlighted();
LatLon location = null; LatLon location = null;
if (trackChartPoints == null) {
trackChartPoints = new TrackChartPoints();
int segmentColor = getTrackSegment(chart).getColor(0);
trackChartPoints.setSegmentColor(segmentColor);
trackChartPoints.setGpx(getGpxItem().group.getGpx());
}
float minimumVisibleXValue = chart.getLowestVisibleX(); float minimumVisibleXValue = chart.getLowestVisibleX();
float maximumVisibleXValue = chart.getHighestVisibleX(); float maximumVisibleXValue = chart.getHighestVisibleX();
@ -304,24 +323,18 @@ public class TrackDetailsMenu {
} }
WptPt wpt = getPoint(chart, gpxItem.chartHighlightPos); WptPt wpt = getPoint(chart, gpxItem.chartHighlightPos);
if (wpt != null) { if (wpt != null) {
if (trackChartPoints == null) {
trackChartPoints = new TrackChartPoints();
int segmentColor = getTrackSegment(chart).getColor(0);
trackChartPoints.setSegmentColor(segmentColor);
trackChartPoints.setGpx(getGpxItem().group.getGpx());
}
location = new LatLon(wpt.lat, wpt.lon); location = new LatLon(wpt.lat, wpt.lon);
trackChartPoints.setHighlightedPoint(location); trackChartPoints.setHighlightedPoint(location);
}
} else {
gpxItem.chartHighlightPos = -1;
}
trackChartPoints.setXAxisPoints(getXAxisPoints(chart)); trackChartPoints.setXAxisPoints(getXAxisPoints(chart));
if (gpxItem.route) { if (gpxItem.route) {
mapActivity.getMapLayers().getMapInfoLayer().setTrackChartPoints(trackChartPoints); mapActivity.getMapLayers().getMapInfoLayer().setTrackChartPoints(trackChartPoints);
} else { } else {
mapActivity.getMapLayers().getGpxLayer().setTrackChartPoints(trackChartPoints); mapActivity.getMapLayers().getGpxLayer().setTrackChartPoints(trackChartPoints);
} }
}
} else {
gpxItem.chartHighlightPos = -1;
}
fitTrackOnMap(chart, location, forceFit); fitTrackOnMap(chart, location, forceFit);
} }
@ -575,14 +588,15 @@ public class TrackDetailsMenu {
} }
private void updateChart(LineChart chart) { private void updateChart(LineChart chart) {
chart.notifyDataSetChanged();
chart.invalidate();
if (gpxItem.chartMatrix != null) { if (gpxItem.chartMatrix != null) {
chart.getViewPortHandler().refresh(new Matrix(gpxItem.chartMatrix), chart, true); chart.getViewPortHandler().refresh(new Matrix(gpxItem.chartMatrix), chart, true);
} }
if (gpxItem.chartHighlightPos != -1) { if (gpxItem.chartHighlightPos != -1) {
chart.highlightValue(gpxItem.chartHighlightPos, 0); chart.highlightValue(gpxItem.chartHighlightPos, 0);
} else { } else {
gpxItem.chartHighlightPos = chart.getLowestVisibleX(); chart.highlightValue(null);
chart.highlightValue(chart.getLowestVisibleX(), 0);
} }
} }

View file

@ -133,6 +133,7 @@ public class TrackSegmentFragment extends OsmAndListFragment {
private int defPointColor; private int defPointColor;
private Paint paintIcon; private Paint paintIcon;
private Bitmap pointSmall; private Bitmap pointSmall;
private GpxDisplayItem generalDisplayItem;
private ImageView imageView; private ImageView imageView;
private RotatedTileBox rotatedTileBox; private RotatedTileBox rotatedTileBox;
@ -273,6 +274,17 @@ public class TrackSegmentFragment extends OsmAndListFragment {
} }
private void updateHeader() { private void updateHeader() {
headerView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
LatLon location = new LatLon(generalDisplayItem.locationStart.lat, generalDisplayItem.locationStart.lon);
final OsmandSettings settings = app.getSettings();
settings.setMapLocationToShow(location.getLatitude(), location.getLongitude(),
settings.getLastKnownMapZoom());
MapActivity.launchMapActivityMoveToTop(getActivity());
}
});
imageView = (ImageView) headerView.findViewById(R.id.imageView); imageView = (ImageView) headerView.findViewById(R.id.imageView);
final View splitColorView = headerView.findViewById(R.id.split_color_view); final View splitColorView = headerView.findViewById(R.id.split_color_view);
final View divider = headerView.findViewById(R.id.divider); final View divider = headerView.findViewById(R.id.divider);
@ -802,6 +814,9 @@ public class TrackSegmentFragment extends OsmAndListFragment {
pager = (WrapContentHeightViewPager) row.findViewById(R.id.pager); pager = (WrapContentHeightViewPager) row.findViewById(R.id.pager);
} }
GpxDisplayItem item = getItem(position); GpxDisplayItem item = getItem(position);
if (position == 0) {
generalDisplayItem = item;
}
if (item != null) { if (item != null) {
pager.setAdapter(new GPXItemPagerAdapter(tabLayout, item)); pager.setAdapter(new GPXItemPagerAdapter(tabLayout, item));
if (create) { if (create) {

View file

@ -334,8 +334,10 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
y + nmHeight / 2 + 3 * (float) Math.ceil(tileBox.getDensity()), y + nmHeight / 2 + 3 * (float) Math.ceil(tileBox.getDensity()),
x + nmWidth / 2 + 3 * (float) Math.ceil(tileBox.getDensity()), x + nmWidth / 2 + 3 * (float) Math.ceil(tileBox.getDensity()),
y - nmHeight / 2 - 2 * (float) Math.ceil(tileBox.getDensity())); y - nmHeight / 2 - 2 * (float) Math.ceil(tileBox.getDensity()));
canvas.drawRoundRect(rect, 5, 5, paintInnerRect); canvas.drawRoundRect(rect, 0, 0, paintInnerRect);
canvas.drawRoundRect(rect, 5, 5, paintOuterRect); canvas.drawRoundRect(rect, 0, 0, paintOuterRect);
// canvas.drawRect(rect, paintInnerRect);
// canvas.drawRect(rect, paintOuterRect);
canvas.drawText(nm, x, y + nmHeight / 2, paintTextIcon); canvas.drawText(nm, x, y + nmHeight / 2, paintTextIcon);
} }
} }
@ -386,6 +388,7 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
} }
if (trackChartPoints != null) { if (trackChartPoints != null) {
LatLon highlightedPoint = trackChartPoints.getHighlightedPoint(); LatLon highlightedPoint = trackChartPoints.getHighlightedPoint();
if (highlightedPoint != null) {
if (highlightedPoint.getLatitude() >= latLonBounds.bottom if (highlightedPoint.getLatitude() >= latLonBounds.bottom
&& highlightedPoint.getLatitude() <= latLonBounds.top && highlightedPoint.getLatitude() <= latLonBounds.top
&& highlightedPoint.getLongitude() >= latLonBounds.left && highlightedPoint.getLongitude() >= latLonBounds.left
@ -396,6 +399,7 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
canvas.drawBitmap(selectedPoint, x - selectedPoint.getWidth() / 2, y - selectedPoint.getHeight() / 2, paintIcon); canvas.drawBitmap(selectedPoint, x - selectedPoint.getWidth() / 2, y - selectedPoint.getHeight() / 2, paintIcon);
} }
} }
}
this.fullObjectsLatLon = fullObjectsLatLon; this.fullObjectsLatLon = fullObjectsLatLon;
this.smallObjectsLatLon = smallObjectsLatLon; this.smallObjectsLatLon = smallObjectsLatLon;
} }
@ -420,10 +424,12 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
paintGridCircle.setColor(color); paintGridCircle.setColor(color);
paintGridCircle.setAlpha(255); paintGridCircle.setAlpha(255);
QuadRect latLonBounds = tileBox.getLatLonBounds(); QuadRect latLonBounds = tileBox.getLatLonBounds();
List<WptPt> xAxisPoints = trackChartPoints.getXAxisPoints();
float r = 3 * tileBox.getDensity(); float r = 3 * tileBox.getDensity();
List<WptPt> xAxisPoints = trackChartPoints.getXAxisPoints();
if (xAxisPoints != null) {
for (int i = 0; i < xAxisPoints.size(); i++) { for (int i = 0; i < xAxisPoints.size(); i++) {
WptPt axisPoint = xAxisPoints.get(i); WptPt axisPoint = xAxisPoints.get(i);
if (axisPoint != null) {
if (axisPoint.getLatitude() >= latLonBounds.bottom if (axisPoint.getLatitude() >= latLonBounds.bottom
&& axisPoint.getLatitude() <= latLonBounds.top && axisPoint.getLatitude() <= latLonBounds.top
&& axisPoint.getLongitude() >= latLonBounds.left && axisPoint.getLongitude() >= latLonBounds.left
@ -435,6 +441,8 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
} }
} }
} }
}
}
private int getFileColor(@NonNull SelectedGpxFile g) { private int getFileColor(@NonNull SelectedGpxFile g) {
return g.getColor() == 0 ? defPointColor : g.getColor(); return g.getColor() == 0 ? defPointColor : g.getColor();