forked from upstream-mirrors/OpenTracks
Display pace in mm:second format.
This commit is contained in:
@@ -1974,7 +1974,7 @@ limitations under the License.
|
||||
</string>
|
||||
<string name="settings_stats_rate_title"
|
||||
translation_description="In the 'Stats' settings, the option to change the preferred rate,
|
||||
either speed (mi/hr) or pace (hr/mi).
|
||||
either speed (mi/hr) or pace (min/mi).
|
||||
|
||||
Character limit: ~23 (1 line)">
|
||||
Preferred rate
|
||||
@@ -2131,7 +2131,7 @@ limitations under the License.
|
||||
Moving time
|
||||
</string>
|
||||
<string name="stats_pace"
|
||||
translation_description="In the 'Stats' page, the pace like hours per mile.
|
||||
translation_description="In the 'Stats' page, the pace like minutes per mile.
|
||||
|
||||
Character limit: ~23 (1 line)">
|
||||
Pace
|
||||
|
||||
@@ -219,6 +219,15 @@ public class DescriptionGeneratorImpl implements DescriptionGenerator {
|
||||
void writePace(double speed, StringBuilder builder, int resId, String lineBreak) {
|
||||
String[] paceInMetrics = StringUtils.getSpeedParts(context, speed, true, false);
|
||||
String[] paceInImperial = StringUtils.getSpeedParts(context, speed, false, false);
|
||||
|
||||
if (paceInMetrics[0] == null) {
|
||||
paceInMetrics[0] = context.getString(R.string.value_unknown);
|
||||
}
|
||||
|
||||
if (paceInImperial[0] == null) {
|
||||
paceInImperial[0] = context.getString(R.string.value_unknown);
|
||||
}
|
||||
|
||||
builder.append(context.getString(resId, paceInMetrics[0], paceInImperial[0]));
|
||||
builder.append(lineBreak);
|
||||
}
|
||||
|
||||
@@ -213,19 +213,18 @@ public class StringUtils {
|
||||
return result;
|
||||
}
|
||||
speed *= UnitConversions.MS_TO_KMH;
|
||||
if (metricUnits) {
|
||||
if (!reportSpeed) {
|
||||
// convert from hours to minutes
|
||||
speed = speed == 0 ? 0.0 : 60.0 / speed;
|
||||
}
|
||||
} else {
|
||||
if (!metricUnits) {
|
||||
speed *= UnitConversions.KM_TO_MI;
|
||||
if (!reportSpeed) {
|
||||
// convert from hours to minutes
|
||||
speed = speed == 0 ? 0.0 : 60.0 / speed;
|
||||
}
|
||||
}
|
||||
result[0] = String.format("%.2f", speed);
|
||||
if (reportSpeed) {
|
||||
result[0] = String.format("%.2f", speed);
|
||||
} else {
|
||||
// convert from hours to minutes
|
||||
double pace = speed == 0 ? 0.0 : 60.0 / speed;
|
||||
int minutes = (int) pace;
|
||||
int seconds = (int) Math.round((pace - minutes) * 60.0);
|
||||
result[0] = String.format("%d:%02d", minutes, seconds);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user