Skip to content

Replace Mapbox with OSMDroid (Explore Activity) #5475

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 51 commits into from
Jan 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
b6a2151
Fixed Grey empty screen at Upload wizard caption step after denying f…
kanahia1 Oct 20, 2023
f916e1f
Empty commit
kanahia1 Oct 20, 2023
b75193b
Merge remote-tracking branch 'origin/main'
kanahia1 Oct 20, 2023
98473a1
Fixed loop issue
kanahia1 Oct 20, 2023
f5f050e
Created docs for earlier commits
kanahia1 Oct 21, 2023
1b3bd3d
Fixed javadoc
kanahia1 Oct 21, 2023
9a9e285
Merge branch 'commons-app:main' into main
kanahia1 Nov 1, 2023
896c1d9
Fixed spaces
kanahia1 Nov 1, 2023
5ae7550
Merge branch 'commons-app:main' into main
kanahia1 Nov 19, 2023
365dd76
Added added basic features to OSM Maps
kanahia1 Nov 19, 2023
4ffafd8
Added search location feature
kanahia1 Dec 11, 2023
2e3d690
Added filter to Open Street Maps
kanahia1 Dec 12, 2023
59d21d2
Fixed chipGroup in Open Street Maps
kanahia1 Dec 13, 2023
ac453df
Removed mapBox code
kanahia1 Dec 13, 2023
ad564d3
Merge branch 'commons-app:main' into main
kanahia1 Dec 14, 2023
a6cbb27
Removed mapBox's code
kanahia1 Dec 14, 2023
0cedf17
Reformat code
kanahia1 Dec 14, 2023
9919ac5
Reformatted code
kanahia1 Dec 14, 2023
e0e0850
Removed rotation feature to map
kanahia1 Dec 16, 2023
3a6365f
Removed rotation files and Fixed Marker click problem
kanahia1 Dec 23, 2023
a017314
Merge branch 'main' into main
kanahia1 Dec 23, 2023
3069518
Ignored failing tests
kanahia1 Dec 23, 2023
fc1855c
Added voice input feature
kanahia1 Dec 31, 2023
7fdd88f
Merge remote-tracking branch 'origin/main'
kanahia1 Dec 31, 2023
78666c6
Fixed test cases
kanahia1 Dec 31, 2023
c9ae0d9
Merge branch 'commons-app:main' into main
kanahia1 Jan 3, 2024
3972967
Merge branch 'commons-app:main' into main
kanahia1 Jan 3, 2024
0dc6b11
Changed caption and description text
kanahia1 Jan 3, 2024
bcda966
Merge branch 'main' into main
kanahia1 Jan 5, 2024
23459cb
Merge branch 'commons-app:main' into main
kanahia1 Jan 13, 2024
21c0a0a
Merge branch 'commons-app:main' into main
kanahia1 Jan 14, 2024
e81f621
Replaced mapbox to osmdroid in upload activity
kanahia1 Jan 15, 2024
23717c3
Merge branch 'commons-app:main' into main
kanahia1 Jan 15, 2024
1d091f4
Merge remote-tracking branch 'origin/main'
kanahia1 Jan 15, 2024
c6f7e6f
Fixed Unit Tests
kanahia1 Jan 15, 2024
cb6dfb7
Made selected marker to be fixed on map
kanahia1 Jan 16, 2024
9814bfe
Changed color of map marker
kanahia1 Jan 17, 2024
3ac441c
Merge branch 'commons-app:main' into main
kanahia1 Jan 17, 2024
a6e855e
Fixes #5439 by capitalizing first letter of voice input
kanahia1 Jan 17, 2024
bf1f2e3
Merge branch 'main' into main
kanahia1 Jan 18, 2024
8179eed
Merge remote-tracking branch 'origin/main'
kanahia1 Jan 18, 2024
8c83306
Merge branch 'commons-app:main' into main
kanahia1 Jan 18, 2024
94a5df8
Merge remote-tracking branch 'origin/main'
kanahia1 Jan 18, 2024
ad3d128
Made UI changes in UploadMediaDetailAdapter
kanahia1 Jan 22, 2024
49a4812
Merge branch 'issue5388' of https://github.com/kanahia1/apps-android-…
kanahia1 Jan 22, 2024
f425ead
Added javadoc
kanahia1 Jan 23, 2024
5331e89
Merge branch 'main' into issue5388
nicolas-raoul Jan 23, 2024
62c10a3
Merge branch 'commons-app:main' into issue5388
kanahia1 Jan 23, 2024
9fb48f6
Merge branch 'commons-app:main' into issue5388
kanahia1 Jan 24, 2024
c05779f
Replaced Mapbox with OSMDroid in explore activity
kanahia1 Jan 24, 2024
181d0e6
Merge branch 'main' into issue5458
kanahia1 Jan 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,32 +14,27 @@ public class ExploreMapContract {

interface View {
boolean isNetworkConnectionEstablished();
void populatePlaces(LatLng curlatLng,LatLng searchLatLng);
void populatePlaces(LatLng curlatLng);
void checkPermissionsAndPerformAction();
void recenterMap(LatLng curLatLng);
void showLocationOffDialog();
void openLocationSettings();
void hideBottomDetailsSheet();
void displayBottomSheetWithInfo(Marker marker);
void addOnCameraMoveListener();
LatLng getMapCenter();
LatLng getMapFocus();
LatLng getLastMapFocus();
void addMarkersToMap(final List<NearbyBaseMarker> nearbyBaseMarkers);
void clearAllMarkers();
void addSearchThisAreaButtonAction();
void setSearchThisAreaButtonVisibility(boolean isVisible);
void setProgressBarVisibility(boolean isVisible);
boolean isDetailsBottomSheetVisible();
boolean isSearchThisAreaButtonVisible();
void addCurrentLocationMarker(LatLng curLatLng);
void updateMapToTrackPosition(LatLng curLatLng);
Context getContext();
LatLng getCameraTarget();
void centerMapToPlace(Place placeToCenter);
LatLng getLastLocation();
com.mapbox.mapboxsdk.geometry.LatLng getLastFocusLocation();
boolean isCurrentLocationMarkerVisible();
void setProjectorLatLngBounds();
void disableFABRecenter();
void enableFABRecenter();
void addNearbyMarkersToMapBoxMap(final List<NearbyBaseMarker> nearbyBaseMarkers, final Marker selectedMarker);
void setMapBoundaries(CameraUpdate cameaUpdate);
void setFABRecenterAction(android.view.View.OnClickListener onClickListener);
boolean backButtonClicked();
}
Expand All @@ -51,9 +46,6 @@ interface UserActions {
void detachView();
void setActionListeners(JsonKvStore applicationKvStore);
boolean backButtonClicked();
void onCameraMove(com.mapbox.mapboxsdk.geometry.LatLng latLng);
void markerUnselected();
void markerSelected(Marker marker);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import timber.log.Timber;

public class ExploreMapController extends MapController {

private final ExploreMapCalls exploreMapCalls;
public LatLng latestSearchLocation; // Can be current and camera target on search this area button is used
public LatLng currentLocation; // current location of user
Expand All @@ -46,13 +47,18 @@ public ExploreMapController(ExploreMapCalls explorePlaces) {
}

/**
* Takes location as parameter and returns ExplorePlaces info that holds curLatLng, mediaList, explorePlaceList and boundaryCoordinates
* @param curLatLng is current geolocation
* @param searchLatLng is the location that we want to search around
* @param checkingAroundCurrentLocation is a boolean flag. True if we want to check around current location, false if another location
* @return explorePlacesInfo info that holds curLatLng, mediaList, explorePlaceList and boundaryCoordinates
* Takes location as parameter and returns ExplorePlaces info that holds curLatLng, mediaList,
* explorePlaceList and boundaryCoordinates
*
* @param curLatLng is current geolocation
* @param searchLatLng is the location that we want to search around
* @param checkingAroundCurrentLocation is a boolean flag. True if we want to check around
* current location, false if another location
* @return explorePlacesInfo info that holds curLatLng, mediaList, explorePlaceList and
* boundaryCoordinates
*/
public ExplorePlacesInfo loadAttractionsFromLocation(LatLng curLatLng, LatLng searchLatLng, boolean checkingAroundCurrentLocation) {
public ExplorePlacesInfo loadAttractionsFromLocation(LatLng curLatLng, LatLng searchLatLng,
boolean checkingAroundCurrentLocation) {

if (searchLatLng == null) {
Timber.d("Loading attractions explore map, but search is null");
Expand All @@ -74,18 +80,23 @@ public ExplorePlacesInfo loadAttractionsFromLocation(LatLng curLatLng, LatLng se
Timber.d("Sorting places by distance...");
final Map<Media, Double> distances = new HashMap<>();
for (Media media : mediaList) {
distances.put(media, computeDistanceBetween(media.getCoordinates(), searchLatLng));
distances.put(media,
computeDistanceBetween(media.getCoordinates(), searchLatLng));
// Find boundaries with basic find max approach
if (media.getCoordinates().getLatitude() < boundaryCoordinates[0].getLatitude()) {
if (media.getCoordinates().getLatitude()
< boundaryCoordinates[0].getLatitude()) {
boundaryCoordinates[0] = media.getCoordinates();
}
if (media.getCoordinates().getLatitude() > boundaryCoordinates[1].getLatitude()) {
if (media.getCoordinates().getLatitude()
> boundaryCoordinates[1].getLatitude()) {
boundaryCoordinates[1] = media.getCoordinates();
}
if (media.getCoordinates().getLongitude() < boundaryCoordinates[2].getLongitude()) {
if (media.getCoordinates().getLongitude()
< boundaryCoordinates[2].getLongitude()) {
boundaryCoordinates[2] = media.getCoordinates();
}
if (media.getCoordinates().getLongitude() > boundaryCoordinates[3].getLongitude()) {
if (media.getCoordinates().getLongitude()
> boundaryCoordinates[3].getLongitude()) {
boundaryCoordinates[3] = media.getCoordinates();
}
}
Expand All @@ -96,7 +107,8 @@ public ExplorePlacesInfo loadAttractionsFromLocation(LatLng curLatLng, LatLng se

// Sets latestSearchRadius to maximum distance among boundaries and search location
for (LatLng bound : boundaryCoordinates) {
double distance = LocationUtils.commonsLatLngToMapBoxLatLng(bound).distanceTo(LocationUtils.commonsLatLngToMapBoxLatLng(latestSearchLocation));
double distance = LocationUtils.commonsLatLngToMapBoxLatLng(bound)
.distanceTo(LocationUtils.commonsLatLngToMapBoxLatLng(latestSearchLocation));
if (distance > latestSearchRadius) {
latestSearchRadius = distance;
}
Expand All @@ -115,6 +127,7 @@ public ExplorePlacesInfo loadAttractionsFromLocation(LatLng curLatLng, LatLng se

/**
* Loads attractions from location for map view, we need to return places in Place data type
*
* @return baseMarkerOptions list that holds nearby places with their icons
*/
public static List<NearbyBaseMarker> loadAttractionsFromLocationToBaseMarkerOptions(
Expand All @@ -123,7 +136,6 @@ public static List<NearbyBaseMarker> loadAttractionsFromLocationToBaseMarkerOpti
Context context,
NearbyBaseMarkerThumbCallback callback,
Marker selectedMarker,
boolean shouldTrackPosition,
ExplorePlacesInfo explorePlacesInfo) {
List<NearbyBaseMarker> baseMarkerOptions = new ArrayList<>();

Expand All @@ -145,7 +157,8 @@ public static List<NearbyBaseMarker> loadAttractionsFromLocationToBaseMarkerOpti
String distance = formatDistanceBetween(curLatLng, explorePlace.location);
explorePlace.setDistance(distance);

nearbyBaseMarker.title(explorePlace.name.substring(5, explorePlace.name.lastIndexOf(".")));
nearbyBaseMarker.title(
explorePlace.name.substring(5, explorePlace.name.lastIndexOf(".")));
nearbyBaseMarker.position(
new com.mapbox.mapboxsdk.geometry.LatLng(
explorePlace.location.getLatitude(),
Expand All @@ -160,12 +173,15 @@ public static List<NearbyBaseMarker> loadAttractionsFromLocationToBaseMarkerOpti
.into(new CustomTarget<Bitmap>() {
// We add icons to markers when bitmaps are ready
@Override
public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
public void onResourceReady(@NonNull Bitmap resource,
@Nullable Transition<? super Bitmap> transition) {
nearbyBaseMarker.setIcon(IconFactory.getInstance(context).fromBitmap(
ImageUtils.addRedBorder(resource, 6, context)));
baseMarkerOptions.add(nearbyBaseMarker);
if (baseMarkerOptions.size() == placeList.size()) { // if true, we added all markers to list and can trigger thumbs ready callback
callback.onNearbyBaseMarkerThumbsReady(baseMarkerOptions, explorePlacesInfo, selectedMarker, shouldTrackPosition);
if (baseMarkerOptions.size()
== placeList.size()) { // if true, we added all markers to list and can trigger thumbs ready callback
callback.onNearbyBaseMarkerThumbsReady(baseMarkerOptions,
explorePlacesInfo, selectedMarker);
}
}

Expand All @@ -177,10 +193,13 @@ public void onLoadCleared(@Nullable Drawable placeholder) {
@Override
public void onLoadFailed(@Nullable final Drawable errorDrawable) {
super.onLoadFailed(errorDrawable);
nearbyBaseMarker.setIcon(IconFactory.getInstance(context).fromResource(R.drawable.image_placeholder_96));
nearbyBaseMarker.setIcon(IconFactory.getInstance(context)
.fromResource(R.drawable.image_placeholder_96));
baseMarkerOptions.add(nearbyBaseMarker);
if (baseMarkerOptions.size() == placeList.size()) { // if true, we added all markers to list and can trigger thumbs ready callback
callback.onNearbyBaseMarkerThumbsReady(baseMarkerOptions, explorePlacesInfo, selectedMarker, shouldTrackPosition);
if (baseMarkerOptions.size()
== placeList.size()) { // if true, we added all markers to list and can trigger thumbs ready callback
callback.onNearbyBaseMarkerThumbsReady(baseMarkerOptions,
explorePlacesInfo, selectedMarker);
}
}
});
Expand All @@ -190,7 +209,9 @@ public void onLoadFailed(@Nullable final Drawable errorDrawable) {
}

interface NearbyBaseMarkerThumbCallback {

// Callback to notify thumbnails of explore markers are added as icons and ready
void onNearbyBaseMarkerThumbsReady(List<NearbyBaseMarker> baseMarkers, ExplorePlacesInfo explorePlacesInfo, Marker selectedMarker, boolean shouldTrackPosition);
void onNearbyBaseMarkerThumbsReady(List<NearbyBaseMarker> baseMarkers,
ExplorePlacesInfo explorePlacesInfo, Marker selectedMarker);
}
}
Loading