Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
103d2a6d93
9 changed files with 234 additions and 139 deletions
|
@ -352,6 +352,9 @@ repositories {
|
||||||
}
|
}
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
jcenter()
|
jcenter()
|
||||||
|
maven {
|
||||||
|
url "https://jitpack.io"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def analytics = (System.getenv("APP_FEATURES") && System.getenv("APP_FEATURES").contains("+play_market") &&
|
def analytics = (System.getenv("APP_FEATURES") && System.getenv("APP_FEATURES").contains("+play_market") &&
|
||||||
|
@ -379,6 +382,7 @@ dependencies {
|
||||||
compile ("com.getkeepsafe.taptargetview:taptargetview:1.6.1"){
|
compile ("com.getkeepsafe.taptargetview:taptargetview:1.6.1"){
|
||||||
exclude group: 'com.android.support'
|
exclude group: 'com.android.support'
|
||||||
}
|
}
|
||||||
|
compile 'com.github.PhilJay:MPAndroidChart:v3.0.1'
|
||||||
}
|
}
|
||||||
if(analytics) {
|
if(analytics) {
|
||||||
println "Apply GMS plugin"
|
println "Apply GMS plugin"
|
||||||
|
|
6
OsmAnd/res/drawable/chart_marker_background.xml
Normal file
6
OsmAnd/res/drawable/chart_marker_background.xml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="rectangle">
|
||||||
|
<corners android:radius="4dp" />
|
||||||
|
<solid android:color="@color/osmand_orange"/>
|
||||||
|
</shape>
|
7
OsmAnd/res/drawable/line_chart_fade_blue.xml
Normal file
7
OsmAnd/res/drawable/line_chart_fade_blue.xml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<gradient
|
||||||
|
android:angle="90"
|
||||||
|
android:startColor="#80367ef2"
|
||||||
|
android:endColor="#ff367ef2" />
|
||||||
|
</shape>
|
7
OsmAnd/res/drawable/line_chart_fade_orange.xml
Normal file
7
OsmAnd/res/drawable/line_chart_fade_orange.xml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<gradient
|
||||||
|
android:angle="90"
|
||||||
|
android:startColor="#80ff8f00"
|
||||||
|
android:endColor="#ffff8f00" />
|
||||||
|
</shape>
|
7
OsmAnd/res/drawable/line_chart_fade_red.xml
Normal file
7
OsmAnd/res/drawable/line_chart_fade_red.xml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<gradient
|
||||||
|
android:angle="90"
|
||||||
|
android:startColor="#80f46646"
|
||||||
|
android:endColor="#fff46646" />
|
||||||
|
</shape>
|
24
OsmAnd/res/layout/chart_marker_view.xml
Normal file
24
OsmAnd/res/layout/chart_marker_view.xml
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center"
|
||||||
|
android:background="@drawable/chart_marker_background" >
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvContent"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
|
android:layout_marginTop="2dp"
|
||||||
|
android:layout_marginBottom="2dp"
|
||||||
|
android:layout_marginLeft="6dp"
|
||||||
|
android:layout_marginRight="6dp"
|
||||||
|
android:text="100 m"
|
||||||
|
android:textSize="@dimen/default_desc_text_size"
|
||||||
|
android:textColor="@android:color/white"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:singleLine="true"/>
|
||||||
|
|
||||||
|
</RelativeLayout>
|
|
@ -6,13 +6,13 @@
|
||||||
android:background="?attr/expandable_list_item_background"
|
android:background="?attr/expandable_list_item_background"
|
||||||
android:minHeight="@dimen/list_item_height"
|
android:minHeight="@dimen/list_item_height"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:paddingLeft="@dimen/list_content_padding"
|
android:paddingTop="10dp">
|
||||||
android:paddingTop="10dp"
|
|
||||||
android:paddingRight="@dimen/list_content_padding" >
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content" >
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingLeft="@dimen/list_content_padding"
|
||||||
|
android:paddingRight="@dimen/list_content_padding">
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
@ -34,7 +34,7 @@
|
||||||
android:maxLines="2"
|
android:maxLines="2"
|
||||||
android:textColor="?android:textColorPrimary"
|
android:textColor="?android:textColorPrimary"
|
||||||
android:textSize="@dimen/default_desc_text_size"
|
android:textSize="@dimen/default_desc_text_size"
|
||||||
tools:text="@string/lorem_ipsum" />
|
tools:text="Additional" />
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
@ -45,13 +45,14 @@
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:textColor="?android:textColorPrimary"
|
android:textColor="?android:textColorPrimary"
|
||||||
android:textSize="@dimen/default_list_text_size"
|
android:textSize="@dimen/default_list_text_size"
|
||||||
tools:text="@string/lorem_ipsum" />
|
tools:text="Name" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/description"
|
android:id="@+id/description"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
@ -59,12 +60,15 @@
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:layout_marginTop="5dp"
|
android:layout_marginTop="5dp"
|
||||||
android:textColor="?android:textColorSecondary"
|
android:textColor="?android:textColorSecondary"
|
||||||
android:textSize="@dimen/default_desc_text_size" />
|
android:textSize="@dimen/default_desc_text_size"
|
||||||
|
android:paddingLeft="@dimen/list_content_padding"
|
||||||
|
android:paddingRight="@dimen/list_content_padding"/>
|
||||||
|
|
||||||
<net.osmand.plus.myplaces.ElevationView
|
<com.github.mikephil.charting.charts.LineChart
|
||||||
android:id="@+id/elevation"
|
android:id="@+id/chart"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="150dp"
|
android:layout_height="150dp"
|
||||||
android:layout_gravity="center_vertical" />
|
android:layout_gravity="center_vertical"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
|
@ -1,115 +0,0 @@
|
||||||
package net.osmand.plus.myplaces;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.graphics.Canvas;
|
|
||||||
import android.graphics.Color;
|
|
||||||
import android.graphics.Paint;
|
|
||||||
import android.graphics.Typeface;
|
|
||||||
import android.util.AttributeSet;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.widget.ImageView;
|
|
||||||
|
|
||||||
import net.osmand.plus.GPXUtilities;
|
|
||||||
import net.osmand.plus.R;
|
|
||||||
import net.osmand.plus.OsmandApplication;
|
|
||||||
import net.osmand.plus.OsmandSettings.MetricsConstants;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by maw on 02.09.15., original credit goes to gibbsnich
|
|
||||||
* Developed further by Hardy 2016-11
|
|
||||||
*/
|
|
||||||
public class ElevationView extends ImageView {
|
|
||||||
|
|
||||||
double maxElevation, minElevation;
|
|
||||||
float xDistance;
|
|
||||||
List<GPXUtilities.Elevation> elevationList;
|
|
||||||
|
|
||||||
private OsmandApplication app;
|
|
||||||
private MetricsConstants mc;
|
|
||||||
|
|
||||||
public ElevationView(Context ctx, AttributeSet as) {
|
|
||||||
super(ctx, as);
|
|
||||||
app = (OsmandApplication) ctx.getApplicationContext();
|
|
||||||
mc = app.getSettings().METRIC_SYSTEM.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onDraw(Canvas canvas) {
|
|
||||||
final float screenScale = getResources().getDisplayMetrics().density;
|
|
||||||
|
|
||||||
final boolean useFeet = (mc == MetricsConstants.MILES_AND_FEET) || (mc == MetricsConstants.MILES_AND_YARDS);
|
|
||||||
final String unit = useFeet ? app.getString(R.string.foot) : app.getString(R.string.m);
|
|
||||||
int stepBase = useFeet ? 200 : 100;
|
|
||||||
final float convEle = useFeet ? 3.28084f : 1.0f;
|
|
||||||
|
|
||||||
final int maxBase = ((int)Math.floor((maxElevation * convEle / stepBase) + 1)) * stepBase;
|
|
||||||
final int minBase = (int)Math.floor((minElevation * convEle / stepBase)) * stepBase;
|
|
||||||
final float yDistance = maxBase - minBase;
|
|
||||||
if ((!useFeet && (yDistance <= 100)) || (useFeet && (yDistance <= 200))) { //Draw 50m/100ft markers for smallest scale
|
|
||||||
stepBase = stepBase/2;
|
|
||||||
}
|
|
||||||
final float xPer = (float)canvas.getWidth() / xDistance;
|
|
||||||
final float yPer = (float)canvas.getHeight() / yDistance;
|
|
||||||
final float canvasRight = (float)canvas.getWidth() - 1f;
|
|
||||||
final float canvasBottom = (float)canvas.getHeight() - 1f;
|
|
||||||
|
|
||||||
// This y transform apparently needed to assure top and bottom lines show up on all devices
|
|
||||||
final float yOffset = 2f;
|
|
||||||
final float ySlope = ((float)canvas.getHeight() - 2f * yOffset) / (float)canvas.getHeight();
|
|
||||||
|
|
||||||
Paint barPaint = new Paint();
|
|
||||||
barPaint.setColor(getResources().getColor(R.color.dialog_inactive_text_color_dark));
|
|
||||||
barPaint.setTextSize((int)(16f * screenScale + 0.5f));
|
|
||||||
barPaint.setTypeface(Typeface.create(Typeface.DEFAULT_BOLD, Typeface.BOLD));
|
|
||||||
float yTextLast = 9999f;
|
|
||||||
for (int i = minBase; i <= maxBase ; i += stepBase) {
|
|
||||||
float y = yOffset + ySlope * (canvasBottom - yPer * (float)(i - minBase));
|
|
||||||
canvas.drawLine(0, y, canvasRight, y, barPaint);
|
|
||||||
if ((yTextLast - y) >= (int)(32f * screenScale + 0.5f)) { // Overlap prevention
|
|
||||||
canvas.drawText(String.valueOf(i) + " " + unit, (int)(8f * screenScale + 0.5f), y - (int)(2f * screenScale + 0.5f), barPaint);
|
|
||||||
yTextLast = y;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
float lastX = 0, lastY = 0;
|
|
||||||
float xDistSum = 0;
|
|
||||||
|
|
||||||
Paint paint = new Paint();
|
|
||||||
paint.setColor(getResources().getColor(R.color.gpx_altitude_asc));
|
|
||||||
paint.setStrokeWidth((int)(2f * screenScale + 0.5f));
|
|
||||||
boolean first = true;
|
|
||||||
if (elevationList != null) {
|
|
||||||
for (GPXUtilities.Elevation elevation : elevationList) {
|
|
||||||
xDistSum += elevation.distance;
|
|
||||||
float nextX = xPer * xDistSum;
|
|
||||||
float nextY = yOffset + ySlope * (canvasBottom - yPer * (float)(elevation.elevation * convEle - minBase));
|
|
||||||
if (first) {
|
|
||||||
first = false;
|
|
||||||
} else {
|
|
||||||
canvas.drawLine(lastX, lastY, nextX, nextY, paint);
|
|
||||||
}
|
|
||||||
lastX = nextX;
|
|
||||||
lastY = nextY;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setElevationData(List<GPXUtilities.Elevation> elevationData) {
|
|
||||||
elevationList = elevationData;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMaxElevation(double max) {
|
|
||||||
maxElevation = max;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMinElevation(double min) {
|
|
||||||
minElevation = min;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTotalDistance(float dist) {
|
|
||||||
xDistance = dist;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -5,14 +5,16 @@ import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Color;
|
||||||
import android.graphics.Paint;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
|
import android.support.v4.app.ActivityCompat;
|
||||||
|
import android.support.v4.content.ContextCompat;
|
||||||
import android.support.v4.view.MenuItemCompat;
|
import android.support.v4.view.MenuItemCompat;
|
||||||
import android.support.v7.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
|
@ -30,11 +32,24 @@ import android.widget.ListView;
|
||||||
import android.widget.Spinner;
|
import android.widget.Spinner;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.github.mikephil.charting.charts.LineChart;
|
||||||
|
import com.github.mikephil.charting.components.Legend;
|
||||||
|
import com.github.mikephil.charting.components.MarkerView;
|
||||||
|
import com.github.mikephil.charting.components.XAxis;
|
||||||
|
import com.github.mikephil.charting.components.YAxis;
|
||||||
|
import com.github.mikephil.charting.data.Entry;
|
||||||
|
import com.github.mikephil.charting.data.LineData;
|
||||||
|
import com.github.mikephil.charting.data.LineDataSet;
|
||||||
|
import com.github.mikephil.charting.highlight.Highlight;
|
||||||
|
import com.github.mikephil.charting.interfaces.datasets.ILineDataSet;
|
||||||
|
import com.github.mikephil.charting.utils.MPPointF;
|
||||||
|
import com.github.mikephil.charting.utils.Utils;
|
||||||
|
|
||||||
import net.osmand.data.FavouritePoint;
|
import net.osmand.data.FavouritePoint;
|
||||||
import net.osmand.data.LatLon;
|
import net.osmand.data.LatLon;
|
||||||
import net.osmand.data.PointDescription;
|
import net.osmand.data.PointDescription;
|
||||||
import net.osmand.plus.FavouritesDbHelper;
|
import net.osmand.plus.FavouritesDbHelper;
|
||||||
import net.osmand.plus.GPXUtilities;
|
import net.osmand.plus.GPXUtilities.Elevation;
|
||||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||||
import net.osmand.plus.GPXUtilities.WptPt;
|
import net.osmand.plus.GPXUtilities.WptPt;
|
||||||
import net.osmand.plus.GpxSelectionHelper;
|
import net.osmand.plus.GpxSelectionHelper;
|
||||||
|
@ -46,6 +61,7 @@ import net.osmand.plus.MapMarkersHelper;
|
||||||
import net.osmand.plus.OsmAndFormatter;
|
import net.osmand.plus.OsmAndFormatter;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandSettings;
|
import net.osmand.plus.OsmandSettings;
|
||||||
|
import net.osmand.plus.OsmandSettings.MetricsConstants;
|
||||||
import net.osmand.plus.R;
|
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;
|
||||||
|
@ -62,6 +78,8 @@ import java.util.List;
|
||||||
|
|
||||||
import gnu.trove.list.array.TIntArrayList;
|
import gnu.trove.list.array.TIntArrayList;
|
||||||
|
|
||||||
|
import static com.github.mikephil.charting.components.XAxis.XAxisPosition.BOTTOM;
|
||||||
|
|
||||||
|
|
||||||
public class SelectedGPXFragment extends OsmAndListFragment {
|
public class SelectedGPXFragment extends OsmAndListFragment {
|
||||||
public static final String ARG_TO_EXPAND_TRACK_INFO = "ARG_TO_EXPAND_TRACK_INFO";
|
public static final String ARG_TO_EXPAND_TRACK_INFO = "ARG_TO_EXPAND_TRACK_INFO";
|
||||||
|
@ -71,7 +89,7 @@ public class SelectedGPXFragment extends OsmAndListFragment {
|
||||||
protected SelectedGPXAdapter adapter;
|
protected SelectedGPXAdapter adapter;
|
||||||
protected TrackActivity activity;
|
protected TrackActivity activity;
|
||||||
private boolean updateEnable;
|
private boolean updateEnable;
|
||||||
|
private MetricsConstants mc;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAttach(Activity activity) {
|
public void onAttach(Activity activity) {
|
||||||
|
@ -81,6 +99,7 @@ public class SelectedGPXFragment extends OsmAndListFragment {
|
||||||
final Collator collator = Collator.getInstance();
|
final Collator collator = Collator.getInstance();
|
||||||
collator.setStrength(Collator.SECONDARY);
|
collator.setStrength(Collator.SECONDARY);
|
||||||
app = (OsmandApplication) activity.getApplication();
|
app = (OsmandApplication) activity.getApplication();
|
||||||
|
mc = app.getSettings().METRIC_SYSTEM.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public TrackActivity getMyActivity() {
|
public TrackActivity getMyActivity() {
|
||||||
|
@ -452,9 +471,53 @@ public class SelectedGPXFragment extends OsmAndListFragment {
|
||||||
@Override
|
@Override
|
||||||
public View getView(int position, View convertView, ViewGroup parent) {
|
public View getView(int position, View convertView, ViewGroup parent) {
|
||||||
View row = convertView;
|
View row = convertView;
|
||||||
|
LineChart mChart = null;
|
||||||
|
final boolean useFeet = (mc == MetricsConstants.MILES_AND_FEET) || (mc == MetricsConstants.MILES_AND_YARDS);
|
||||||
if (row == null) {
|
if (row == null) {
|
||||||
LayoutInflater inflater = getMyActivity().getLayoutInflater();
|
LayoutInflater inflater = getMyActivity().getLayoutInflater();
|
||||||
row = inflater.inflate(R.layout.gpx_item_list_item, parent, false);
|
row = inflater.inflate(R.layout.gpx_item_list_item, parent, false);
|
||||||
|
|
||||||
|
mChart = (LineChart) row.findViewById(R.id.chart);
|
||||||
|
//mChart.setHardwareAccelerationEnabled(true);
|
||||||
|
mChart.setTouchEnabled(true);
|
||||||
|
mChart.setDragEnabled(true);
|
||||||
|
mChart.setScaleEnabled(true);
|
||||||
|
mChart.setPinchZoom(true);
|
||||||
|
mChart.setScaleYEnabled(false);
|
||||||
|
mChart.setAutoScaleMinMaxEnabled(true);
|
||||||
|
mChart.setDrawBorders(false);
|
||||||
|
mChart.getDescription().setEnabled(false);
|
||||||
|
mChart.setMaxVisibleValueCount(10);
|
||||||
|
mChart.setMinOffset(0f);
|
||||||
|
|
||||||
|
mChart.setExtraTopOffset(24f);
|
||||||
|
mChart.setExtraBottomOffset(16f);
|
||||||
|
|
||||||
|
// create a custom MarkerView (extend MarkerView) and specify the layout
|
||||||
|
// to use for it
|
||||||
|
MyMarkerView mv = new MyMarkerView(getActivity(), R.layout.chart_marker_view, useFeet);
|
||||||
|
mv.setChartView(mChart); // For bounds control
|
||||||
|
mChart.setMarker(mv); // Set the marker to the chart
|
||||||
|
mChart.setDrawMarkers(true);
|
||||||
|
|
||||||
|
XAxis xAxis = mChart.getXAxis();
|
||||||
|
xAxis.setDrawAxisLine(false);
|
||||||
|
xAxis.setDrawGridLines(false);
|
||||||
|
xAxis.setDrawAxisLine(false);
|
||||||
|
xAxis.setPosition(BOTTOM);
|
||||||
|
|
||||||
|
YAxis yAxis = mChart.getAxisLeft();
|
||||||
|
yAxis.enableGridDashedLine(10f, 5f, 0f);
|
||||||
|
yAxis.setGridColor(ActivityCompat.getColor(getActivity(), R.color.divider_color));
|
||||||
|
yAxis.setDrawAxisLine(false);
|
||||||
|
yAxis.setPosition(YAxis.YAxisLabelPosition.INSIDE_CHART);
|
||||||
|
yAxis.setXOffset(16f);
|
||||||
|
yAxis.setYOffset(-6f);
|
||||||
|
|
||||||
|
Legend legend = mChart.getLegend();
|
||||||
|
legend.setEnabled(false);
|
||||||
|
|
||||||
|
mChart.getAxisRight().setEnabled(false);
|
||||||
}
|
}
|
||||||
GpxDisplayItem child = getItem(position);
|
GpxDisplayItem child = getItem(position);
|
||||||
TextView label = (TextView) row.findViewById(R.id.name);
|
TextView label = (TextView) row.findViewById(R.id.name);
|
||||||
|
@ -495,15 +558,66 @@ public class SelectedGPXFragment extends OsmAndListFragment {
|
||||||
description.setVisibility(View.GONE);
|
description.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
ElevationView elevationImg = (ElevationView) row.findViewById(R.id.elevation);
|
if (mChart != null) {
|
||||||
if (child.analysis != null && child.analysis.elevationData != null && child.analysis.isElevationSpecified() && (child.analysis.totalDistance > 0)) {
|
if (child.analysis != null && child.analysis.elevationData != null && child.analysis.isElevationSpecified() && (child.analysis.totalDistance > 0)) {
|
||||||
elevationImg.setElevationData(child.analysis.elevationData);
|
|
||||||
elevationImg.setMaxElevation(child.analysis.maxElevation);
|
if (child.analysis.minElevation >= 0) {
|
||||||
elevationImg.setMinElevation(child.analysis.minElevation);
|
//mChart.getAxisLeft().setAxisMinimum(0f);
|
||||||
elevationImg.setTotalDistance(child.analysis.totalDistance); //Use raw data for graph, not channel detection noise filter (facilitates visual double check)
|
}
|
||||||
elevationImg.setVisibility(View.VISIBLE);
|
|
||||||
} else {
|
final float convEle = useFeet ? 3.28084f : 1.0f;
|
||||||
elevationImg.setVisibility(View.GONE);
|
final float divX = child.analysis.totalDistance > 1000 ? 1000f : 1f;
|
||||||
|
|
||||||
|
ArrayList<Entry> values = new ArrayList<>();
|
||||||
|
List<Elevation> elevationData = child.analysis.elevationData;
|
||||||
|
float nextX = 0;
|
||||||
|
float nextY;
|
||||||
|
for (Elevation e : elevationData) {
|
||||||
|
if (e.distance > 0) {
|
||||||
|
nextX += (float) e.distance / divX;
|
||||||
|
nextY = (float) (e.elevation * convEle);
|
||||||
|
values.add(new Entry(nextX, nextY));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LineDataSet dataSet = new LineDataSet(values, "");
|
||||||
|
|
||||||
|
dataSet.setColor(Color.BLACK);
|
||||||
|
dataSet.setDrawValues(false);
|
||||||
|
dataSet.setLineWidth(0f);
|
||||||
|
dataSet.setValueTextSize(9f);
|
||||||
|
dataSet.setDrawFilled(true);
|
||||||
|
dataSet.setFormLineWidth(1f);
|
||||||
|
dataSet.setFormSize(15.f);
|
||||||
|
|
||||||
|
dataSet.setDrawCircles(false);
|
||||||
|
dataSet.setDrawCircleHole(false);
|
||||||
|
|
||||||
|
dataSet.setHighlightEnabled(true);
|
||||||
|
dataSet.setDrawVerticalHighlightIndicator(true);
|
||||||
|
dataSet.setDrawHorizontalHighlightIndicator(false);
|
||||||
|
dataSet.setHighLightColor(Color.BLACK);
|
||||||
|
|
||||||
|
if (Utils.getSDKInt() >= 18) {
|
||||||
|
// fill drawable only supported on api level 18 and above
|
||||||
|
Drawable drawable = ContextCompat.getDrawable(getActivity(), R.drawable.line_chart_fade_orange);
|
||||||
|
dataSet.setFillDrawable(drawable);
|
||||||
|
} else {
|
||||||
|
dataSet.setFillColor(ContextCompat.getColor(getActivity(), R.color.osmand_orange));
|
||||||
|
}
|
||||||
|
ArrayList<ILineDataSet> dataSets = new ArrayList<ILineDataSet>();
|
||||||
|
dataSets.add(dataSet); // add the datasets
|
||||||
|
|
||||||
|
// create a data object with the datasets
|
||||||
|
LineData data = new LineData(dataSets);
|
||||||
|
|
||||||
|
// set data
|
||||||
|
mChart.setData(data);
|
||||||
|
|
||||||
|
mChart.setVisibility(View.VISIBLE);
|
||||||
|
} else {
|
||||||
|
mChart.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return row;
|
return row;
|
||||||
|
@ -562,6 +676,43 @@ public class SelectedGPXFragment extends OsmAndListFragment {
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class MyMarkerView extends MarkerView {
|
||||||
|
|
||||||
|
private TextView tvContent;
|
||||||
|
private String altSuffix;
|
||||||
|
|
||||||
|
public MyMarkerView(Context context, int layoutResource, boolean useFeet) {
|
||||||
|
super(context, layoutResource);
|
||||||
|
|
||||||
|
tvContent = (TextView) findViewById(R.id.tvContent);
|
||||||
|
if (!useFeet) {
|
||||||
|
altSuffix = getContext().getString(R.string.m);
|
||||||
|
} else {
|
||||||
|
altSuffix = getContext().getString(R.string.foot);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// callbacks everytime the MarkerView is redrawn, can be used to update the
|
||||||
|
// content (user-interface)
|
||||||
|
@Override
|
||||||
|
public void refreshContent(Entry e, Highlight highlight) {
|
||||||
|
tvContent.setText(Integer.toString((int)e.getY()) + " " + altSuffix);
|
||||||
|
super.refreshContent(e, highlight);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MPPointF getOffset() {
|
||||||
|
return new MPPointF(-(getWidth() / 2), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MPPointF getOffsetForDrawingAtPoint(float posX, float posY) {
|
||||||
|
MPPointF offset = getOffset();
|
||||||
|
offset.y = -posY;
|
||||||
|
return offset;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static class SplitTrackAsyncTask extends AsyncTask<Void, Void, Void> {
|
public static class SplitTrackAsyncTask extends AsyncTask<Void, Void, Void> {
|
||||||
@Nullable private final SelectedGpxFile mSelectedGpxFile;
|
@Nullable private final SelectedGpxFile mSelectedGpxFile;
|
||||||
@NonNull private final SelectedGPXFragment mFragment;
|
@NonNull private final SelectedGPXFragment mFragment;
|
||||||
|
|
Loading…
Reference in a new issue