diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/AbstractChartFragment.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/AbstractChartFragment.java index b1ae9cc48..d6db6f5ea 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/AbstractChartFragment.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/AbstractChartFragment.java @@ -230,7 +230,7 @@ public abstract class AbstractChartFragment extends AbstractGBFragment { } protected void showDateBar(boolean show) { - getChartsHost().getDateBar().setVisibility(show ? View.VISIBLE : View.INVISIBLE); + getChartsHost().getDateBar().setVisibility(show ? View.VISIBLE : View.GONE); } @Override diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/LiveActivityFragment.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/LiveActivityFragment.java index 00a6e6bb4..c2ac03045 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/LiveActivityFragment.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/LiveActivityFragment.java @@ -29,6 +29,7 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.WindowManager; +import android.widget.TextView; import android.widget.Toast; import com.github.mikephil.charting.charts.BarLineChartBase; @@ -60,6 +61,7 @@ import nodomain.freeyourgadget.gadgetbridge.activities.HeartRateUtils; import nodomain.freeyourgadget.gadgetbridge.database.DBHandler; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; import nodomain.freeyourgadget.gadgetbridge.model.ActivitySample; +import nodomain.freeyourgadget.gadgetbridge.model.ActivityUser; import nodomain.freeyourgadget.gadgetbridge.model.DeviceService; import nodomain.freeyourgadget.gadgetbridge.model.Measurement; import nodomain.freeyourgadget.gadgetbridge.util.GB; @@ -78,6 +80,7 @@ public class LiveActivityFragment extends AbstractChartFragment { private BarLineChartBase mStepsPerMinuteHistoryChart; private CustomBarChart mStepsPerMinuteCurrentChart; private CustomBarChart mTotalStepsChart; + private TextView mMaxHeartRateView; private final Steps mSteps = new Steps(); private ScheduledExecutorService pulseScheduler; @@ -85,6 +88,7 @@ public class LiveActivityFragment extends AbstractChartFragment { private List heartRateValues; private LineDataSet mHeartRateSet; private int mHeartRate; + private int mMaxHeartRate = 0; private TimestampTranslation tsTranslation; private class Steps { @@ -189,6 +193,10 @@ public class LiveActivityFragment extends AbstractChartFragment { private void setCurrentHeartRate(int heartRate, int timestamp) { addHistoryDataSet(true); mHeartRate = heartRate; + if (mMaxHeartRate < mHeartRate) { + mMaxHeartRate = mHeartRate; + } + mMaxHeartRateView.setText(getContext().getString(R.string.live_activity_max_heart_rate, heartRate, mMaxHeartRate)); } private int getCurrentHeartRate() { @@ -233,10 +241,9 @@ public class LiveActivityFragment extends AbstractChartFragment { } mHistorySet.addEntry(new Entry(timestamp, stepsPerMinute)); int hr = getCurrentHeartRate(); - if (hr < 0) { - hr = 0; + if (hr > HeartRateUtils.getInstance().getMinHeartRate()) { + mHeartRateSet.addEntry(new Entry(timestamp, hr)); } - mHeartRateSet.addEntry(new Entry(timestamp, hr)); } private boolean addHistoryDataSet(boolean force) { @@ -272,8 +279,13 @@ public class LiveActivityFragment extends AbstractChartFragment { stepsPerMinuteEntry = new BarEntry(1, 0); mStepsPerMinuteData = setupCurrentChart(mStepsPerMinuteCurrentChart, stepsPerMinuteEntry, getString(R.string.live_activity_current_steps_per_minute)); + mStepsPerMinuteData.setDrawValues(true); + mStepsPerMinuteData.setValueTextColor(DESCRIPTION_COLOR); mTotalStepsData = setupTotalStepsChart(mTotalStepsChart, totalStepsEntry, getString(R.string.live_activity_total_steps)); + mTotalStepsData.setDrawValues(true); + mTotalStepsData.setValueTextColor(DESCRIPTION_COLOR); setupHistoryChart(mStepsPerMinuteHistoryChart); + mMaxHeartRateView = rootView.findViewById(R.id.livechart_max_heart_rate); LocalBroadcastManager.getInstance(getActivity()).registerReceiver(mReceiver, filterLocal); @@ -385,7 +397,7 @@ public class LiveActivityFragment extends AbstractChartFragment { } private BarDataSet setupCurrentChart(CustomBarChart chart, BarEntry entry, String title) { - mStepsPerMinuteCurrentChart.getAxisLeft().setAxisMaxValue(MAX_STEPS_PER_MINUTE); + mStepsPerMinuteCurrentChart.getAxisLeft().setAxisMaximum(MAX_STEPS_PER_MINUTE); return setupCommonChart(chart, entry, title); } @@ -408,9 +420,7 @@ public class LiveActivityFragment extends AbstractChartFragment { List entries = new ArrayList<>(); List colors = new ArrayList<>(); - entries.add(new BarEntry(0, 0)); entries.add(entry); - entries.add(new BarEntry(2, 0)); colors.add(akActivity.color); colors.add(akActivity.color); colors.add(akActivity.color); @@ -432,7 +442,9 @@ public class LiveActivityFragment extends AbstractChartFragment { } private BarDataSet setupTotalStepsChart(CustomBarChart chart, BarEntry entry, String label) { - mTotalStepsChart.getAxisLeft().setAxisMaximum(5000); // TODO: use daily goal - already reached steps + mTotalStepsChart.getAxisLeft().addLimitLine(new LimitLine(GBApplication.getPrefs().getInt(ActivityUser.PREF_USER_STEPS_GOAL, 10000), "ss")); // TODO: use daily goal - already reached steps + mTotalStepsChart.getAxisLeft().setAxisMinimum(0); + mTotalStepsChart.setAutoScaleMinMaxEnabled(true); return setupCommonChart(chart, entry, label); // at the moment, these look the same } @@ -455,6 +467,7 @@ public class LiveActivityFragment extends AbstractChartFragment { x.setDrawGridLines(false); x.setEnabled(true); x.setTextColor(CHART_TEXT_COLOR); + x.setValueFormatter(new SampleXLabelFormatter(tsTranslation)); x.setDrawLimitLinesBehindData(true); YAxis y = chart.getAxisLeft(); @@ -470,8 +483,6 @@ public class LiveActivityFragment extends AbstractChartFragment { yAxisRight.setDrawLabels(true); yAxisRight.setDrawTopYLabelEntry(false); yAxisRight.setTextColor(CHART_TEXT_COLOR); - yAxisRight.setAxisMaximum(HeartRateUtils.getInstance().getMaxHeartRate()); - yAxisRight.setAxisMinimum(HeartRateUtils.getInstance().getMinHeartRate()); mHistorySet = new LineDataSet(new ArrayList(), getString(R.string.live_activity_steps_history)); mHistorySet.setAxisDependency(YAxis.AxisDependency.LEFT); diff --git a/app/src/main/res/layout/fragment_live_activity.xml b/app/src/main/res/layout/fragment_live_activity.xml index b2a460940..2aabfebcf 100644 --- a/app/src/main/res/layout/fragment_live_activity.xml +++ b/app/src/main/res/layout/fragment_live_activity.xml @@ -30,6 +30,10 @@ android:layout_weight="20"> --> + Всего шагов История шагов за минуту Начните вашу активность + Текущая / максимальная ЧСС: %1$d / %2$d Активность Быстрый сон Глубокий сон diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 2e863afcc..7942f6cf4 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -405,6 +405,7 @@ Total steps Steps per minute history Start your activity + Current / Max heart rate: %1$d / %2$d Activity Light sleep Deep sleep