Explore nearby pictures (#4910)

* Add map fragment for explore and search

* Create structure of explore map by defining view and user action interfaces to presenter

* Add methods to map start, bottom sheet and permission

* Make the simple map visible

* Imitate methods from nearby map for permission needed and non needed map initialisation operations, however, needs to be tested and reactor

* a level of abstraction

* update media params to include coordinates

* Implement pageable presenter to explore

* Create Root fragment for map and media

* Iplement two presenter one for map operations, the other for pageable operations

* Construct general structure for both explore with search query and just by location

* fix injection issue

* Make default explore work with zoom level

* increase offscreen page limit with newly added fragment

* Make two distinct api calls for search with and without query

* Before trying to use same presenter for both search with and without query

* Add notes for Madhur

* Add Madhur's fixes for binding

* Call serch with and without query from the same spot

* partially solve zoom issue

* Make tab view unswipble while map is being used on search activity

* make viewpager unswipable while map is being used

* Code cleanup and reverting unnecessry edits

* Add search this area methods

* Implement search this area button functionality

* Fix search this area button, current location FAB and bottom attribution UI elements

* Add marker click action

* Solve bookmarkdao injection issue

* Make display bottom sheet details on marker click

* remove label and set bottom sheet behavior

* Remove irrelevan buttons like wikidata and article buttons

* Cancel bookmark feature for commons images for know, needs to be thought

* Add search this area button

* Add location off dialog

* Implement back button for explore map fragment while not on search activity

* Make thumbnails visible, they need some styling though

* Make gridle views even more beautiful

* Remove classes added to support query

* Remove query related code from Reach Activity

* Solve two progressbar issue

* Remove query related ekstra codes

* Remove not needed anymore callback

* Make medai details work

* Remove all old removed code dependencies

* Solve initial load takes too long issue

* Solve current position track

* Add placeholder for possible load issues

* Add red stroke to bitmap

* Add borders to rectangles

* Change media details text to details

* Fix file name extension anf File: prefix

* Fix some code style issues

* Fix some style issues

* Fix style issues

* Fix build issue

* Fix test about etMediaListFromSearch

* Fix test issue with Seacrh Activity

* Fix conflict mark
This commit is contained in:
neslihanturan 2022-04-14 11:28:17 +03:00 committed by GitHub
parent 7655562272
commit ee1bf4b5b6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
28 changed files with 2172 additions and 59 deletions

View file

@ -11,6 +11,8 @@ 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.MapController;
import fr.free.nrw.commons.R;
import fr.free.nrw.commons.location.LatLng;
import fr.free.nrw.commons.utils.UiUtils;
@ -24,7 +26,11 @@ import java.util.Map;
import javax.inject.Inject;
import timber.log.Timber;
public class NearbyController {
import static fr.free.nrw.commons.utils.LengthUtils.computeDistanceBetween;
import static fr.free.nrw.commons.utils.LengthUtils.formatDistanceBetween;
public class NearbyController extends MapController {
private static final int MAX_RESULTS = 1000;
private final NearbyPlaces nearbyPlaces;
public static double currentLocationSearchRadius = 10.0; //in kilometers
@ -223,16 +229,6 @@ public class NearbyController {
return baseMarkerOptions;
}
/**
* We pass this variable as a group of placeList and boundaryCoordinates
*/
public class NearbyPlacesInfo {
public List<Place> placeList; // List of nearby places
public LatLng[] boundaryCoordinates; // Corners of nearby area
public LatLng curLatLng; // Current location when this places are populated
public LatLng searchLatLng; // Search location for finding this places
}
/**
* Updates makerLabelList item isBookmarked value
* @param place place which is bookmarked

View file

@ -7,7 +7,6 @@ import android.os.Parcelable;
import android.text.TextUtils;
import androidx.annotation.Nullable;
import fr.free.nrw.commons.nearby.NearbyController.NearbyPlacesInfo;
import org.apache.commons.lang3.StringUtils;
import fr.free.nrw.commons.location.LatLng;
@ -34,7 +33,19 @@ public class Place implements Parcelable {
public String distance;
public final Sitelinks siteLinks;
private boolean isMonument;
private String thumb;
public Place() {
language = null;
name = null;
label = null;
longDescription = null;
location = null;
category = null;
pic = null;
exists = null;
siteLinks = null;
}
public Place(String language,String name, Label label, String longDescription, LatLng location, String category, Sitelinks siteLinks, String pic, Boolean exists) {
this.language = language;
@ -47,6 +58,20 @@ public class Place implements Parcelable {
this.pic = (pic == null) ? "":pic;
this.exists = exists;
}
public Place(String name, String longDescription, LatLng location, String category, Sitelinks siteLinks, String pic, String thumb) {
this.name = name;
this.longDescription = longDescription;
this.location = location;
this.category = category;
this.siteLinks = siteLinks;
this.pic = (pic == null) ? "":pic;
this.thumb = thumb;
this.language = null;
this.label = null;
this.exists = true;
}
public Place(Parcel in) {
this.language = in.readString();
this.name = in.readString();
@ -269,4 +294,12 @@ public class Place implements Parcelable {
return new Place[size];
}
};
public String getThumb() {
return thumb;
}
public void setThumb(String thumb) {
this.thumb = thumb;
}
}

View file

@ -81,6 +81,7 @@ import com.mapbox.mapboxsdk.maps.UiSettings;
import com.mapbox.pluginscalebar.ScaleBarOptions;
import com.mapbox.pluginscalebar.ScaleBarPlugin;
import fr.free.nrw.commons.CommonsApplication;
import fr.free.nrw.commons.MapController.NearbyPlacesInfo;
import fr.free.nrw.commons.R;
import fr.free.nrw.commons.Utils;
import fr.free.nrw.commons.auth.LoginActivity;
@ -97,7 +98,6 @@ 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.NearbyController.NearbyPlacesInfo;
import fr.free.nrw.commons.nearby.NearbyFilterSearchRecyclerViewAdapter;
import fr.free.nrw.commons.nearby.NearbyFilterState;
import fr.free.nrw.commons.nearby.NearbyMarker;
@ -710,7 +710,6 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
@Override
public void setFilterState() {
Log.d("deneme5","setfilterState");
chipNeedsPhoto.setChecked(NearbyFilterState.getInstance().isNeedPhotoSelected());
chipExists.setChecked(NearbyFilterState.getInstance().isExistsSelected());
chipWlm.setChecked(NearbyFilterState.getInstance().isWlmSelected());
@ -1077,7 +1076,7 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
final fr.free.nrw.commons.location.LatLng curlatLng,
final fr.free.nrw.commons.location.LatLng searchLatLng, @Nullable final String customQuery){
final Observable<NearbyPlacesInfo> nearbyPlacesInfoObservable = Observable
final Observable<NearbyController.NearbyPlacesInfo> nearbyPlacesInfoObservable = Observable
.fromCallable(() -> nearbyController
.loadAttractionsFromLocation(curlatLng, searchLatLng,
false, true, Utils.isMonumentsEnabled(new Date()), customQuery));

View file

@ -196,7 +196,7 @@ public class NearbyParentFragmentPresenter
Timber.d("ADVANCED_QUERY_SEARCH");
lockUnlockNearby(true);
nearbyParentFragmentView.setProgressBarVisibility(true);
LatLng updatedLocationByUser = deriveUpdatedLocationFromSearchQuery(customQuery);
LatLng updatedLocationByUser = LocationUtils.deriveUpdatedLocationFromSearchQuery(customQuery);
if (updatedLocationByUser == null) {
updatedLocationByUser = lastLocation;
}
@ -222,38 +222,6 @@ public class NearbyParentFragmentPresenter
}
}
private LatLng deriveUpdatedLocationFromSearchQuery(String customQuery) {
LatLng latLng = null;
final int indexOfPrefix = customQuery.indexOf("Point(");
if (indexOfPrefix == -1) {
Timber.e("Invalid prefix index - Seems like user has entered an invalid query");
return latLng;
}
final int indexOfSuffix = customQuery.indexOf(")\"", indexOfPrefix);
if (indexOfSuffix == -1) {
Timber.e("Invalid suffix index - Seems like user has entered an invalid query");
return latLng;
}
String latLngString = customQuery.substring(indexOfPrefix+"Point(".length(), indexOfSuffix);
if (latLngString.isEmpty()) {
return null;
}
String latLngArray[] = latLngString.split(" ");
if (latLngArray.length != 2) {
return null;
}
try {
latLng = new LatLng(Double.parseDouble(latLngArray[1].trim()),
Double.parseDouble(latLngArray[0].trim()), 1f);
}catch (Exception e){
Timber.e("Error while parsing user entered lat long: %s", e);
}
return latLng;
}
/**
* Populates places for custom location, should be used for finding nearby places around a
* location where you are not at.