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

Commit

Permalink
randomize messages being spoken
Browse files Browse the repository at this point in the history
  • Loading branch information
DorreenRostami committed Nov 25, 2023
1 parent 2137098 commit 3ebb1ed
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public class VoiceAnnouncementManager implements SharedPreferences.OnSharedPrefe
@NonNull
private Duration nextTotalTime = TOTALTIME_OFF;


public VoiceAnnouncementManager(@NonNull TrackRecordingService trackRecordingService) {
this.trackRecordingService = trackRecordingService;
}
Expand Down Expand Up @@ -90,24 +91,25 @@ public void update(@NonNull Context context, @NonNull Track track) {
return;
}

// boolean announce = false;
boolean announce = false;
this.trackStatistics = track.getTrackStatistics();

if (trackStatistics.getTotalDistance().greaterThan(nextTotalDistance)) {
updateNextTaskDistance();
voiceAnnouncement.announceMotivation();
// announce = true;
// voiceAnnouncement.announceMotivation();
announce = true;
}

if (!trackStatistics.getTotalTime().minus(nextTotalTime).isNegative()) {
updateNextDuration();
voiceAnnouncement.announce(track);
// announce = true;
// voiceAnnouncement.announce(track);
announce = true;
}


// if (announce) {
if (announce) {
// voiceAnnouncement.announce(track);
// }
voiceAnnouncement.announceMotivation();
}
}


Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package de.dennisguse.opentracks.services.announcement;

import java.util.Random;
import static android.text.Spanned.SPAN_INCLUSIVE_EXCLUSIVE;
import static de.dennisguse.opentracks.settings.PreferencesUtils.shouldVoiceAnnounceAverageHeartRate;
import static de.dennisguse.opentracks.settings.PreferencesUtils.shouldVoiceAnnounceAverageSpeedPace;
Expand Down Expand Up @@ -167,10 +168,12 @@ static Spannable getAnnouncement(Context context, TrackStatistics trackStatistic
}

static Spannable getMotivationalAnnouncements(){
//TODO - randomize the motivational quotes and pass the value
//int randomchoice = 5;
MotivationalAnnouncements ma = new MotivationalAnnouncements();
Random random = new Random();
int i = random.nextInt(ma.motivations.length); //random number between 0 (inclusive) and length of the array (exclusive)

SpannableStringBuilder motivator = new SpannableStringBuilder();
return (motivator.append(new MotivationalAnnouncements().motivations[5]));
return (motivator.append(ma.motivations[i]));
}

private static void appendDuration(@NonNull Context context, @NonNull SpannableStringBuilder builder, @NonNull Duration duration) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package de.dennisguse.opentracks.util;

public class MotivationalAnnouncements {
public String []motivations = {"You are doing great","Kudos","Play Hard or Go Home","Yippee","Faster if you can","Its okay,You can do this","I believe in you",
public String []motivations = {"You are doing great","Kudos","Go Hard or Go Home","Yippee","Faster if you can","Its okay,You can do this","I believe in you",
"You're the best sportsperson I have ever seen","Keep going"};


Expand Down

0 comments on commit 3ebb1ed

Please sign in to comment.