Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2017-06-07 12:24:48 +02:00
commit 3d82d313bf
4 changed files with 44 additions and 2 deletions

View file

@ -239,6 +239,7 @@
<color name="gpx_chart_orange">#ff8800</color>
<color name="gpx_chart_red">#ff0000</color>
<color name="gpx_chart_green">#23b03b</color>
<color name="gpx_chart_black_grid">#000000</color>
<color name="gpx_chart_blue_grid">#c32561c2</color>
<color name="gpx_chart_orange_grid">#c3b35f00</color>
<color name="gpx_chart_red_grid">#c3b30000</color>

View file

@ -103,6 +103,8 @@ public class GPXUtilities {
}
public static class WptPt extends GPXExtensions implements LocationPoint {
public boolean firstPoint = false;
public boolean lastPoint = false;
public double lat;
public double lon;
public String name = null;
@ -214,6 +216,8 @@ public class GPXUtilities {
}
public static class TrkSegment extends GPXExtensions {
public boolean generalSegment = false;
public List<WptPt> points = new ArrayList<>();
public List<Renderable.RenderableSegment> renders = new ArrayList<>();
@ -326,6 +330,9 @@ public class GPXUtilities {
public GPXTrackAnalysis prepareInformation(long filestamp, SplitSegment... splitSegments) {
float[] calculations = new float[1];
long startTimeOfSingleSegment = 0;
long endTimeOfSingleSegment = 0;
float totalElevation = 0;
int elevationPoints = 0;
int speedCount = 0;
@ -365,6 +372,18 @@ public class GPXUtilities {
}
long time = point.time;
if (time != 0) {
if (s.segment.generalSegment) {
if (point.firstPoint) {
startTimeOfSingleSegment = time;
} else if (point.lastPoint) {
endTimeOfSingleSegment = time;
}
if (startTimeOfSingleSegment != 0 && endTimeOfSingleSegment != 0) {
timeSpan += endTimeOfSingleSegment - startTimeOfSingleSegment;
startTimeOfSingleSegment = 0;
endTimeOfSingleSegment = 0;
}
}
startTime = Math.min(startTime, time);
endTime = Math.max(endTime, time);
}
@ -527,7 +546,9 @@ public class GPXUtilities {
// OUTPUT:
// 1. Total distance, Start time, End time
// 2. Time span
if (timeSpan == 0) {
timeSpan = endTime - startTime;
}
// 3. Time moving, if any
// 4. Elevation, eleUp, eleDown, if recorded
@ -767,11 +788,14 @@ public class GPXUtilities {
for (WptPt wptPt : s.points) {
waypoints.add(new WptPt(wptPt));
}
waypoints.get(0).firstPoint = true;
waypoints.get(waypoints.size() - 1).lastPoint = true;
segment.points.addAll(waypoints);
}
}
}
if (segment.points.size() > 0) {
segment.generalSegment = true;
generalSegment = segment;
}
}

View file

@ -952,7 +952,10 @@ public class GpxUiHelper {
XAxis xAxis = mChart.getXAxis();
xAxis.setDrawAxisLine(false);
xAxis.setDrawGridLines(false);
xAxis.setDrawGridLines(true);
xAxis.setGridLineWidth(1.5f);
xAxis.setGridColor(ActivityCompat.getColor(mChart.getContext(), R.color.gpx_chart_black_grid));
xAxis.enableGridDashedLine(25f, Float.MAX_VALUE, 0f);
xAxis.setPosition(BOTTOM);
xAxis.setTextColor(light ? mChart.getResources().getColor(R.color.secondary_text_light) : mChart.getResources().getColor(R.color.secondary_text_dark));

View file

@ -819,6 +819,7 @@ public class TrackSegmentFragment extends OsmAndListFragment {
private String[] titles;
private Map<GPXTabItemType, List<ILineDataSet>> dataSetsMap = new HashMap<>();
private TrkSegment segment;
private float listViewYPos;
GPXItemPagerAdapter(PagerSlidingTabStrip tabs, GpxDisplayItem gpxItem) {
super();
@ -964,6 +965,10 @@ public class TrackSegmentFragment extends OsmAndListFragment {
return wpt;
}
private void scrollBy(int px) {
getListView().setSelectionFromTop(getListView().getFirstVisiblePosition(), getListView().getChildAt(0).getTop() - px);
}
@Override
public int getCount() {
return tabTypes.length;
@ -999,6 +1004,15 @@ public class TrackSegmentFragment extends OsmAndListFragment {
@Override
public boolean onTouch(View v, MotionEvent event) {
getListView().requestDisallowInterceptTouchEvent(true);
switch (event.getAction()) {
case android.view.MotionEvent.ACTION_DOWN:
listViewYPos = event.getRawY();
break;
case android.view.MotionEvent.ACTION_MOVE:
scrollBy(Math.round(listViewYPos - event.getRawY()));
listViewYPos = event.getRawY();
break;
}
return false;
}
});