mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-25 18:15:49 +01:00
Add minimum/maximum heart rate popup, fixes #1483
This commit is contained in:
parent
6960b10e5d
commit
4c39dceecd
@ -65,7 +65,7 @@ public class ChartsActivity extends AbstractGBFragmentActivity implements Charts
|
|||||||
|
|
||||||
LimitedQueue mActivityAmountCache = new LimitedQueue(60);
|
LimitedQueue mActivityAmountCache = new LimitedQueue(60);
|
||||||
|
|
||||||
private static class ShowDurationDialog extends Dialog {
|
public static class ShowDurationDialog extends Dialog {
|
||||||
private final String mDuration;
|
private final String mDuration;
|
||||||
private TextView durationLabel;
|
private TextView durationLabel;
|
||||||
|
|
||||||
|
@ -28,6 +28,8 @@ import android.view.ViewGroup;
|
|||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||||
|
|
||||||
import com.github.mikephil.charting.animation.Easing;
|
import com.github.mikephil.charting.animation.Easing;
|
||||||
import com.github.mikephil.charting.charts.Chart;
|
import com.github.mikephil.charting.charts.Chart;
|
||||||
import com.github.mikephil.charting.charts.LineChart;
|
import com.github.mikephil.charting.charts.LineChart;
|
||||||
@ -73,7 +75,10 @@ public class SleepChartFragment extends AbstractChartFragment {
|
|||||||
private PieChart mSleepAmountChart;
|
private PieChart mSleepAmountChart;
|
||||||
private TextView mSleepchartInfo;
|
private TextView mSleepchartInfo;
|
||||||
private TextView heartRateAverageLabel;
|
private TextView heartRateAverageLabel;
|
||||||
private ImageView heartRateWidget;
|
private ImageView heartRateIcon;
|
||||||
|
private int heartRateMin = 0;
|
||||||
|
private int heartRateMax = 0;
|
||||||
|
|
||||||
|
|
||||||
private int mSmartAlarmFrom = -1;
|
private int mSmartAlarmFrom = -1;
|
||||||
private int mSmartAlarmTo = -1;
|
private int mSmartAlarmTo = -1;
|
||||||
@ -192,6 +197,8 @@ public class SleepChartFragment extends AbstractChartFragment {
|
|||||||
mActivityChart.getXAxis().setValueFormatter(mcd.getChartsData().getXValueFormatter());
|
mActivityChart.getXAxis().setValueFormatter(mcd.getChartsData().getXValueFormatter());
|
||||||
mActivityChart.setData(mcd.getChartsData().getData());
|
mActivityChart.setData(mcd.getChartsData().getData());
|
||||||
mSleepchartInfo.setText(buildYouSleptText(pieData));
|
mSleepchartInfo.setText(buildYouSleptText(pieData));
|
||||||
|
heartRateMin = mcd.getHeartRateAxisMin();
|
||||||
|
heartRateMax = mcd.getHeartRateAxisMax();
|
||||||
|
|
||||||
if (!CHARTS_SLEEP_RANGE_24H
|
if (!CHARTS_SLEEP_RANGE_24H
|
||||||
&& supportsHeartrate(getChartsHost().getDevice())
|
&& supportsHeartrate(getChartsHost().getDevice())
|
||||||
@ -289,8 +296,17 @@ public class SleepChartFragment extends AbstractChartFragment {
|
|||||||
mActivityChart = rootView.findViewById(R.id.sleepchart);
|
mActivityChart = rootView.findViewById(R.id.sleepchart);
|
||||||
mSleepAmountChart = rootView.findViewById(R.id.sleepchart_pie_light_deep);
|
mSleepAmountChart = rootView.findViewById(R.id.sleepchart_pie_light_deep);
|
||||||
mSleepchartInfo = rootView.findViewById(R.id.sleepchart_info);
|
mSleepchartInfo = rootView.findViewById(R.id.sleepchart_info);
|
||||||
heartRateWidget = rootView.findViewById(R.id.heartrate_widget_icon);
|
heartRateIcon = rootView.findViewById(R.id.heartrate_widget_icon);
|
||||||
heartRateAverageLabel = rootView.findViewById(R.id.heartrate_widget_label);
|
heartRateAverageLabel = rootView.findViewById(R.id.heartrate_widget_label);
|
||||||
|
ConstraintLayout heartRateWidgetLayout = rootView.findViewById(R.id.heartrate_widget_layout);
|
||||||
|
|
||||||
|
heartRateWidgetLayout.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
String detailedDuration = String.format(getString(R.string.charts_min_max_heartrate_popup), heartRateMin, heartRateMax);
|
||||||
|
new ChartsActivity.ShowDurationDialog(detailedDuration, getContext()).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
setupActivityChart();
|
setupActivityChart();
|
||||||
setupSleepAmountChart();
|
setupSleepAmountChart();
|
||||||
@ -372,7 +388,7 @@ public class SleepChartFragment extends AbstractChartFragment {
|
|||||||
deepSleepEntry.label = akDeepSleep.label;
|
deepSleepEntry.label = akDeepSleep.label;
|
||||||
deepSleepEntry.formColor = akDeepSleep.color;
|
deepSleepEntry.formColor = akDeepSleep.color;
|
||||||
legendEntries.add(deepSleepEntry);
|
legendEntries.add(deepSleepEntry);
|
||||||
heartRateWidget.setVisibility(View.GONE); //hide heart icon
|
heartRateIcon.setVisibility(View.GONE); //hide heart icon
|
||||||
|
|
||||||
if (supportsHeartrate(getChartsHost().getDevice())) {
|
if (supportsHeartrate(getChartsHost().getDevice())) {
|
||||||
LegendEntry hrEntry = new LegendEntry();
|
LegendEntry hrEntry = new LegendEntry();
|
||||||
@ -384,7 +400,7 @@ public class SleepChartFragment extends AbstractChartFragment {
|
|||||||
hrAverageEntry.label = HEARTRATE_AVERAGE_LABEL;
|
hrAverageEntry.label = HEARTRATE_AVERAGE_LABEL;
|
||||||
hrAverageEntry.formColor = Color.RED;
|
hrAverageEntry.formColor = Color.RED;
|
||||||
legendEntries.add(hrAverageEntry);
|
legendEntries.add(hrAverageEntry);
|
||||||
heartRateWidget.setVisibility(View.VISIBLE);
|
heartRateIcon.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
chart.getLegend().setCustom(legendEntries);
|
chart.getLegend().setCustom(legendEntries);
|
||||||
@ -432,12 +448,12 @@ public class SleepChartFragment extends AbstractChartFragment {
|
|||||||
private final DefaultChartsData<LineData> chartsData;
|
private final DefaultChartsData<LineData> chartsData;
|
||||||
private final MySleepChartsData pieData;
|
private final MySleepChartsData pieData;
|
||||||
private final float heartRateAverage;
|
private final float heartRateAverage;
|
||||||
private float heartRateAxisMax;
|
private int heartRateAxisMax;
|
||||||
private float heartRateAxisMin;
|
private int heartRateAxisMin;
|
||||||
private float intensityAxisMax;
|
private float intensityAxisMax;
|
||||||
private float intensityAxisMin;
|
private float intensityAxisMin;
|
||||||
|
|
||||||
public MyChartsData(MySleepChartsData pieData, DefaultChartsData<LineData> chartsData, float heartRateAverage, float heartRateAxisMin, float heartRateAxisMax, float intensityAxisMin, float intensityAxisMax) {
|
public MyChartsData(MySleepChartsData pieData, DefaultChartsData<LineData> chartsData, float heartRateAverage, int heartRateAxisMin, int heartRateAxisMax, float intensityAxisMin, float intensityAxisMax) {
|
||||||
this.pieData = pieData;
|
this.pieData = pieData;
|
||||||
this.chartsData = chartsData;
|
this.chartsData = chartsData;
|
||||||
this.heartRateAverage = heartRateAverage;
|
this.heartRateAverage = heartRateAverage;
|
||||||
@ -457,13 +473,11 @@ public class SleepChartFragment extends AbstractChartFragment {
|
|||||||
return heartRateAverage;
|
return heartRateAverage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getHeartRateAxisMax() {
|
public int getHeartRateAxisMax() {
|
||||||
return heartRateAxisMax;
|
return heartRateAxisMax;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getHeartRateAxisMin() {
|
public int getHeartRateAxisMin() { return heartRateAxisMin; }
|
||||||
return heartRateAxisMin;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getIntensityAxisMax() {
|
public float getIntensityAxisMax() {
|
||||||
return intensityAxisMax;
|
return intensityAxisMax;
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:orientation="vertical"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/charts_duration_label"
|
android:id="@+id/charts_duration_label"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"></TextView>
|
android:layout_height="wrap_content"
|
||||||
|
android:padding="5dp" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
@ -509,6 +509,7 @@
|
|||||||
<string name="abstract_chart_fragment_kind_not_worn">Not worn</string>
|
<string name="abstract_chart_fragment_kind_not_worn">Not worn</string>
|
||||||
<string name="you_slept">You slept from %1$s to %2$s</string>
|
<string name="you_slept">You slept from %1$s to %2$s</string>
|
||||||
<string name="you_did_not_sleep">You did not sleep</string>
|
<string name="you_did_not_sleep">You did not sleep</string>
|
||||||
|
<string name="charts_min_max_heartrate_popup">Lowest heart rate: %1$d \nHighest heart rate: %2$d</string>
|
||||||
<string name="device_not_connected">Not connected.</string>
|
<string name="device_not_connected">Not connected.</string>
|
||||||
<string name="user_feedback_all_alarms_disabled">All alarms disabled</string>
|
<string name="user_feedback_all_alarms_disabled">All alarms disabled</string>
|
||||||
<string name="pref_title_keep_data_on_device">Keep activity data on device</string>
|
<string name="pref_title_keep_data_on_device">Keep activity data on device</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user