Working update
This commit is contained in:
parent
2dda6ef65f
commit
3e44d6c3b4
@ -67,7 +67,6 @@ dependencies {
|
|||||||
implementation 'com.auth0.android:jwtdecode:1.1.1'
|
implementation 'com.auth0.android:jwtdecode:1.1.1'
|
||||||
implementation 'com.annimon:stream:1.2.1'
|
implementation 'com.annimon:stream:1.2.1'
|
||||||
implementation 'com.google.android.gms:play-services-location:16.0.0'
|
implementation 'com.google.android.gms:play-services-location:16.0.0'
|
||||||
// FloatingBarMenu
|
|
||||||
implementation 'com.getbase:floatingactionbutton:1.10.1'
|
implementation 'com.getbase:floatingactionbutton:1.10.1'
|
||||||
implementation 'org.apache.commons:commons-collections4:4.0'
|
implementation 'org.apache.commons:commons-collections4:4.0'
|
||||||
}
|
}
|
||||||
|
@ -148,10 +148,10 @@ public class LoginActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void loginProcess(String email, String password) {
|
private void loginProcess(String email, String password) {
|
||||||
ValidateUser user = new ValidateUser(email, password);
|
//ValidateUser user = new ValidateUser(email, password);
|
||||||
//LdapUser fakeUser = new LdapUser(email, password,"wmi","tutor",email,"Fałszywy",email);
|
LdapUser fakeUser = new LdapUser(email, password,"wmi","tutor",email,"Fałszywy",email);
|
||||||
disposable.add(ldapService.validate(user)
|
// disposable.add(ldapService.validate(user)
|
||||||
//disposable.add(ldapService.fakeValidate(fakeUser)
|
disposable.add(ldapService.fakeValidate(fakeUser)
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(this::handleResponse, this::handleError));
|
.subscribe(this::handleResponse, this::handleError));
|
||||||
|
@ -4,6 +4,7 @@ import android.Manifest;
|
|||||||
import android.animation.ObjectAnimator;
|
import android.animation.ObjectAnimator;
|
||||||
import android.animation.ValueAnimator;
|
import android.animation.ValueAnimator;
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
|
import android.graphics.Color;
|
||||||
import android.location.Location;
|
import android.location.Location;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
@ -24,6 +25,8 @@ import com.getbase.floatingactionbutton.FloatingActionButton;
|
|||||||
import com.jakewharton.retrofit2.adapter.rxjava2.HttpException;
|
import com.jakewharton.retrofit2.adapter.rxjava2.HttpException;
|
||||||
import com.mapbox.android.core.permissions.PermissionsListener;
|
import com.mapbox.android.core.permissions.PermissionsListener;
|
||||||
import com.mapbox.android.core.permissions.PermissionsManager;
|
import com.mapbox.android.core.permissions.PermissionsManager;
|
||||||
|
import com.mapbox.geojson.FeatureCollection;
|
||||||
|
import com.mapbox.geojson.LineString;
|
||||||
import com.mapbox.geojson.Point;
|
import com.mapbox.geojson.Point;
|
||||||
import com.mapbox.mapboxsdk.Mapbox;
|
import com.mapbox.mapboxsdk.Mapbox;
|
||||||
import com.mapbox.mapboxsdk.annotations.Icon;
|
import com.mapbox.mapboxsdk.annotations.Icon;
|
||||||
@ -38,6 +41,10 @@ import com.mapbox.mapboxsdk.location.modes.RenderMode;
|
|||||||
import com.mapbox.mapboxsdk.maps.MapView;
|
import com.mapbox.mapboxsdk.maps.MapView;
|
||||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||||
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
|
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
|
||||||
|
import com.mapbox.mapboxsdk.style.expressions.Expression;
|
||||||
|
import com.mapbox.mapboxsdk.style.layers.CircleLayer;
|
||||||
|
import com.mapbox.mapboxsdk.style.layers.SymbolLayer;
|
||||||
|
import com.mapbox.mapboxsdk.style.sources.GeoJsonSource;
|
||||||
import com.uam.wmi.findmytutor.R;
|
import com.uam.wmi.findmytutor.R;
|
||||||
import com.uam.wmi.findmytutor.model.Coordinate;
|
import com.uam.wmi.findmytutor.model.Coordinate;
|
||||||
import com.uam.wmi.findmytutor.model.PredefinedCoordViewModel;
|
import com.uam.wmi.findmytutor.model.PredefinedCoordViewModel;
|
||||||
@ -67,6 +74,32 @@ import io.reactivex.schedulers.Schedulers;
|
|||||||
import okhttp3.ResponseBody;
|
import okhttp3.ResponseBody;
|
||||||
import timber.log.Timber;
|
import timber.log.Timber;
|
||||||
|
|
||||||
|
import com.mapbox.geojson.Feature;
|
||||||
|
|
||||||
|
import static com.mapbox.mapboxsdk.style.expressions.Expression.all;
|
||||||
|
import static com.mapbox.mapboxsdk.style.expressions.Expression.division;
|
||||||
|
import static com.mapbox.mapboxsdk.style.expressions.Expression.exponential;
|
||||||
|
import static com.mapbox.mapboxsdk.style.expressions.Expression.get;
|
||||||
|
import static com.mapbox.mapboxsdk.style.expressions.Expression.gt;
|
||||||
|
import static com.mapbox.mapboxsdk.style.expressions.Expression.gte;
|
||||||
|
import static com.mapbox.mapboxsdk.style.expressions.Expression.has;
|
||||||
|
import static com.mapbox.mapboxsdk.style.expressions.Expression.interpolate;
|
||||||
|
import static com.mapbox.mapboxsdk.style.expressions.Expression.literal;
|
||||||
|
import static com.mapbox.mapboxsdk.style.expressions.Expression.lt;
|
||||||
|
import static com.mapbox.mapboxsdk.style.expressions.Expression.rgb;
|
||||||
|
import static com.mapbox.mapboxsdk.style.expressions.Expression.stop;
|
||||||
|
import static com.mapbox.mapboxsdk.style.expressions.Expression.toNumber;
|
||||||
|
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.iconColor;
|
||||||
|
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconImage;
|
||||||
|
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconSize;
|
||||||
|
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textAllowOverlap;
|
||||||
|
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textColor;
|
||||||
|
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textField;
|
||||||
|
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textIgnorePlacement;
|
||||||
|
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textSize;
|
||||||
|
|
||||||
public class MapActivity extends BaseActivity
|
public class MapActivity extends BaseActivity
|
||||||
implements PermissionsListener, OnMapReadyCallback {
|
implements PermissionsListener, OnMapReadyCallback {
|
||||||
|
|
||||||
@ -99,6 +132,7 @@ public class MapActivity extends BaseActivity
|
|||||||
private boolean isTutor;
|
private boolean isTutor;
|
||||||
private ApproximatedLocalization approximatedLocalization;
|
private ApproximatedLocalization approximatedLocalization;
|
||||||
private boolean shouldFetchNewCoords = true;
|
private boolean shouldFetchNewCoords = true;
|
||||||
|
private GeoJsonSource geoJsonSource = null;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@ -171,6 +205,8 @@ public class MapActivity extends BaseActivity
|
|||||||
|
|
||||||
setOnMapClickListener();
|
setOnMapClickListener();
|
||||||
MapUtils.setMapBoundsArea(getApplicationContext(), mapboxMap, mapView, true);
|
MapUtils.setMapBoundsArea(getApplicationContext(), mapboxMap, mapView, true);
|
||||||
|
convertMarkersToGeoJson();
|
||||||
|
addClusteredGeoJsonSource();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateUserHashMap(String userId, Long markerId) {
|
private void updateUserHashMap(String userId, Long markerId) {
|
||||||
@ -219,6 +255,32 @@ public class MapActivity extends BaseActivity
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void convertMarkersToGeoJson(){
|
||||||
|
List<Point> coordinates = Stream.of(coordsMap.values())
|
||||||
|
.map(c -> Point.fromLngLat(c.getLongitude(), c.getLatitude()))
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
LineString lineString = LineString.fromLngLats(coordinates);
|
||||||
|
FeatureCollection featureCollection = FeatureCollection.fromFeatures(
|
||||||
|
new Feature[]{Feature.fromGeometry(lineString)});
|
||||||
|
|
||||||
|
geoJsonSource = new GeoJsonSource("markers", featureCollection);
|
||||||
|
mapboxMap.addSource(geoJsonSource);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateGeoJsonSource(){
|
||||||
|
List<Point> coordinates = Stream.of(coordsMap.values())
|
||||||
|
.map(c -> Point.fromLngLat(c.getLongitude(), c.getLatitude()))
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
LineString lineString = LineString.fromLngLats(coordinates);
|
||||||
|
FeatureCollection featureCollection = FeatureCollection.fromFeatures(
|
||||||
|
new Feature[]{Feature.fromGeometry(lineString)});
|
||||||
|
|
||||||
|
geoJsonSource = new GeoJsonSource("markers", featureCollection);
|
||||||
|
}
|
||||||
|
|
||||||
private void handleError(Throwable error) {
|
private void handleError(Throwable error) {
|
||||||
showError(error);
|
showError(error);
|
||||||
}
|
}
|
||||||
@ -307,6 +369,73 @@ public class MapActivity extends BaseActivity
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void addClusteredGeoJsonSource() {
|
||||||
|
|
||||||
|
// Use the earthquakes GeoJSON source to create three layers: One layer for each cluster category.
|
||||||
|
// Each point range gets a different fill color.
|
||||||
|
int[][] layers = new int[][] {
|
||||||
|
new int[] {150, ContextCompat.getColor(this, R.color.mapboxRed)},
|
||||||
|
new int[] {20, ContextCompat.getColor(this, R.color.mapboxGreen)},
|
||||||
|
new int[] {0, ContextCompat.getColor(this, R.color.mapbox_blue)}
|
||||||
|
};
|
||||||
|
|
||||||
|
//Creating a marker layer for single data points
|
||||||
|
SymbolLayer unclustered = new SymbolLayer("unclustered-points", "markers");
|
||||||
|
|
||||||
|
unclustered.setProperties(
|
||||||
|
iconImage("cross-icon-id"),
|
||||||
|
iconSize(
|
||||||
|
division(
|
||||||
|
get("mag"), literal(4.0f)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
iconColor(
|
||||||
|
interpolate(exponential(1), get("mag"),
|
||||||
|
stop(2.0, rgb(0, 255, 0)),
|
||||||
|
stop(4.5, rgb(0, 0, 255)),
|
||||||
|
stop(7.0, rgb(255, 0, 0))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
mapboxMap.addLayer(unclustered);
|
||||||
|
|
||||||
|
for (int i = 0; i < layers.length; i++) {
|
||||||
|
//Add clusters' circles
|
||||||
|
CircleLayer circles = new CircleLayer("cluster-" + i, "markers");
|
||||||
|
circles.setProperties(
|
||||||
|
circleColor(layers[i][1]),
|
||||||
|
circleRadius(18f)
|
||||||
|
);
|
||||||
|
|
||||||
|
Expression pointCount = toNumber(get("point_count"));
|
||||||
|
|
||||||
|
// Add a filter to the cluster layer that hides the circles based on "point_count"
|
||||||
|
circles.setFilter(
|
||||||
|
i == 0
|
||||||
|
? all(has("point_count"),
|
||||||
|
gte(pointCount, literal(layers[i][0]))
|
||||||
|
) : all(has("point_count"),
|
||||||
|
gt(pointCount, literal(layers[i][0])),
|
||||||
|
lt(pointCount, literal(layers[i - 1][0]))
|
||||||
|
)
|
||||||
|
);
|
||||||
|
mapboxMap.addLayer(circles);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Add the count labels
|
||||||
|
SymbolLayer count = new SymbolLayer("count", "markers");
|
||||||
|
count.setProperties(
|
||||||
|
textField(Expression.toString(get("point_count"))),
|
||||||
|
textSize(12f),
|
||||||
|
textColor(Color.WHITE),
|
||||||
|
textIgnorePlacement(true),
|
||||||
|
textAllowOverlap(true)
|
||||||
|
);
|
||||||
|
mapboxMap.addLayer(count);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public void showLocationDialog(LatLng latLng) {
|
public void showLocationDialog(LatLng latLng) {
|
||||||
|
|
||||||
LayoutInflater layoutInflaterAndroid = LayoutInflater.from(getApplicationContext());
|
LayoutInflater layoutInflaterAndroid = LayoutInflater.from(getApplicationContext());
|
||||||
@ -501,6 +630,7 @@ public class MapActivity extends BaseActivity
|
|||||||
// For next fetch
|
// For next fetch
|
||||||
previousCoordsIds.clear();
|
previousCoordsIds.clear();
|
||||||
previousCoordsIds.addAll(currentCoordsIds);
|
previousCoordsIds.addAll(currentCoordsIds);
|
||||||
|
updateGeoJsonSource();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -26,7 +26,7 @@ public class ApiClient {
|
|||||||
private static Retrofit retrofit = null;
|
private static Retrofit retrofit = null;
|
||||||
private static int REQUEST_TIMEOUT = 60;
|
private static int REQUEST_TIMEOUT = 60;
|
||||||
private static OkHttpClient okHttpClient;
|
private static OkHttpClient okHttpClient;
|
||||||
private static final String BASE_URL = "https://s416084.projektstudencki.pl/master/";
|
private static final String BASE_URL = "https://s416084.projektstudencki.pl/develop/";
|
||||||
|
|
||||||
public static Retrofit getClient(Context context) {
|
public static Retrofit getClient(Context context) {
|
||||||
|
|
||||||
|
@ -1,42 +1,23 @@
|
|||||||
package com.uam.wmi.findmytutor.utils;
|
package com.uam.wmi.findmytutor.utils;
|
||||||
|
|
||||||
import android.support.annotation.NonNull;
|
|
||||||
|
|
||||||
import com.google.gson.GsonBuilder;
|
|
||||||
import com.mapbox.geojson.BoundingBox;
|
|
||||||
import com.mapbox.geojson.Feature;
|
import com.mapbox.geojson.Feature;
|
||||||
import com.mapbox.geojson.FeatureCollection;
|
import com.mapbox.geojson.FeatureCollection;
|
||||||
import com.mapbox.geojson.Geometry;
|
|
||||||
import com.mapbox.geojson.Point;
|
import com.mapbox.geojson.Point;
|
||||||
import com.mapbox.geojson.Polygon;
|
import com.mapbox.geojson.Polygon;
|
||||||
import com.mapbox.geojson.gson.BoundingBoxDeserializer;
|
|
||||||
import com.mapbox.geojson.gson.GeoJsonAdapterFactory;
|
|
||||||
import com.mapbox.geojson.gson.GeometryDeserializer;
|
|
||||||
import com.mapbox.geojson.gson.PointDeserializer;
|
|
||||||
import com.mapbox.turf.TurfJoins;
|
import com.mapbox.turf.TurfJoins;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
;
|
|
||||||
|
|
||||||
public class ApproximatedLocalization {
|
public class ApproximatedLocalization {
|
||||||
private FeatureCollection buildingSchema = null;
|
private FeatureCollection buildingSchema = null;
|
||||||
|
|
||||||
public ApproximatedLocalization(String buildingObject) {
|
public ApproximatedLocalization(String buildingObject) {
|
||||||
buildingSchema = fromJson(buildingObject);
|
buildingSchema = FeatureCollection.fromJson(buildingObject);
|
||||||
}
|
|
||||||
|
|
||||||
private FeatureCollection fromJson(@NonNull String json) {
|
|
||||||
GsonBuilder gson = new GsonBuilder();
|
|
||||||
|
|
||||||
gson.registerTypeAdapterFactory(GeoJsonAdapterFactory.create());
|
|
||||||
gson.registerTypeAdapter(Point.class, new PointDeserializer());
|
|
||||||
gson.registerTypeAdapter(Geometry.class, new GeometryDeserializer());
|
|
||||||
gson.registerTypeAdapter(BoundingBox.class, new BoundingBoxDeserializer());
|
|
||||||
|
|
||||||
return gson.create().fromJson(json, FeatureCollection.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getNameOfBuildingPart(Point point) {
|
public String getNameOfBuildingPart(Point point) {
|
||||||
|
@ -9,7 +9,7 @@ public class Const {
|
|||||||
public final static Integer onlineBackgroundLocationInterval = 15000;
|
public final static Integer onlineBackgroundLocationInterval = 15000;
|
||||||
public final static Integer offlineBackgroundLocationInterval = 36000;
|
public final static Integer offlineBackgroundLocationInterval = 36000;
|
||||||
public final static Integer defaultMapZoom = 17;
|
public final static Integer defaultMapZoom = 17;
|
||||||
public final static Integer searchMapZoom = 13;
|
public final static Integer searchMapZoom = 4;
|
||||||
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";
|
||||||
|
@ -42,7 +42,7 @@ public class MapUtils {
|
|||||||
// Map Bounds Area
|
// Map Bounds Area
|
||||||
public static void setZoom(MapboxMap mapboxMap, Integer zoom) {
|
public static void setZoom(MapboxMap mapboxMap, Integer zoom) {
|
||||||
makeNewCamera(mapboxMap, 52.466799, 16.927002, zoom, 0, 0, 1000);
|
makeNewCamera(mapboxMap, 52.466799, 16.927002, zoom, 0, 0, 1000);
|
||||||
mapboxMap.setMinZoomPreference(16); // TODO export to map config
|
mapboxMap.setMinZoomPreference(5); // TODO export to map config
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void makeNewCamera(MapboxMap mapboxMap, double lat, double lon, int zoomParam, int bearingParam, int tiltParam, int duration) {
|
public static void makeNewCamera(MapboxMap mapboxMap, double lat, double lon, int zoomParam, int bearingParam, int tiltParam, int duration) {
|
||||||
|
Loading…
Reference in New Issue
Block a user