mirror of
https://codeberg.org/OpenTracksApp/OpenTracks.git
synced 2026-10-02 17:43:06 +02:00
Cleanup in VoiceAnnouncement: rename to start() and stop().
This commit is contained in:
+4
-4
@@ -60,11 +60,11 @@ public class VoiceAnnouncementManagerTest {
|
||||
// when
|
||||
TrackStatistics statistics = new TrackStatistics();
|
||||
statistics.setTotalDistance(Distance.ofKilometer(13));
|
||||
voiceAnnouncementManager.restore(statistics);
|
||||
voiceAnnouncementManager.start(statistics);
|
||||
assertEquals(Distance.of(15000), voiceAnnouncementManager.getNextTotalDistance());
|
||||
|
||||
statistics.setTotalDistance(Distance.of(15100));
|
||||
voiceAnnouncementManager.restore(statistics);
|
||||
voiceAnnouncementManager.start(statistics);
|
||||
assertEquals(Distance.of(20000), voiceAnnouncementManager.getNextTotalDistance());
|
||||
}
|
||||
|
||||
@@ -80,11 +80,11 @@ public class VoiceAnnouncementManagerTest {
|
||||
// when
|
||||
TrackStatistics statistics = new TrackStatistics();
|
||||
statistics.setTotalTime(Duration.ofSeconds(91));
|
||||
voiceAnnouncementManager.restore(statistics);
|
||||
voiceAnnouncementManager.start(statistics);
|
||||
assertEquals(Duration.ofSeconds(95), voiceAnnouncementManager.getNextTotalTime());
|
||||
|
||||
statistics.setTotalTime(Duration.ofSeconds(95));
|
||||
voiceAnnouncementManager.restore(statistics);
|
||||
voiceAnnouncementManager.start(statistics);
|
||||
assertEquals(Duration.ofSeconds(100), voiceAnnouncementManager.getNextTotalTime());
|
||||
}
|
||||
|
||||
|
||||
@@ -135,7 +135,7 @@ public class TrackRecordingService extends Service implements TrackPointCreator.
|
||||
|
||||
egm2008CorrectionManager = null;
|
||||
try {
|
||||
voiceAnnouncementManager.shutdown();
|
||||
voiceAnnouncementManager.stop();
|
||||
} finally {
|
||||
voiceAnnouncementManager = null;
|
||||
}
|
||||
@@ -194,16 +194,13 @@ public class TrackRecordingService extends Service implements TrackPointCreator.
|
||||
resumeTrack(recordingStatus.getTrackId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Common code for starting a new track or resuming a track.
|
||||
*/
|
||||
private void startRecording() {
|
||||
// Update instance variables
|
||||
handler.postDelayed(updateRecordingData, RECORDING_DATA_UPDATE_INTERVAL.toMillis());
|
||||
|
||||
startSensors();
|
||||
|
||||
voiceAnnouncementManager.restore(trackRecordingManager.getTrackStatistics());
|
||||
voiceAnnouncementManager.start(trackRecordingManager.getTrackStatistics());
|
||||
}
|
||||
|
||||
public void tryStartSensors() {
|
||||
@@ -267,7 +264,7 @@ public class TrackRecordingService extends Service implements TrackPointCreator.
|
||||
recordingDataObservable.postValue(NOT_RECORDING);
|
||||
}
|
||||
|
||||
voiceAnnouncementManager.shutdown();
|
||||
voiceAnnouncementManager.stop();
|
||||
|
||||
// Update instance variables
|
||||
trackPointCreator.stop();
|
||||
|
||||
@@ -178,7 +178,7 @@ public class VoiceAnnouncement {
|
||||
tts.speak(announcement, TextToSpeech.QUEUE_FLUSH, null, "not used");
|
||||
}
|
||||
|
||||
public void shutdown() {
|
||||
public void stop() {
|
||||
if (tts != null) {
|
||||
tts.shutdown();
|
||||
tts = null;
|
||||
|
||||
+5
-5
@@ -61,7 +61,7 @@ public class VoiceAnnouncementManager implements SharedPreferences.OnSharedPrefe
|
||||
PreferencesUtils.registerOnSharedPreferenceChangeListener(this);
|
||||
}
|
||||
|
||||
public void restore(@Nullable TrackStatistics trackStatistics) {
|
||||
public void start(@Nullable TrackStatistics trackStatistics) {
|
||||
voiceAnnouncement = new VoiceAnnouncement(trackRecordingService);
|
||||
voiceAnnouncement.start();
|
||||
|
||||
@@ -92,22 +92,22 @@ public class VoiceAnnouncementManager implements SharedPreferences.OnSharedPrefe
|
||||
}
|
||||
}
|
||||
|
||||
public void shutdown() {
|
||||
public void stop() {
|
||||
PreferencesUtils.unregisterOnSharedPreferenceChangeListener(this);
|
||||
if (voiceAnnouncement != null) {
|
||||
voiceAnnouncement.shutdown();
|
||||
voiceAnnouncement.stop();
|
||||
voiceAnnouncement = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void setFrequency(Duration frequency) {
|
||||
this.totalTimeFrequency = frequency;
|
||||
restore(this.trackStatistics);
|
||||
start(this.trackStatistics);
|
||||
}
|
||||
|
||||
public void setFrequency(Distance frequency) {
|
||||
this.distanceFrequency = frequency;
|
||||
restore(this.trackStatistics);
|
||||
start(this.trackStatistics);
|
||||
}
|
||||
|
||||
public void updateNextTaskDistance() {
|
||||
|
||||
Reference in New Issue
Block a user