Skip to content
This repository has been archived by the owner on Jan 12, 2024. It is now read-only.

Commit

Permalink
Merge pull request #307 from rilling/Group7-181-current-heart-rate-as…
Browse files Browse the repository at this point in the history
…-speech-output

Group7 181 current heart rate as speech output
  • Loading branch information
anash3420 authored Nov 28, 2023
2 parents 3a580ac + 92952c9 commit 2e0d4e3
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down
1 change: 1 addition & 0 deletions src/main/res/values/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@
<string name="voice_announce_average_speed_pace_key" translatable="false">voiceAnnounceAverageSpeedPace</string>
<string name="voice_announce_lap_speed_pace_key" translatable="false">voiceAnnounceLapSpeedPace</string>
<string name="voice_announce_average_heart_rate_key" translatable="false">voiceAnnounceAverageHeartRate</string>
<string name="voice_announce_current_heart_rate_key" translatable="false">voiceAnnounceCurrentHeartRate</string>
<string name="voice_announce_lap_heart_rate_key" translatable="false">voiceAnnounceLapHeartRate</string>

<string name="export_trackfileformat_key" translatable="false">exportTrackFileFormat</string>
Expand Down
1 change: 1 addition & 0 deletions src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,7 @@ limitations under the License.
<string name="settings_announcements_totaltime_frequency">Time interval</string>
<string name="settings_announcements_distance_frequency">Distance interval</string>
<string name="settings_announcements_average_heart_rate">Average heart rate</string>
<string name="settings_announcements_current_heart_rate">Current heart rate</string>
<string name="settings_announcements_lap_heart_rate">Lap heart rate</string>
<string name="settings_announcements_average_speed_pace">Average speed/pace</string>
<string name="settings_announcements_lap_speed_pace">Lap speed/pace</string>
Expand Down
5 changes: 5 additions & 0 deletions src/main/res/xml/settings_announcements.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@
android:key="@string/voice_announce_average_heart_rate_key"
android:title="@string/settings_announcements_average_heart_rate" />

<SwitchPreference
android:defaultValue="false"
android:key="@string/voice_announce_current_heart_rate_key"
android:title="@string/settings_announcements_current_heart_rate" />

<SwitchPreference
android:defaultValue="false"
android:key="@string/voice_announce_lap_heart_rate_key"
Expand Down

0 comments on commit 2e0d4e3

Please sign in to comment.