mirror of
https://github.com/russok/FitoTrack.git
synced 2025-10-29 00:32:11 -07:00
give vocal updates
This commit is contained in:
parent
07b362ddcc
commit
a0a1f44ef9
@ -49,6 +49,12 @@ android {
|
|||||||
sourceCompatibility = '1.8'
|
sourceCompatibility = '1.8'
|
||||||
targetCompatibility = '1.8'
|
targetCompatibility = '1.8'
|
||||||
}
|
}
|
||||||
|
lintOptions {
|
||||||
|
checkReleaseBuilds false
|
||||||
|
// Or, if you prefer, you can continue to check for errors in release builds,
|
||||||
|
// but continue the build even when errors are found:
|
||||||
|
// abortOnError false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
|||||||
@ -38,6 +38,8 @@ import android.view.ViewGroup;
|
|||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import android.speech.tts.TextToSpeech;
|
||||||
|
|
||||||
import androidx.core.app.ActivityCompat;
|
import androidx.core.app.ActivityCompat;
|
||||||
|
|
||||||
import org.mapsforge.core.graphics.Paint;
|
import org.mapsforge.core.graphics.Paint;
|
||||||
@ -171,6 +173,7 @@ public class RecordWorkoutActivity extends FitoTrackActivity implements Location
|
|||||||
if(isResumed){
|
if(isResumed){
|
||||||
mHandler.post(this::updateDescription);
|
mHandler.post(this::updateDescription);
|
||||||
}
|
}
|
||||||
|
mHandler.post(this::speechUpdate);
|
||||||
}
|
}
|
||||||
}catch (InterruptedException e){
|
}catch (InterruptedException e){
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -178,14 +181,41 @@ public class RecordWorkoutActivity extends FitoTrackActivity implements Location
|
|||||||
}).start();
|
}).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
int i= 0;
|
private void speechUpdate() {
|
||||||
|
long duration = recorder.getDuration();
|
||||||
|
if (duration / interval == lastSpeechUpdate / interval)
|
||||||
|
return;
|
||||||
|
|
||||||
private void updateDescription(){
|
timeView.setText(UnitUtils.getHourMinuteSecondTime(duration));
|
||||||
i++;
|
final String distanceCaption = getString(R.string.workoutDistance);
|
||||||
timeView.setText(UnitUtils.getHourMinuteSecondTime(recorder.getDuration()));
|
final String distance = UnitUtils.getDistance(recorder.getDistance());
|
||||||
infoViews[0].setText(getString(R.string.workoutDistance), UnitUtils.getDistance(recorder.getDistance()));
|
final String avgSpeedCaption = getString(R.string.workoutAvgSpeed);
|
||||||
|
final String avgSpeed = UnitUtils.getSpeed(Math.min(100d, recorder.getAvgSpeed()));
|
||||||
|
|
||||||
|
tts = new TextToSpeech(this, (int status) -> {
|
||||||
|
if (status != TextToSpeech.SUCCESS) return;
|
||||||
|
final String text = distanceCaption + ": " + distance + ". "
|
||||||
|
+ avgSpeedCaption + ": " + avgSpeed;
|
||||||
|
tts.speak(text, TextToSpeech.QUEUE_FLUSH, null, "updateDescription" + duration);
|
||||||
|
});
|
||||||
|
|
||||||
|
lastSpeechUpdate = duration;
|
||||||
|
}
|
||||||
|
|
||||||
|
TextToSpeech tts;
|
||||||
|
long lastSpeechUpdate = 0;
|
||||||
|
final long interval = 60 * 1000;
|
||||||
|
|
||||||
|
private void updateDescription() {
|
||||||
|
long duration = recorder.getDuration();
|
||||||
|
timeView.setText(UnitUtils.getHourMinuteSecondTime(duration));
|
||||||
|
final String distanceCaption = getString(R.string.workoutDistance);
|
||||||
|
final String distance = UnitUtils.getDistance(recorder.getDistance());
|
||||||
|
final String avgSpeedCaption = getString(R.string.workoutAvgSpeed);
|
||||||
|
final String avgSpeed = UnitUtils.getSpeed(Math.min(100d, recorder.getAvgSpeed()));
|
||||||
|
infoViews[0].setText(distanceCaption, distance);
|
||||||
infoViews[1].setText(getString(R.string.workoutBurnedEnergy), recorder.getCalories() + " kcal");
|
infoViews[1].setText(getString(R.string.workoutBurnedEnergy), recorder.getCalories() + " kcal");
|
||||||
infoViews[2].setText(getString(R.string.workoutAvgSpeed), UnitUtils.getSpeed(Math.min(100d, recorder.getAvgSpeed())));
|
infoViews[2].setText(avgSpeedCaption, avgSpeed);
|
||||||
infoViews[3].setText(getString(R.string.workoutPauseDuration), UnitUtils.getHourMinuteSecondTime(recorder.getPauseDuration()));
|
infoViews[3].setText(getString(R.string.workoutPauseDuration), UnitUtils.getHourMinuteSecondTime(recorder.getPauseDuration()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -48,7 +48,7 @@ public class WorkoutRecorder implements LocationListener.LocationChangeListener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final int PAUSE_TIME= 10000;
|
private static final int PAUSE_TIME= 1000*1000;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Time after which the workout is stopped and saved automatically because there is no activity anymore
|
* Time after which the workout is stopped and saved automatically because there is no activity anymore
|
||||||
|
|||||||
@ -57,7 +57,7 @@
|
|||||||
<string name="workoutPace">Pace</string>
|
<string name="workoutPace">Pace</string>
|
||||||
<string name="workoutRoute">Route</string>
|
<string name="workoutRoute">Route</string>
|
||||||
<string name="workoutSpeed">Speed</string>
|
<string name="workoutSpeed">Speed</string>
|
||||||
<string name="workoutAvgSpeed">Avg. Speed</string>
|
<string name="workoutAvgSpeed">Average Speed</string>
|
||||||
<string name="workoutTopSpeed">Top Speed</string>
|
<string name="workoutTopSpeed">Top Speed</string>
|
||||||
<string name="workoutBurnedEnergy">Burned Energy</string>
|
<string name="workoutBurnedEnergy">Burned Energy</string>
|
||||||
<string name="workoutTotalEnergy">Total Energy</string>
|
<string name="workoutTotalEnergy">Total Energy</string>
|
||||||
|
|||||||
@ -26,7 +26,7 @@ buildscript {
|
|||||||
|
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:3.5.2'
|
classpath 'com.android.tools.build:gradle:3.4.2'
|
||||||
|
|
||||||
// NOTE: Do not place your application dependencies here; they belong
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
// in the individual module build.gradle files
|
// in the individual module build.gradle files
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user