From d4b07c307d693f7986879418df39ef0f7a6bb880 Mon Sep 17 00:00:00 2001 From: Jaymin Suhagiya Date: Sat, 18 Nov 2023 21:17:11 -0500 Subject: [PATCH 1/9] Added current heart rate in settings --- src/main/res/values/strings.xml | 1 + src/main/res/xml/settings_announcements.xml | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 4db8181a7..4d2694c99 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -403,6 +403,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 cfbb37b03..bf63d26c4 100644 --- a/src/main/res/xml/settings_announcements.xml +++ b/src/main/res/xml/settings_announcements.xml @@ -57,6 +57,11 @@ android:key="@string/voice_announce_average_heart_rate_key" android:title="@string/settings_announcements_average_heart_rate" /> + + Date: Thu, 23 Nov 2023 19:47:28 -0500 Subject: [PATCH 2/9] Replaced Duplicate Key to Resolve Code Breaking --- src/main/res/values/settings.xml | 1 + src/main/res/xml/settings_announcements.xml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/res/values/settings.xml b/src/main/res/values/settings.xml index 95ea4ecc1..9d2d9c9d2 100644 --- a/src/main/res/values/settings.xml +++ b/src/main/res/values/settings.xml @@ -245,6 +245,7 @@ voiceAnnounceAverageSpeedPace voiceAnnounceLapSpeedPace voiceAnnounceAverageHeartRate + voiceAnnounceCurrentHeartRate voiceAnnounceLapHeartRate exportTrackFileFormat diff --git a/src/main/res/xml/settings_announcements.xml b/src/main/res/xml/settings_announcements.xml index bf63d26c4..d25d60c3a 100644 --- a/src/main/res/xml/settings_announcements.xml +++ b/src/main/res/xml/settings_announcements.xml @@ -59,7 +59,7 @@ Date: Fri, 24 Nov 2023 20:36:46 -0500 Subject: [PATCH 3/9] Added current heart rate announcement function --- .../de/dennisguse/opentracks/settings/PreferencesUtils.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/de/dennisguse/opentracks/settings/PreferencesUtils.java b/src/main/java/de/dennisguse/opentracks/settings/PreferencesUtils.java index e0303a261..7f0df25b5 100644 --- a/src/main/java/de/dennisguse/opentracks/settings/PreferencesUtils.java +++ b/src/main/java/de/dennisguse/opentracks/settings/PreferencesUtils.java @@ -428,6 +428,10 @@ 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); + } + public static Distance getRecordingDistanceIntervalDefault() { return Distance.of(getRecordingDistanceIntervalDefaultInternal()); } From ee7c2b73d5de6668e5b61789afd3247f6527433d Mon Sep 17 00:00:00 2001 From: Mohammad Ehtesham Arif Date: Sat, 25 Nov 2023 01:14:08 -0500 Subject: [PATCH 4/9] Added code for Locate the heart rate voice announcement --- .../announcement/VoiceAnnouncementUtils.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) 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 c06ec5db8..3a4a31200 100644 --- a/src/main/java/de/dennisguse/opentracks/services/announcement/VoiceAnnouncementUtils.java +++ b/src/main/java/de/dennisguse/opentracks/services/announcement/VoiceAnnouncementUtils.java @@ -7,6 +7,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 android.content.Context; import android.icu.text.MessageFormat; @@ -80,9 +81,9 @@ static Spannable getAnnouncement(Context context, TrackStatistics trackStatistic // Punctuation helps introduce natural pauses in TTS builder.append("."); } - if (totalDistance.isZero()) { - return builder; - } +// if (totalDistance.isZero()) { +// return builder; +// } // Announce time Duration movingTime = trackStatistics.getMovingTime(); @@ -148,7 +149,14 @@ static Spannable getAnnouncement(Context context, TrackStatistics trackStatistic appendCardinal(builder, context.getString(R.string.sensor_state_heart_rate_value, currentHeartRate), currentHeartRate); builder.append("."); } - + + if(shouldVoiceAnnounceCurrentHeartRate()){ + builder.append(context.getString(R.string.current_heart_rate)) + .append(" ") + .append("80"); + builder.append("."); +        } + return builder; } From fa43187dbf42b032da863f241bfeeb98ac67b0f5 Mon Sep 17 00:00:00 2001 From: anash3420 Date: Sat, 25 Nov 2023 18:38:59 -0500 Subject: [PATCH 5/9] Integrated Dummy Heart Rate Announcement to real time --- .../announcement/VoiceAnnouncementUtils.java | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) 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 3a4a31200..12948f767 100644 --- a/src/main/java/de/dennisguse/opentracks/services/announcement/VoiceAnnouncementUtils.java +++ b/src/main/java/de/dennisguse/opentracks/services/announcement/VoiceAnnouncementUtils.java @@ -149,14 +149,12 @@ static Spannable getAnnouncement(Context context, TrackStatistics trackStatistic appendCardinal(builder, context.getString(R.string.sensor_state_heart_rate_value, currentHeartRate), currentHeartRate); builder.append("."); } - - if(shouldVoiceAnnounceCurrentHeartRate()){ - builder.append(context.getString(R.string.current_heart_rate)) - .append(" ") - .append("80"); + 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; } @@ -212,5 +210,4 @@ private static void appendCardinal(@NonNull SpannableStringBuilder builder, @Non builder.append(" ") .append(localizedText, new TtsSpan.CardinalBuilder().setNumber(number).build(), SPAN_INCLUSIVE_EXCLUSIVE); } -} - +} \ No newline at end of file From b071579b6ea3ccb5a7c3a2c4f7d7d5952c49ae4a Mon Sep 17 00:00:00 2001 From: jothibasulkv01 <59483225+jothibasulkv01@users.noreply.github.com> Date: Sun, 26 Nov 2023 00:00:18 -0500 Subject: [PATCH 6/9] Added testing class for voice announcement --- .../de/dennisguse/opentracks/settings/PreferencesUtils.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/de/dennisguse/opentracks/settings/PreferencesUtils.java b/src/main/java/de/dennisguse/opentracks/settings/PreferencesUtils.java index 7f0df25b5..871fc2afd 100644 --- a/src/main/java/de/dennisguse/opentracks/settings/PreferencesUtils.java +++ b/src/main/java/de/dennisguse/opentracks/settings/PreferencesUtils.java @@ -431,6 +431,11 @@ public static Distance getRecordingDistanceInterval() { 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()); From bff3fac7c0896d0d6e92930f189cb9f9a3a29622 Mon Sep 17 00:00:00 2001 From: Ashish Jaddu <51579203+ashishreddy2411@users.noreply.github.com> Date: Sun, 26 Nov 2023 21:49:21 -0500 Subject: [PATCH 7/9] Integrating Max heart rate in Track Activity --- .../java/de/dennisguse/opentracks/TrackStoppedActivity.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/de/dennisguse/opentracks/TrackStoppedActivity.java b/src/main/java/de/dennisguse/opentracks/TrackStoppedActivity.java index 03ddd5fc4..386aabc98 100644 --- a/src/main/java/de/dennisguse/opentracks/TrackStoppedActivity.java +++ b/src/main/java/de/dennisguse/opentracks/TrackStoppedActivity.java @@ -46,6 +46,10 @@ protected void onCreate(Bundle savedInstanceState) { ContentProviderUtils contentProviderUtils = new ContentProviderUtils(this); Track track = contentProviderUtils.getTrack(trackId); + try { + SensorStatistics sensorStatistics = contentProviderUtils.getSensorStats(trackId); + float maxHr = sensorStatistics.getMaxHeartRate().getBPM(); + }catch (Exception e){} viewBinding.trackEditName.setText(track.getName()); From d25b6dc114aa44e6ce9461eedd0886dbc490cb86 Mon Sep 17 00:00:00 2001 From: Ashish Jaddu <51579203+ashishreddy2411@users.noreply.github.com> Date: Sun, 26 Nov 2023 21:50:10 -0500 Subject: [PATCH 8/9] Update VoiceAnnouncementUtils.java --- .../services/announcement/VoiceAnnouncementUtils.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 de7e7dc9f..d36278cce 100644 --- a/src/main/java/de/dennisguse/opentracks/services/announcement/VoiceAnnouncementUtils.java +++ b/src/main/java/de/dennisguse/opentracks/services/announcement/VoiceAnnouncementUtils.java @@ -94,9 +94,9 @@ static Spannable getAnnouncement(Context context, TrackStatistics trackStatistic // Punctuation helps introduce natural pauses in TTS builder.append("."); } -// if (totalDistance.isZero()) { -// return builder; -// } + if (totalDistance.isZero()) { + return builder; + } // Announce time Duration movingTime = trackStatistics.getMovingTime(); @@ -233,4 +233,4 @@ private static void appendCardinal(@NonNull SpannableStringBuilder builder, @Non builder.append(" ") .append(localizedText, new TtsSpan.CardinalBuilder().setNumber(number).build(), SPAN_INCLUSIVE_EXCLUSIVE); } -} \ No newline at end of file +} From 92952c99436725a652fec7b397c8bdf1e87f6271 Mon Sep 17 00:00:00 2001 From: Ashish Jaddu <51579203+ashishreddy2411@users.noreply.github.com> Date: Sun, 26 Nov 2023 22:02:02 -0500 Subject: [PATCH 9/9] Updated Integration. --- .../de/dennisguse/opentracks/TrackStoppedActivity.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/de/dennisguse/opentracks/TrackStoppedActivity.java b/src/main/java/de/dennisguse/opentracks/TrackStoppedActivity.java index 386aabc98..49b5b237d 100644 --- a/src/main/java/de/dennisguse/opentracks/TrackStoppedActivity.java +++ b/src/main/java/de/dennisguse/opentracks/TrackStoppedActivity.java @@ -16,6 +16,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; @@ -46,9 +47,12 @@ protected void onCreate(Bundle savedInstanceState) { ContentProviderUtils contentProviderUtils = new ContentProviderUtils(this); Track track = contentProviderUtils.getTrack(trackId); - try { + try { SensorStatistics sensorStatistics = contentProviderUtils.getSensorStats(trackId); - float maxHr = sensorStatistics.getMaxHeartRate().getBPM(); + if(sensorStatistics!=null) + { + float maxHr = sensorStatistics.getMaxHeartRate().getBPM(); + } }catch (Exception e){} viewBinding.trackEditName.setText(track.getName());