mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2026-07-31 07:44:24 +02:00
Add diving graphs (garmin)
This commit is contained in:
committed by
José Rebelo
parent
6fdd645758
commit
dc60a72e4f
+70
@@ -2,6 +2,7 @@ package nodomain.freeyourgadget.gadgetbridge.activities.workouts.charts;
|
||||
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.ActivitySummaryEntries.UNIT_BPM;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.ActivitySummaryEntries.UNIT_BREATHS_PER_MIN;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.ActivitySummaryEntries.UNIT_CELSIUS;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.ActivitySummaryEntries.UNIT_KMPH;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.ActivitySummaryEntries.UNIT_METERS;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.ActivitySummaryEntries.UNIT_METERS_PER_SECOND;
|
||||
@@ -53,6 +54,8 @@ public class DefaultWorkoutCharts {
|
||||
final List<Entry> elevationDataPoints = new ArrayList<>();
|
||||
final List<Entry> powerDataPoints = new ArrayList<>();
|
||||
final List<Entry> respiratoryRatePoints = new ArrayList<>();
|
||||
final List<Entry> temperatureDataPoints = new ArrayList<>();
|
||||
final List<Entry> depthDataPoints = new ArrayList<>();
|
||||
boolean hasSpeedValues = false;
|
||||
boolean hasCadenceValues = false;
|
||||
boolean hasElevationValues = false;
|
||||
@@ -94,6 +97,16 @@ public class DefaultWorkoutCharts {
|
||||
if (point.getRespiratoryRate() >= 0) {
|
||||
respiratoryRatePoints.add(new Entry(tsShorten, point.getRespiratoryRate()));
|
||||
}
|
||||
|
||||
// Depth (diving activity)
|
||||
if (point.getDepth() > 0) {
|
||||
depthDataPoints.add(new Entry(tsShorten, (float) point.getDepth() * -1));
|
||||
}
|
||||
|
||||
// Temperature
|
||||
if (point.getTemperature() > -273) {
|
||||
temperatureDataPoints.add(new Entry(tsShorten, (float) point.getTemperature()));
|
||||
}
|
||||
}
|
||||
|
||||
if (!heartRateDataPoints.isEmpty()) {
|
||||
@@ -120,6 +133,14 @@ public class DefaultWorkoutCharts {
|
||||
charts.add(createRespiratoryRateChart(context, respiratoryRatePoints));
|
||||
}
|
||||
|
||||
if (!depthDataPoints.isEmpty()) {
|
||||
charts.add(createDepthChart(context, depthDataPoints));
|
||||
}
|
||||
|
||||
if (!temperatureDataPoints.isEmpty()) {
|
||||
charts.add(createTemperatureChart(context, temperatureDataPoints));
|
||||
}
|
||||
|
||||
return charts;
|
||||
}
|
||||
|
||||
@@ -265,6 +286,55 @@ public class DefaultWorkoutCharts {
|
||||
);
|
||||
}
|
||||
|
||||
private static WorkoutChart createDepthChart(final Context context,
|
||||
final List<Entry> depthDataPoints) {
|
||||
final String label = String.format("%s(%s)", context.getString(R.string.diving_depth), getUnitString(context, UNIT_METERS));
|
||||
final LineDataSet dataset = createLineDataSet(context, depthDataPoints, label, ContextCompat.getColor(context, R.color.chart_line_depth));
|
||||
final ValueFormatter integerFormatter = new ValueFormatter() {
|
||||
@Override
|
||||
public String getFormattedValue(float value) {
|
||||
return String.valueOf((int) value);
|
||||
}
|
||||
};
|
||||
return new WorkoutChart(
|
||||
"diving_depth",
|
||||
context.getString(R.string.diving_depth),
|
||||
ActivitySummaryEntries.GROUP_DIVING,
|
||||
new LineData(dataset),
|
||||
integerFormatter,
|
||||
getUnitString(context, UNIT_METERS)
|
||||
);
|
||||
}
|
||||
|
||||
private static WorkoutChart createTemperatureChart(final Context context,
|
||||
final List<Entry> temperatureDataPoints) {
|
||||
final String label = String.format("%s(%s)", context.getString(R.string.menuitem_temperature), getUnitString(context, UNIT_CELSIUS));
|
||||
final LineDataSet dataset = createLineDataSet(context, temperatureDataPoints, label, ContextCompat.getColor(context, R.color.chart_line_heart_rate));
|
||||
final ValueFormatter integerFormatter = new ValueFormatter() {
|
||||
@Override
|
||||
public String getFormattedValue(float value) {
|
||||
return String.valueOf((int) value);
|
||||
}
|
||||
};
|
||||
return new WorkoutChart(
|
||||
"temperature",
|
||||
context.getString(R.string.menuitem_temperature),
|
||||
ActivitySummaryEntries.GROUP_OTHER,
|
||||
new LineData(dataset),
|
||||
integerFormatter,
|
||||
getUnitString(context, UNIT_CELSIUS),
|
||||
lineChart -> {
|
||||
YAxis yAxisLeft = lineChart.getAxisLeft();
|
||||
yAxisLeft.setAxisMinimum(0);
|
||||
yAxisLeft.setAxisMaximum(35);
|
||||
YAxis yAxisRight = lineChart.getAxisRight();
|
||||
yAxisRight.setAxisMinimum(0);
|
||||
yAxisRight.setAxisMaximum(35);
|
||||
return kotlin.Unit.INSTANCE;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public static String getUnitString(final Context context, final String unit) {
|
||||
final int resId = context.getResources().getIdentifier(unit, "string", context.getPackageName());
|
||||
if (resId != 0) {
|
||||
|
||||
@@ -43,6 +43,8 @@ public class ActivityPoint {
|
||||
private int cadence = -1;
|
||||
private int power = -1;
|
||||
private float respiratoryRate = -1;
|
||||
private double depth = -1;
|
||||
private double temperature = -273;
|
||||
|
||||
// e.g. to describe a pause during the activity
|
||||
private @Nullable String description;
|
||||
@@ -118,4 +120,10 @@ public class ActivityPoint {
|
||||
public void setRespiratoryRate(final float respiratoryRate) {
|
||||
this.respiratoryRate = respiratoryRate;
|
||||
}
|
||||
|
||||
public double getTemperature() {return temperature; }
|
||||
public void setTemperature(final double temperature) { this.temperature = temperature; }
|
||||
public double getDepth() {return depth; }
|
||||
public void setDepth(final double depth) { this.depth = depth; }
|
||||
|
||||
}
|
||||
|
||||
+1
@@ -230,6 +230,7 @@ public class ActivitySummaryEntries {
|
||||
public static final String UNIT_SECONDS_PER_100_METERS = "seconds_100m";
|
||||
public static final String UNIT_MINUTES_PER_100_YARDS = "minutes_100yd";
|
||||
public static final String UNIT_SECONDS_PER_100_YARDS = "seconds_100yd";
|
||||
public static final String UNIT_CELSIUS = "unit_celsius";
|
||||
|
||||
public static final String GROUP_PACE = "Pace";
|
||||
public static final String GROUP_ACTIVITY = "Activity";
|
||||
|
||||
+7
@@ -1010,6 +1010,13 @@ public class FitRecord extends RecordData {
|
||||
if (getEnhancedRespirationRate() != null) {
|
||||
activityPoint.setRespiratoryRate(getEnhancedRespirationRate());
|
||||
}
|
||||
if (getTemperature() != null) {
|
||||
activityPoint.setTemperature(getTemperature());
|
||||
}
|
||||
if (getDepth() != null) {
|
||||
activityPoint.setDepth(getDepth());
|
||||
}
|
||||
|
||||
return activityPoint;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,6 +97,7 @@
|
||||
<color name="chart_line_swolf" type="color">#F9DB22</color>
|
||||
<color name="chart_line_stroke_rate" type="color">#6495ED</color>
|
||||
<color name="chart_highline_dolor" type="color">#ffff8800</color>
|
||||
<color name="chart_line_depth" type="color">#ff4040ff</color>
|
||||
|
||||
<attr name="row_separator" format="color" />
|
||||
<color name="alternate_row_background_light">#FFEDEDED</color>
|
||||
|
||||
@@ -2657,6 +2657,7 @@
|
||||
<string name="workout_set_repetitions_weight_kg">%1$d x %2$.2f kg</string>
|
||||
<string name="workout_set_repetitions_weight_lbs">%1$d x %2$.2f lbs</string>
|
||||
<string name="diving_avg_depth">Average depth</string>
|
||||
<string name="diving_depth">Depth</string>
|
||||
<string name="diving_avg_descent_rate">Average descent rate</string>
|
||||
<string name="diving_avg_ascent_rate">Average ascent rate</string>
|
||||
<string name="diving_max_descent_rate">Max descent rate</string>
|
||||
|
||||
Reference in New Issue
Block a user