mirror of
https://codeberg.org/OpenTracksApp/OpenTracks.git
synced 2026-10-02 09:33:06 +02:00
Chagne gps accuracy default tp 50m
This commit is contained in:
@@ -143,16 +143,16 @@ limitations under the License.
|
||||
<item>900</item>
|
||||
<item>1800</item>
|
||||
</string-array>
|
||||
<string-array name="min_required_accuracy_values">
|
||||
<string-array name="recording_gps_accuracy_values">
|
||||
<item>10</item>
|
||||
<item>20</item>
|
||||
<item>30</item>
|
||||
<item>50</item>
|
||||
<item>100</item>
|
||||
<item>200</item>
|
||||
<item>500</item>
|
||||
<item>1000</item>
|
||||
<item>2000</item>
|
||||
<item>5000</item>
|
||||
</string-array>
|
||||
<string-array name="sensor_type_all_options">
|
||||
<item>@string/settings_sensor_type_polar</item>
|
||||
|
||||
@@ -33,7 +33,7 @@ limitations under the License.
|
||||
<string name="max_recording_distance_key">maxRecordingDistance</string>
|
||||
<string name="min_recording_distance_key">minRecordingDistance</string>
|
||||
<string name="min_recording_interval_key">minRecordingInterval</string>
|
||||
<string name="min_required_accuracy_key">minRequiredAccuracy</string>
|
||||
<string name="recording_gps_accuracy_key">recordingGpsAccuracy</string>
|
||||
<string name="report_speed_key">reportSpeed</string>
|
||||
<string name="sensor_type_key">sensorType</string>
|
||||
<string name="share_track_invite_key">shareTrackInvite</string>
|
||||
|
||||
@@ -46,8 +46,8 @@ limitations under the License.
|
||||
android:key="@string/max_recording_distance_key"
|
||||
android:title="@string/settings_recording_max_recording_distance_title" />
|
||||
<com.google.android.apps.mytracks.IntegerListPreference
|
||||
android:defaultValue="200"
|
||||
android:key="@string/min_required_accuracy_key"
|
||||
android:defaultValue="50"
|
||||
android:key="@string/recording_gps_accuracy_key"
|
||||
android:title="@string/settings_recording_min_required_accuracy_title" />
|
||||
<com.google.android.apps.mytracks.IntegerListPreference
|
||||
android:defaultValue="10"
|
||||
|
||||
@@ -64,7 +64,7 @@ public class TrackDataHub implements DataSourceListener {
|
||||
private boolean recordingTrackPaused;
|
||||
private boolean metricUnits;
|
||||
private boolean reportSpeed;
|
||||
private int minRequiredAccuracy;
|
||||
private int recordingGpsAccuracy;
|
||||
private int minRecordingDistance;
|
||||
|
||||
// Track points sampling state
|
||||
@@ -295,13 +295,13 @@ public class TrackDataHub implements DataSourceListener {
|
||||
}
|
||||
}
|
||||
if (key == null
|
||||
|| key.equals(PreferencesUtils.getKey(context, R.string.min_required_accuracy_key))) {
|
||||
minRequiredAccuracy = PreferencesUtils.getInt(context, R.string.min_required_accuracy_key,
|
||||
PreferencesUtils.MIN_REQUIRED_ACCURACY_DEFAULT);
|
||||
|| key.equals(PreferencesUtils.getKey(context, R.string.recording_gps_accuracy_key))) {
|
||||
recordingGpsAccuracy = PreferencesUtils.getInt(context, R.string.recording_gps_accuracy_key,
|
||||
PreferencesUtils.RECORDING_GPS_ACCURACY_DEFAULT);
|
||||
if (key != null) {
|
||||
for (TrackDataListener trackDataListener :
|
||||
trackDataManager.getListeners(TrackDataType.PREFERENCE)) {
|
||||
if (trackDataListener.onMinRequiredAccuracy(minRequiredAccuracy)) {
|
||||
if (trackDataListener.onRecordingGpsAccuracy(recordingGpsAccuracy)) {
|
||||
loadDataForListener(trackDataListener);
|
||||
}
|
||||
}
|
||||
@@ -338,7 +338,7 @@ public class TrackDataHub implements DataSourceListener {
|
||||
trackDataManager.getListeners(TrackDataType.PREFERENCE)) {
|
||||
trackDataListener.onMetricUnitsChanged(metricUnits);
|
||||
trackDataListener.onReportSpeedChanged(reportSpeed);
|
||||
trackDataListener.onMinRequiredAccuracy(minRequiredAccuracy);
|
||||
trackDataListener.onRecordingGpsAccuracy(recordingGpsAccuracy);
|
||||
trackDataListener.onMinRecordingDistanceChanged(minRecordingDistance);
|
||||
}
|
||||
|
||||
@@ -366,7 +366,7 @@ public class TrackDataHub implements DataSourceListener {
|
||||
if (trackDataTypes.contains(TrackDataType.PREFERENCE)) {
|
||||
trackDataListener.onMetricUnitsChanged(metricUnits);
|
||||
trackDataListener.onReportSpeedChanged(reportSpeed);
|
||||
trackDataListener.onMinRequiredAccuracy(minRequiredAccuracy);
|
||||
trackDataListener.onRecordingGpsAccuracy(recordingGpsAccuracy);
|
||||
trackDataListener.onMinRecordingDistanceChanged(minRecordingDistance);
|
||||
}
|
||||
|
||||
@@ -580,13 +580,11 @@ public class TrackDataHub implements DataSourceListener {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the minRequiredAccuracy.
|
||||
*
|
||||
* @return the minRequiredAccuracy
|
||||
* Gets the recordingGpsAccuracy.
|
||||
*/
|
||||
@VisibleForTesting
|
||||
int getMinRequiredAccuracy() {
|
||||
return minRequiredAccuracy;
|
||||
int getRecordingGpsAccuracy() {
|
||||
return recordingGpsAccuracy;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -109,12 +109,12 @@ public interface TrackDataListener {
|
||||
public boolean onReportSpeedChanged(boolean reportSpeed);
|
||||
|
||||
/**
|
||||
* Called when the min required accuracy preference value is changed.
|
||||
* Called when the recording gps accuracy preference value is changed.
|
||||
*
|
||||
* @param minRequiredAccuracy the new value
|
||||
* @param recordingGpsAccuracy the new value
|
||||
* @return true to reload all the data, false otherwise
|
||||
*/
|
||||
public boolean onMinRequiredAccuracy(int minRequiredAccuracy);
|
||||
public boolean onRecordingGpsAccuracy(int recordingGpsAccuracy);
|
||||
|
||||
/**
|
||||
* Called when the min recording distance preference value is changed.
|
||||
|
||||
@@ -283,7 +283,7 @@ public class ChartFragment extends Fragment implements TrackDataListener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onMinRequiredAccuracy(int minRequiredAccuracy) {
|
||||
public boolean onRecordingGpsAccuracy(int minRequiredAccuracy) {
|
||||
// We don't care.
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ public class MyTracksMapFragment extends SupportMapFragment implements TrackData
|
||||
// Current location
|
||||
private Location currentLocation;
|
||||
private Location lastTrackPoint;
|
||||
private int minRequiredAccuracy = PreferencesUtils.MIN_REQUIRED_ACCURACY_DEFAULT;
|
||||
private int recordingGpsAccuracy = PreferencesUtils.RECORDING_GPS_ACCURACY_DEFAULT;
|
||||
|
||||
/**
|
||||
* True to continue keeping the current location visible on the screen.
|
||||
@@ -492,8 +492,8 @@ public class MyTracksMapFragment extends SupportMapFragment implements TrackData
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onMinRequiredAccuracy(int newValue) {
|
||||
minRequiredAccuracy = newValue;
|
||||
public boolean onRecordingGpsAccuracy(int newValue) {
|
||||
recordingGpsAccuracy = newValue;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -714,7 +714,7 @@ public class MyTracksMapFragment extends SupportMapFragment implements TrackData
|
||||
hasGoodFix = false;
|
||||
} else {
|
||||
hasFix = !LocationUtils.isLocationOld(currentLocation);
|
||||
hasGoodFix = currentLocation.getAccuracy() <= minRequiredAccuracy;
|
||||
hasGoodFix = currentLocation.getAccuracy() <= recordingGpsAccuracy;
|
||||
}
|
||||
if (!hasFix) {
|
||||
message = getString(R.string.gps_wait_for_signal);
|
||||
|
||||
@@ -56,7 +56,7 @@ public class StatsFragment extends Fragment implements TrackDataListener {
|
||||
|
||||
private Location lastLocation = null;
|
||||
private TripStatistics lastTripStatistics = null;
|
||||
private int minRequiredAccuracy = PreferencesUtils.MIN_REQUIRED_ACCURACY_DEFAULT;
|
||||
private int recordingGpsAccuracy = PreferencesUtils.RECORDING_GPS_ACCURACY_DEFAULT;
|
||||
|
||||
// A runnable to update the total time field.
|
||||
private final Runnable updateTotalTime = new Runnable() {
|
||||
@@ -148,7 +148,7 @@ public class StatsFragment extends Fragment implements TrackDataListener {
|
||||
|
||||
if (lastLocation != null) {
|
||||
boolean hasFix = !LocationUtils.isLocationOld(lastLocation);
|
||||
boolean hasGoodFix = lastLocation.getAccuracy() <= minRequiredAccuracy;
|
||||
boolean hasGoodFix = lastLocation.getAccuracy() <= recordingGpsAccuracy;
|
||||
|
||||
if (!hasFix || !hasGoodFix) {
|
||||
lastLocation = null;
|
||||
@@ -207,8 +207,8 @@ public class StatsFragment extends Fragment implements TrackDataListener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onMinRequiredAccuracy(int newValue) {
|
||||
minRequiredAccuracy = newValue;
|
||||
public boolean onRecordingGpsAccuracy(int newValue) {
|
||||
recordingGpsAccuracy = newValue;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -116,7 +116,7 @@ public class TrackRecordingService extends Service {
|
||||
private LocationListenerPolicy locationListenerPolicy;
|
||||
private int minRecordingDistance;
|
||||
private int maxRecordingDistance;
|
||||
private int minRequiredAccuracy;
|
||||
private int recordingGpsAccuracy;
|
||||
private int autoResumeTrackTimeout;
|
||||
private long currentRecordingInterval;
|
||||
|
||||
@@ -204,10 +204,11 @@ public class TrackRecordingService extends Service {
|
||||
R.string.max_recording_distance_key,
|
||||
PreferencesUtils.MAX_RECORDING_DISTANCE_DEFAULT);
|
||||
}
|
||||
if (key == null
|
||||
|| key.equals(PreferencesUtils.getKey(context, R.string.min_required_accuracy_key))) {
|
||||
minRequiredAccuracy = PreferencesUtils.getInt(context,
|
||||
R.string.min_required_accuracy_key, PreferencesUtils.MIN_REQUIRED_ACCURACY_DEFAULT);
|
||||
if (key == null || key.equals(
|
||||
PreferencesUtils.getKey(context, R.string.recording_gps_accuracy_key))) {
|
||||
recordingGpsAccuracy = PreferencesUtils.getInt(context,
|
||||
R.string.recording_gps_accuracy_key,
|
||||
PreferencesUtils.RECORDING_GPS_ACCURACY_DEFAULT);
|
||||
}
|
||||
if (key == null || key.equals(
|
||||
PreferencesUtils.getKey(context, R.string.auto_resume_track_timeout_key))) {
|
||||
@@ -887,7 +888,7 @@ public class TrackRecordingService extends Service {
|
||||
return;
|
||||
}
|
||||
|
||||
if (location.getAccuracy() > minRequiredAccuracy) {
|
||||
if (location.getAccuracy() > recordingGpsAccuracy) {
|
||||
Log.d(TAG, "Ignore onLocationChangedAsync. Poor accuracy.");
|
||||
return;
|
||||
}
|
||||
|
||||
+12
-12
@@ -55,8 +55,8 @@ public class RecordingSettingsActivity extends AbstractSettingsActivity {
|
||||
configListPreference(R.string.max_recording_distance_key,
|
||||
PreferencesUtils.MAX_RECORDING_DISTANCE_DEFAULT, R.array.max_recording_distance_values,
|
||||
metricUnits);
|
||||
configListPreference(R.string.min_required_accuracy_key,
|
||||
PreferencesUtils.MIN_REQUIRED_ACCURACY_DEFAULT, R.array.min_required_accuracy_values,
|
||||
configListPreference(R.string.recording_gps_accuracy_key,
|
||||
PreferencesUtils.RECORDING_GPS_ACCURACY_DEFAULT, R.array.recording_gps_accuracy_values,
|
||||
metricUnits);
|
||||
configListPreference(R.string.auto_resume_track_timeout_key,
|
||||
PreferencesUtils.AUTO_RESUME_TRACK_TIMEOUT_DEFAULT,
|
||||
@@ -121,8 +121,8 @@ public class RecordingSettingsActivity extends AbstractSettingsActivity {
|
||||
case R.string.max_recording_distance_key:
|
||||
setMaxRecordingDistanceSummaryAndOptions(summary, options, values, metricUnits);
|
||||
break;
|
||||
case R.string.min_required_accuracy_key:
|
||||
setMinRequiredAccuracySummaryAndOptions(summary, options, values, metricUnits);
|
||||
case R.string.recording_gps_accuracy_key:
|
||||
setRecordingGpsAccuracySummaryAndOptions(summary, options, values, metricUnits);
|
||||
break;
|
||||
case R.string.auto_resume_track_timeout_key:
|
||||
setAutoResumeTrackTimeoutSummaryAndOptions(summary, options, values);
|
||||
@@ -248,14 +248,14 @@ public class RecordingSettingsActivity extends AbstractSettingsActivity {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the min required accuracy summary and options.
|
||||
* Sets the recording gps accuracy summary and options.
|
||||
*
|
||||
* @param summary the summary
|
||||
* @param options the options
|
||||
* @param values the values
|
||||
* @param metricUnits true for metric units
|
||||
*/
|
||||
private void setMinRequiredAccuracySummaryAndOptions(
|
||||
private void setRecordingGpsAccuracySummaryAndOptions(
|
||||
String[] summary, String[] options, String[] values, boolean metricUnits) {
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
int value = Integer.parseInt(values[i]);
|
||||
@@ -263,13 +263,13 @@ public class RecordingSettingsActivity extends AbstractSettingsActivity {
|
||||
if (metricUnits) {
|
||||
displayValue = getString(R.string.value_integer_meter, value);
|
||||
switch (value) {
|
||||
case PreferencesUtils.MIN_REQUIRED_ACCURACY_DEFAULT:
|
||||
case PreferencesUtils.RECORDING_GPS_ACCURACY_DEFAULT:
|
||||
options[i] = getString(R.string.value_integer_meter_recommended, value);
|
||||
break;
|
||||
case PreferencesUtils.MIN_REQUIRED_ACCURACY_EXCELLENT:
|
||||
case PreferencesUtils.RECORDING_GPS_ACCURACY_EXCELLENT:
|
||||
options[i] = getString(R.string.value_integer_meter_excellent_gps, value);
|
||||
break;
|
||||
case PreferencesUtils.MIN_REQUIRED_ACCURACY_POOR:
|
||||
case PreferencesUtils.RECORDING_GPS_ACCURACY_POOR:
|
||||
options[i] = getString(R.string.value_integer_meter_poor_gps, value);
|
||||
break;
|
||||
default:
|
||||
@@ -280,10 +280,10 @@ public class RecordingSettingsActivity extends AbstractSettingsActivity {
|
||||
if (feet < 2000) {
|
||||
displayValue = getString(R.string.value_integer_feet, feet);
|
||||
switch (value) {
|
||||
case PreferencesUtils.MIN_REQUIRED_ACCURACY_DEFAULT:
|
||||
case PreferencesUtils.RECORDING_GPS_ACCURACY_DEFAULT:
|
||||
options[i] = getString(R.string.value_integer_feet_recommended, feet);
|
||||
break;
|
||||
case PreferencesUtils.MIN_REQUIRED_ACCURACY_EXCELLENT:
|
||||
case PreferencesUtils.RECORDING_GPS_ACCURACY_EXCELLENT:
|
||||
options[i] = getString(R.string.value_integer_feet_excellent_gps, feet);
|
||||
break;
|
||||
default:
|
||||
@@ -293,7 +293,7 @@ public class RecordingSettingsActivity extends AbstractSettingsActivity {
|
||||
double mile = feet * UnitConversions.FT_TO_MI;
|
||||
displayValue = getString(R.string.value_float_mile, mile);
|
||||
switch (value) {
|
||||
case PreferencesUtils.MIN_REQUIRED_ACCURACY_POOR:
|
||||
case PreferencesUtils.RECORDING_GPS_ACCURACY_POOR:
|
||||
options[i] = getString(R.string.value_float_mile_poor_gps, mile);
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -83,11 +83,11 @@ public class PreferencesUtils {
|
||||
public static final int MIN_RECORDING_INTERVAL_ADAPT_BATTERY_LIFE = -2;
|
||||
public static final int MIN_RECORDING_INTERVAL_DEFAULT = 0;
|
||||
|
||||
// Values for min_required_accuracy
|
||||
public static final int MIN_REQUIRED_ACCURACY_DEFAULT = 200;
|
||||
public static final int MIN_REQUIRED_ACCURACY_EXCELLENT = 10;
|
||||
public static final int MIN_REQUIRED_ACCURACY_POOR = 5000;
|
||||
|
||||
// Values for recording_gps_accuracy
|
||||
public static final int RECORDING_GPS_ACCURACY_DEFAULT = 50;
|
||||
public static final int RECORDING_GPS_ACCURACY_EXCELLENT = 10;
|
||||
public static final int RECORDING_GPS_ACCURACY_POOR = 2000;
|
||||
|
||||
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;
|
||||
|
||||
@@ -529,21 +529,23 @@ public class TrackDataHubTest extends AndroidTestCase {
|
||||
PreferencesUtils.setBoolean(context, R.string.report_speed_key, true);
|
||||
PreferencesUtils.setString(
|
||||
context, R.string.stats_units_key, PreferencesUtils.STATS_UNITS_DEFAULT);
|
||||
PreferencesUtils.setInt(context, R.string.min_required_accuracy_key,
|
||||
PreferencesUtils.MIN_REQUIRED_ACCURACY_DEFAULT);
|
||||
PreferencesUtils.setInt(context, R.string.recording_gps_accuracy_key,
|
||||
PreferencesUtils.RECORDING_GPS_ACCURACY_DEFAULT);
|
||||
PreferencesUtils.setInt(context, R.string.min_recording_distance_key,
|
||||
PreferencesUtils.MIN_RECORDING_DISTANCE_DEFAULT);
|
||||
|
||||
dataSource.registerOnSharedPreferenceChangeListener(capture(preferenceChangeListenerCapture));
|
||||
expect(trackDataListener1.onMetricUnitsChanged(true)).andReturn(false);
|
||||
expect(trackDataListener1.onReportSpeedChanged(true)).andReturn(false);
|
||||
expect(trackDataListener1.onMinRequiredAccuracy(PreferencesUtils.MIN_REQUIRED_ACCURACY_DEFAULT))
|
||||
expect(
|
||||
trackDataListener1.onRecordingGpsAccuracy(PreferencesUtils.RECORDING_GPS_ACCURACY_DEFAULT))
|
||||
.andReturn(false);
|
||||
expect(trackDataListener1.onMinRecordingDistanceChanged(
|
||||
PreferencesUtils.MIN_RECORDING_DISTANCE_DEFAULT)).andReturn(false);
|
||||
expect(trackDataListener2.onMetricUnitsChanged(true)).andReturn(false);
|
||||
expect(trackDataListener2.onReportSpeedChanged(true)).andReturn(false);
|
||||
expect(trackDataListener2.onMinRequiredAccuracy(PreferencesUtils.MIN_REQUIRED_ACCURACY_DEFAULT))
|
||||
expect(
|
||||
trackDataListener2.onRecordingGpsAccuracy(PreferencesUtils.RECORDING_GPS_ACCURACY_DEFAULT))
|
||||
.andReturn(false);
|
||||
expect(trackDataListener2.onMinRecordingDistanceChanged(
|
||||
PreferencesUtils.MIN_RECORDING_DISTANCE_DEFAULT)).andReturn(false);
|
||||
@@ -749,14 +751,14 @@ public class TrackDataHubTest extends AndroidTestCase {
|
||||
*/
|
||||
public void testNotifyPreferenceChanged_minRequiredAccuracy() {
|
||||
int value = 1;
|
||||
PreferencesUtils.setInt(context, R.string.min_required_accuracy_key, value);
|
||||
PreferencesUtils.setInt(context, R.string.recording_gps_accuracy_key, value);
|
||||
trackDataHub.notifyPreferenceChanged(PreferencesUtils
|
||||
.getKey(context, R.string.min_required_accuracy_key));
|
||||
assertEquals(value, trackDataHub.getMinRequiredAccuracy());
|
||||
PreferencesUtils.setInt(context, R.string.min_required_accuracy_key, value + 1);
|
||||
.getKey(context, R.string.recording_gps_accuracy_key));
|
||||
assertEquals(value, trackDataHub.getRecordingGpsAccuracy());
|
||||
PreferencesUtils.setInt(context, R.string.recording_gps_accuracy_key, value + 1);
|
||||
trackDataHub.notifyPreferenceChanged(PreferencesUtils
|
||||
.getKey(context, R.string.min_required_accuracy_key));
|
||||
assertEquals(value + 1, trackDataHub.getMinRequiredAccuracy());
|
||||
.getKey(context, R.string.recording_gps_accuracy_key));
|
||||
assertEquals(value + 1, trackDataHub.getRecordingGpsAccuracy());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+3
-3
@@ -669,14 +669,14 @@ public class TrackRecordingServiceTest extends ServiceTestCase<TestRecordingServ
|
||||
|
||||
@MediumTest
|
||||
public void testWithProperties_minRequiredAccuracyDefault() throws Exception {
|
||||
PreferencesUtils.setInt(context, R.string.min_required_accuracy_key,
|
||||
PreferencesUtils.MIN_REQUIRED_ACCURACY_DEFAULT);
|
||||
PreferencesUtils.setInt(context, R.string.recording_gps_accuracy_key,
|
||||
PreferencesUtils.RECORDING_GPS_ACCURACY_DEFAULT);
|
||||
fullRecordingSession();
|
||||
}
|
||||
|
||||
@MediumTest
|
||||
public void testWithProperties_minRequiredAccuracy() throws Exception {
|
||||
PreferencesUtils.setInt(context, R.string.min_required_accuracy_key, 500);
|
||||
PreferencesUtils.setInt(context, R.string.recording_gps_accuracy_key, 500);
|
||||
fullRecordingSession();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user