Merge branch 'developToMapPravilnie' of git.wmi.amu.edu.pl:s416084/find-my-tutor-android into developToMapPravilnie
This commit is contained in:
commit
9cd0f053e3
@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding">
|
||||
<file url="file://$PROJECT_DIR$/app/src/main/java/com/uam/wmi/findmytutor/activity/MapFragment.java" charset="UTF-8" />
|
||||
</component>
|
||||
</project>
|
@ -57,6 +57,7 @@ dependencies {
|
||||
implementation 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
|
||||
implementation 'com.auth0.android:jwtdecode:1.1.1'
|
||||
implementation 'com.annimon:stream:1.2.1'
|
||||
implementation 'com.google.android.gms:play-services-location:16.0.0'
|
||||
|
||||
// FloatingBarMenu
|
||||
implementation 'com.getbase:floatingactionbutton:1.10.1'
|
||||
|
@ -50,6 +50,10 @@
|
||||
android:name=".activity.SettingsActivity"
|
||||
android:label="@string/title_activity_settings" />
|
||||
|
||||
<activity
|
||||
android:name=".service.GoogleLocalizationActivity"
|
||||
android:label="@string/title_activity_settings" />
|
||||
|
||||
<service
|
||||
android:name=".service.BackgroundLocalizationService"
|
||||
android:exported="false"
|
||||
|
@ -184,10 +184,13 @@ public abstract class BaseActivity
|
||||
}
|
||||
|
||||
public void handleBackgroundTaskLifeCycle() {
|
||||
if (PrefUtils.isEnableSharingLocalization(getApplicationContext())
|
||||
&& !PrefUtils.isBackgroundLocationServiceRunning(getApplicationContext())) {
|
||||
Boolean shouldServiceRun = PrefUtils.isEnableSharingLocalization(getApplicationContext())
|
||||
&& !PrefUtils.isBackgroundLocationServiceRunning(getApplicationContext());
|
||||
|
||||
if (shouldServiceRun){
|
||||
startBackgroundLocalizationTask();
|
||||
} else if(PrefUtils.isBackgroundLocationServiceRunning(getApplicationContext())) {
|
||||
} else if(PrefUtils.isBackgroundLocationServiceRunning(getApplicationContext()) &&
|
||||
!PrefUtils.isEnableSharingLocalization(getApplicationContext())) {
|
||||
stopBackgroundLocalizationTask();
|
||||
}
|
||||
}
|
||||
@ -294,12 +297,6 @@ public abstract class BaseActivity
|
||||
overridePendingTransition(0, 0);
|
||||
}
|
||||
|
||||
private void setFragment(Fragment fragment) {
|
||||
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
|
||||
fragmentTransaction.replace(R.id.activity_content, fragment);
|
||||
fragmentTransaction.commit();
|
||||
}
|
||||
|
||||
private void removeFragment(Fragment fragment) {
|
||||
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
|
||||
fragmentTransaction.hide(fragment);
|
||||
|
@ -176,7 +176,7 @@ public class LoginActivity extends AppCompatActivity {
|
||||
|
||||
private void getUserProfile(String userId) {
|
||||
|
||||
disposable.add(userService.getUserByID(userId)
|
||||
disposable.add(userService.getUserById(userId)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(this::saveUserProfileToSharedPreferences, this::handleError));
|
||||
|
@ -6,59 +6,53 @@ import android.animation.ValueAnimator;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Color;
|
||||
import android.location.Location;
|
||||
import android.location.LocationManager;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.support.design.widget.FloatingActionButton;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.animation.LinearInterpolator;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.jakewharton.retrofit2.adapter.rxjava2.HttpException;
|
||||
import com.mapbox.android.core.permissions.PermissionsListener;
|
||||
import com.mapbox.android.core.permissions.PermissionsManager;
|
||||
import com.mapbox.mapboxsdk.Mapbox;
|
||||
import com.mapbox.mapboxsdk.annotations.Icon;
|
||||
import com.mapbox.mapboxsdk.annotations.IconFactory;
|
||||
import com.mapbox.mapboxsdk.annotations.Marker;
|
||||
import com.mapbox.mapboxsdk.annotations.MarkerOptions;
|
||||
import com.mapbox.mapboxsdk.camera.CameraPosition;
|
||||
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
import com.mapbox.mapboxsdk.location.LocationComponent;
|
||||
import com.mapbox.mapboxsdk.location.LocationComponentOptions;
|
||||
import com.mapbox.mapboxsdk.location.modes.CameraMode;
|
||||
import com.mapbox.mapboxsdk.location.modes.RenderMode;
|
||||
import com.mapbox.mapboxsdk.style.layers.CircleLayer;
|
||||
import com.mapbox.mapboxsdk.style.layers.Layer;
|
||||
import com.mapbox.mapboxsdk.style.sources.VectorSource;
|
||||
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.NONE;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.VISIBLE;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleColor;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.view.View;
|
||||
import android.view.animation.LinearInterpolator;
|
||||
import android.widget.Button;
|
||||
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleRadius;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility;
|
||||
|
||||
import com.mapbox.mapboxsdk.Mapbox;
|
||||
import com.mapbox.mapboxsdk.annotations.Marker;
|
||||
import com.mapbox.mapboxsdk.annotations.MarkerOptions;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
import com.mapbox.mapboxsdk.maps.MapView;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
|
||||
import com.mapbox.mapboxsdk.style.layers.CircleLayer;
|
||||
import com.mapbox.mapboxsdk.style.layers.Layer;
|
||||
import com.mapbox.mapboxsdk.style.sources.VectorSource;
|
||||
import com.uam.wmi.findmytutor.R;
|
||||
import com.uam.wmi.findmytutor.model.Coordinate;
|
||||
import com.uam.wmi.findmytutor.model.User;
|
||||
import com.uam.wmi.findmytutor.network.ApiClient;
|
||||
import com.uam.wmi.findmytutor.service.CoordinateService;
|
||||
import com.uam.wmi.findmytutor.service.UserService;
|
||||
import com.uam.wmi.findmytutor.utils.PrefUtils;
|
||||
import com.uam.wmi.findmytutor.utils.RestApiHelper;
|
||||
import com.uam.wmi.findmytutor.utils.mapUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
@ -69,26 +63,29 @@ import io.reactivex.observers.DisposableSingleObserver;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import okhttp3.ResponseBody;
|
||||
import timber.log.Timber;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.NONE;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.VISIBLE;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleColor;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleRadius;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility;
|
||||
|
||||
|
||||
public class MapActivity extends BaseActivity
|
||||
implements PermissionsListener, OnMapReadyCallback {
|
||||
private String tag = getClass().getName();
|
||||
|
||||
|
||||
private String tag = getClass().getName();
|
||||
private PermissionsManager permissionsManager;
|
||||
private LocationComponent locationComponent;
|
||||
LocationManager mLocationManager;
|
||||
|
||||
|
||||
private CoordinateService coordinateService;
|
||||
private CompositeDisposable disposable = new CompositeDisposable();
|
||||
private UserService userService;
|
||||
|
||||
private CompositeDisposable disposable = new CompositeDisposable();
|
||||
private int mInterval = 10000;
|
||||
private Handler mHandler = new Handler();
|
||||
private Runnable mStatusChecker;
|
||||
|
||||
private MapView mapView;
|
||||
private MapboxMap mapboxMap;
|
||||
private Marker droppedMarker;
|
||||
@ -101,19 +98,19 @@ public class MapActivity extends BaseActivity
|
||||
private int bearingParam = 180;
|
||||
private int tiltParam = 30;
|
||||
|
||||
Locale myLocale;
|
||||
String currentLanguage = "pl", currentLang;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
final SharedPreferences sharedPref = getSharedPreferences("fmtPrefs", Context.MODE_PRIVATE);
|
||||
final String authToken = sharedPref.getString("authToken", null);
|
||||
|
||||
|
||||
// fetching coords service
|
||||
coordinateService = ApiClient.getClient(getApplicationContext())
|
||||
.create(CoordinateService.class);
|
||||
|
||||
userService = ApiClient.getClient(getApplicationContext())
|
||||
.create(UserService.class);
|
||||
|
||||
mStatusChecker = () -> {
|
||||
try {
|
||||
fetchTopCoords();
|
||||
@ -131,8 +128,6 @@ public class MapActivity extends BaseActivity
|
||||
|
||||
//start background task
|
||||
handleBackgroundTaskLifeCycle();
|
||||
|
||||
currentLanguage = getIntent().getStringExtra(currentLang);
|
||||
}
|
||||
|
||||
|
||||
@ -142,19 +137,68 @@ public class MapActivity extends BaseActivity
|
||||
mStatusChecker.run();
|
||||
enableLocationPlugin();
|
||||
|
||||
// // TODO what should happend on click?
|
||||
// mapboxMap.setOnMarkerClickListener(marker1 -> {
|
||||
//
|
||||
// // Show a toast with the title of the selected marker
|
||||
//// Toast.makeText(MapActivity.this, marker.getTitle(), Toast.LENGTH_SHORT).show();
|
||||
// return true;
|
||||
// });
|
||||
mapboxMap.setOnMarkerClickListener(marker -> {
|
||||
createMarkerModal(marker.getTitle());
|
||||
return true;
|
||||
});
|
||||
|
||||
|
||||
setOnMapLongClickListener();
|
||||
// addStaticLayer();
|
||||
}
|
||||
|
||||
private void createMarkerModal(String userId) {
|
||||
disposable.add(userService.getUserById(userId)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(this::createMarkerModal, this::handleError));
|
||||
}
|
||||
|
||||
private void createMarkerModal(User user) {
|
||||
String cordStatus = coordsMap.get(user.getId()).getLabel();
|
||||
|
||||
LayoutInflater layoutInflaterAndroid = LayoutInflater.from(getApplicationContext());
|
||||
@SuppressLint("InflateParams") View view = layoutInflaterAndroid.inflate(R.layout.marker_modal, null);
|
||||
|
||||
AlertDialog.Builder alertDialogBuilderUserInput = new android.support.v7.app.AlertDialog.Builder(this);
|
||||
alertDialogBuilderUserInput.setView(view);
|
||||
|
||||
alertDialogBuilderUserInput.setNegativeButton(R.string.cancel, (dialog, id) -> {
|
||||
// User cancelled the dialog
|
||||
});
|
||||
|
||||
TextView userName = view.findViewById(R.id.userName);
|
||||
TextView status = view.findViewById(R.id.label);
|
||||
|
||||
userName.setText(String.format("%s %s", user.getFirstName(), user.getLastName()));
|
||||
status.setText(String.format("%s ", cordStatus));
|
||||
|
||||
final AlertDialog alertDialog = alertDialogBuilderUserInput.create();
|
||||
|
||||
alertDialog.show();
|
||||
}
|
||||
|
||||
|
||||
private void handleError(Throwable error) {
|
||||
showError(error);
|
||||
}
|
||||
|
||||
|
||||
private void showError(Throwable e) {
|
||||
String message;
|
||||
|
||||
if (e instanceof HttpException) {
|
||||
ResponseBody responseBody = ((HttpException) e).response().errorBody();
|
||||
message = RestApiHelper.getErrorMessage(responseBody);
|
||||
}else {
|
||||
message = "Network Error!";
|
||||
}
|
||||
|
||||
|
||||
Toast.makeText(MapActivity.this, message, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
|
||||
private void setOnMapLongClickListener() {
|
||||
|
||||
final boolean[] cancel = {false};
|
||||
@ -193,7 +237,8 @@ public class MapActivity extends BaseActivity
|
||||
latLng.getLongitude(),
|
||||
latLng.getAltitude(),
|
||||
PrefUtils.getUserFirstName(getApplicationContext()) + " " + PrefUtils.getUserLastName(getApplicationContext()),
|
||||
PrefUtils.getUserId(getApplicationContext())
|
||||
PrefUtils.getUserId(getApplicationContext()),
|
||||
PrefUtils.getLocationLevel(getApplicationContext())
|
||||
);
|
||||
|
||||
disposable.add(
|
||||
@ -330,6 +375,7 @@ public class MapActivity extends BaseActivity
|
||||
|
||||
for (Coordinate element : coordsList) {
|
||||
String id = element.getUserId();
|
||||
String newLabel = element.getLabel();
|
||||
|
||||
Coordinate coordinate = coordsMap.get(id);
|
||||
Log.e(tag, "hashMapSize: " + coordsMap.size());
|
||||
@ -346,6 +392,7 @@ public class MapActivity extends BaseActivity
|
||||
if (!statement) {
|
||||
Log.e(tag, "replace and animate");
|
||||
Marker marker = markerHash.get(id);
|
||||
|
||||
LatLng toDestination = new LatLng(element.getLatitude(), element.getLongitude());
|
||||
// TODO fix flickiering markers
|
||||
ValueAnimator markerAnimator = ObjectAnimator.ofObject(marker, "position",
|
||||
@ -356,23 +403,25 @@ public class MapActivity extends BaseActivity
|
||||
markerAnimator.setInterpolator(new LinearInterpolator());
|
||||
markerAnimator.start();
|
||||
|
||||
|
||||
// chba niepotrzbene
|
||||
mapboxMap.getMarkerViewManager().update();
|
||||
|
||||
|
||||
coordsMap.put(id, element);
|
||||
marker.setPosition(toDestination);
|
||||
|
||||
}
|
||||
} else {
|
||||
|
||||
Log.e(tag, "Marker Added: " + id);
|
||||
|
||||
coordsMap.put(id, element);
|
||||
Marker marker = mapboxMap.addMarker(new MarkerOptions()
|
||||
.title(element.getLabel())
|
||||
.title(id)
|
||||
.position(new LatLng(element.getLatitude(), element.getLongitude())));
|
||||
markerHash.put(id, marker);
|
||||
}
|
||||
|
||||
coordsMap.get(id).setLabel(newLabel);
|
||||
}
|
||||
|
||||
// For next fetch
|
||||
@ -510,7 +559,7 @@ public class MapActivity extends BaseActivity
|
||||
|
||||
permissionsManager = new PermissionsManager(this);
|
||||
permissionsManager.requestLocationPermissions(this);
|
||||
permissionsManager.onRequestPermissionsResult(0, new String[] {Manifest.permission.ACCESS_FINE_LOCATION}, new int[] {0});
|
||||
permissionsManager.onRequestPermissionsResult(0, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, new int[]{0});
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -52,6 +52,13 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
||||
addPreferencesFromResource(R.layout.pref_main);
|
||||
|
||||
Preference languagesList = findPreference(getResources().getString(R.string.key_language));
|
||||
languagesList.setDefaultValue(0);
|
||||
|
||||
if(PrefUtils.getLocale(getActivity()).equals("pl")){
|
||||
languagesList.setDefaultValue(1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
languagesList.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
|
||||
|
@ -14,13 +14,17 @@ import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.uam.wmi.findmytutor.R;
|
||||
import com.uam.wmi.findmytutor.service.BackgroundLocalizationService;
|
||||
import com.uam.wmi.findmytutor.utils.PrefUtils;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
@ -28,25 +32,45 @@ import static com.mapbox.mapboxsdk.Mapbox.getApplicationContext;
|
||||
|
||||
|
||||
public class SharingFragment extends PreferenceFragment {
|
||||
private HashMap<Integer, String> locationLevelMapping;
|
||||
// private HashMap<Integer, String> statusMapping;
|
||||
|
||||
@SuppressLint("ResourceType")
|
||||
@Override
|
||||
public void onCreate(final Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
locationLevelMapping = new HashMap<Integer, String>();
|
||||
locationLevelMapping.put(0,"presence");
|
||||
locationLevelMapping.put(1,"approximated");
|
||||
locationLevelMapping.put(2,"exact");
|
||||
|
||||
addPreferencesFromResource(R.layout.pref_sharing);
|
||||
Preference manualStatus = findPreference("key_manual_status");
|
||||
Preference locationSharing = findPreference("key_sharing_enabled");
|
||||
Preference locationMode = findPreference("key_location_level");
|
||||
Preference statusList = findPreference("key_status_value");
|
||||
|
||||
|
||||
manualStatus.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
ListPreference lp = (ListPreference) findPreference("key_status_value");
|
||||
updateListPreference(lp, newValue, "manual_statuses");
|
||||
return true;
|
||||
});
|
||||
locationMode.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
ListPreference lp = (ListPreference) preference;
|
||||
PrefUtils.storeLocationMode(getApplicationContext(),locationLevelMapping.get(Integer.parseInt((String) newValue)));
|
||||
return true;
|
||||
});
|
||||
statusList.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
ListPreference lp = (ListPreference) preference;
|
||||
CharSequence [] entries = lp.getEntries();
|
||||
PrefUtils.storeStatus(getApplicationContext(),(String) entries[Integer.parseInt((String) newValue)]);
|
||||
return true;
|
||||
});
|
||||
|
||||
locationSharing.setOnPreferenceChangeListener((buttonView, isChecked) -> {
|
||||
PrefUtils.storeEnableSharingLocalization(getApplicationContext(), (Boolean) isChecked);
|
||||
locationSharing.setOnPreferenceChangeListener((buttonView, newValue) -> {
|
||||
PrefUtils.storeEnableSharingLocalization(getApplicationContext(), (Boolean) newValue);
|
||||
((MapActivity)getActivity()).handleBackgroundTaskLifeCycle();
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
@ -64,15 +88,22 @@ public class SharingFragment extends PreferenceFragment {
|
||||
return view;
|
||||
}
|
||||
|
||||
public String getListPreferenceValue(String key){
|
||||
ListPreference lp = (ListPreference) findPreference(key);
|
||||
return (String)lp.getEntry();
|
||||
|
||||
}
|
||||
protected void updateListPreference(ListPreference lp,Object newValue,String storageKey){
|
||||
CharSequence [] entries = lp.getEntries();
|
||||
Set<String> defaultEntries = new HashSet(Arrays.asList(entries));
|
||||
SharedPreferences sharedPref = getActivity().getPreferences(Context.MODE_PRIVATE);
|
||||
|
||||
Set <String> manualStatusSet = sharedPref.getStringSet(storageKey,defaultEntries);
|
||||
manualStatusSet.add((String) newValue);
|
||||
String [] manualStatusArr = manualStatusSet.toArray(new String[0]);
|
||||
Arrays.sort(manualStatusArr);
|
||||
setListPreferenceData(lp.getKey(),manualStatusArr);
|
||||
|
||||
SharedPreferences.Editor editor = sharedPref.edit();
|
||||
editor.putStringSet(storageKey,manualStatusSet);
|
||||
editor.apply();
|
||||
@ -84,7 +115,7 @@ public class SharingFragment extends PreferenceFragment {
|
||||
CharSequence[] entryValues = new CharSequence [entries.length];
|
||||
|
||||
for (int i = 0; i < entries.length; i++){
|
||||
entryValues[i] = Integer.toString(i+1);
|
||||
entryValues[i] = Integer.toString(i);
|
||||
}
|
||||
|
||||
lp.setDefaultValue("1");
|
||||
|
@ -46,8 +46,4 @@ public class StartupActivity extends AppCompatActivity {
|
||||
|
||||
finish();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -105,7 +105,6 @@ public class UsersListFragment extends Fragment {
|
||||
}
|
||||
}));
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void searchUser(String textToSearch) {
|
||||
@ -217,11 +216,13 @@ public class UsersListFragment extends Fragment {
|
||||
}
|
||||
|
||||
private void showError(Throwable e) {
|
||||
String message = e.toString();
|
||||
String message;
|
||||
|
||||
if (e instanceof HttpException) {
|
||||
ResponseBody responseBody = ((HttpException) e).response().errorBody();
|
||||
message = RestApiHelper.getErrorMessage(responseBody);
|
||||
}else{
|
||||
message = "Network Error !";
|
||||
}
|
||||
|
||||
Snackbar.make(coordinatorLayout, message, Snackbar.LENGTH_LONG)
|
||||
|
@ -44,7 +44,7 @@ public class Coordinate extends BaseResponse {
|
||||
@SerializedName("label")
|
||||
private String label;
|
||||
|
||||
public Coordinate (Double latitude, Double longitude, Double altitude, String label, String userId) {
|
||||
public Coordinate (Double latitude, Double longitude, Double altitude, String label, String userId, String displayMode) {
|
||||
//if (!latitudeRange.contains(latitude)) throw new IllegalArgumentException("Inappropriate latitude value" + latitude);
|
||||
//if (!longtitudeRange.contains(longitude)) throw new IllegalArgumentException("Inappropriate longitude value" + longitude);
|
||||
|
||||
@ -53,6 +53,7 @@ public class Coordinate extends BaseResponse {
|
||||
this.altitude = altitude;
|
||||
this.label = label;
|
||||
this.userId = userId;
|
||||
this.displayMode = displayMode;
|
||||
}
|
||||
|
||||
public Coordinate (Double latitude) {
|
||||
|
@ -23,6 +23,9 @@ import android.support.v4.app.ActivityCompat;
|
||||
import android.support.v4.app.NotificationCompat;
|
||||
import android.util.Log;
|
||||
|
||||
import com.google.android.gms.location.FusedLocationProviderClient;
|
||||
import com.google.android.gms.location.LocationServices;
|
||||
import com.google.android.gms.tasks.OnSuccessListener;
|
||||
import com.jakewharton.retrofit2.adapter.rxjava2.HttpException;
|
||||
import com.uam.wmi.findmytutor.model.Coordinate;
|
||||
import com.uam.wmi.findmytutor.network.ApiClient;
|
||||
@ -31,6 +34,7 @@ import com.uam.wmi.findmytutor.utils.RestApiHelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.CompositeDisposable;
|
||||
@ -58,6 +62,7 @@ public class BackgroundLocalizationService extends Service {
|
||||
private Handler mHandler = new Handler();
|
||||
private HandlerThread mHandlerThread = null;
|
||||
private Runnable mStatusChecker;
|
||||
private FusedLocationProviderClient mFusedLocationClient;
|
||||
|
||||
public BackgroundLocalizationService() {
|
||||
providers.add(LocationManager.GPS_PROVIDER);
|
||||
@ -107,6 +112,9 @@ public class BackgroundLocalizationService extends Service {
|
||||
startForeground(1001, notification);
|
||||
}
|
||||
|
||||
mFusedLocationClient = LocationServices.getFusedLocationProviderClient(this);
|
||||
|
||||
|
||||
initializeLocationManager();
|
||||
|
||||
Integer providerIndex = 0;
|
||||
@ -194,8 +202,21 @@ public class BackgroundLocalizationService extends Service {
|
||||
|
||||
Log.e("Best localization:", String.valueOf(bestLocation));
|
||||
|
||||
if (bestLocation != null)
|
||||
/* if (bestLocation != null)
|
||||
fn_update(bestLocation);
|
||||
*/
|
||||
|
||||
mFusedLocationClient.getLastLocation().addOnSuccessListener(
|
||||
new OnSuccessListener<Location>() {
|
||||
@Override
|
||||
public void onSuccess(Location location) {
|
||||
if (location != null) {
|
||||
mLastLocation = location;
|
||||
fn_update(location);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
private void fn_update(Location location) {
|
||||
@ -285,8 +306,9 @@ public class BackgroundLocalizationService extends Service {
|
||||
latitude,
|
||||
longitude,
|
||||
altitude,
|
||||
PrefUtils.getUserFirstName(getApplicationContext()) + " " + PrefUtils.getUserLastName(getApplicationContext()),
|
||||
PrefUtils.getUserId(getApplicationContext())
|
||||
PrefUtils.getUserStatus(getApplicationContext()),
|
||||
PrefUtils.getUserId(getApplicationContext()),
|
||||
PrefUtils.getLocationLevel(getApplicationContext())
|
||||
);
|
||||
|
||||
disposable.add(
|
||||
@ -320,7 +342,5 @@ public class BackgroundLocalizationService extends Service {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -40,7 +40,7 @@ public interface UserService {
|
||||
Single<PagedResultReturnedTutors> getPagedStudents(@Path("pageNum") String pageNum);
|
||||
|
||||
@GET("api/users/{id}")
|
||||
Single<User> getUserByID(@Path("id") String userID);
|
||||
Single <User> getUserById(@Path("id") String userID);
|
||||
|
||||
@PUT("api/users/{id}")
|
||||
Completable updateUserByID(@Path("id") String userID, @Body User user);
|
||||
|
@ -2,8 +2,10 @@ package com.uam.wmi.findmytutor.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.preference.ListPreference;
|
||||
import android.preference.PreferenceFragment;
|
||||
import android.util.Log;
|
||||
|
||||
import com.uam.wmi.findmytutor.activity.SharingFragment;
|
||||
import com.auth0.android.jwt.Claim;
|
||||
import com.auth0.android.jwt.JWT;
|
||||
|
||||
@ -15,10 +17,9 @@ public class PrefUtils {
|
||||
}
|
||||
|
||||
public static SharedPreferences getSharedPreferences(Context context) {
|
||||
return context.getSharedPreferences("APP_PREF", Context.MODE_PRIVATE);
|
||||
return context.getSharedPreferences("com.uam.wmi.findmytutor_preferences", Context.MODE_PRIVATE);
|
||||
}
|
||||
|
||||
|
||||
public static void getAllKeys(Context context){
|
||||
Map<String,?> keys = getSharedPreferences(context).getAll();
|
||||
|
||||
@ -33,9 +34,6 @@ public class PrefUtils {
|
||||
editor.clear().apply();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static void storeApiKey(Context context, String apiKey) {
|
||||
SharedPreferences.Editor editor = getSharedPreferences(context).edit();
|
||||
editor.putString("API_KEY", apiKey);
|
||||
@ -56,9 +54,13 @@ public class PrefUtils {
|
||||
return getSharedPreferences(context).getString("USER_ID", null);
|
||||
}
|
||||
|
||||
|
||||
public static String getUserStatus(Context context) {
|
||||
return getSharedPreferences(context).getString("USER_STATUS", "Android");
|
||||
return getSharedPreferences(context).getString("status_entry", "Available");
|
||||
}
|
||||
public static void storeStatus(Context context, String status){
|
||||
SharedPreferences.Editor editor = getSharedPreferences(context).edit();
|
||||
editor.putString("status_entry", status);
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
public static void storeIsTutor(Context applicationContext, boolean isTutor) {
|
||||
@ -82,12 +84,20 @@ public class PrefUtils {
|
||||
}
|
||||
|
||||
public static boolean isEnableSharingLocalization(Context context) {
|
||||
return getSharedPreferences(context).getBoolean("IS_ENABLE_SHARING_LOCALIZATION", false);
|
||||
return getSharedPreferences(context).getBoolean("key_sharing_enabled", false);
|
||||
}
|
||||
|
||||
public static void storeEnableSharingLocalization(Context context,Boolean isChecked) {
|
||||
SharedPreferences.Editor editor = getSharedPreferences(context).edit();
|
||||
editor.putBoolean("IS_ENABLE_SHARING_LOCALIZATION", isChecked);
|
||||
editor.putBoolean("key_sharing_enabled", isChecked);
|
||||
editor.apply();
|
||||
}
|
||||
public static String getLocationLevel(Context context){
|
||||
return getSharedPreferences(context).getString("location_mode", "exact");
|
||||
}
|
||||
public static void storeLocationMode(Context context, String mode){
|
||||
SharedPreferences.Editor editor = getSharedPreferences(context).edit();
|
||||
editor.putString("location_mode", mode);
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
@ -136,5 +146,4 @@ public class PrefUtils {
|
||||
editor.putBoolean("BACKGROUND_SERVICE_STATUS", status);
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
}
|
BIN
app/src/main/res/drawable-v21/custom_marker.png
Normal file
BIN
app/src/main/res/drawable-v21/custom_marker.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 923 B |
BIN
app/src/main/res/drawable-v24/custom_marker.png
Normal file
BIN
app/src/main/res/drawable-v24/custom_marker.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 923 B |
BIN
app/src/main/res/drawable/custom_marker.png
Normal file
BIN
app/src/main/res/drawable/custom_marker.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 923 B |
4
app/src/main/res/drawable/ic_cancel.xml
Normal file
4
app/src/main/res/drawable/ic_cancel.xml
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
</selector>
|
4
app/src/main/res/drawable/ic_launch.xml
Normal file
4
app/src/main/res/drawable/ic_launch.xml
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
</selector>
|
30
app/src/main/res/layout/marker_modal.xml
Normal file
30
app/src/main/res/layout/marker_modal.xml
Normal file
@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="@dimen/activity_margin"
|
||||
android:paddingTop="@dimen/activity_margin"
|
||||
android:paddingRight="@dimen/activity_margin">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/userName"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/dimen_10"
|
||||
android:fontFamily="sans-serif-medium"
|
||||
android:lineSpacingExtra="8sp"
|
||||
android:textColor="@color/colorAccent"
|
||||
android:textSize="@dimen/lbl_new_note_title"
|
||||
android:textStyle="normal" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/label"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:lineSpacingExtra="8sp"
|
||||
android:paddingTop="5dp"
|
||||
android:textColor="@color/note_list_text"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
@ -5,6 +5,7 @@
|
||||
tools:ignore="MissingDefaultResource"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<PreferenceCategory android:title="@string/settings_category_location">
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
@ -20,6 +21,9 @@
|
||||
android:key="@string/key_location_level"
|
||||
android:summary="%s"
|
||||
android:title="@string/title_location_level" />
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory android:title="@string/settings_category_status">
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:disableDependentsState="false"
|
||||
@ -39,6 +43,9 @@
|
||||
android:singleLine="true"
|
||||
android:title="@string/title_manual_status"
|
||||
/>
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory android:title="@string/settings_category_manuallocation">
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:disableDependentsState="false"
|
||||
@ -47,7 +54,7 @@
|
||||
android:title="@string/manual_location"/>
|
||||
<ListPreference
|
||||
android:defaultValue="1"
|
||||
android:key="manual_location_list_title"
|
||||
android:key="key_manual_location_value"
|
||||
android:entries="@array/manual_location_entries"
|
||||
android:entryValues="@array/manual_location_values"
|
||||
android:summary="%s"
|
||||
@ -58,8 +65,6 @@
|
||||
android:singleLine="true"
|
||||
android:title="@string/title_manual_location"
|
||||
/>
|
||||
|
||||
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
</PreferenceScreen>
|
@ -123,6 +123,11 @@
|
||||
<string name="action_log_in">Zaloguj!</string>
|
||||
<string name="error_invalid_login_name">Niepoprawny format loginu.</string>
|
||||
<string name="user_list_nav">Lista użytkowników</string>
|
||||
<string name="select_a_location">Wybierz lokalizacje</string>
|
||||
<string name="user_location_permission_not_granted">Nie dodano uprawnień do lokalizacji.</string>
|
||||
<string name="user_location_permission_explanation">Ta aplikacja potrzebuje uprawnień do lokalizacji.</string>
|
||||
<string name="settings_category_status">Ustawienia statusu</string>
|
||||
<string name="settings_category_manuallocation">Ręczny wybór lokalizacji</string>
|
||||
</resources>
|
||||
|
||||
|
||||
|
@ -47,6 +47,8 @@
|
||||
<string name="title_sharing">Sharing</string>
|
||||
|
||||
<string name="settings_category_location">Location sharing</string>
|
||||
<string name="settings_category_status">Status settings</string>
|
||||
<string name="settings_category_manuallocation">Manual location override</string>
|
||||
<string name="title_location_level">Sharing level</string>
|
||||
<string name="location_level_presence">Only presence</string>
|
||||
<string name="location_level_approximated">Approximated</string>
|
||||
@ -166,9 +168,9 @@
|
||||
<string name="title_activity_main2">Main2Activity</string>
|
||||
|
||||
<!--PulsingLayerOpacityColorActivity activity-->
|
||||
<string name="fab_title_hotels">Hotels</string>
|
||||
<string name="fab_title_parks">Parks</string>
|
||||
<string name="fab_title_attractions">Attractions</string>
|
||||
<string name="fab_title_hotels">TODO</string>
|
||||
<string name="fab_title_parks">THIS</string>
|
||||
<string name="fab_title_attractions">TOO</string>
|
||||
<string name="select_a_location">Select a location</string>
|
||||
<string name="user_location_permission_explanation">This app needs location permissions in order to show its functionality.</string>
|
||||
<string name="user_location_permission_not_granted">You didn\'t grant location permissions.</string>
|
||||
@ -187,5 +189,10 @@
|
||||
<string name="action_log_in">Log in </string>
|
||||
<string name="user_list_nav">Users list</string>
|
||||
<string name="error_invalid_login_name">Invalid login format.</string>
|
||||
<string name="title_locale_utils">Locale utils</string>
|
||||
<string name="permission_denied_explanation">Permission denied</string>
|
||||
<string name="permission_rationale">permission should be granted</string>
|
||||
<string name="launch_activity" />
|
||||
<string name="remove_location_updates" />
|
||||
|
||||
</resources>
|
||||
|
Loading…
Reference in New Issue
Block a user