button add rm manual location quick fix #44

Merged
s411201 merged 1 commits from mapManualLocation into develop 2018-11-22 12:45:13 +01:00
3 changed files with 14 additions and 19 deletions

View File

@ -10,7 +10,7 @@ android {
applicationId "com.uam.wmi.findmytutor"
minSdkVersion 22
targetSdkVersion 27
versionCode 1
versionCode 3
versionName "0.9.0-alpha"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true

View File

@ -4,8 +4,6 @@ import android.Manifest;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.SharedPreferences;
import android.location.Location;
import android.os.Bundle;
import android.os.Handler;
@ -80,7 +78,7 @@ public class MapActivity extends BaseActivity
private MapView mapView;
private MapboxMap mapboxMap;
private Button selectLocationButton;
private Marker droppedMarker;
private Button removeLocationButton;
private Marker tmpLocalMarker;
private Coordinate droppedMarkercoordinate;
private HashMap<String, Coordinate> coordsMap = new HashMap<>();
@ -97,7 +95,6 @@ public class MapActivity extends BaseActivity
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final SharedPreferences sharedPref = getSharedPreferences("fmtPrefs", Context.MODE_PRIVATE);
myID = PrefUtils.getUserId(getApplicationContext());
// fetching coords service
@ -119,7 +116,7 @@ public class MapActivity extends BaseActivity
Bundle extras = getIntent().getExtras();
selectLocationButton = findViewById(R.id.select_location_button);
removeLocationButton = findViewById(R.id.remove_location_button);
Mapbox.getInstance(this, getString(R.string.access_token));
mapView = findViewById(R.id.mapView);
mapView.onCreate(savedInstanceState);
@ -138,15 +135,15 @@ public class MapActivity extends BaseActivity
mapboxMap.setOnMarkerClickListener(marker -> {
String id = marker.getTitle();
if (id.equals(myID)) {
Log.e(tag + "Manual", "my own marker from API");
Button rmButton = findViewById(R.id.remove_location_button);
rmButton.setVisibility(View.VISIBLE);
rmButton.setOnClickListener(view -> {
selectLocationButton.setVisibility(View.GONE);
removeLocationButton.setVisibility(View.VISIBLE);
removeLocationButton.setOnClickListener(view -> {
Log.e(tag + "Manual", "manual coords sending stopped");
// TODO to remove after BGserv
manualLocHandler.removeCallbacks(manualLocStatusChecker);
rmButton.setVisibility(View.GONE);
removeLocationButton.setVisibility(View.GONE);
Toast.makeText(MapActivity.this, "Your marker will disappear in next couple minutes", Toast.LENGTH_SHORT).show();
});
@ -235,6 +232,7 @@ public class MapActivity extends BaseActivity
mapboxMap.addOnMapLongClickListener((LatLng latLng) -> {
selectLocationButton.setVisibility(View.VISIBLE);
removeLocationButton.setVisibility(View.GONE);
Icon icon = IconFactory.getInstance(MapActivity.this).fromResource(R.drawable.green_marker);
if (tmpLocalMarker == null) {
@ -336,12 +334,7 @@ public class MapActivity extends BaseActivity
public void onSuccess(List<Coordinate> coordsList) {
if (coordsList.isEmpty() && droppedMarker == null) {
Timber.e("200 empty []");
mapboxMap.clear();
}
if (coordsList.isEmpty()) {
if (coordsList.isEmpty() && tmpLocalMarker != null) {
Timber.e("200 empty []");
mapboxMap.clear();
return;

View File

@ -38,11 +38,11 @@ public class mapUtils {
mapboxMap.setLatLngBoundsForCameraTarget(WMI_BOUNDS);
makeNewCamera(mapboxMap, 52.466799, 16.927002, 17, 0, 0, 4000);
mapboxMap.setMinZoomPreference(16); // TODO export to map config
// drawBoundsArea(context, mapboxMap, mapView, check);
drawBoundsArea(context, mapboxMap, mapView, check);
} else {
mapboxMap.setLatLngBoundsForCameraTarget(null);
mapboxMap.setMinZoomPreference(2);
// drawBoundsArea(context, mapboxMap, mapView, check);
drawBoundsArea(context, mapboxMap, mapView, check);
}
}
@ -59,6 +59,8 @@ public class mapUtils {
private static View crosshair;
private static void drawBoundsArea(Context context, MapboxMap mapboxMap, MapView mapView, Boolean check) {
if (check) {
// Visualise bounds area
// showBoundsArea