mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-25 01:55:50 +01:00
Respiratory rate: fix strings, margins, missing data on chart
This commit is contained in:
parent
9ae56ae88c
commit
a11f6871cd
@ -1901,7 +1901,7 @@ public class GBApplication extends Application {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final String newPrefValue;
|
final String newPrefValue;
|
||||||
if (!StringUtils.isBlank(chartsTabsValue)) {
|
if (!StringUtils.isBlank(chartsTabsValue) && !chartsTabsValue.contains("respiratoryrate")) {
|
||||||
newPrefValue = chartsTabsValue + ",respiratoryrate";
|
newPrefValue = chartsTabsValue + ",respiratoryrate";
|
||||||
} else {
|
} else {
|
||||||
newPrefValue = "respiratoryrate";
|
newPrefValue = "respiratoryrate";
|
||||||
|
@ -106,11 +106,29 @@ public class RespiratoryRateDailyFragment extends RespiratoryRateFragment<Respir
|
|||||||
respiratoryRateChart.getLegend().setTextColor(TEXT_COLOR);
|
respiratoryRateChart.getLegend().setTextColor(TEXT_COLOR);
|
||||||
respiratoryRateChart.getLegend().setCustom(legendEntries);
|
respiratoryRateChart.getLegend().setCustom(legendEntries);
|
||||||
|
|
||||||
final List<Entry> lineEntries = new ArrayList<>();
|
final List<ILineDataSet> lineDataSets = new ArrayList<>();
|
||||||
|
List<Entry> lineEntries = new ArrayList<>();
|
||||||
final TimestampTranslation tsTranslation = new TimestampTranslation();
|
final TimestampTranslation tsTranslation = new TimestampTranslation();
|
||||||
|
int lastTsShorten = 0;
|
||||||
for (final AbstractRespiratoryRateSample sample : respiratoryRateDay.respiratoryRateSamples) {
|
for (final AbstractRespiratoryRateSample sample : respiratoryRateDay.respiratoryRateSamples) {
|
||||||
int ts = (int) (sample.getTimestamp() / 1000L);
|
int ts = (int) (sample.getTimestamp() / 1000L);
|
||||||
lineEntries.add(new Entry(tsTranslation.shorten(ts), (int) sample.getRespiratoryRate()));
|
int tsShorten = tsTranslation.shorten(ts);
|
||||||
|
if (lastTsShorten == 0 || (tsShorten - lastTsShorten) <= 300) {
|
||||||
|
lineEntries.add(new Entry(tsShorten, (int) sample.getRespiratoryRate()));
|
||||||
|
} else {
|
||||||
|
if (!lineEntries.isEmpty()) {
|
||||||
|
List<Entry> clone = new ArrayList<>(lineEntries.size());
|
||||||
|
clone.addAll(lineEntries);
|
||||||
|
lineDataSets.add(createDataSet(clone));
|
||||||
|
lineEntries.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
lastTsShorten = tsShorten;
|
||||||
|
lineEntries.add(new Entry(tsShorten, (int) sample.getRespiratoryRate()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!lineEntries.isEmpty()) {
|
||||||
|
lineDataSets.add(createDataSet(lineEntries));
|
||||||
}
|
}
|
||||||
|
|
||||||
respiratoryRateChart.getXAxis().setValueFormatter(new SampleXLabelFormatter(tsTranslation, "HH:mm"));
|
respiratoryRateChart.getXAxis().setValueFormatter(new SampleXLabelFormatter(tsTranslation, "HH:mm"));
|
||||||
@ -130,12 +148,26 @@ public class RespiratoryRateDailyFragment extends RespiratoryRateFragment<Respir
|
|||||||
lineDataSet.setDrawValues(false);
|
lineDataSet.setDrawValues(false);
|
||||||
lineDataSet.setMode(LineDataSet.Mode.CUBIC_BEZIER);
|
lineDataSet.setMode(LineDataSet.Mode.CUBIC_BEZIER);
|
||||||
|
|
||||||
final List<ILineDataSet> lineDataSets = new ArrayList<>();
|
|
||||||
lineDataSets.add(lineDataSet);
|
lineDataSets.add(lineDataSet);
|
||||||
final LineData lineData = new LineData(lineDataSets);
|
final LineData lineData = new LineData(lineDataSets);
|
||||||
respiratoryRateChart.setData(lineData);
|
respiratoryRateChart.setData(lineData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected LineDataSet createDataSet(final List<Entry> values) {
|
||||||
|
final LineDataSet lineDataSet = new LineDataSet(values, getString(R.string.respiratoryRate));
|
||||||
|
lineDataSet.setColor(getResources().getColor(R.color.respiratory_rate_color));
|
||||||
|
lineDataSet.setDrawCircles(false);
|
||||||
|
lineDataSet.setLineWidth(2f);
|
||||||
|
lineDataSet.setFillAlpha(255);
|
||||||
|
lineDataSet.setDrawCircles(false);
|
||||||
|
lineDataSet.setCircleColor(getResources().getColor(R.color.respiratory_rate_color));
|
||||||
|
lineDataSet.setAxisDependency(YAxis.AxisDependency.LEFT);
|
||||||
|
lineDataSet.setDrawValues(false);
|
||||||
|
lineDataSet.setMode(LineDataSet.Mode.CUBIC_BEZIER);
|
||||||
|
|
||||||
|
return lineDataSet;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void renderCharts() {
|
protected void renderCharts() {
|
||||||
respiratoryRateChart.invalidate();
|
respiratoryRateChart.invalidate();
|
||||||
|
@ -168,8 +168,8 @@ public class RespiratoryRatePeriodFragment extends RespiratoryRateFragment<Respi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LineDataSet awakeDataSet = createDataSet(lineAwakeRateAvgEntries, getString(R.string.awake_avg), R.color.respiratory_rate_color);
|
LineDataSet awakeDataSet = createDataSet(lineAwakeRateAvgEntries, getString(R.string.sleep_colored_stats_awake_avg), R.color.respiratory_rate_color);
|
||||||
LineDataSet sleepDataSet = createDataSet(lineSleepRateEntries, getString(R.string.awake_avg), R.color.chart_light_sleep_light);
|
LineDataSet sleepDataSet = createDataSet(lineSleepRateEntries, getString(R.string.sleep_avg), R.color.chart_light_sleep_light);
|
||||||
|
|
||||||
final List<ILineDataSet> lineDataSets = new ArrayList<>();
|
final List<ILineDataSet> lineDataSets = new ArrayList<>();
|
||||||
lineDataSets.add(awakeDataSet);
|
lineDataSets.add(awakeDataSet);
|
||||||
@ -177,7 +177,7 @@ public class RespiratoryRatePeriodFragment extends RespiratoryRateFragment<Respi
|
|||||||
|
|
||||||
List<LegendEntry> legendEntries = new ArrayList<>(1);
|
List<LegendEntry> legendEntries = new ArrayList<>(1);
|
||||||
LegendEntry awakeEntry = new LegendEntry();
|
LegendEntry awakeEntry = new LegendEntry();
|
||||||
awakeEntry.label = getString(R.string.awake_avg);
|
awakeEntry.label = getString(R.string.sleep_colored_stats_awake_avg);
|
||||||
awakeEntry.formColor = getResources().getColor(R.color.respiratory_rate_color);
|
awakeEntry.formColor = getResources().getColor(R.color.respiratory_rate_color);
|
||||||
LegendEntry sleepEntry = new LegendEntry();
|
LegendEntry sleepEntry = new LegendEntry();
|
||||||
sleepEntry.label = getString(R.string.sleep_avg);
|
sleepEntry.label = getString(R.string.sleep_avg);
|
||||||
|
@ -51,7 +51,7 @@
|
|||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/awake_avg"
|
android:text="@string/sleep_colored_stats_awake_avg"
|
||||||
android:textSize="12sp" />
|
android:textSize="12sp" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
@ -77,7 +77,6 @@
|
|||||||
<LinearLayout
|
<LinearLayout
|
||||||
style="@style/GridTile"
|
style="@style/GridTile"
|
||||||
android:layout_marginStart="1dp"
|
android:layout_marginStart="1dp"
|
||||||
android:layout_marginTop="2dp"
|
|
||||||
>
|
>
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/day_lowest"
|
android:id="@+id/day_lowest"
|
||||||
@ -95,7 +94,6 @@
|
|||||||
<LinearLayout
|
<LinearLayout
|
||||||
style="@style/GridTile"
|
style="@style/GridTile"
|
||||||
android:layout_marginStart="1dp"
|
android:layout_marginStart="1dp"
|
||||||
android:layout_marginTop="2dp"
|
|
||||||
>
|
>
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/day_highest"
|
android:id="@+id/day_highest"
|
||||||
|
@ -71,7 +71,7 @@
|
|||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/awake_avg"
|
android:text="@string/sleep_colored_stats_awake_avg"
|
||||||
android:textSize="12sp" />
|
android:textSize="12sp" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</GridLayout>
|
</GridLayout>
|
||||||
|
@ -3114,6 +3114,7 @@
|
|||||||
<item>@string/menuitem_temperature</item>
|
<item>@string/menuitem_temperature</item>
|
||||||
<item>@string/menuitem_weight</item>
|
<item>@string/menuitem_weight</item>
|
||||||
<item>@string/watchface_widget_type_calories</item>
|
<item>@string/watchface_widget_type_calories</item>
|
||||||
|
<item>@string/p_respiratory_rate</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
<string-array name="pref_charts_tabs_values">
|
<string-array name="pref_charts_tabs_values">
|
||||||
|
@ -1019,7 +1019,6 @@
|
|||||||
<string name="sleep_colored_stats_light_avg">Light AVG</string>
|
<string name="sleep_colored_stats_light_avg">Light AVG</string>
|
||||||
<string name="sleep_colored_stats_rem_avg">REM AVG</string>
|
<string name="sleep_colored_stats_rem_avg">REM AVG</string>
|
||||||
<string name="sleep_colored_stats_awake_avg">Awake AVG</string>
|
<string name="sleep_colored_stats_awake_avg">Awake AVG</string>
|
||||||
<string name="awake_avg">Awake AVG</string>
|
|
||||||
<string name="sleep_avg">Sleep AVG</string>
|
<string name="sleep_avg">Sleep AVG</string>
|
||||||
<string name="lowest">Lowest</string>
|
<string name="lowest">Lowest</string>
|
||||||
<string name="highest">Highest</string>
|
<string name="highest">Highest</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user