mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-29 13:53:54 +01:00
Removed MapBox related imports (#5631)
* Fixed Grey empty screen at Upload wizard caption step after denying files permission * Empty commit * Fixed loop issue * Created docs for earlier commits * Fixed javadoc * Fixed spaces * Added added basic features to OSM Maps * Added search location feature * Added filter to Open Street Maps * Fixed chipGroup in Open Street Maps * Removed mapBox code * Removed mapBox's code * Reformat code * Reformatted code * Removed rotation feature to map * Removed rotation files and Fixed Marker click problem * Ignored failing tests * Added voice input feature * Fixed test cases * Changed caption and description text * Replaced mapbox to osmdroid in upload activity * Fixed Unit Tests * Made selected marker to be fixed on map * Changed color of map marker * Fixes #5439 by capitalizing first letter of voice input * Removed mapbox code1 * Removed mapbox code2 * Fixed failing tests * Fixed failing due to merging
This commit is contained in:
parent
9041e1bc0c
commit
d112be04db
33 changed files with 261 additions and 831 deletions
|
|
@ -1,26 +1,18 @@
|
|||
package fr.free.nrw.commons.nearby;
|
||||
|
||||
import com.mapbox.mapboxsdk.annotations.Marker;
|
||||
|
||||
/**
|
||||
* This class groups visual map item Marker with the reated data of displayed place and information
|
||||
* of bookmark
|
||||
*/
|
||||
public class MarkerPlaceGroup {
|
||||
private Marker marker; // Marker item from the map
|
||||
private boolean isBookmarked; // True if user bookmarked the place
|
||||
private Place place; // Place of the location displayed by the marker
|
||||
|
||||
public MarkerPlaceGroup(Marker marker, boolean isBookmarked, Place place) {
|
||||
this.marker = marker;
|
||||
public MarkerPlaceGroup(boolean isBookmarked, Place place) {
|
||||
this.isBookmarked = isBookmarked;
|
||||
this.place = place;
|
||||
}
|
||||
|
||||
public Marker getMarker() {
|
||||
return marker;
|
||||
}
|
||||
|
||||
public Place getPlace() {
|
||||
return place;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,93 +0,0 @@
|
|||
package fr.free.nrw.commons.nearby;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import com.mapbox.mapboxsdk.annotations.BaseMarkerOptions;
|
||||
import com.mapbox.mapboxsdk.annotations.Icon;
|
||||
import com.mapbox.mapboxsdk.annotations.IconFactory;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
import java.util.Objects;
|
||||
|
||||
public class NearbyBaseMarker extends BaseMarkerOptions<NearbyMarker, NearbyBaseMarker> {
|
||||
|
||||
public static final Parcelable.Creator<NearbyBaseMarker> CREATOR = new Parcelable.Creator<NearbyBaseMarker>() {
|
||||
@Override
|
||||
public NearbyBaseMarker createFromParcel(Parcel in) {
|
||||
return new NearbyBaseMarker(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NearbyBaseMarker[] newArray(int size) {
|
||||
return new NearbyBaseMarker[size];
|
||||
}
|
||||
};
|
||||
|
||||
private Place place;
|
||||
|
||||
public NearbyBaseMarker() {
|
||||
}
|
||||
|
||||
private NearbyBaseMarker(Parcel in) {
|
||||
position(in.readParcelable(LatLng.class.getClassLoader()));
|
||||
snippet(in.readString());
|
||||
String iconId = in.readString();
|
||||
Bitmap iconBitmap = in.readParcelable(Bitmap.class.getClassLoader());
|
||||
Icon icon = IconFactory.recreate(iconId, iconBitmap);
|
||||
icon(icon);
|
||||
title(in.readString());
|
||||
place(in.readParcelable(Place.class.getClassLoader()));
|
||||
}
|
||||
|
||||
public NearbyBaseMarker place(Place place) {
|
||||
this.place = place;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NearbyBaseMarker getThis() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NearbyMarker getMarker() {
|
||||
return new NearbyMarker(this, place);
|
||||
}
|
||||
|
||||
public Place getPlace() {
|
||||
return place;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeParcelable(position, flags);
|
||||
dest.writeString(snippet);
|
||||
dest.writeString(icon.getId());
|
||||
dest.writeParcelable(icon.getBitmap(), flags);
|
||||
dest.writeString(title);
|
||||
dest.writeParcelable(place, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final NearbyBaseMarker that = (NearbyBaseMarker) o;
|
||||
return Objects.equals(place.location, that.place.location);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(place);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,18 +1,11 @@
|
|||
package fr.free.nrw.commons.nearby;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Bitmap;
|
||||
import androidx.annotation.MainThread;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.vectordrawable.graphics.drawable.VectorDrawableCompat;
|
||||
import com.mapbox.mapboxsdk.annotations.IconFactory;
|
||||
import com.mapbox.mapboxsdk.annotations.Marker;
|
||||
|
||||
import fr.free.nrw.commons.BaseMarker;
|
||||
import fr.free.nrw.commons.MapController;
|
||||
import fr.free.nrw.commons.R;
|
||||
import fr.free.nrw.commons.location.LatLng;
|
||||
import fr.free.nrw.commons.utils.UiUtils;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
|
|
@ -36,8 +29,6 @@ public class NearbyController extends MapController {
|
|||
public static double latestSearchRadius = 10.0; // Any last search radius except closest result search
|
||||
|
||||
public static List<MarkerPlaceGroup> markerLabelList = new ArrayList<>();
|
||||
public static Map<Boolean, Marker> markerExistsMap;
|
||||
public static Map<Boolean, Marker> markerNeedPicMap;
|
||||
|
||||
@Inject
|
||||
public NearbyController(NearbyPlaces nearbyPlaces) {
|
||||
|
|
@ -151,81 +142,33 @@ public class NearbyController extends MapController {
|
|||
* @param placeList list of nearby places in Place data type
|
||||
* @return BaseMarkerOptions list that holds nearby places
|
||||
*/
|
||||
public static List<NearbyBaseMarker> loadAttractionsFromLocationToBaseMarkerOptions(
|
||||
public static List<BaseMarker> loadAttractionsFromLocationToBaseMarkerOptions(
|
||||
LatLng curLatLng,
|
||||
List<Place> placeList,
|
||||
Context context,
|
||||
List<Place> bookmarkplacelist) {
|
||||
List<NearbyBaseMarker> baseMarkerOptions = new ArrayList<>();
|
||||
List<Place> placeList) {
|
||||
List<BaseMarker> baseMarkersList = new ArrayList<>();
|
||||
|
||||
if (placeList == null) {
|
||||
return baseMarkerOptions;
|
||||
return baseMarkersList;
|
||||
}
|
||||
|
||||
placeList = placeList.subList(0, Math.min(placeList.size(), MAX_RESULTS));
|
||||
|
||||
VectorDrawableCompat vectorDrawable = null;
|
||||
VectorDrawableCompat vectorDrawableGreen = null;
|
||||
VectorDrawableCompat vectorDrawableGrey = null;
|
||||
VectorDrawableCompat vectorDrawableMonuments = null;
|
||||
vectorDrawable = null;
|
||||
try {
|
||||
vectorDrawable = VectorDrawableCompat.create(
|
||||
context.getResources(), R.drawable.ic_custom_map_marker, context.getTheme());
|
||||
vectorDrawableGreen = VectorDrawableCompat.create(
|
||||
context.getResources(), R.drawable.ic_custom_map_marker_green, context.getTheme());
|
||||
vectorDrawableGrey = VectorDrawableCompat.create(
|
||||
context.getResources(), R.drawable.ic_custom_map_marker_grey, context.getTheme());
|
||||
vectorDrawableMonuments = VectorDrawableCompat
|
||||
.create(context.getResources(), R.drawable.ic_custom_map_marker_monuments,
|
||||
context.getTheme());
|
||||
} catch (Resources.NotFoundException e) {
|
||||
// ignore when running tests.
|
||||
for (Place place : placeList) {
|
||||
BaseMarker baseMarker = new BaseMarker();
|
||||
String distance = formatDistanceBetween(curLatLng, place.location);
|
||||
place.setDistance(distance);
|
||||
baseMarker.setTitle(place.name);
|
||||
baseMarker.setPosition(
|
||||
new fr.free.nrw.commons.location.LatLng(
|
||||
place.location.getLatitude(),
|
||||
place.location.getLongitude(),0));
|
||||
baseMarker.setPlace(place);
|
||||
baseMarkersList.add(baseMarker);
|
||||
}
|
||||
if (vectorDrawable != null) {
|
||||
Bitmap icon = UiUtils.getBitmap(vectorDrawable);
|
||||
Bitmap iconGreen = UiUtils.getBitmap(vectorDrawableGreen);
|
||||
Bitmap iconGrey = UiUtils.getBitmap(vectorDrawableGrey);
|
||||
Bitmap iconMonuments = UiUtils.getBitmap(vectorDrawableMonuments);
|
||||
|
||||
for (Place place : placeList) {
|
||||
NearbyBaseMarker nearbyBaseMarker = new NearbyBaseMarker();
|
||||
String distance = formatDistanceBetween(curLatLng, place.location);
|
||||
place.setDistance(distance);
|
||||
|
||||
nearbyBaseMarker.title(place.name);
|
||||
nearbyBaseMarker.position(
|
||||
new com.mapbox.mapboxsdk.geometry.LatLng(
|
||||
place.location.getLatitude(),
|
||||
place.location.getLongitude()));
|
||||
nearbyBaseMarker.place(place);
|
||||
// Check if string is only spaces or empty, if so place doesn't have any picture
|
||||
|
||||
if (place.isMonument()) {
|
||||
nearbyBaseMarker.icon(IconFactory.getInstance(context)
|
||||
.fromBitmap(iconMonuments));
|
||||
}
|
||||
else if (!place.pic.trim().isEmpty()) {
|
||||
if (iconGreen != null) {
|
||||
nearbyBaseMarker.icon(IconFactory.getInstance(context)
|
||||
.fromBitmap(iconGreen));
|
||||
}
|
||||
} else if (!place.exists) { // Means that the topic of the Wikidata item does not exist in the real world anymore, for instance it is a past event, or a place that was destroyed
|
||||
if (iconGrey != null) {
|
||||
nearbyBaseMarker.icon(IconFactory.getInstance(context)
|
||||
.fromBitmap(iconGrey));
|
||||
}
|
||||
} else {
|
||||
nearbyBaseMarker.icon(IconFactory.getInstance(context)
|
||||
.fromBitmap(icon));
|
||||
}
|
||||
baseMarkerOptions.add(nearbyBaseMarker);
|
||||
}
|
||||
}
|
||||
|
||||
return baseMarkerOptions;
|
||||
return baseMarkersList;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Updates makerLabelList item isBookmarked value
|
||||
* @param place place which is bookmarked
|
||||
|
|
@ -236,7 +179,7 @@ public class NearbyController extends MapController {
|
|||
for (ListIterator<MarkerPlaceGroup> iter = markerLabelList.listIterator(); iter.hasNext();) {
|
||||
MarkerPlaceGroup markerPlaceGroup = iter.next();
|
||||
if (markerPlaceGroup.getPlace().getWikiDataEntityId().equals(place.getWikiDataEntityId())) {
|
||||
iter.set(new MarkerPlaceGroup(markerPlaceGroup.getMarker(), isBookmarked, place));
|
||||
iter.set(new MarkerPlaceGroup(isBookmarked, place));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,27 +0,0 @@
|
|||
package fr.free.nrw.commons.nearby;
|
||||
|
||||
import com.mapbox.mapboxsdk.annotations.Marker;
|
||||
|
||||
public class NearbyMarker extends Marker {
|
||||
private final Place place;
|
||||
private NearbyBaseMarker nearbyBaseMarker;
|
||||
|
||||
/**
|
||||
* Creates a instance of {@link Marker} using the builder of Marker.
|
||||
*
|
||||
* @param baseMarkerOptions The builder used to construct the Marker.
|
||||
*/
|
||||
NearbyMarker(NearbyBaseMarker baseMarkerOptions, Place place) {
|
||||
super(baseMarkerOptions);
|
||||
this.place = place;
|
||||
this.nearbyBaseMarker = baseMarkerOptions;
|
||||
}
|
||||
|
||||
public NearbyBaseMarker getNearbyBaseMarker() {
|
||||
return nearbyBaseMarker;
|
||||
}
|
||||
|
||||
public Place getPlace() {
|
||||
return place;
|
||||
}
|
||||
}
|
||||
|
|
@ -2,12 +2,11 @@ package fr.free.nrw.commons.nearby.contract;
|
|||
|
||||
import android.content.Context;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.mapbox.mapboxsdk.annotations.Marker;
|
||||
import fr.free.nrw.commons.BaseMarker;
|
||||
import fr.free.nrw.commons.kvstore.JsonKvStore;
|
||||
import fr.free.nrw.commons.location.LatLng;
|
||||
import fr.free.nrw.commons.location.LocationServiceManager.LocationChangeType;
|
||||
import fr.free.nrw.commons.nearby.Label;
|
||||
import fr.free.nrw.commons.nearby.NearbyBaseMarker;
|
||||
import fr.free.nrw.commons.nearby.Place;
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -45,16 +44,12 @@ public interface NearbyParentFragmentContract {
|
|||
|
||||
void hideBottomDetailsSheet();
|
||||
|
||||
void displayBottomSheetWithInfo(Marker marker);
|
||||
|
||||
void addSearchThisAreaButtonAction();
|
||||
|
||||
void setSearchThisAreaButtonVisibility(boolean isVisible);
|
||||
|
||||
void setProgressBarVisibility(boolean isVisible);
|
||||
|
||||
void setTabItemContributions();
|
||||
|
||||
boolean isDetailsBottomSheetVisible();
|
||||
|
||||
void setBottomSheetDetailsSmaller();
|
||||
|
|
@ -75,18 +70,14 @@ public interface NearbyParentFragmentContract {
|
|||
|
||||
void addCurrentLocationMarker(LatLng curLatLng);
|
||||
|
||||
void updateMapToTrackPosition(LatLng curLatLng);
|
||||
|
||||
void clearAllMarkers();
|
||||
|
||||
Context getContext();
|
||||
|
||||
void updateMapMarkers(List<NearbyBaseMarker> nearbyBaseMarkers, Marker selectedMarker);
|
||||
void updateMapMarkers(List<BaseMarker> BaseMarkers);
|
||||
|
||||
void filterOutAllMarkers();
|
||||
|
||||
void displayAllMarkers();
|
||||
|
||||
void filterMarkersByLabels(List<Label> selectedLabels, boolean existsSelected,
|
||||
boolean needPhotoSelected, boolean wlmSelected, boolean filterForPlaceState,
|
||||
boolean filterForAllNoneType);
|
||||
|
|
@ -105,15 +96,9 @@ public interface NearbyParentFragmentContract {
|
|||
|
||||
LatLng getMapFocus();
|
||||
|
||||
com.mapbox.mapboxsdk.geometry.LatLng getLastFocusLocation();
|
||||
|
||||
boolean isCurrentLocationMarkerVisible();
|
||||
|
||||
boolean isAdvancedQueryFragmentVisible();
|
||||
|
||||
void showHideAdvancedQueryFragment(boolean shouldShow);
|
||||
|
||||
void centerMapToPosition(@Nullable LatLng searchLatLng);
|
||||
}
|
||||
|
||||
interface NearbyListView {
|
||||
|
|
@ -137,12 +122,10 @@ public interface NearbyParentFragmentContract {
|
|||
|
||||
boolean backButtonClicked();
|
||||
|
||||
void onCameraMove(com.mapbox.mapboxsdk.geometry.LatLng latLng);
|
||||
|
||||
void filterByMarkerType(List<Label> selectedLabels, int state, boolean filterForPlaceState,
|
||||
boolean filterForAllNoneType);
|
||||
|
||||
void updateMapMarkersToController(List<NearbyBaseMarker> nearbyBaseMarkers);
|
||||
void updateMapMarkersToController(List<BaseMarker> baseMarkers);
|
||||
|
||||
void searchViewGainedFocus();
|
||||
|
||||
|
|
|
|||
|
|
@ -68,9 +68,7 @@ import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
|||
import com.google.android.material.snackbar.Snackbar;
|
||||
import com.jakewharton.rxbinding2.view.RxView;
|
||||
import com.jakewharton.rxbinding3.appcompat.RxSearchView;
|
||||
import com.mapbox.mapboxsdk.annotations.Marker;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLngBounds;
|
||||
import fr.free.nrw.commons.BaseMarker;
|
||||
import fr.free.nrw.commons.CommonsApplication;
|
||||
import fr.free.nrw.commons.MapController.NearbyPlacesInfo;
|
||||
import fr.free.nrw.commons.R;
|
||||
|
|
@ -87,11 +85,9 @@ import fr.free.nrw.commons.location.LocationUpdateListener;
|
|||
import fr.free.nrw.commons.nearby.CheckBoxTriStates;
|
||||
import fr.free.nrw.commons.nearby.Label;
|
||||
import fr.free.nrw.commons.nearby.MarkerPlaceGroup;
|
||||
import fr.free.nrw.commons.nearby.NearbyBaseMarker;
|
||||
import fr.free.nrw.commons.nearby.NearbyController;
|
||||
import fr.free.nrw.commons.nearby.NearbyFilterSearchRecyclerViewAdapter;
|
||||
import fr.free.nrw.commons.nearby.NearbyFilterState;
|
||||
import fr.free.nrw.commons.nearby.NearbyMarker;
|
||||
import fr.free.nrw.commons.nearby.Place;
|
||||
import fr.free.nrw.commons.nearby.contract.NearbyParentFragmentContract;
|
||||
import fr.free.nrw.commons.nearby.fragments.AdvanceQueryFragment.Callback;
|
||||
|
|
@ -100,7 +96,6 @@ import fr.free.nrw.commons.upload.FileUtils;
|
|||
import fr.free.nrw.commons.utils.DialogUtil;
|
||||
import fr.free.nrw.commons.utils.ExecutorUtils;
|
||||
import fr.free.nrw.commons.utils.LayoutUtils;
|
||||
import fr.free.nrw.commons.utils.LocationUtils;
|
||||
import fr.free.nrw.commons.utils.NearbyFABUtils;
|
||||
import fr.free.nrw.commons.utils.NetworkUtils;
|
||||
import fr.free.nrw.commons.utils.PermissionUtils;
|
||||
|
|
@ -259,7 +254,6 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
|||
private NearbyParentFragmentPresenter presenter;
|
||||
private boolean isDarkTheme;
|
||||
private boolean isFABsExpanded;
|
||||
private Marker selectedMarker;
|
||||
private Place selectedPlace;
|
||||
private Place clickedMarkerPlace;
|
||||
private boolean isClickedMarkerBookmarked;
|
||||
|
|
@ -269,12 +263,10 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
|||
private boolean recenterToUserLocation;
|
||||
private GeoPoint mapCenter;
|
||||
IntentFilter intentFilter = new IntentFilter(NETWORK_INTENT_ACTION);
|
||||
private Marker currentLocationMarker;
|
||||
private Place lastPlaceToCenter;
|
||||
private fr.free.nrw.commons.location.LatLng lastKnownLocation;
|
||||
private boolean isVisibleToUser;
|
||||
private fr.free.nrw.commons.location.LatLng lastFocusLocation;
|
||||
private LatLngBounds latLngBounds;
|
||||
private PlaceAdapter adapter;
|
||||
private GeoPoint lastMapFocus;
|
||||
private NearbyParentFragmentInstanceReadyCallback nearbyParentFragmentInstanceReadyCallback;
|
||||
|
|
@ -1060,22 +1052,6 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
|||
return mapFocusedLatLng;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LatLng getLastFocusLocation() {
|
||||
return lastFocusLocation == null ? null
|
||||
: LocationUtils.commonsLatLngToMapBoxLatLng(lastFocusLocation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCurrentLocationMarkerVisible() {
|
||||
if (latLngBounds == null || currentLocationMarker == null) {
|
||||
Timber.d("Map projection bounds are null");
|
||||
return false;
|
||||
} else {
|
||||
return latLngBounds.contains(currentLocationMarker.getPosition());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAdvancedQueryFragmentVisible() {
|
||||
return isAdvancedQueryFragmentVisible;
|
||||
|
|
@ -1088,16 +1064,6 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
|||
isAdvancedQueryFragmentVisible = shouldShow;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void centerMapToPosition(fr.free.nrw.commons.location.LatLng searchLatLng) {
|
||||
if (null != searchLatLng && !(
|
||||
mapView.getMapCenter().getLatitude() == searchLatLng.getLatitude()
|
||||
&& mapView.getMapCenter().getLongitude() == searchLatLng.getLongitude())) {
|
||||
recenterMarkerToPosition(
|
||||
new GeoPoint(searchLatLng.getLatitude(), searchLatLng.getLongitude()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNetworkConnectionEstablished() {
|
||||
return NetworkUtils.isInternetConnectionEstablished(getActivity());
|
||||
|
|
@ -1256,8 +1222,7 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
|||
*/
|
||||
private void updateMapMarkers(final NearbyController.NearbyPlacesInfo nearbyPlacesInfo,
|
||||
final boolean shouldUpdateSelectedMarker) {
|
||||
presenter.updateMapMarkers(nearbyPlacesInfo, selectedMarker, shouldUpdateSelectedMarker);
|
||||
//TODO
|
||||
presenter.updateMapMarkers(nearbyPlacesInfo, shouldUpdateSelectedMarker);
|
||||
setFilterState();
|
||||
}
|
||||
|
||||
|
|
@ -1320,7 +1285,6 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTabItemContributions() {
|
||||
((MainActivity) getActivity()).binding.pager.setCurrentItem(0);
|
||||
// TODO
|
||||
|
|
@ -1492,7 +1456,7 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
|||
* Adds a marker for the user's current position. Adds a circle which uses the accuracy * 2, to
|
||||
* draw a circle which represents the user's position with an accuracy of 95%.
|
||||
* <p>
|
||||
* Should be called only on creation of mapboxMap, there is other method to update markers
|
||||
* Should be called only on creation of Map, there is other method to update markers
|
||||
* location with users move.
|
||||
*
|
||||
* @param curLatLng current location
|
||||
|
|
@ -1510,24 +1474,10 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes map camera follow users location with animation
|
||||
*
|
||||
* @param curLatLng current location of user
|
||||
*/
|
||||
@Override
|
||||
public void updateMapToTrackPosition(final fr.free.nrw.commons.location.LatLng curLatLng) {
|
||||
Timber.d("Updates map camera to track user position");
|
||||
if (null != mapView) {
|
||||
recenterMap(curLatLng);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateMapMarkers(final List<NearbyBaseMarker> nearbyBaseMarkers,
|
||||
final Marker selectedMarker) {
|
||||
public void updateMapMarkers(final List<BaseMarker> BaseMarkers) {
|
||||
if (mapView != null) {
|
||||
presenter.updateMapMarkersToController(nearbyBaseMarkers);
|
||||
presenter.updateMapMarkersToController(BaseMarkers);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1536,17 +1486,6 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
|||
clearAllMarkers();
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays all markers
|
||||
*/
|
||||
@Override
|
||||
public void displayAllMarkers() {
|
||||
for (final MarkerPlaceGroup markerPlaceGroup : NearbyController.markerLabelList) {
|
||||
updateMarker(markerPlaceGroup.getIsBookmarked(), markerPlaceGroup.getPlace(),
|
||||
NearbyController.currentLocation);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters markers based on selectedLabels and chips
|
||||
*
|
||||
|
|
@ -1610,13 +1549,13 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
|||
}
|
||||
}
|
||||
if (selectedLabels == null || selectedLabels.size() == 0) {
|
||||
ArrayList<NearbyBaseMarker> markerArrayList = new ArrayList<>();
|
||||
ArrayList<BaseMarker> markerArrayList = new ArrayList<>();
|
||||
for (final MarkerPlaceGroup markerPlaceGroup : NearbyController.markerLabelList) {
|
||||
NearbyBaseMarker nearbyBaseMarker = new NearbyBaseMarker();
|
||||
nearbyBaseMarker.place(markerPlaceGroup.getPlace());
|
||||
BaseMarker nearbyBaseMarker = new BaseMarker();
|
||||
nearbyBaseMarker.setPlace(markerPlaceGroup.getPlace());
|
||||
markerArrayList.add(nearbyBaseMarker);
|
||||
}
|
||||
addMarkersToMap(markerArrayList, null);
|
||||
addMarkersToMap(markerArrayList);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1727,8 +1666,7 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
|||
* @param nearbyBaseMarkers The list of Place objects containing information about the
|
||||
* locations.
|
||||
*/
|
||||
private void addMarkersToMap(List<NearbyBaseMarker> nearbyBaseMarkers,
|
||||
final Marker selectedMarker) {
|
||||
private void addMarkersToMap(List<BaseMarker> nearbyBaseMarkers) {
|
||||
ArrayList<OverlayItem> items = new ArrayList<>();
|
||||
for (int i = 0; i < nearbyBaseMarkers.size(); i++) {
|
||||
Drawable icon = ContextCompat.getDrawable(getContext(),
|
||||
|
|
@ -1854,16 +1792,6 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
|||
bottomSheetDetailsBehavior.setState(BottomSheetBehavior.STATE_HIDDEN);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void displayBottomSheetWithInfo(final Marker marker) {
|
||||
selectedMarker = marker;
|
||||
final NearbyMarker nearbyMarker = (NearbyMarker) marker;
|
||||
final Place place = nearbyMarker.getNearbyBaseMarker().getPlace();
|
||||
passInfoToSheet(place);
|
||||
hideBottomSheet();
|
||||
bottomSheetDetailsBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
|
||||
}
|
||||
|
||||
/**
|
||||
* If nearby details bottom sheet state is collapsed: show fab plus If nearby details bottom
|
||||
* sheet state is expanded: show fab plus If nearby details bottom sheet state is hidden: hide
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import android.location.Location;
|
|||
import android.view.View;
|
||||
import androidx.annotation.MainThread;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.mapbox.mapboxsdk.annotations.Marker;
|
||||
import fr.free.nrw.commons.BaseMarker;
|
||||
import fr.free.nrw.commons.bookmarks.locations.BookmarkLocationsDao;
|
||||
import fr.free.nrw.commons.kvstore.JsonKvStore;
|
||||
import fr.free.nrw.commons.location.LatLng;
|
||||
|
|
@ -23,14 +23,12 @@ import fr.free.nrw.commons.location.LocationUpdateListener;
|
|||
import fr.free.nrw.commons.nearby.CheckBoxTriStates;
|
||||
import fr.free.nrw.commons.nearby.Label;
|
||||
import fr.free.nrw.commons.nearby.MarkerPlaceGroup;
|
||||
import fr.free.nrw.commons.nearby.NearbyBaseMarker;
|
||||
import fr.free.nrw.commons.nearby.NearbyController;
|
||||
import fr.free.nrw.commons.nearby.NearbyFilterState;
|
||||
import fr.free.nrw.commons.nearby.contract.NearbyParentFragmentContract;
|
||||
import fr.free.nrw.commons.utils.LocationUtils;
|
||||
import fr.free.nrw.commons.wikidata.WikidataEditListener;
|
||||
import java.lang.reflect.Proxy;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import timber.log.Timber;
|
||||
|
||||
|
|
@ -138,12 +136,6 @@ public class NearbyParentFragmentPresenter
|
|||
nearbyParentFragmentView.hideBottomSheet();
|
||||
}
|
||||
|
||||
|
||||
public void markerSelected(Marker marker) {
|
||||
nearbyParentFragmentView.displayBottomSheetWithInfo(marker);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Nearby updates takes time, since they are network operations. During update time, we don't
|
||||
* want to get any other calls from user. So locking nearby.
|
||||
|
|
@ -215,9 +207,6 @@ public class NearbyParentFragmentPresenter
|
|||
nearbyParentFragmentView.populatePlaces(nearbyParentFragmentView.getMapFocus());
|
||||
} else { // Means location changed slightly, ie user is walking or driving.
|
||||
Timber.d("Means location changed slightly");
|
||||
if (nearbyParentFragmentView.isCurrentLocationMarkerVisible()) { // Means user wants to see their live location
|
||||
nearbyParentFragmentView.recenterMap(curLatLng);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -227,17 +216,14 @@ public class NearbyParentFragmentPresenter
|
|||
*
|
||||
* @param nearbyPlacesInfo This variable has placeToCenter list information and distances.
|
||||
*/
|
||||
public void updateMapMarkers(NearbyController.NearbyPlacesInfo nearbyPlacesInfo,
|
||||
Marker selectedMarker, boolean shouldTrackPosition) {
|
||||
public void updateMapMarkers(NearbyController.NearbyPlacesInfo nearbyPlacesInfo, boolean shouldTrackPosition) {
|
||||
if (null != nearbyParentFragmentView) {
|
||||
nearbyParentFragmentView.clearAllMarkers();
|
||||
List<NearbyBaseMarker> nearbyBaseMarkers = NearbyController
|
||||
List<BaseMarker> baseMarkers = NearbyController
|
||||
.loadAttractionsFromLocationToBaseMarkerOptions(nearbyPlacesInfo.curLatLng,
|
||||
// Curlatlang will be used to calculate distances
|
||||
nearbyPlacesInfo.placeList,
|
||||
nearbyParentFragmentView.getContext(),
|
||||
bookmarkLocationDao.getAllBookmarksLocations());
|
||||
nearbyParentFragmentView.updateMapMarkers(nearbyBaseMarkers, selectedMarker);
|
||||
nearbyPlacesInfo.placeList);
|
||||
nearbyParentFragmentView.updateMapMarkers(baseMarkers);
|
||||
lockUnlockNearby(false); // So that new location updates wont come
|
||||
nearbyParentFragmentView.setProgressBarVisibility(false);
|
||||
nearbyParentFragmentView.updateListFragment(nearbyPlacesInfo.placeList);
|
||||
|
|
@ -277,24 +263,6 @@ public class NearbyParentFragmentPresenter
|
|||
Timber.d("Location changed medium");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCameraMove(com.mapbox.mapboxsdk.geometry.LatLng latLng) {
|
||||
// If our nearby markers are calculated at least once
|
||||
if (NearbyController.latestSearchLocation != null) {
|
||||
double distance = latLng.distanceTo
|
||||
(LocationUtils.commonsLatLngToMapBoxLatLng(NearbyController.latestSearchLocation));
|
||||
if (nearbyParentFragmentView.isNetworkConnectionEstablished()) {
|
||||
if (distance > NearbyController.latestSearchRadius) {
|
||||
//nearbyParentFragmentView.setSearchThisAreaButtonVisibility(true);
|
||||
} else {
|
||||
nearbyParentFragmentView.setSearchThisAreaButtonVisibility(false);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
nearbyParentFragmentView.setSearchThisAreaButtonVisibility(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void filterByMarkerType(List<Label> selectedLabels, int state,
|
||||
boolean filterForPlaceState, boolean filterForAllNoneType) {
|
||||
|
|
@ -329,23 +297,14 @@ public class NearbyParentFragmentPresenter
|
|||
|
||||
@Override
|
||||
@MainThread
|
||||
public void updateMapMarkersToController(List<NearbyBaseMarker> nearbyBaseMarkers) {
|
||||
NearbyController.markerExistsMap = new HashMap<>();
|
||||
NearbyController.markerNeedPicMap = new HashMap<>();
|
||||
public void updateMapMarkersToController(List<BaseMarker> baseMarkers) {
|
||||
NearbyController.markerLabelList.clear();
|
||||
for (int i = 0; i < nearbyBaseMarkers.size(); i++) {
|
||||
NearbyBaseMarker nearbyBaseMarker = nearbyBaseMarkers.get(i);
|
||||
for (int i = 0; i < baseMarkers.size(); i++) {
|
||||
BaseMarker nearbyBaseMarker = baseMarkers.get(i);
|
||||
NearbyController.markerLabelList.add(
|
||||
new MarkerPlaceGroup(nearbyBaseMarker.getMarker(),
|
||||
new MarkerPlaceGroup(
|
||||
bookmarkLocationDao.findBookmarkLocation(nearbyBaseMarker.getPlace()),
|
||||
nearbyBaseMarker.getPlace()));
|
||||
//TODO: fix bookmark location
|
||||
NearbyController.markerExistsMap.put(
|
||||
(nearbyBaseMarkers.get(i).getPlace().hasWikidataLink()),
|
||||
nearbyBaseMarkers.get(i).getMarker());
|
||||
NearbyController.markerNeedPicMap.put(
|
||||
((nearbyBaseMarkers.get(i).getPlace().pic == null) ? true : false),
|
||||
nearbyBaseMarkers.get(i).getMarker());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -414,14 +373,4 @@ public class NearbyParentFragmentPresenter
|
|||
initializeMapOperations();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean areLocationsClose(LatLng cameraTarget, LatLng lastKnownLocation) {
|
||||
double distance = LocationUtils.commonsLatLngToMapBoxLatLng(cameraTarget)
|
||||
.distanceTo(LocationUtils.commonsLatLngToMapBoxLatLng(lastKnownLocation));
|
||||
if (distance > NearbyController.currentLocationSearchRadius * 3 / 4) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue