Adjust to develop
This commit is contained in:
commit
d9909a66bd
@ -29,7 +29,7 @@
|
|||||||
</value>
|
</value>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8 (1)" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectType">
|
<component name="ProjectType">
|
||||||
|
@ -10,7 +10,7 @@ android {
|
|||||||
applicationId "com.uam.wmi.findmytutor"
|
applicationId "com.uam.wmi.findmytutor"
|
||||||
minSdkVersion 22
|
minSdkVersion 22
|
||||||
targetSdkVersion 27
|
targetSdkVersion 27
|
||||||
versionCode 8
|
versionCode 14
|
||||||
versionName "0.9.1-alpha"
|
versionName "0.9.1-alpha"
|
||||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||||
vectorDrawables.useSupportLibrary = true
|
vectorDrawables.useSupportLibrary = true
|
||||||
@ -28,8 +28,14 @@ repositories {
|
|||||||
url 'http://dl.bintray.com/amulyakhare/maven'
|
url 'http://dl.bintray.com/amulyakhare/maven'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
def acraVersion = '5.2.1'
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
implementation "ch.acra:acra-http:$acraVersion"
|
||||||
|
implementation "ch.acra:acra-toast:$acraVersion"
|
||||||
|
implementation "ch.acra:acra-notification:$acraVersion"
|
||||||
|
|
||||||
|
|
||||||
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||||
implementation 'com.android.support:preference-v7:27.1.1'
|
implementation 'com.android.support:preference-v7:27.1.1'
|
||||||
implementation 'com.android.support:appcompat-v7:27.1.1'
|
implementation 'com.android.support:appcompat-v7:27.1.1'
|
||||||
|
Binary file not shown.
@ -17,6 +17,7 @@
|
|||||||
<uses-feature android:name="android.hardware.location.gps" />
|
<uses-feature android:name="android.hardware.location.gps" />
|
||||||
|
|
||||||
<application
|
<application
|
||||||
|
android:name=".FindMyTutor"
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
android:icon="@mipmap/ic_launcher"
|
android:icon="@mipmap/ic_launcher"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
@ -53,7 +54,7 @@
|
|||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".activity.TutorTab"
|
android:name=".activity.TutorTab"
|
||||||
android:theme="@style/AppTheme"></activity>
|
android:theme="@style/AppTheme"/>
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
75
app/src/main/java/com/uam/wmi/findmytutor/FindMyTutor.java
Normal file
75
app/src/main/java/com/uam/wmi/findmytutor/FindMyTutor.java
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
package com.uam.wmi.findmytutor;
|
||||||
|
|
||||||
|
import android.app.Application;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.content.res.Configuration;
|
||||||
|
|
||||||
|
import static org.acra.ReportField.*;
|
||||||
|
import org.acra.ACRA;
|
||||||
|
import org.acra.annotation.AcraNotification;
|
||||||
|
import org.acra.config.CoreConfigurationBuilder;
|
||||||
|
import org.acra.config.HttpSenderConfigurationBuilder;
|
||||||
|
import org.acra.config.ToastConfigurationBuilder;
|
||||||
|
import org.acra.data.StringFormat;
|
||||||
|
import org.acra.sender.HttpSender;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
|
@AcraNotification(resText = R.string.notification_text,
|
||||||
|
resTitle = R.string.notification_title,
|
||||||
|
resChannelName = R.string.notification_channel)
|
||||||
|
public class FindMyTutor extends Application {
|
||||||
|
@Override
|
||||||
|
protected void attachBaseContext(Context base) {
|
||||||
|
super.attachBaseContext(base);
|
||||||
|
|
||||||
|
// ACRA core
|
||||||
|
CoreConfigurationBuilder builder = new CoreConfigurationBuilder(this)
|
||||||
|
.setBuildConfigClass(BuildConfig.class)
|
||||||
|
.setReportContent(REPORT_ID, PHONE_MODEL, LOGCAT, USER_APP_START_DATE, USER_CRASH_DATE, SHARED_PREFERENCES,
|
||||||
|
ANDROID_VERSION, STACK_TRACE, CUSTOM_DATA, BUILD_CONFIG)
|
||||||
|
.setReportFormat(StringFormat.JSON);
|
||||||
|
|
||||||
|
// Toast for user
|
||||||
|
builder.setBuildConfigClass(BuildConfig.class)
|
||||||
|
.setReportFormat(StringFormat.JSON);
|
||||||
|
builder.getPluginConfigurationBuilder(
|
||||||
|
ToastConfigurationBuilder.class
|
||||||
|
).setResText(R.string.acra_toast_text);
|
||||||
|
|
||||||
|
SharedPreferences sharedPreferences = base.getSharedPreferences("com.uam.wmi.findmytutor_preferences", Context.MODE_PRIVATE);
|
||||||
|
Map header = new HashMap();
|
||||||
|
String token = sharedPreferences.getString("API_KEY", "KEY_EMPTY");
|
||||||
|
header.put("Authorization","Bearer " + token);
|
||||||
|
|
||||||
|
// Api POST
|
||||||
|
builder.getPluginConfigurationBuilder(
|
||||||
|
HttpSenderConfigurationBuilder.class
|
||||||
|
// ).setUri("http://192.168.0.15:3000/api/acra")
|
||||||
|
).setUri("https://s416084.projektstudencki.pl/develop/api/Feedback/autoFeedback")
|
||||||
|
.setHttpMethod(HttpSender.Method.POST)
|
||||||
|
.setHttpHeaders(header)
|
||||||
|
.setEnabled(true);
|
||||||
|
|
||||||
|
ACRA.init(this, builder);
|
||||||
|
//Shared preferences
|
||||||
|
ACRA.getErrorReporter().putCustomData("USER_ID", sharedPreferences.getString("USER_ID", "no user id"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Called by the system when the device configuration changes while your component is running.
|
||||||
|
// Overriding this method is totally optional!
|
||||||
|
@Override
|
||||||
|
public void onConfigurationChanged(Configuration newConfig) {
|
||||||
|
super.onConfigurationChanged(newConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
// This is called when the overall system is running low on memory,
|
||||||
|
// and would like actively running processes to tighten their belts.
|
||||||
|
// Overriding this method is totally optional!
|
||||||
|
@Override
|
||||||
|
public void onLowMemory() {
|
||||||
|
super.onLowMemory();
|
||||||
|
}
|
||||||
|
}
|
@ -20,19 +20,16 @@ import android.support.v7.app.ActionBarDrawerToggle;
|
|||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.support.v7.widget.SearchView;
|
import android.support.v7.widget.SearchView;
|
||||||
import android.support.v7.widget.Toolbar;
|
import android.support.v7.widget.Toolbar;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.mapbox.mapboxsdk.Mapbox;
|
|
||||||
import com.uam.wmi.findmytutor.R;
|
import com.uam.wmi.findmytutor.R;
|
||||||
import com.uam.wmi.findmytutor.service.BackgroundLocalizationService;
|
import com.uam.wmi.findmytutor.service.BackgroundLocalizationService;
|
||||||
import com.uam.wmi.findmytutor.utils.ActiveFragment;
|
import com.uam.wmi.findmytutor.utils.ActiveFragment;
|
||||||
import com.uam.wmi.findmytutor.utils.FeedbackUtils;
|
import com.uam.wmi.findmytutor.utils.FeedbackUtils;
|
||||||
import com.uam.wmi.findmytutor.utils.MapUtils;
|
|
||||||
import com.uam.wmi.findmytutor.utils.PrefUtils;
|
import com.uam.wmi.findmytutor.utils.PrefUtils;
|
||||||
import com.uam.wmi.findmytutor.utils.RxSearchObservable;
|
import com.uam.wmi.findmytutor.utils.RxSearchObservable;
|
||||||
|
|
||||||
@ -49,8 +46,8 @@ import io.reactivex.functions.Function;
|
|||||||
import io.reactivex.schedulers.Schedulers;
|
import io.reactivex.schedulers.Schedulers;
|
||||||
|
|
||||||
|
|
||||||
import static com.uam.wmi.findmytutor.utils.Consts.deafultMapZoom;
|
import static com.uam.wmi.findmytutor.utils.Const.defaultMapZoom;
|
||||||
import static com.uam.wmi.findmytutor.utils.Consts.searchMapZoom;
|
import static com.uam.wmi.findmytutor.utils.Const.searchMapZoom;
|
||||||
import static com.uam.wmi.findmytutor.utils.PrefUtils.storeBackgroundLocationStatus;
|
import static com.uam.wmi.findmytutor.utils.PrefUtils.storeBackgroundLocationStatus;
|
||||||
|
|
||||||
|
|
||||||
@ -276,7 +273,7 @@ public abstract class BaseActivity
|
|||||||
searchView.setOnQueryTextFocusChangeListener((v, hasFocus) -> {
|
searchView.setOnQueryTextFocusChangeListener((v, hasFocus) -> {
|
||||||
if (!hasFocus && activeFragment.equals(ActiveFragment.NONE)) {
|
if (!hasFocus && activeFragment.equals(ActiveFragment.NONE)) {
|
||||||
restoreMapMarkers();
|
restoreMapMarkers();
|
||||||
adjustMapToSearch(deafultMapZoom);
|
adjustMapToSearch(defaultMapZoom);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(hasFocus && activeFragment.equals(ActiveFragment.NONE)){
|
if(hasFocus && activeFragment.equals(ActiveFragment.NONE)){
|
||||||
|
@ -21,7 +21,6 @@ import com.auth0.android.jwt.JWT;
|
|||||||
import com.jakewharton.retrofit2.adapter.rxjava2.HttpException;
|
import com.jakewharton.retrofit2.adapter.rxjava2.HttpException;
|
||||||
import com.uam.wmi.findmytutor.R;
|
import com.uam.wmi.findmytutor.R;
|
||||||
import com.uam.wmi.findmytutor.model.JwtToken;
|
import com.uam.wmi.findmytutor.model.JwtToken;
|
||||||
import com.uam.wmi.findmytutor.model.LdapUser;
|
|
||||||
import com.uam.wmi.findmytutor.model.User;
|
import com.uam.wmi.findmytutor.model.User;
|
||||||
import com.uam.wmi.findmytutor.model.ValidateUser;
|
import com.uam.wmi.findmytutor.model.ValidateUser;
|
||||||
import com.uam.wmi.findmytutor.network.ApiClient;
|
import com.uam.wmi.findmytutor.network.ApiClient;
|
||||||
|
@ -80,8 +80,6 @@ public class MapActivity extends BaseActivity
|
|||||||
private int mInterval = 10000;
|
private int mInterval = 10000;
|
||||||
private Handler mHandler = new Handler();
|
private Handler mHandler = new Handler();
|
||||||
private Runnable mStatusChecker;
|
private Runnable mStatusChecker;
|
||||||
private Handler manualLocHandler = new Handler();
|
|
||||||
private Runnable manualLocStatusChecker;
|
|
||||||
private MapView mapView;
|
private MapView mapView;
|
||||||
private MapboxMap mapboxMap;
|
private MapboxMap mapboxMap;
|
||||||
private Button selectLocationButton;
|
private Button selectLocationButton;
|
||||||
@ -343,7 +341,6 @@ public class MapActivity extends BaseActivity
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
alertDialog.show();
|
alertDialog.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -623,8 +620,6 @@ public class MapActivity extends BaseActivity
|
|||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
mapView.onDestroy();
|
mapView.onDestroy();
|
||||||
mHandler.removeCallbacks(mStatusChecker);
|
mHandler.removeCallbacks(mStatusChecker);
|
||||||
// TODO remove after BG sending
|
|
||||||
manualLocHandler.removeCallbacks(manualLocStatusChecker);
|
|
||||||
disposable.dispose();
|
disposable.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -232,7 +232,7 @@ public class SharingFragment extends PreferenceFragment {
|
|||||||
lp.setDefaultValue(0);
|
lp.setDefaultValue(0);
|
||||||
lp.setEntryValues(entryValues);
|
lp.setEntryValues(entryValues);
|
||||||
|
|
||||||
if(entries.length > 0)
|
if(entries.length > 0 && activeId != null)
|
||||||
lp.setValueIndex(activeId);
|
lp.setValueIndex(activeId);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -3,8 +3,9 @@ package com.uam.wmi.findmytutor.model;
|
|||||||
import android.util.Range;
|
import android.util.Range;
|
||||||
|
|
||||||
import com.google.gson.annotations.SerializedName;
|
import com.google.gson.annotations.SerializedName;
|
||||||
import com.uam.wmi.findmytutor.utils.Consts;
|
import com.uam.wmi.findmytutor.utils.Const;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@ -15,8 +16,9 @@ import io.swagger.annotations.ApiModelProperty;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
public class Coordinate extends BaseResponse {
|
public class Coordinate extends BaseResponse {
|
||||||
private Range<Double> latitudeRange = Consts.latitudeRange;
|
private Range<Double> latitudeRange = Const.latitudeRange;
|
||||||
private Range<Double> longtitudeRange = Consts.longitudeRange;
|
private Range<Double> longtitudeRange = Const.longitudeRange;
|
||||||
|
private List<String> allowedApproximatedLocations = Const.validApproximatedLocations;
|
||||||
|
|
||||||
@SerializedName("coordinateId")
|
@SerializedName("coordinateId")
|
||||||
private UUID coordinateId = null;
|
private UUID coordinateId = null;
|
||||||
@ -48,7 +50,7 @@ public class Coordinate extends BaseResponse {
|
|||||||
public Coordinate (Double latitude, Double longitude, Double altitude, String approximatedLocation, String label, String userId, String displayMode) {
|
public Coordinate (Double latitude, Double longitude, Double altitude, String approximatedLocation, String label, String userId, String displayMode) {
|
||||||
if (!latitudeRange.contains(latitude)) throw new IllegalArgumentException("Inappropriate latitude value" + latitude);
|
if (!latitudeRange.contains(latitude)) throw new IllegalArgumentException("Inappropriate latitude value" + latitude);
|
||||||
if (!longtitudeRange.contains(longitude)) throw new IllegalArgumentException("Inappropriate longitude value" + longitude);
|
if (!longtitudeRange.contains(longitude)) throw new IllegalArgumentException("Inappropriate longitude value" + longitude);
|
||||||
//if (approximatedLocation == null) throw new IllegalArgumentException("Inappropriate approximatedLocation");
|
if (!allowedApproximatedLocations.contains(approximatedLocation)) throw new IllegalArgumentException("Inappropriate approximatedLocation");
|
||||||
|
|
||||||
this.latitude = latitude;
|
this.latitude = latitude;
|
||||||
this.longitude = longitude;
|
this.longitude = longitude;
|
||||||
|
@ -41,6 +41,7 @@ public class ApiClient {
|
|||||||
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
|
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
return retrofit;
|
return retrofit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,14 +52,6 @@ public class ApiClient {
|
|||||||
.readTimeout(REQUEST_TIMEOUT, TimeUnit.SECONDS)
|
.readTimeout(REQUEST_TIMEOUT, TimeUnit.SECONDS)
|
||||||
.writeTimeout(REQUEST_TIMEOUT, TimeUnit.SECONDS);
|
.writeTimeout(REQUEST_TIMEOUT, TimeUnit.SECONDS);
|
||||||
|
|
||||||
// Android 7.0.0 fix: https://stackoverflow.com/questions/39133437/sslhandshakeexception-handshake-failed-on-android-n-7-0?fbclid=IwAR1FpUjQlE_iP_2hiZ3okHoFs-Ik4AilVcJaKDKs4FHNFIxn7wb-Uxb_WWY
|
|
||||||
ConnectionSpec spec = new ConnectionSpec.Builder(ConnectionSpec.MODERN_TLS)
|
|
||||||
.tlsVersions(TlsVersion.TLS_1_2)
|
|
||||||
.cipherSuites(CipherSuite.TLS_DHE_RSA_WITH_AES_256_CBC_SHA)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
httpClient.connectionSpecs(Collections.singletonList(spec));
|
|
||||||
|
|
||||||
HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
|
HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
|
||||||
interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
|
interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
|
||||||
|
|
||||||
|
@ -16,7 +16,6 @@ import android.os.AsyncTask;
|
|||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.HandlerThread;
|
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.support.annotation.RequiresApi;
|
import android.support.annotation.RequiresApi;
|
||||||
import android.support.v4.app.ActivityCompat;
|
import android.support.v4.app.ActivityCompat;
|
||||||
@ -32,18 +31,15 @@ import com.mapbox.mapboxsdk.geometry.LatLng;
|
|||||||
import com.uam.wmi.findmytutor.model.Coordinate;
|
import com.uam.wmi.findmytutor.model.Coordinate;
|
||||||
import com.uam.wmi.findmytutor.network.ApiClient;
|
import com.uam.wmi.findmytutor.network.ApiClient;
|
||||||
import com.uam.wmi.findmytutor.utils.ApproximatedLocalization;
|
import com.uam.wmi.findmytutor.utils.ApproximatedLocalization;
|
||||||
|
import com.uam.wmi.findmytutor.utils.MapUtils;
|
||||||
import com.uam.wmi.findmytutor.utils.PrefUtils;
|
import com.uam.wmi.findmytutor.utils.PrefUtils;
|
||||||
import com.uam.wmi.findmytutor.utils.RestApiHelper;
|
import com.uam.wmi.findmytutor.utils.RestApiHelper;
|
||||||
import com.uam.wmi.findmytutor.utils.SharingLevel;
|
import com.uam.wmi.findmytutor.utils.SharingLevel;
|
||||||
import com.uam.wmi.findmytutor.utils.MapUtils;
|
|
||||||
|
|
||||||
import org.apache.commons.collections4.Predicate;
|
|
||||||
import org.apache.commons.collections4.queue.CircularFifoQueue;
|
import org.apache.commons.collections4.queue.CircularFifoQueue;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Queue;
|
|
||||||
import java.util.TimerTask;
|
import java.util.TimerTask;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
|
||||||
@ -53,9 +49,9 @@ import io.reactivex.observers.DisposableSingleObserver;
|
|||||||
import io.reactivex.schedulers.Schedulers;
|
import io.reactivex.schedulers.Schedulers;
|
||||||
import okhttp3.ResponseBody;
|
import okhttp3.ResponseBody;
|
||||||
|
|
||||||
import static com.uam.wmi.findmytutor.utils.Consts.presenceApproximatedName;
|
import static com.uam.wmi.findmytutor.utils.Const.presenceApproximatedName;
|
||||||
import static com.uam.wmi.findmytutor.utils.Consts.presenceLatitude;
|
import static com.uam.wmi.findmytutor.utils.Const.presenceLatitude;
|
||||||
import static com.uam.wmi.findmytutor.utils.Consts.presenceLongitude;
|
import static com.uam.wmi.findmytutor.utils.Const.presenceLongitude;
|
||||||
import static com.uam.wmi.findmytutor.utils.PrefUtils.storeBackgroundLocationStatus;
|
import static com.uam.wmi.findmytutor.utils.PrefUtils.storeBackgroundLocationStatus;
|
||||||
|
|
||||||
public class BackgroundLocalizationService extends Service {
|
public class BackgroundLocalizationService extends Service {
|
||||||
@ -66,22 +62,17 @@ public class BackgroundLocalizationService extends Service {
|
|||||||
private static long notify_interval = 10000;
|
private static long notify_interval = 10000;
|
||||||
private static long notify_interval_inside_building = 10000;
|
private static long notify_interval_inside_building = 10000;
|
||||||
private static long notify_interval_outside_building = 360000;
|
private static long notify_interval_outside_building = 360000;
|
||||||
|
|
||||||
//private static long notify_interval_outside_building = 900000;
|
|
||||||
private static int coordinatesHistoryLength = 10;
|
private static int coordinatesHistoryLength = 10;
|
||||||
|
private Location mLastLocation;
|
||||||
|
private Boolean stopService = false;
|
||||||
|
private ArrayList<String> providers = new ArrayList<String>();
|
||||||
|
private LocationListener[] mLocationListeners;
|
||||||
private CircularFifoQueue<Location> coordinatesHistory = new CircularFifoQueue<Location>(coordinatesHistoryLength);
|
private CircularFifoQueue<Location> coordinatesHistory = new CircularFifoQueue<Location>(coordinatesHistoryLength);
|
||||||
Location mLastLocation;
|
|
||||||
Boolean stopService = false;
|
|
||||||
ArrayList<String> providers = new ArrayList<String>();
|
|
||||||
LocationListener[] mLocationListeners;
|
|
||||||
|
|
||||||
private LocationManager mLocationManager = null;
|
private LocationManager mLocationManager = null;
|
||||||
private Handler mHandler = new Handler();
|
private Handler mHandler = new Handler();
|
||||||
private HandlerThread mHandlerThread = null;
|
|
||||||
private Runnable mStatusChecker;
|
private Runnable mStatusChecker;
|
||||||
private FusedLocationProviderClient mFusedLocationClient;
|
private FusedLocationProviderClient mFusedLocationClient;
|
||||||
|
|
||||||
|
|
||||||
public BackgroundLocalizationService() {
|
public BackgroundLocalizationService() {
|
||||||
providers.add(LocationManager.GPS_PROVIDER);
|
providers.add(LocationManager.GPS_PROVIDER);
|
||||||
providers.add(LocationManager.NETWORK_PROVIDER);
|
providers.add(LocationManager.NETWORK_PROVIDER);
|
||||||
@ -168,8 +159,6 @@ public class BackgroundLocalizationService extends Service {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void changeBackgroundMode() {
|
private void changeBackgroundMode() {
|
||||||
if (coordinatesHistory.size() > 4) {
|
if (coordinatesHistory.size() > 4) {
|
||||||
Boolean shouldExtendTimeInterval = Stream.of(coordinatesHistory)
|
Boolean shouldExtendTimeInterval = Stream.of(coordinatesHistory)
|
||||||
@ -178,28 +167,18 @@ public class BackgroundLocalizationService extends Service {
|
|||||||
Boolean shouldAbbreviateTimeInterval = Stream.of(coordinatesHistory).
|
Boolean shouldAbbreviateTimeInterval = Stream.of(coordinatesHistory).
|
||||||
map(MapUtils::checkIfCoordinateIsValid).toList().get(coordinatesHistory.size() - 1);
|
map(MapUtils::checkIfCoordinateIsValid).toList().get(coordinatesHistory.size() - 1);
|
||||||
|
|
||||||
|
|
||||||
if (shouldExtendTimeInterval) {
|
if (shouldExtendTimeInterval) {
|
||||||
notify_interval = notify_interval_outside_building;
|
notify_interval = notify_interval_outside_building;
|
||||||
} else if (shouldAbbreviateTimeInterval) {
|
} else if (shouldAbbreviateTimeInterval) {
|
||||||
notify_interval = notify_interval_inside_building;
|
notify_interval = notify_interval_inside_building;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.e("COORD_HISTORY", String.valueOf(Stream.of(coordinatesHistory)
|
|
||||||
.map(MapUtils::checkIfCoordinateIsValid).toList()));
|
|
||||||
|
|
||||||
Log.e("COORD_HISTORY", String.valueOf(Stream.of(coordinatesHistory)
|
|
||||||
.map(x -> x.getLatitude() + " " + x.getLongitude()).toList()));
|
|
||||||
Log.e("COORD_NEW INTERVAL", String.valueOf(notify_interval));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@RequiresApi(api = Build.VERSION_CODES.O)
|
@RequiresApi(api = Build.VERSION_CODES.O)
|
||||||
private void startMyOwnForeground() {
|
private void startMyOwnForeground() {
|
||||||
|
|
||||||
String NOTIFICATION_CHANNEL_ID = "com.example.simpleapp";
|
String NOTIFICATION_CHANNEL_ID = "com.example.fmt";
|
||||||
String channelName = "My Background Service";
|
String channelName = "My Background Service";
|
||||||
NotificationChannel chan = new NotificationChannel(NOTIFICATION_CHANNEL_ID, channelName, NotificationManager.IMPORTANCE_NONE);
|
NotificationChannel chan = new NotificationChannel(NOTIFICATION_CHANNEL_ID, channelName, NotificationManager.IMPORTANCE_NONE);
|
||||||
chan.setLightColor(Color.BLUE);
|
chan.setLightColor(Color.BLUE);
|
||||||
@ -280,7 +259,6 @@ public class BackgroundLocalizationService extends Service {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mLocationManager.removeUpdates(listener);
|
mLocationManager.removeUpdates(listener);
|
||||||
Log.i(TAG, "Removed");
|
|
||||||
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
Log.i(TAG, "fail to remove location listener, ignore", ex);
|
Log.i(TAG, "fail to remove location listener, ignore", ex);
|
||||||
@ -297,13 +275,6 @@ public class BackgroundLocalizationService extends Service {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class TimerTaskToGetLocation extends TimerTask {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
mHandler.post(BackgroundLocalizationService.this::fn_getlocation);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class LocationListener implements android.location.LocationListener {
|
private class LocationListener implements android.location.LocationListener {
|
||||||
|
|
||||||
public LocationListener(String provider) {
|
public LocationListener(String provider) {
|
||||||
@ -372,8 +343,6 @@ public class BackgroundLocalizationService extends Service {
|
|||||||
approximatedBuildingPart = PrefUtils.getManualLocationApproximation(getApplicationContext());
|
approximatedBuildingPart = PrefUtils.getManualLocationApproximation(getApplicationContext());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Coordinate coordinate = new Coordinate(
|
Coordinate coordinate = new Coordinate(
|
||||||
latitude,
|
latitude,
|
||||||
@ -400,14 +369,7 @@ public class BackgroundLocalizationService extends Service {
|
|||||||
@SuppressLint("LongLogTag")
|
@SuppressLint("LongLogTag")
|
||||||
@Override
|
@Override
|
||||||
public void onError(Throwable e) {
|
public void onError(Throwable e) {
|
||||||
|
|
||||||
Log.e("CoordinateService onError", e.getMessage());
|
Log.e("CoordinateService onError", e.getMessage());
|
||||||
|
|
||||||
if (e instanceof HttpException) {
|
|
||||||
ResponseBody responseBody = ((HttpException) e).response().errorBody();
|
|
||||||
Log.e("CoordinateService onError", RestApiHelper.getErrorMessage(responseBody));
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
|
@ -48,7 +48,7 @@ public class ApproximatedLocalization {
|
|||||||
return Objects.requireNonNull(Objects.requireNonNull(feature.getStringProperty("name")));
|
return Objects.requireNonNull(Objects.requireNonNull(feature.getStringProperty("name")));
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return Const.presenceApproximatedName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Double> getMiddlePointOfBuildingPart(String buildingPart) {
|
public List<Double> getMiddlePointOfBuildingPart(String buildingPart) {
|
||||||
|
@ -2,13 +2,16 @@ package com.uam.wmi.findmytutor.utils;
|
|||||||
|
|
||||||
import android.util.Range;
|
import android.util.Range;
|
||||||
|
|
||||||
public class Consts {
|
import java.util.Arrays;
|
||||||
public final static Integer deafultMapZoom = 17;
|
import java.util.List;
|
||||||
|
|
||||||
|
public class Const {
|
||||||
|
public final static Integer defaultMapZoom = 17;
|
||||||
public final static Integer searchMapZoom = 13;
|
public final static Integer searchMapZoom = 13;
|
||||||
public final static Double presenceLatitude = 52.466365;
|
public final static Double presenceLatitude = 52.466365;
|
||||||
public final static Double presenceLongitude = 16.926792;
|
public final static Double presenceLongitude = 16.926792;
|
||||||
public final static String presenceApproximatedName = "Unknown";
|
public final static String presenceApproximatedName = "Unknown";
|
||||||
public final static Range<Double> latitudeRange = Range.create(52.466092, 52.467529);
|
public final static Range<Double> latitudeRange = Range.create(52.466092, 52.467529);
|
||||||
public final static Range<Double> longitudeRange = Range.create(16.926159, 16.927759);
|
public final static Range<Double> longitudeRange = Range.create(16.926159, 16.927759);
|
||||||
|
public final static List<String> validApproximatedLocations = Arrays.asList("Skrzydło B", "Skrzydło A", "Aule", "Łącznik", "Biblioteka", "Hol", "Unknown");
|
||||||
}
|
}
|
@ -3,7 +3,6 @@ package com.uam.wmi.findmytutor.utils;
|
|||||||
import android.animation.TypeEvaluator;
|
import android.animation.TypeEvaluator;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.location.Location;
|
import android.location.Location;
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import com.mapbox.mapboxsdk.camera.CameraPosition;
|
import com.mapbox.mapboxsdk.camera.CameraPosition;
|
||||||
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
|
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
|
||||||
@ -15,8 +14,8 @@ import com.mapbox.mapboxsdk.maps.MapboxMap;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
||||||
import static com.uam.wmi.findmytutor.utils.Consts.latitudeRange;
|
import static com.uam.wmi.findmytutor.utils.Const.latitudeRange;
|
||||||
import static com.uam.wmi.findmytutor.utils.Consts.longitudeRange;
|
import static com.uam.wmi.findmytutor.utils.Const.longitudeRange;
|
||||||
|
|
||||||
public class MapUtils {
|
public class MapUtils {
|
||||||
|
|
||||||
|
@ -159,9 +159,14 @@
|
|||||||
<string name="network_error">Błąd sieci!</string>
|
<string name="network_error">Błąd sieci!</string>
|
||||||
<string name="manual_status_error">Błąd podczas pobierania danych.</string>
|
<string name="manual_status_error">Błąd podczas pobierania danych.</string>
|
||||||
<string name="error_status_fetch">Błąd podczas pobierania statusów.</string>
|
<string name="error_status_fetch">Błąd podczas pobierania statusów.</string>
|
||||||
|
<string name="notification_text">Upss. Coś poszło nie tak. Pracujemy nad tym!</string>
|
||||||
<string name="lack_duty_hours">Brak informacji o dyzurze.</string>
|
<string name="lack_duty_hours">Brak informacji o dyzurze.</string>
|
||||||
<string name="lack_note">Brak notatki.</string>
|
<string name="lack_note">Brak notatki.</string>
|
||||||
<string name="search">Wyszukiwarka</string>
|
<string name="search">Wyszukiwarka</string>
|
||||||
|
<string name="description_notdisturb">Nie przeszkadzać</string>
|
||||||
|
<string name="description_awaiting">Czekam na studentów</string>
|
||||||
|
<string name="description_onholidays">Na wakacjach</string>
|
||||||
|
<string name="title_description">Status</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
||||||
|
|
||||||
|
@ -73,11 +73,16 @@
|
|||||||
<string name="key_location_level">key_location_level</string>
|
<string name="key_location_level">key_location_level</string>
|
||||||
|
|
||||||
<string name="status_list_title">Choose status</string>
|
<string name="status_list_title">Choose status</string>
|
||||||
<string name="key_status_value">key_status_value</string>
|
<string name="key_status_value" translatable="false">key_status_value</string>
|
||||||
<string name="status_switch_title">Status</string>
|
<string name="status_switch_title">Status</string>
|
||||||
<string name="description_busy">Busy</string>
|
<string name="description_busy">Busy</string>
|
||||||
<string name="description_available">Available</string>
|
<string name="description_available">Available</string>
|
||||||
<string name="description_consultation">Consultation</string>
|
<string name="description_consultation">Consultation</string>
|
||||||
|
<string name="description_notdisturb">Do not disturb</string>
|
||||||
|
<string name="description_awaiting">Waiting for students</string>
|
||||||
|
<string name="description_onholidays">On holidays</string>
|
||||||
|
|
||||||
|
<string name="title_description">Status</string>
|
||||||
<string name="title_manual_status">Add custom status</string>
|
<string name="title_manual_status">Add custom status</string>
|
||||||
|
|
||||||
|
|
||||||
@ -228,7 +233,13 @@
|
|||||||
<string name="network_error">Network Error!</string>
|
<string name="network_error">Network Error!</string>
|
||||||
<string name="manual_status_error">Error handling status fetch</string>
|
<string name="manual_status_error">Error handling status fetch</string>
|
||||||
<string name="error_status_fetch">Error handling status fetch</string>
|
<string name="error_status_fetch">Error handling status fetch</string>
|
||||||
|
|
||||||
|
<string name="acra_toast_text" translatable="false">Sorry, the application crashed. A report will be sent to the developers</string>
|
||||||
|
<string name="notification_text">Sorry, the application crashed. A report will be sent to the developers</string>
|
||||||
|
<string name="notification_title" translatable="false">FMT Crash</string>
|
||||||
|
<string name="notification_channel" translatable="false">FMT</string>
|
||||||
<string name="lack_duty_hours">Lack information about duty hours</string>
|
<string name="lack_duty_hours">Lack information about duty hours</string>
|
||||||
<string name="lack_note">No note.</string>
|
<string name="lack_note">No note.</string>
|
||||||
<string name="search">Search</string>
|
<string name="search">Search</string>
|
||||||
|
<string name="mockup_location_string" translatable="false">mock location string</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
Reference in New Issue
Block a user