mirror of
https://codeberg.org/OpenTracksApp/OpenTracks.git
synced 2026-10-10 05:03:06 +02:00
Use a list preference for the preferred rate setting
This commit is contained in:
@@ -91,7 +91,6 @@ public class PreferencesUtils {
|
||||
|
||||
public static final long RECORDING_TRACK_ID_DEFAULT = -1L;
|
||||
public static final boolean RECORDING_TRACK_PAUSED_DEFAULT = true;
|
||||
public static final boolean REPORT_SPEED_DEFAULT = true;
|
||||
public static final long SELECTED_TRACK_ID_DEFAULT = -1L;
|
||||
public static final String SENSOR_TYPE_DEFAULT = "NONE";
|
||||
|
||||
@@ -102,6 +101,7 @@ public class PreferencesUtils {
|
||||
public static final int SPLIT_FREQUENCY_DEFAULT = 0;
|
||||
|
||||
// Stats
|
||||
public static final String STATS_RATE_DEFAULT = "SPEED";
|
||||
public static final boolean STATS_SHOW_COORDINATE_DEFAULT = false;
|
||||
public static final boolean STATS_SHOW_GRADE_ELEVATION_DEFAULT = false;
|
||||
public static final String STATS_UNITS_DEFAULT = "METRIC";
|
||||
@@ -257,4 +257,14 @@ public class PreferencesUtils {
|
||||
return PreferencesUtils.STATS_UNITS_DEFAULT.equals(
|
||||
getString(context, R.string.stats_units_key, PreferencesUtils.STATS_UNITS_DEFAULT));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the preferred rate is speed, false if the preferred rate is pace.
|
||||
*
|
||||
* @param context the context
|
||||
*/
|
||||
public static boolean isReportSpeed(Context context) {
|
||||
return PreferencesUtils.STATS_RATE_DEFAULT.equals(
|
||||
getString(context, R.string.stats_rate_key, PreferencesUtils.STATS_RATE_DEFAULT));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,8 +50,7 @@ public class StatsUtils {
|
||||
*/
|
||||
public static void setLocationValues(Activity activity, Location location, boolean isRecording) {
|
||||
boolean metricUnits = PreferencesUtils.isMetricUnits(activity);
|
||||
boolean reportSpeed = PreferencesUtils.getBoolean(
|
||||
activity, R.string.report_speed_key, PreferencesUtils.REPORT_SPEED_DEFAULT);
|
||||
boolean reportSpeed = PreferencesUtils.isReportSpeed(activity);
|
||||
|
||||
// Set speed/pace
|
||||
double speed = isRecording && location != null && location.hasSpeed() ? location.getSpeed()
|
||||
@@ -111,8 +110,7 @@ public class StatsUtils {
|
||||
*/
|
||||
public static void setTripStatisticsValues(Activity activity, TripStatistics tripStatistics) {
|
||||
boolean metricUnits = PreferencesUtils.isMetricUnits(activity);
|
||||
boolean reportSpeed = PreferencesUtils.getBoolean(
|
||||
activity, R.string.report_speed_key, PreferencesUtils.REPORT_SPEED_DEFAULT);
|
||||
boolean reportSpeed = PreferencesUtils.isReportSpeed(activity);
|
||||
|
||||
// Set total distance
|
||||
double totalDistance = tripStatistics == null ? Double.NaN : tripStatistics.getTotalDistance();
|
||||
|
||||
Reference in New Issue
Block a user