Setting: add option to adjust idle speed.

New default: 0.5km/h (replaces 0.5mp/h).

Fixes #1004.
This commit is contained in:
Dennis Guse
2021-10-31 22:53:02 +01:00
parent 41e5e71804
commit a9228017fc
6 changed files with 73 additions and 5 deletions
@@ -5,6 +5,7 @@ import androidx.annotation.NonNull;
import java.time.Duration;
import java.util.Objects;
import de.dennisguse.opentracks.settings.PreferencesUtils;
import de.dennisguse.opentracks.util.UnitConversions;
public class Speed {
@@ -25,6 +26,10 @@ public class Speed {
return of(Float.parseFloat(speed_mps));
}
public static Speed ofKMH(double speed_kmh) {
return of(Distance.ofKilometer(speed_kmh), Duration.ofHours(1));
}
public static Speed zero() {
return of(0.0);
}
@@ -42,10 +47,6 @@ public class Speed {
return Speed.of(Math.abs(speed1.speed_mps - speed2.speed_mps));
}
// Anything faster than that (in meters per second) will be considered moving.
private static final double MAX_NO_MOVEMENT_SPEED = 0.224;
private final double speed_mps;
private Speed(double speed_mps) {
@@ -65,7 +66,7 @@ public class Speed {
}
public boolean isMoving() {
return !isInvalid() && speed_mps >= MAX_NO_MOVEMENT_SPEED;
return !isInvalid() && greaterThan(PreferencesUtils.getIdleSpeed());
}
public boolean lessThan(Speed speed) {