Merge branch 'extend-bg-history' of s416084/find-my-tutor-android into develop

This commit is contained in:
Mieszko Wrzeszczyński 2019-01-04 10:13:56 +00:00 committed by Gogs
commit 42f501f8e2
4 changed files with 9 additions and 6 deletions

View File

@ -10,7 +10,7 @@ android {
applicationId "com.uam.wmi.findmytutor" applicationId "com.uam.wmi.findmytutor"
minSdkVersion 22 minSdkVersion 22
targetSdkVersion 27 targetSdkVersion 27
versionCode 30 versionCode 33
versionName "0.9.6-beta" versionName "0.9.6-beta"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true vectorDrawables.useSupportLibrary = true

View File

@ -70,6 +70,8 @@ import io.reactivex.schedulers.Schedulers;
import okhttp3.ResponseBody; import okhttp3.ResponseBody;
import timber.log.Timber; import timber.log.Timber;
import static com.uam.wmi.findmytutor.utils.Const.mapRefreshInterval;
public class MapActivity extends BaseActivity public class MapActivity extends BaseActivity
implements PermissionsListener, OnMapReadyCallback { implements PermissionsListener, OnMapReadyCallback {
@ -80,7 +82,7 @@ public class MapActivity extends BaseActivity
private UserService userService; private UserService userService;
private CompositeDisposable disposable = new CompositeDisposable(); private CompositeDisposable disposable = new CompositeDisposable();
private int mInterval = 10000; private int mInterval = mapRefreshInterval;
private Handler mHandler = new Handler(); private Handler mHandler = new Handler();
private Runnable mStatusChecker; private Runnable mStatusChecker;
private MapView mapView; private MapView mapView;
@ -603,7 +605,6 @@ public class MapActivity extends BaseActivity
} }
} }
// Add the mapView lifecycle to the activity's lifecycle methods
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
@ -615,6 +616,7 @@ public class MapActivity extends BaseActivity
protected void onStart() { protected void onStart() {
super.onStart(); super.onStart();
mapView.onStart(); mapView.onStart();
shouldFetchNewCoords = true;
} }
@Override @Override

View File

@ -62,7 +62,7 @@ public class BackgroundLocalizationService extends Service {
private static Integer notify_interval = onlineBackgroundLocationInterval; private static Integer notify_interval = onlineBackgroundLocationInterval;
private static Integer notify_interval_inside_building = onlineBackgroundLocationInterval; private static Integer notify_interval_inside_building = onlineBackgroundLocationInterval;
private static Integer notify_interval_outside_building = offlineBackgroundLocationInterval; private static Integer notify_interval_outside_building = offlineBackgroundLocationInterval;
private static int coordinatesHistoryLength = 5; private static int coordinatesHistoryLength = 10;
private Boolean highAccuracyMode; private Boolean highAccuracyMode;
private Location mLastLocation; private Location mLastLocation;
private Boolean stopService = false; private Boolean stopService = false;
@ -195,7 +195,7 @@ public class BackgroundLocalizationService extends Service {
notify_interval = notify_interval_inside_building; notify_interval = notify_interval_inside_building;
} }
if (coordinatesHistory.size() > 4 && shouldExtendTimeInterval) { if (coordinatesHistory.size() > coordinatesHistoryLength && shouldExtendTimeInterval) {
notify_interval = notify_interval_outside_building; notify_interval = notify_interval_outside_building;
} }
@ -203,7 +203,6 @@ public class BackgroundLocalizationService extends Service {
if (changedMode != 0) { if (changedMode != 0) {
updateListeners(); updateListeners();
} }
} }
@RequiresApi(api = Build.VERSION_CODES.O) @RequiresApi(api = Build.VERSION_CODES.O)
@ -294,6 +293,7 @@ public class BackgroundLocalizationService extends Service {
latitude = location.getLatitude(); latitude = location.getLatitude();
longitude = location.getLongitude(); longitude = location.getLongitude();
altitude = location.getAltitude(); altitude = location.getAltitude();
approximatedLocalization = new ApproximatedLocalization(MapUtils.loadJsonFromAsset(getApplicationContext(), "building.geojson")); approximatedLocalization = new ApproximatedLocalization(MapUtils.loadJsonFromAsset(getApplicationContext(), "building.geojson"));
approximatedBuildingPart = approximatedLocalization.getNameOfBuildingPart(Point.fromLngLat(longitude, latitude)); approximatedBuildingPart = approximatedLocalization.getNameOfBuildingPart(Point.fromLngLat(longitude, latitude));
} }

View File

@ -7,6 +7,7 @@ import java.util.List;
public class Const { public class Const {
public final static String BASE_URL = "https://s416084.projektstudencki.pl/master/"; public final static String BASE_URL = "https://s416084.projektstudencki.pl/master/";
public final static Integer mapRefreshInterval = 5000;
public final static Integer onlineBackgroundLocationInterval = 7000; public final static Integer onlineBackgroundLocationInterval = 7000;
public final static Integer offlineBackgroundLocationInterval = 360000; public final static Integer offlineBackgroundLocationInterval = 360000;
public final static Integer defaultMapZoom = 17; public final static Integer defaultMapZoom = 17;