diff --git a/src/main/java/de/dennisguse/opentracks/TrackStoppedActivity.java b/src/main/java/de/dennisguse/opentracks/TrackStoppedActivity.java index 668f46996..8681845a9 100644 --- a/src/main/java/de/dennisguse/opentracks/TrackStoppedActivity.java +++ b/src/main/java/de/dennisguse/opentracks/TrackStoppedActivity.java @@ -17,6 +17,7 @@ import de.dennisguse.opentracks.fragments.ChooseActivityTypeDialogFragment; import de.dennisguse.opentracks.services.TrackRecordingServiceConnection; import de.dennisguse.opentracks.settings.PreferencesUtils; +import de.dennisguse.opentracks.stats.SensorStatistics; import de.dennisguse.opentracks.ui.aggregatedStatistics.ConfirmDeleteDialogFragment; import de.dennisguse.opentracks.util.ExportUtils; import de.dennisguse.opentracks.util.IntentUtils; @@ -47,6 +48,13 @@ protected void onCreate(Bundle savedInstanceState) { ContentProviderUtils contentProviderUtils = new ContentProviderUtils(this); Track track = contentProviderUtils.getTrack(trackId); + try { + SensorStatistics sensorStatistics = contentProviderUtils.getSensorStats(trackId); + if(sensorStatistics!=null) + { + float maxHr = sensorStatistics.getMaxHeartRate().getBPM(); + } + }catch (Exception e){} viewBinding.trackEditName.setText(track.getName()); diff --git a/src/main/java/de/dennisguse/opentracks/services/announcement/VoiceAnnouncementUtils.java b/src/main/java/de/dennisguse/opentracks/services/announcement/VoiceAnnouncementUtils.java index 8c06904fd..483410552 100644 --- a/src/main/java/de/dennisguse/opentracks/services/announcement/VoiceAnnouncementUtils.java +++ b/src/main/java/de/dennisguse/opentracks/services/announcement/VoiceAnnouncementUtils.java @@ -8,6 +8,7 @@ import static de.dennisguse.opentracks.settings.PreferencesUtils.shouldVoiceAnnounceLapSpeedPace; import static de.dennisguse.opentracks.settings.PreferencesUtils.shouldVoiceAnnounceMovingTime; import static de.dennisguse.opentracks.settings.PreferencesUtils.shouldVoiceAnnounceTotalDistance; +import static de.dennisguse.opentracks.settings.PreferencesUtils.shouldVoiceAnnounceCurrentHeartRate; import static de.dennisguse.opentracks.settings.PreferencesUtils.shouldVoiceAnnounceTime; import android.content.Context; @@ -170,6 +171,11 @@ static Spannable getAnnouncement(Context context, TrackStatistics trackStatistic currentHeartRate); builder.append("."); } + if(shouldVoiceAnnounceCurrentHeartRate() && currentInterval != null && currentInterval.hasAverageHeartRate()){ + int currentHeartRate = Math.round(currentInterval.getAverageHeartRate().getBPM()); + builder.append(context.getString(R.string.current_heart_rate)).append(" ").append(String.valueOf(currentHeartRate)); + builder.append("."); + } return builder; } diff --git a/src/main/java/de/dennisguse/opentracks/settings/PreferencesUtils.java b/src/main/java/de/dennisguse/opentracks/settings/PreferencesUtils.java index cda505284..2f6ac562d 100644 --- a/src/main/java/de/dennisguse/opentracks/settings/PreferencesUtils.java +++ b/src/main/java/de/dennisguse/opentracks/settings/PreferencesUtils.java @@ -506,6 +506,15 @@ public static Distance getRecordingDistanceInterval() { return Distance.of(getInt(R.string.recording_distance_interval_key, getRecordingDistanceIntervalDefaultInternal())); } + public static boolean shouldVoiceAnnounceCurrentHeartRate() { + return getBoolean(R.string.voice_announce_current_heart_rate_key, false); + } + + @VisibleForTesting + public static void setVoiceAnnounceCurrentHeartRate(boolean value) { + setBoolean(R.string.voice_announce_current_heart_rate_key, value); + } + public static Distance getRecordingDistanceIntervalDefault() { return Distance.of(getRecordingDistanceIntervalDefaultInternal()); } diff --git a/src/main/res/values/settings.xml b/src/main/res/values/settings.xml index 80095c4fa..1e2864f82 100644 --- a/src/main/res/values/settings.xml +++ b/src/main/res/values/settings.xml @@ -284,6 +284,7 @@ voiceAnnounceAverageSpeedPace voiceAnnounceLapSpeedPace voiceAnnounceAverageHeartRate + voiceAnnounceCurrentHeartRate voiceAnnounceLapHeartRate exportTrackFileFormat diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index dee82caf5..c38d3bd0d 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -432,6 +432,7 @@ limitations under the License. Time interval Distance interval Average heart rate + Current heart rate Lap heart rate Average speed/pace Lap speed/pace diff --git a/src/main/res/xml/settings_announcements.xml b/src/main/res/xml/settings_announcements.xml index 50f733176..04d5a0014 100644 --- a/src/main/res/xml/settings_announcements.xml +++ b/src/main/res/xml/settings_announcements.xml @@ -64,6 +64,11 @@ android:key="@string/voice_announce_average_heart_rate_key" android:title="@string/settings_announcements_average_heart_rate" /> + +