GPS Status: TrackListActivity uses the value of gps status from the service to select appropiate icon.

This commit is contained in:
Román
2020-08-04 15:13:38 +02:00
committed by Román Martínez
parent e2b741dd08
commit 9837680540
6 changed files with 55 additions and 19 deletions
@@ -698,4 +698,8 @@ public class TrackRecordingService extends Service implements HandlerServer.Hand
public void setRemoteSensorManager(BluetoothRemoteSensorManager remoteSensorManager) {
this.remoteSensorManager = remoteSensorManager;
}
public GpsStatusValue getGpsStatus() {
return handlerServer.getGpsStatus();
}
}
@@ -4,6 +4,7 @@ import androidx.annotation.VisibleForTesting;
import de.dennisguse.opentracks.content.data.TrackPoint;
import de.dennisguse.opentracks.content.sensor.SensorDataSet;
import de.dennisguse.opentracks.services.handlers.GpsStatusValue;
import de.dennisguse.opentracks.services.sensors.BluetoothRemoteSensorManager;
/**
@@ -27,6 +28,11 @@ class TrackRecordingServiceBinder extends android.os.Binder implements TrackReco
trackRecordingService.addListener(listener);
}
@Override
public GpsStatusValue getGpsStatus() {
return trackRecordingService.getGpsStatus();
}
@Override
public void startGps() {
trackRecordingService.tryStartGps();
@@ -19,6 +19,7 @@ import androidx.annotation.VisibleForTesting;
import de.dennisguse.opentracks.content.data.TrackPoint;
import de.dennisguse.opentracks.content.sensor.SensorDataSet;
import de.dennisguse.opentracks.services.handlers.GpsStatusValue;
import de.dennisguse.opentracks.services.sensors.BluetoothRemoteSensorManager;
/**
@@ -112,4 +113,6 @@ public interface TrackRecordingServiceInterface {
void newTrackPoint(TrackPoint trackPoint, int recordingGpsAccuracy);
void setListener(BoundServiceListener listener);
GpsStatusValue getGpsStatus();
}
@@ -60,6 +60,10 @@ public class HandlerServer {
service.newGpsStatus(gpsStatusValue);
}
public GpsStatusValue getGpsStatus() {
return locationHandler.getGpsStatus();
}
public interface HandlerServerInterface {
void newTrackPoint(TrackPoint trackPoint, int gpsAccuracy);
void newGpsStatus(GpsStatusValue gpsStatusValue);
@@ -90,6 +90,10 @@ class LocationHandler implements HandlerServer.Handler, LocationListener, GpsSta
*/
@Override
public void onLocationChanged(@NonNull Location location) {
if (gpsStatus != null) {
gpsStatus.onLocationChanged(location);
}
if (!LocationUtils.isValidLocation(location)) {
Log.w(TAG, "Ignore newTrackPoint. location is invalid.");
return;
@@ -122,10 +126,16 @@ class LocationHandler implements HandlerServer.Handler, LocationListener, GpsSta
@Override
public void onProviderEnabled(@NonNull String provider) {
if (gpsStatus != null) {
gpsStatus.onGpsEnabled();
}
}
@Override
public void onProviderDisabled(@NonNull String provider) {
if (gpsStatus != null) {
gpsStatus.onGpsDisabled();
}
}
private void registerLocationListener() {
@@ -161,4 +171,8 @@ class LocationHandler implements HandlerServer.Handler, LocationListener, GpsSta
public void onGpsStatusChanged(GpsStatusValue prevStatus, GpsStatusValue currentStatus) {
handlerServer.sendGpsStatus(currentStatus);
}
public GpsStatusValue getGpsStatus() {
return gpsStatus != null ? gpsStatus.getGpsStatus() : GpsStatusValue.GPS_NONE;
}
}