- 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:
Jimmy Shih
2012-08-23 14:58:36 -07:00
parent 02f0f4831e
commit 9f63125816
3 changed files with 38 additions and 24 deletions
+6 -1
View File
@@ -683,11 +683,16 @@ limitations under the License.
translation_description="On application start, message when there is no GPS on the device."> translation_description="On application start, message when there is no GPS on the device.">
No GPS is found on the device. No GPS is found on the device.
</string> </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 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.">
Waiting for a better GPS signal. Make sure the sky is visible. Waiting for a better GPS signal. Make sure the sky is visible.
</string> </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 --> <!-- Help page -->
<string name="help_about" <string name="help_about"
@@ -277,6 +277,10 @@ public class MapFragment extends Fragment
public void onLocationStateChanged(LocationState state) { public void onLocationStateChanged(LocationState state) {
final String message; final String message;
final boolean isGpsDisabled; final boolean isGpsDisabled;
if (!isSelectedTrackRecording()) {
message = null;
isGpsDisabled = false;
} else {
switch (state) { switch (state) {
case DISABLED: case DISABLED:
String setting = getString( String setting = getString(
@@ -286,10 +290,13 @@ public class MapFragment extends Fragment
isGpsDisabled = true; isGpsDisabled = true;
break; break;
case NO_FIX: case NO_FIX:
case BAD_FIX:
message = getString(R.string.gps_wait_for_signal); message = getString(R.string.gps_wait_for_signal);
isGpsDisabled = false; isGpsDisabled = false;
break; break;
case BAD_FIX:
message = getString(R.string.gps_wait_for_better_signal);
isGpsDisabled = false;
break;
case GOOD_FIX: case GOOD_FIX:
message = null; message = null;
isGpsDisabled = false; isGpsDisabled = false;
@@ -297,7 +304,7 @@ public class MapFragment extends Fragment
default: default:
throw new IllegalArgumentException("Unexpected state: " + state); throw new IllegalArgumentException("Unexpected state: " + state);
} }
}
getActivity().runOnUiThread(new Runnable() { getActivity().runOnUiThread(new Runnable() {
@Override @Override
public void run() { public void run() {
@@ -285,7 +285,7 @@ public class TrackRecordingService extends Service {
// Require announcementExecutor and splitExecutor to be created. // Require announcementExecutor and splitExecutor to be created.
sharedPreferenceChangeListener.onSharedPreferenceChanged(sharedPreferences, null); 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 * 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); double distanceToLastTrackLocation = location.distanceTo(lastTrackLocation);
if (distanceToLastTrackLocation < minRecordingDistance && sensorDataSet == null) { if (distanceToLastTrackLocation < minRecordingDistance && sensorDataSet == null) {
// skip Log.d(TAG, "Not recording location due to min recording distance.");
} else if (distanceToLastTrackLocation > maxRecordingDistance) { } else if (distanceToLastTrackLocation > maxRecordingDistance) {
insertLocation(track, lastLocation, lastTrackLocation); insertLocation(track, lastLocation, lastTrackLocation);
Location pause = new Location(LocationManager.GPS_PROVIDER); 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) { private void insertLocation(Track track, Location location, Location lastRecordedLocation) {
if (location == null) { if (location == null) {
Log.w(TAG, "Ignore insertLocation. loation is null.");
return; return;
} }
if (location.equals(lastRecordedLocation)) { if (location.equals(lastRecordedLocation)) {
Log.w(TAG, "Ignore insertLocation. loation same as last recorded location.");
return; return;
} }