forked from upstream-mirrors/OpenTracks
- In MapView, only show the no gps message when recording.
- Different messages for no gps signal and need better gps signal. - Add debug line when location is not inserted due to accuracy issue and min recording distance requirement.
This commit is contained in:
@@ -683,12 +683,17 @@ limitations under the License.
|
||||
translation_description="On application start, message when there is no GPS on the device.">
|
||||
No GPS is found on the device.
|
||||
</string>
|
||||
<string name="gps_wait_for_signal"
|
||||
<string name="gps_wait_for_better_signal"
|
||||
translation_description="In the main view, the message on the top indicating My Tracks is
|
||||
waiting for a better GPS signal.">
|
||||
Waiting for a better GPS signal. Make sure the sky is visible.
|
||||
</string>
|
||||
|
||||
<string name="gps_wait_for_signal"
|
||||
translation_description="In the main view, the message on the top indicating My Tracks is
|
||||
waiting for a better GPS signal.">
|
||||
Waiting for GPS signal. Make sure the sky is visible.
|
||||
</string>
|
||||
|
||||
<!-- Help page -->
|
||||
<string name="help_about"
|
||||
translation_description="In the 'Help' page, the button on the bottom to open the 'About My
|
||||
|
||||
@@ -277,27 +277,34 @@ public class MapFragment extends Fragment
|
||||
public void onLocationStateChanged(LocationState state) {
|
||||
final String message;
|
||||
final boolean isGpsDisabled;
|
||||
switch (state) {
|
||||
case DISABLED:
|
||||
String setting = getString(
|
||||
GoogleLocationUtils.isAvailable(getActivity()) ? R.string.gps_google_location_settings
|
||||
: R.string.gps_location_access);
|
||||
message = getString(R.string.gps_disabled, setting);
|
||||
isGpsDisabled = true;
|
||||
break;
|
||||
case NO_FIX:
|
||||
case BAD_FIX:
|
||||
message = getString(R.string.gps_wait_for_signal);
|
||||
isGpsDisabled = false;
|
||||
break;
|
||||
case GOOD_FIX:
|
||||
message = null;
|
||||
isGpsDisabled = false;
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("Unexpected state: " + state);
|
||||
if (!isSelectedTrackRecording()) {
|
||||
message = null;
|
||||
isGpsDisabled = false;
|
||||
} else {
|
||||
switch (state) {
|
||||
case DISABLED:
|
||||
String setting = getString(
|
||||
GoogleLocationUtils.isAvailable(getActivity()) ? R.string.gps_google_location_settings
|
||||
: R.string.gps_location_access);
|
||||
message = getString(R.string.gps_disabled, setting);
|
||||
isGpsDisabled = true;
|
||||
break;
|
||||
case NO_FIX:
|
||||
message = getString(R.string.gps_wait_for_signal);
|
||||
isGpsDisabled = false;
|
||||
break;
|
||||
case BAD_FIX:
|
||||
message = getString(R.string.gps_wait_for_better_signal);
|
||||
isGpsDisabled = false;
|
||||
break;
|
||||
case GOOD_FIX:
|
||||
message = null;
|
||||
isGpsDisabled = false;
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("Unexpected state: " + state);
|
||||
}
|
||||
}
|
||||
|
||||
getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
@@ -285,7 +285,7 @@ public class TrackRecordingService extends Service {
|
||||
// Require announcementExecutor and splitExecutor to be created.
|
||||
sharedPreferenceChangeListener.onSharedPreferenceChanged(sharedPreferences, null);
|
||||
|
||||
timer.schedule(checkLocationListener, 5 * ONE_MINUTE, ONE_MINUTE);
|
||||
timer.schedule(checkLocationListener, 0, ONE_MINUTE);
|
||||
|
||||
/*
|
||||
* Try to restart the previous recording track in case the service has been
|
||||
@@ -843,7 +843,7 @@ public class TrackRecordingService extends Service {
|
||||
|
||||
double distanceToLastTrackLocation = location.distanceTo(lastTrackLocation);
|
||||
if (distanceToLastTrackLocation < minRecordingDistance && sensorDataSet == null) {
|
||||
// skip
|
||||
Log.d(TAG, "Not recording location due to min recording distance.");
|
||||
} else if (distanceToLastTrackLocation > maxRecordingDistance) {
|
||||
insertLocation(track, lastLocation, lastTrackLocation);
|
||||
Location pause = new Location(LocationManager.GPS_PROVIDER);
|
||||
@@ -873,9 +873,11 @@ public class TrackRecordingService extends Service {
|
||||
|
||||
private void insertLocation(Track track, Location location, Location lastRecordedLocation) {
|
||||
if (location == null) {
|
||||
Log.w(TAG, "Ignore insertLocation. loation is null.");
|
||||
return;
|
||||
}
|
||||
if (location.equals(lastRecordedLocation)) {
|
||||
Log.w(TAG, "Ignore insertLocation. loation same as last recorded location.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user