Merge branch 'develop' into blackNwhiteLists
This commit is contained in:
commit
1eed752b1a
@ -29,7 +29,7 @@
|
|||||||
</value>
|
</value>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8 (1)" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" 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">
|
||||||
|
@ -53,6 +53,7 @@ import io.reactivex.schedulers.Schedulers;
|
|||||||
|
|
||||||
import static com.mapbox.mapboxsdk.Mapbox.getApplicationContext;
|
import static com.mapbox.mapboxsdk.Mapbox.getApplicationContext;
|
||||||
import static com.uam.wmi.findmytutor.utils.Const.defaultMapZoom;
|
import static com.uam.wmi.findmytutor.utils.Const.defaultMapZoom;
|
||||||
|
import static com.uam.wmi.findmytutor.utils.Const.onlineBackgroundLocationInterval;
|
||||||
import static com.uam.wmi.findmytutor.utils.Const.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;
|
||||||
|
|
||||||
@ -200,7 +201,6 @@ public abstract class BaseActivity
|
|||||||
public void stopBackgroundLocalizationTask() {
|
public void stopBackgroundLocalizationTask() {
|
||||||
Intent stopIntent = new Intent(getApplicationContext(), BackgroundLocalizationService.class);
|
Intent stopIntent = new Intent(getApplicationContext(), BackgroundLocalizationService.class);
|
||||||
stopIntent.putExtra("request_stop", true);
|
stopIntent.putExtra("request_stop", true);
|
||||||
Log.e("Localization", "JEstem w stop BG");
|
|
||||||
|
|
||||||
stopService(stopIntent);
|
stopService(stopIntent);
|
||||||
|
|
||||||
@ -210,6 +210,7 @@ public abstract class BaseActivity
|
|||||||
checkPermissions();
|
checkPermissions();
|
||||||
|
|
||||||
Intent startIntent = new Intent(getApplicationContext(), BackgroundLocalizationService.class);
|
Intent startIntent = new Intent(getApplicationContext(), BackgroundLocalizationService.class);
|
||||||
|
startIntent.putExtra("notify_interval", onlineBackgroundLocationInterval);
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.O) {
|
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.O) {
|
||||||
startForegroundService(startIntent);
|
startForegroundService(startIntent);
|
||||||
@ -219,17 +220,12 @@ public abstract class BaseActivity
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void handleBackgroundTaskLifeCycle() {
|
public void handleBackgroundTaskLifeCycle() {
|
||||||
Log.e("Localization", String.valueOf(PrefUtils.isEnableSharingLocalization(getApplicationContext())));
|
|
||||||
Boolean shouldServiceRun = PrefUtils.isEnableSharingLocalization(getApplicationContext()) && isTutor;
|
Boolean shouldServiceRun = PrefUtils.isEnableSharingLocalization(getApplicationContext()) && isTutor;
|
||||||
Log.e("Localization", String.valueOf(shouldServiceRun));
|
|
||||||
|
|
||||||
if (shouldServiceRun) {
|
if (shouldServiceRun) {
|
||||||
startBackgroundLocalizationTask();
|
startBackgroundLocalizationTask();
|
||||||
Log.e("Localization", "JEstem i odpalam");
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
stopBackgroundLocalizationTask();
|
stopBackgroundLocalizationTask();
|
||||||
Log.e("Localization", "JEstem i nie odpalam");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -285,7 +281,6 @@ public abstract class BaseActivity
|
|||||||
getMenuInflater().inflate(R.menu.menu_main, menu);
|
getMenuInflater().inflate(R.menu.menu_main, menu);
|
||||||
infoMenuItem = menu.findItem(R.id.action_info);
|
infoMenuItem = menu.findItem(R.id.action_info);
|
||||||
|
|
||||||
|
|
||||||
MenuItem myActionMenuItem = menu.findItem(R.id.action_search);
|
MenuItem myActionMenuItem = menu.findItem(R.id.action_search);
|
||||||
searchView = (SearchView) myActionMenuItem.getActionView();
|
searchView = (SearchView) myActionMenuItem.getActionView();
|
||||||
|
|
||||||
@ -295,6 +290,10 @@ public abstract class BaseActivity
|
|||||||
adjustMapToSearch(defaultMapZoom);
|
adjustMapToSearch(defaultMapZoom);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!hasFocus && activeFragment.equals(ActiveFragment.USER_LIST)) {
|
||||||
|
((UsersListFragment) userListFragment).restoreUsersList();
|
||||||
|
}
|
||||||
|
|
||||||
if(hasFocus && activeFragment.equals(ActiveFragment.NONE)){
|
if(hasFocus && activeFragment.equals(ActiveFragment.NONE)){
|
||||||
adjustMapToSearch(searchMapZoom);
|
adjustMapToSearch(searchMapZoom);
|
||||||
}
|
}
|
||||||
@ -303,6 +302,7 @@ public abstract class BaseActivity
|
|||||||
RxSearchObservable.fromView(searchView)
|
RxSearchObservable.fromView(searchView)
|
||||||
.skip(0)
|
.skip(0)
|
||||||
.map(String::toLowerCase)
|
.map(String::toLowerCase)
|
||||||
|
.filter(t -> !t.isEmpty())
|
||||||
.debounce(250, TimeUnit.MILLISECONDS)
|
.debounce(250, TimeUnit.MILLISECONDS)
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
@ -333,7 +333,7 @@ public class MapActivity extends BaseActivity
|
|||||||
|
|
||||||
final AlertDialog alertDialog = alertDialogBuilderUserInput.create();
|
final AlertDialog alertDialog = alertDialogBuilderUserInput.create();
|
||||||
|
|
||||||
EditText modalUserInput = view.findViewById(R.id.feedback_input);
|
EditText modalUserInput = view.findViewById(R.id.manual_input);
|
||||||
|
|
||||||
alertDialog.setOnShowListener(dialogInterface -> {
|
alertDialog.setOnShowListener(dialogInterface -> {
|
||||||
Button sendButton = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE);
|
Button sendButton = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE);
|
||||||
|
@ -153,6 +153,8 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
|
|||||||
|
|
||||||
/** Sharing level list **/
|
/** Sharing level list **/
|
||||||
locationMode.setOnPreferenceChangeListener((preference, newValue) -> {
|
locationMode.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||||
|
((MapActivity) getActivity()).stopBackgroundLocalizationTask();
|
||||||
|
((MapActivity) getActivity()).startBackgroundLocalizationTask();
|
||||||
|
|
||||||
PrefUtils.storeLocationMode(getApplicationContext(), locationLevelMapping.get(Integer.parseInt((String) newValue)));
|
PrefUtils.storeLocationMode(getApplicationContext(), locationLevelMapping.get(Integer.parseInt((String) newValue)));
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ import android.support.v7.widget.DefaultItemAnimator;
|
|||||||
import android.support.v7.widget.LinearLayoutManager;
|
import android.support.v7.widget.LinearLayoutManager;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.view.Gravity;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuInflater;
|
import android.view.MenuInflater;
|
||||||
@ -160,11 +161,7 @@ public class UsersListFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void searchUser(String textToSearch) {
|
public void searchUser(String textToSearch) {
|
||||||
|
searchTutorInBackend(textToSearch);
|
||||||
tutorsFiltered.clear();
|
|
||||||
tutorsFiltered.addAll(Stream.of(tutorsList).filter(t ->
|
|
||||||
t.toSearchAbleString().toLowerCase().contains(textToSearch.toLowerCase())).toList());
|
|
||||||
mAdapter.notifyDataSetChanged();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showNoteDialog(final User user) {
|
private void showNoteDialog(final User user) {
|
||||||
@ -232,7 +229,7 @@ public class UsersListFragment extends Fragment {
|
|||||||
private void fetchAllTutors() {
|
private void fetchAllTutors() {
|
||||||
disposable.add(
|
disposable.add(
|
||||||
(fetchOnlyOnlineUsers ?
|
(fetchOnlyOnlineUsers ?
|
||||||
userService.getAllOnlineTutors() :
|
userService.getAllActiveTutors() :
|
||||||
userService.getAllOfflineTutors())
|
userService.getAllOfflineTutors())
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
@ -276,6 +273,31 @@ public class UsersListFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void searchTutorInBackend(String searchString) {
|
||||||
|
disposable.add(
|
||||||
|
userService.searchUser(searchString)
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribeWith(new DisposableSingleObserver<List<User>>() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(List<User> users) {
|
||||||
|
tutorsFiltered.clear();
|
||||||
|
tutorsFiltered.addAll(users);
|
||||||
|
mAdapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(Throwable e) {
|
||||||
|
showSearchError(e);
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void restoreUsersList(){
|
||||||
|
fetchAllTutors();
|
||||||
|
}
|
||||||
|
|
||||||
private int sortByUserName(User t1, User t2) {
|
private int sortByUserName(User t1, User t2) {
|
||||||
return plCollator.compare(t1.getLastName(), t2.getLastName());
|
return plCollator.compare(t1.getLastName(), t2.getLastName());
|
||||||
}
|
}
|
||||||
@ -288,11 +310,33 @@ public class UsersListFragment extends Fragment {
|
|||||||
ResponseBody responseBody = ((HttpException) e).response().errorBody();
|
ResponseBody responseBody = ((HttpException) e).response().errorBody();
|
||||||
message = RestApiHelper.getErrorMessage(responseBody);
|
message = RestApiHelper.getErrorMessage(responseBody);
|
||||||
} else {
|
} else {
|
||||||
message = "Network Error !";
|
message = getString(R.string.network_err);
|
||||||
}
|
}
|
||||||
|
|
||||||
Snackbar.make(coordinatorLayout, message, Snackbar.LENGTH_LONG)
|
createSnackbar(message);
|
||||||
.show();
|
}
|
||||||
|
|
||||||
|
private void showSearchError(Throwable e) {
|
||||||
|
String message;
|
||||||
|
Log.e(TAG, String.valueOf(e));
|
||||||
|
|
||||||
|
if (e instanceof HttpException) {
|
||||||
|
ResponseBody responseBody = ((HttpException) e).response().errorBody();
|
||||||
|
message = RestApiHelper.getErrorMessage(responseBody);
|
||||||
|
} else {
|
||||||
|
message = getString(R.string.search_null);
|
||||||
|
}
|
||||||
|
|
||||||
|
createSnackbar(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createSnackbar(String msg){
|
||||||
|
Snackbar snackbar = Snackbar.make(coordinatorLayout, msg, Snackbar.LENGTH_LONG);
|
||||||
|
View view = snackbar.getView();
|
||||||
|
CoordinatorLayout.LayoutParams params=(CoordinatorLayout.LayoutParams)view.getLayoutParams();
|
||||||
|
params.gravity = Gravity.TOP;
|
||||||
|
view.setLayoutParams(params);
|
||||||
|
snackbar.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void toggleEmptyNotes() {
|
private void toggleEmptyNotes() {
|
||||||
|
@ -11,11 +11,13 @@ import android.content.Intent;
|
|||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.location.Location;
|
import android.location.Location;
|
||||||
|
import android.location.LocationListener;
|
||||||
import android.location.LocationManager;
|
import android.location.LocationManager;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
|
import android.os.Looper;
|
||||||
import android.support.annotation.RequiresApi;
|
import android.support.annotation.RequiresApi;
|
||||||
import android.support.v4.app.ActivityCompat;
|
import android.support.v4.app.ActivityCompat;
|
||||||
import android.support.v4.app.NotificationCompat;
|
import android.support.v4.app.NotificationCompat;
|
||||||
@ -23,6 +25,9 @@ import android.util.Log;
|
|||||||
|
|
||||||
import com.annimon.stream.Stream;
|
import com.annimon.stream.Stream;
|
||||||
import com.google.android.gms.location.FusedLocationProviderClient;
|
import com.google.android.gms.location.FusedLocationProviderClient;
|
||||||
|
import com.google.android.gms.location.LocationCallback;
|
||||||
|
import com.google.android.gms.location.LocationRequest;
|
||||||
|
import com.google.android.gms.location.LocationResult;
|
||||||
import com.google.android.gms.location.LocationServices;
|
import com.google.android.gms.location.LocationServices;
|
||||||
import com.mapbox.geojson.Point;
|
import com.mapbox.geojson.Point;
|
||||||
import com.mapbox.mapboxsdk.geometry.LatLng;
|
import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||||
@ -54,10 +59,11 @@ import static java.lang.String.valueOf;
|
|||||||
public class BackgroundLocalizationService extends Service {
|
public class BackgroundLocalizationService extends Service {
|
||||||
|
|
||||||
private static final String TAG = "MyLocationService";
|
private static final String TAG = "MyLocationService";
|
||||||
private static long notify_interval = onlineBackgroundLocationInterval;
|
private static Integer notify_interval = onlineBackgroundLocationInterval;
|
||||||
private static long notify_interval_inside_building = onlineBackgroundLocationInterval;
|
private static Integer notify_interval_inside_building = onlineBackgroundLocationInterval;
|
||||||
private static long notify_interval_outside_building = offlineBackgroundLocationInterval;
|
private static Integer notify_interval_outside_building = offlineBackgroundLocationInterval;
|
||||||
private static int coordinatesHistoryLength = 5;
|
private static int coordinatesHistoryLength = 5;
|
||||||
|
private Boolean highAccuracyMode;
|
||||||
private Location mLastLocation;
|
private Location mLastLocation;
|
||||||
private Boolean stopService = false;
|
private Boolean stopService = false;
|
||||||
private ArrayList<String> providers = new ArrayList<String>();
|
private ArrayList<String> providers = new ArrayList<String>();
|
||||||
@ -66,6 +72,10 @@ public class BackgroundLocalizationService extends Service {
|
|||||||
private Runnable mStatusChecker;
|
private Runnable mStatusChecker;
|
||||||
private FusedLocationProviderClient mFusedLocationClient;
|
private FusedLocationProviderClient mFusedLocationClient;
|
||||||
private Location fakeLoc = null;
|
private Location fakeLoc = null;
|
||||||
|
private LocationRequest mLocationRequest;
|
||||||
|
private Location mCurrentLocation;
|
||||||
|
private LocationCallback mLocationCallback;
|
||||||
|
private LocationListener mLocationListener;
|
||||||
|
|
||||||
public BackgroundLocalizationService() {
|
public BackgroundLocalizationService() {
|
||||||
providers.add(LocationManager.GPS_PROVIDER);
|
providers.add(LocationManager.GPS_PROVIDER);
|
||||||
@ -90,7 +100,9 @@ public class BackgroundLocalizationService extends Service {
|
|||||||
|
|
||||||
if (intent != null) {
|
if (intent != null) {
|
||||||
stopService = intent.getBooleanExtra("request_stop", false);
|
stopService = intent.getBooleanExtra("request_stop", false);
|
||||||
|
notify_interval = intent.getIntExtra("notify_interval", onlineBackgroundLocationInterval);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stopService) {
|
if (stopService) {
|
||||||
storeBackgroundLocationStatus(getApplication(), false);
|
storeBackgroundLocationStatus(getApplication(), false);
|
||||||
stopForeground(true);
|
stopForeground(true);
|
||||||
@ -101,6 +113,20 @@ public class BackgroundLocalizationService extends Service {
|
|||||||
return START_STICKY;
|
return START_STICKY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void createLocationCallback() {
|
||||||
|
mLocationCallback = new LocationCallback() {
|
||||||
|
@Override
|
||||||
|
public void onLocationResult(LocationResult locationResult) {
|
||||||
|
super.onLocationResult(locationResult);
|
||||||
|
if (locationResult != null) {
|
||||||
|
mCurrentLocation = locationResult.getLastLocation();
|
||||||
|
sendCoordinateToBackend(mCurrentLocation);
|
||||||
|
changeBackgroundMode();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
Log.e(TAG, "onCreate");
|
Log.e(TAG, "onCreate");
|
||||||
@ -114,20 +140,14 @@ public class BackgroundLocalizationService extends Service {
|
|||||||
startForeground(1001, notification);
|
startForeground(1001, notification);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!stopService && !PrefUtils.getLocationLevel(getApplicationContext()).equals(SharingLevel.MANUAL.toString())) {
|
||||||
if (!stopService) {
|
createFusedLocationClient();
|
||||||
|
} else if (!stopService &&
|
||||||
|
PrefUtils.getLocationLevel(getApplicationContext()).equals(SharingLevel.MANUAL.toString())) {
|
||||||
mStatusChecker = () -> {
|
mStatusChecker = () -> {
|
||||||
try {
|
try {
|
||||||
if (PrefUtils.getLocationLevel(getApplicationContext()).equals(SharingLevel.MANUAL.toString())) {
|
|
||||||
sendCoordinateToBackend(fakeLoc);
|
sendCoordinateToBackend(fakeLoc);
|
||||||
} else {
|
|
||||||
mFusedLocationClient = LocationServices.getFusedLocationProviderClient(this);
|
|
||||||
getLocalizationFromListeners();
|
|
||||||
changeBackgroundMode();
|
|
||||||
}
|
|
||||||
} finally {
|
} finally {
|
||||||
mFusedLocationClient = null;
|
|
||||||
destroyLocationListeners();
|
|
||||||
mHandler.postDelayed(mStatusChecker, notify_interval);
|
mHandler.postDelayed(mStatusChecker, notify_interval);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -136,21 +156,54 @@ public class BackgroundLocalizationService extends Service {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void createFusedLocationClient() {
|
||||||
|
Integer saveMode = Long.valueOf(notify_interval).compareTo(Long.valueOf(offlineBackgroundLocationInterval));
|
||||||
|
|
||||||
|
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
mLocationRequest = new LocationRequest();
|
||||||
|
|
||||||
|
if (saveMode != 0) {
|
||||||
|
mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
|
||||||
|
} else {
|
||||||
|
mLocationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY);
|
||||||
|
}
|
||||||
|
|
||||||
|
mLocationRequest.setFastestInterval(notify_interval);
|
||||||
|
mLocationRequest.setInterval(notify_interval);
|
||||||
|
|
||||||
|
createLocationCallback();
|
||||||
|
|
||||||
|
if (!stopService) {
|
||||||
|
mFusedLocationClient = LocationServices.getFusedLocationProviderClient(this);
|
||||||
|
mFusedLocationClient.requestLocationUpdates(mLocationRequest,
|
||||||
|
mLocationCallback, Looper.getMainLooper());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void changeBackgroundMode() {
|
private void changeBackgroundMode() {
|
||||||
if (coordinatesHistory.size() > 4) {
|
Integer prevInterval = notify_interval;
|
||||||
Boolean shouldExtendTimeInterval = Stream.of(coordinatesHistory)
|
Boolean shouldExtendTimeInterval = Stream.of(coordinatesHistory)
|
||||||
.map(MapUtils::checkIfCoordinateIsValid).takeWhile(s -> !s).toList().size() == coordinatesHistory.size();
|
.map(MapUtils::checkIfCoordinateIsValid).takeWhile(s -> !s).toList().size() == coordinatesHistory.size();
|
||||||
|
|
||||||
Boolean shouldAbbreviateTimeInterval = Stream.of(coordinatesHistory).
|
Boolean shouldAbbreviateTimeInterval = Stream.of(coordinatesHistory).
|
||||||
map(MapUtils::checkIfCoordinateIsValid).toList().get(coordinatesHistory.size() - 1);
|
map(MapUtils::checkIfCoordinateIsValid).filter(x -> x).toList().size() > 0;
|
||||||
|
|
||||||
if (shouldExtendTimeInterval) {
|
if (shouldAbbreviateTimeInterval) {
|
||||||
notify_interval = notify_interval_outside_building;
|
|
||||||
} else if (shouldAbbreviateTimeInterval) {
|
|
||||||
notify_interval = notify_interval_inside_building;
|
notify_interval = notify_interval_inside_building;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (coordinatesHistory.size() > 4 && shouldExtendTimeInterval) {
|
||||||
|
notify_interval = notify_interval_outside_building;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Integer changedMode = Long.valueOf(prevInterval).compareTo(Long.valueOf(notify_interval));
|
||||||
|
if (changedMode != 0) {
|
||||||
|
updateListeners();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiresApi(api = Build.VERSION_CODES.O)
|
@RequiresApi(api = Build.VERSION_CODES.O)
|
||||||
@ -173,30 +226,6 @@ public class BackgroundLocalizationService extends Service {
|
|||||||
startForeground(2, notification);
|
startForeground(2, notification);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getLocalizationFromListeners() {
|
|
||||||
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
|
|
||||||
// TODO: Consider calling
|
|
||||||
// ActivityCompat#requestPermissions
|
|
||||||
// here to request the missing permissions, and then overriding
|
|
||||||
// public void onRequestPermissionsResult(int requestCode, String[] permissions,
|
|
||||||
// int[] grantResults)
|
|
||||||
// to handle the case where the user grants the permission. See the documentation
|
|
||||||
// for ActivityCompat#requestPermissions for more details.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
mFusedLocationClient.getLastLocation().addOnSuccessListener(
|
|
||||||
location -> {
|
|
||||||
if (location != null) {
|
|
||||||
mLastLocation = location;
|
|
||||||
coordinatesHistory.add(location);
|
|
||||||
sendCoordinateToBackend(location);
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void sendCoordinateToBackend(Location location) {
|
private void sendCoordinateToBackend(Location location) {
|
||||||
new Task(location).execute();
|
new Task(location).execute();
|
||||||
}
|
}
|
||||||
@ -211,7 +240,41 @@ public class BackgroundLocalizationService extends Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void destroyLocationListeners() {
|
private void destroyLocationListeners() {
|
||||||
|
if (mFusedLocationClient != null) {
|
||||||
|
mFusedLocationClient.removeLocationUpdates(mLocationCallback);
|
||||||
|
mFusedLocationClient = null;
|
||||||
|
mLocationCallback = null;
|
||||||
|
mLocationRequest = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateListeners() {
|
||||||
|
if (mFusedLocationClient != null) {
|
||||||
|
mFusedLocationClient.removeLocationUpdates(mLocationCallback)
|
||||||
|
.addOnCompleteListener(task -> {
|
||||||
|
restartService();
|
||||||
|
mFusedLocationClient = null;
|
||||||
|
mLocationCallback = null;
|
||||||
|
mLocationRequest = null;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void restartService() {
|
||||||
|
|
||||||
|
Intent stopIntent = new Intent(getApplicationContext(), BackgroundLocalizationService.class);
|
||||||
|
stopIntent.putExtra("request_stop", true);
|
||||||
|
|
||||||
|
stopService(stopIntent);
|
||||||
|
|
||||||
|
Intent startIntent = new Intent(getApplicationContext(), BackgroundLocalizationService.class);
|
||||||
|
startIntent.putExtra("notify_interval", notify_interval);
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.O) {
|
||||||
|
startForegroundService(startIntent);
|
||||||
|
} else {
|
||||||
|
startService(startIntent);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -260,6 +323,12 @@ public class BackgroundLocalizationService extends Service {
|
|||||||
approximatedBuildingPart = PrefUtils.getManualLocationApproximation(getApplicationContext());
|
approximatedBuildingPart = PrefUtils.getManualLocationApproximation(getApplicationContext());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Location fakeLoc = new Location("");
|
||||||
|
|
||||||
|
fakeLoc.setLatitude(latitude);
|
||||||
|
fakeLoc.setLongitude(longitude);
|
||||||
|
coordinatesHistory.add(fakeLoc);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Coordinate coordinate = new Coordinate(
|
Coordinate coordinate = new Coordinate(
|
||||||
latitude,
|
latitude,
|
||||||
@ -277,7 +346,6 @@ public class BackgroundLocalizationService extends Service {
|
|||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribeWith(new DisposableCompletableObserver() {
|
.subscribeWith(new DisposableCompletableObserver() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onComplete() {
|
public void onComplete() {
|
||||||
Log.e(TAG, "CoordinateSuccess");
|
Log.e(TAG, "CoordinateSuccess");
|
||||||
@ -285,9 +353,7 @@ public class BackgroundLocalizationService extends Service {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(Throwable e) {
|
public void onError(Throwable e) {
|
||||||
|
|
||||||
Log.e(TAG, "onErr" + valueOf(e));
|
Log.e(TAG, "onErr" + valueOf(e));
|
||||||
|
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
|
@ -19,6 +19,7 @@ import retrofit2.http.HTTP;
|
|||||||
import retrofit2.http.POST;
|
import retrofit2.http.POST;
|
||||||
import retrofit2.http.PUT;
|
import retrofit2.http.PUT;
|
||||||
import retrofit2.http.Path;
|
import retrofit2.http.Path;
|
||||||
|
import retrofit2.http.Query;
|
||||||
|
|
||||||
|
|
||||||
public interface UserService {
|
public interface UserService {
|
||||||
@ -34,9 +35,15 @@ public interface UserService {
|
|||||||
@GET("api/users/tutors/online")
|
@GET("api/users/tutors/online")
|
||||||
Single <List<User>> getAllOnlineTutors();
|
Single <List<User>> getAllOnlineTutors();
|
||||||
|
|
||||||
|
@GET("api/users/tutors/active")
|
||||||
|
Single <List<User>> getAllActiveTutors();
|
||||||
|
|
||||||
@GET("api/users/tutors/offline")
|
@GET("api/users/tutors/offline")
|
||||||
Single <List<User>> getAllOfflineTutors();
|
Single <List<User>> getAllOfflineTutors();
|
||||||
|
|
||||||
|
@GET("api/users/tutors/search")
|
||||||
|
Single <List<User>> searchUser(@Query(value = "searchString", encoded = true) String searchString);
|
||||||
|
|
||||||
@POST("api/users")
|
@POST("api/users")
|
||||||
Completable createUser(@Body User user);
|
Completable createUser(@Body User user);
|
||||||
|
|
||||||
|
@ -6,9 +6,9 @@ import java.util.Arrays;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class Const {
|
public class Const {
|
||||||
public final static String BASE_URL = "https://s416084.projektstudencki.pl/develop/";
|
public final static String BASE_URL = "https://s416084.projektstudencki.pl/master/";
|
||||||
public final static Integer onlineBackgroundLocationInterval = 7000;
|
public final static Integer onlineBackgroundLocationInterval = 7000;
|
||||||
public final static Integer offlineBackgroundLocationInterval = 36000;
|
public final static Integer offlineBackgroundLocationInterval = 360000;
|
||||||
public final static Integer defaultMapZoom = 17;
|
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;
|
||||||
|
@ -21,6 +21,7 @@ public class RxSearchObservable {
|
|||||||
@Override
|
@Override
|
||||||
public boolean onQueryTextSubmit(String s) {
|
public boolean onQueryTextSubmit(String s) {
|
||||||
subject.onNext(s);
|
subject.onNext(s);
|
||||||
|
searchView.clearFocus();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,6 +32,8 @@ public class RxSearchObservable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
@ -72,4 +72,6 @@
|
|||||||
android:text="@string/info_icon_userlist_summary"
|
android:text="@string/info_icon_userlist_summary"
|
||||||
android:textColor="@color/half_black"/>
|
android:textColor="@color/half_black"/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
@ -24,14 +24,14 @@
|
|||||||
android:textStyle="normal" />
|
android:textStyle="normal" />
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/feedback_input"
|
android:id="@+id/manual_input"
|
||||||
android:layout_width="315dp"
|
android:layout_width="315dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentTop="true"
|
android:layout_alignParentTop="true"
|
||||||
android:layout_centerHorizontal="true"
|
android:layout_centerHorizontal="true"
|
||||||
android:layout_marginTop="50dp"
|
android:layout_marginTop="50dp"
|
||||||
android:ems="10"
|
android:ems="10"
|
||||||
android:hint="@string/modal_feedback_hint"
|
android:hint="@string/modal_manual_hint"
|
||||||
android:maxLength="30"
|
android:maxLength="30"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
android:requiresFadingEdge="vertical"
|
android:requiresFadingEdge="vertical"
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="90dp"
|
android:layout_height="90dp"
|
||||||
android:clickable="true"
|
android:clickable="true"
|
||||||
android:focusable="true"
|
android:focusable="true"
|
||||||
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/firstName"
|
android:id="@+id/firstName"
|
||||||
android:layout_width="271dp"
|
android:layout_width="270dp"
|
||||||
android:layout_height="22dp"
|
android:layout_height="22dp"
|
||||||
android:layout_alignParentStart="true"
|
android:layout_alignParentStart="true"
|
||||||
android:layout_alignParentTop="true"
|
android:layout_alignParentTop="true"
|
||||||
@ -26,23 +26,25 @@
|
|||||||
android:id="@+id/lastName"
|
android:id="@+id/lastName"
|
||||||
android:layout_width="270dp"
|
android:layout_width="270dp"
|
||||||
android:layout_height="22dp"
|
android:layout_height="22dp"
|
||||||
|
android:layout_marginStart="12dp"
|
||||||
android:layout_below="@+id/firstName"
|
android:layout_below="@+id/firstName"
|
||||||
android:layout_alignEnd="@+id/firstName"
|
android:layout_alignEnd="@+id/firstName"
|
||||||
android:layout_marginTop="10dp"
|
android:layout_marginTop="10dp"
|
||||||
android:layout_marginEnd="0dp"
|
android:layout_marginEnd="0dp"
|
||||||
|
android:layout_alignParentStart="true"
|
||||||
android:textColor="@color/note_list_text"
|
android:textColor="@color/note_list_text"
|
||||||
android:textSize="15sp" />
|
android:textSize="15sp" />
|
||||||
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/isOnline"
|
android:id="@+id/isOnline"
|
||||||
android:layout_width="48dp"
|
android:layout_width="50dp"
|
||||||
android:layout_height="30dp"
|
android:layout_height="30dp"
|
||||||
android:layout_below="@+id/firstName"
|
android:layout_below="@+id/firstName"
|
||||||
android:layout_marginStart="7dp"
|
android:layout_marginStart="7dp"
|
||||||
android:layout_marginTop="-10dp"
|
android:layout_marginTop="-10dp"
|
||||||
android:layout_toEndOf="@+id/firstName"
|
|
||||||
android:textColor="@color/note_list_text"
|
android:textColor="@color/note_list_text"
|
||||||
|
android:layout_alignParentEnd="true"
|
||||||
android:textSize="@dimen/note_list_text" />
|
android:textSize="@dimen/note_list_text" />
|
||||||
|
|
||||||
|
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
android:id="@+id/action_search"
|
android:id="@+id/action_search"
|
||||||
android:icon="@drawable/ic_menu_search"
|
android:icon="@drawable/ic_menu_search"
|
||||||
app:showAsAction="always"
|
app:showAsAction="always"
|
||||||
|
android:focusable="true"
|
||||||
|
android:focusableInTouchMode="true"
|
||||||
app:actionViewClass="android.support.v7.widget.SearchView"
|
app:actionViewClass="android.support.v7.widget.SearchView"
|
||||||
android:title="@string/search"/>
|
android:title="@string/search"/>
|
||||||
<item
|
<item
|
||||||
|
@ -253,15 +253,18 @@
|
|||||||
<string name="scrap_tutor_tab">Pobierz dane z WMI</string>
|
<string name="scrap_tutor_tab">Pobierz dane z WMI</string>
|
||||||
<string name="scrap_tutor_msg">Dane zostały zaktualizwane!</string>
|
<string name="scrap_tutor_msg">Dane zostały zaktualizwane!</string>
|
||||||
|
|
||||||
<string name="no_online_users">Brak użytkowników online.</string>
|
<!--(ENG) Checkbox online users list -->
|
||||||
|
<string name="no_online_users">Brak aktywnych użytkowników.</string>
|
||||||
<string name="no_offline_users">Brak użytkowników offline.</string>
|
<string name="no_offline_users">Brak użytkowników offline.</string>
|
||||||
<string name="only_online_users">Tylko użytkownicy online</string>
|
|
||||||
<string name="activity_title_blacklist">Czarna lista</string>
|
<string name="activity_title_blacklist">Czarna lista</string>
|
||||||
<string name="activity_title_whitelist">Biała lista</string>
|
<string name="activity_title_whitelist">Biała lista</string>
|
||||||
<string name="title_activity_white_list">Biała lista</string>
|
<string name="title_activity_white_list">Biała lista</string>
|
||||||
<string name="white_list_title">Dodaj użytkownika do białej listy</string>
|
<string name="white_list_title">Dodaj użytkownika do białej listy</string>
|
||||||
<string name="no_such_a_user">Nie ma takiego użytkownika</string>
|
<string name="no_such_a_user">Nie ma takiego użytkownika</string>
|
||||||
|
<string name="only_online_users">Tylko aktywni użytkownicy</string>
|
||||||
|
<string name="network_err">Błąd sieci!</string>
|
||||||
|
<string name="search_null">Brak wyników!</string>
|
||||||
|
<string name="modal_manual_hint">Nadaj nazwę tej lokalizacji.</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
||||||
|
|
||||||
|
@ -298,6 +298,7 @@
|
|||||||
<string name="info_icon_userlist_tab_level_status_offline">- user is currently offline</string>
|
<string name="info_icon_userlist_tab_level_status_offline">- user is currently offline</string>
|
||||||
<string name="info_icon_userlist_tab_level_status_inactive">- user is inactive </string>
|
<string name="info_icon_userlist_tab_level_status_inactive">- user is inactive </string>
|
||||||
<string name="info_icon_userlist_tab_level_status_inactive_tip">(didn’t share any localization data since 7 days)</string>
|
<string name="info_icon_userlist_tab_level_status_inactive_tip">(didn’t share any localization data since 7 days)</string>
|
||||||
|
<<<<<<< HEAD
|
||||||
<string name="title_activity_black_list">BlackList</string>
|
<string name="title_activity_black_list">BlackList</string>
|
||||||
<string name="title_activity_white_list">Whitelist</string>
|
<string name="title_activity_white_list">Whitelist</string>
|
||||||
<string name="index_user">User index</string>
|
<string name="index_user">User index</string>
|
||||||
@ -393,11 +394,17 @@
|
|||||||
"For example, position the FAB to one side of stream of a cards so the FAB won’t interfere "
|
"For example, position the FAB to one side of stream of a cards so the FAB won’t interfere "
|
||||||
"when a user tries to pick up one of cards.\n\n"
|
"when a user tries to pick up one of cards.\n\n"
|
||||||
</string>
|
</string>
|
||||||
|
=======
|
||||||
|
<string name="info_icon_userlist_summary">After clicking on a name, the tutor tab will pop up, containing details about selected tutor.\n\nYou can search for any tutor on the map by entering his name and surname in the search field.\n\nBy default, only active users are shown. You can change that in menu (three dots icon).\n\nYou can also search for a tutor directly, by entering name and surname of person that you look for.</string>
|
||||||
|
|
||||||
|
<!--(ENG) Blacklist -->
|
||||||
|
<string name="title_activity_black_list">Blacklist</string>
|
||||||
|
<string name="index_user">User index</string>
|
||||||
|
<string name="black_list_title">Add user to blacklist</string>
|
||||||
|
>>>>>>> develop
|
||||||
<string name="add">Add</string>
|
<string name="add">Add</string>
|
||||||
<string name="info_icon_userlist_summary">After clicking on a name, the tutor tab will pop up, containing details about selected tutor.</string>
|
|
||||||
|
|
||||||
<string name="possitive_dialog_button">Yes</string>
|
<string name="possitive_dialog_button">Yes</string>
|
||||||
|
|
||||||
<string name="pref_title_acra" translatable="false">App issues reporting</string>
|
<string name="pref_title_acra" translatable="false">App issues reporting</string>
|
||||||
|
|
||||||
<!--(ENG) Profile Activity strings-->
|
<!--(ENG) Profile Activity strings-->
|
||||||
@ -424,9 +431,15 @@
|
|||||||
<string name="off">OFF</string>
|
<string name="off">OFF</string>
|
||||||
<string name="scrap_tutor_tab">Scrap!</string>
|
<string name="scrap_tutor_tab">Scrap!</string>
|
||||||
<string name="scrap_tutor_msg">Data updated!</string>
|
<string name="scrap_tutor_msg">Data updated!</string>
|
||||||
<string name="no_online_users">Currently, there are no\nonline users.</string>
|
|
||||||
|
<!--(ENG) Checkbox online users list -->
|
||||||
|
<string name="no_online_users">Currently, there are no\nactive users.</string>
|
||||||
<string name="no_offline_users">Currently, there are no\noffline users.</string>
|
<string name="no_offline_users">Currently, there are no\noffline users.</string>
|
||||||
<string name="only_online_users">Only online users</string>
|
<string name="only_online_users">Only online users</string>
|
||||||
<string name="no_such_a_user">No such a user</string>
|
<string name="no_such_a_user">No such a user</string>
|
||||||
|
|
||||||
|
<string name="network_err">Network Error !</string>
|
||||||
|
<string name="search_null">Search response is empty!</string>
|
||||||
|
<string name="modal_manual_hint">Insert a name for this localization.</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
Reference in New Issue
Block a user