Skip to content

Removed MapBox related imports #5631

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
Mar 21, 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
cd69c81
Fixes #5439 by capitalizing first letter of voice input
kanahia1 Jan 17, 2024
c5bf7ff
Merge branch 'main' into issue5439
kanahia1 Jan 18, 2024
23626d2
Merge branch 'main' into issue5439
kanahia1 Jan 18, 2024
bd6e039
Merge branch 'main' into issue5439
kanahia1 Jan 18, 2024
bcca120
Merge branch 'commons-app:main' into issue5439
kanahia1 Mar 17, 2024
1df5e2c
Merge remote-tracking branch 'origin/issue5439' into issues5439
kanahia1 Mar 17, 2024
9380f47
Merge branch 'commons-app:main' into issue5439
kanahia1 Mar 18, 2024
e26d270
Merge remote-tracking branch 'origin/issue5439' into issues5439
kanahia1 Mar 18, 2024
6b9f261
Removed mapbox code1
kanahia1 Mar 19, 2024
1ed9064
Removed mapbox code2
kanahia1 Mar 19, 2024
60138b5
Fixed failing tests
kanahia1 Mar 19, 2024
a0ef312
Merge branch 'main' into issues5439
kanahia1 Mar 20, 2024
dd31041
Fixed failing due to merging
kanahia1 Mar 20, 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
64 changes: 64 additions & 0 deletions app/src/main/java/fr/free/nrw/commons/BaseMarker.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package fr.free.nrw.commons

import android.content.Context
import android.graphics.Bitmap
import android.graphics.Canvas
import android.graphics.drawable.BitmapDrawable
import android.graphics.drawable.Drawable
import fr.free.nrw.commons.location.LatLng
import fr.free.nrw.commons.nearby.Place

class BaseMarker {
private var _position: LatLng = LatLng(0.0, 0.0, 0f)
private var _title: String = ""
private var _place: Place = Place()
private var _icon: Bitmap? = null

var position: LatLng
get() = _position
set(value) {
_position = value
}
var title: String
get() = _title
set(value) {
_title = value
}

var place: Place
get() = _place
set(value) {
_place = value
}
var icon: Bitmap?
get() = _icon
set(value) {
_icon = value
}

constructor() {
}

fun fromResource(context: Context, drawableResId: Int) {
val drawable: Drawable = context.resources.getDrawable(drawableResId)
icon = if (drawable is BitmapDrawable) {
(drawable as BitmapDrawable).bitmap
} else {
val bitmap = Bitmap.createBitmap(
drawable.intrinsicWidth,
drawable.intrinsicHeight, Bitmap.Config.ARGB_8888
)
val canvas = Canvas(bitmap)
drawable.setBounds(0, 0, canvas.width, canvas.height)
drawable.draw(canvas)
bitmap
}
}
}







33 changes: 33 additions & 0 deletions app/src/main/java/fr/free/nrw/commons/CameraPosition.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package fr.free.nrw.commons

import android.os.Parcel
import android.os.Parcelable

class CameraPosition(val latitude: Double, val longitude: Double, val zoom: Double) : Parcelable {

constructor(parcel: Parcel) : this(
parcel.readDouble(),
parcel.readDouble(),
parcel.readDouble()
)

override fun writeToParcel(parcel: Parcel, flags: Int) {
parcel.writeDouble(latitude)
parcel.writeDouble(longitude)
parcel.writeDouble(zoom)
}

override fun describeContents(): Int {
return 0
}

companion object CREATOR : Parcelable.Creator<CameraPosition> {
override fun createFromParcel(parcel: Parcel): CameraPosition {
return CameraPosition(parcel)
}

override fun newArray(size: Int): Array<CameraPosition?> {
return arrayOfNulls(size)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import android.app.Activity;
import android.content.Intent;
import com.mapbox.mapboxsdk.camera.CameraPosition;
import fr.free.nrw.commons.CameraPosition;
import fr.free.nrw.commons.Media;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.core.content.ContextCompat;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.mapbox.mapboxsdk.camera.CameraPosition;
import com.mapbox.mapboxsdk.geometry.LatLng;
import fr.free.nrw.commons.CameraPosition;
import fr.free.nrw.commons.Media;
import fr.free.nrw.commons.R;
import fr.free.nrw.commons.Utils;
Expand All @@ -43,7 +42,6 @@
import fr.free.nrw.commons.location.LocationServiceManager;
import fr.free.nrw.commons.theme.BaseActivity;
import fr.free.nrw.commons.utils.SystemThemeUtils;
import fr.free.nrw.commons.utils.ViewUtilWrapper;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
import java.util.List;
Expand Down Expand Up @@ -214,9 +212,9 @@ protected void onCreate(@Nullable final Bundle savedInstanceState) {
fabCenterOnLocation.setVisibility(View.GONE);
markerImage.setVisibility(View.GONE);
shadow.setVisibility(View.GONE);
assert cameraPosition.target != null;
showSelectedLocationMarker(new GeoPoint(cameraPosition.target.getLatitude(),
cameraPosition.target.getLongitude()));
assert cameraPosition != null;
showSelectedLocationMarker(new GeoPoint(cameraPosition.getLatitude(),
cameraPosition.getLongitude()));
}
setupMapView();
}
Expand Down Expand Up @@ -295,9 +293,11 @@ private void onClickModifyLocation() {
smallToolbarText.setText(getResources().getString(R.string.pan_and_zoom_to_adjust));
fabCenterOnLocation.setVisibility(View.VISIBLE);
removeSelectedLocationMarker();
if (cameraPosition.target != null) {
mapView.getController().animateTo(new GeoPoint(cameraPosition.target.getLatitude(),
cameraPosition.target.getLongitude()));
if (cameraPosition != null && mapView != null) {
if (mapView.getController() != null) {
mapView.getController().animateTo(new GeoPoint(cameraPosition.getLatitude(),
cameraPosition.getLongitude()));
}
}
}

Expand All @@ -314,9 +314,9 @@ public void showInMap() {
* move the location to the current media coordinates
*/
private void adjustCameraBasedOnOptions() {
if (cameraPosition.target != null) {
mapView.getController().setCenter(new GeoPoint(cameraPosition.target.getLatitude(),
cameraPosition.target.getLongitude()));
if (cameraPosition != null) {
mapView.getController().setCenter(new GeoPoint(cameraPosition.getLatitude(),
cameraPosition.getLongitude()));
}
}

Expand All @@ -343,8 +343,8 @@ void placeSelected() {
if (media == null) {
final Intent returningIntent = new Intent();
returningIntent.putExtra(LocationPickerConstants.MAP_CAMERA_POSITION,
new CameraPosition(new LatLng(mapView.getMapCenter().getLatitude(),
mapView.getMapCenter().getLongitude()), 14f, 0, 0));
new CameraPosition(mapView.getMapCenter().getLatitude(),
mapView.getMapCenter().getLongitude(), 14.0));
setResult(AppCompatActivity.RESULT_OK, returningIntent);
} else {
updateCoordinates(String.valueOf(mapView.getMapCenter().getLatitude()),
Expand Down Expand Up @@ -408,8 +408,8 @@ private void removeSelectedLocationMarker() {
for (int i = 0; i < overlays.size(); i++) {
if (overlays.get(i) instanceof Marker) {
Marker item = (Marker) overlays.get(i);
if (cameraPosition.target.getLatitude() == item.getPosition().getLatitude()
&& cameraPosition.target.getLongitude() == item.getPosition().getLongitude()) {
if (cameraPosition.getLatitude() == item.getPosition().getLatitude()
&& cameraPosition.getLongitude() == item.getPosition().getLongitude()) {
mapView.getOverlays().remove(i);
mapView.invalidate();
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import androidx.annotation.NonNull;
import androidx.lifecycle.AndroidViewModel;
import androidx.lifecycle.MutableLiveData;
import com.mapbox.mapboxsdk.camera.CameraPosition;
import fr.free.nrw.commons.CameraPosition;
import org.jetbrains.annotations.NotNull;
import retrofit2.Call;
import retrofit2.Callback;
Expand Down
12 changes: 0 additions & 12 deletions app/src/main/java/fr/free/nrw/commons/MapStyle.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -427,8 +427,6 @@ public void toggleLimitedConnectionMode() {
public void centerMapToPlace(Place place) {
setSelectedItemId(NavTab.NEARBY.code());
nearbyParentFragment.setNearbyParentFragmentInstanceReadyCallback(new NearbyParentFragmentInstanceReadyCallback() {
// if mapBox initialize in nearbyParentFragment then MapReady() function called
// so that nearbyParentFragemt.centerMaptoPlace(place) not throw any null pointer exception
@Override
public void onReady() {
nearbyParentFragment.centerMapToPlace(place);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package fr.free.nrw.commons.explore.map;

import android.content.Context;
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;
import fr.free.nrw.commons.nearby.NearbyBaseMarker;
import java.util.List;

public class ExploreMapContract {
Expand All @@ -18,11 +17,10 @@ interface View {
void showLocationOffDialog();
void openLocationSettings();
void hideBottomDetailsSheet();
void displayBottomSheetWithInfo(Marker marker);
LatLng getMapCenter();
LatLng getMapFocus();
LatLng getLastMapFocus();
void addMarkersToMap(final List<NearbyBaseMarker> nearbyBaseMarkers);
void addMarkersToMap(final List<BaseMarker> nearbyBaseMarkers);
void clearAllMarkers();
void addSearchThisAreaButtonAction();
void setSearchThisAreaButtonVisibility(boolean isVisible);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@
import com.bumptech.glide.request.RequestOptions;
import com.bumptech.glide.request.target.CustomTarget;
import com.bumptech.glide.request.transition.Transition;
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.Media;
import fr.free.nrw.commons.R;
import fr.free.nrw.commons.location.LatLng;
import fr.free.nrw.commons.nearby.NearbyBaseMarker;
import fr.free.nrw.commons.nearby.Place;
import fr.free.nrw.commons.utils.ImageUtils;
import fr.free.nrw.commons.utils.LocationUtils;
Expand Down Expand Up @@ -107,8 +105,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.calculateDistance(bound.getLatitude(),
bound.getLongitude(), searchLatLng.getLatitude(), searchLatLng.getLongitude());
if (distance > latestSearchRadius) {
latestSearchRadius = distance;
}
Expand All @@ -130,17 +128,16 @@ public ExplorePlacesInfo loadAttractionsFromLocation(LatLng curLatLng, LatLng se
*
* @return baseMarkerOptions list that holds nearby places with their icons
*/
public static List<NearbyBaseMarker> loadAttractionsFromLocationToBaseMarkerOptions(
public static List<BaseMarker> loadAttractionsFromLocationToBaseMarkerOptions(
LatLng curLatLng,
final List<Place> placeList,
Context context,
NearbyBaseMarkerThumbCallback callback,
Marker selectedMarker,
ExplorePlacesInfo explorePlacesInfo) {
List<NearbyBaseMarker> baseMarkerOptions = new ArrayList<>();
List<BaseMarker> baseMarkerList = new ArrayList<>();

if (placeList == null) {
return baseMarkerOptions;
return baseMarkerList;
}

VectorDrawableCompat vectorDrawable = null;
Expand All @@ -153,17 +150,17 @@ public static List<NearbyBaseMarker> loadAttractionsFromLocationToBaseMarkerOpti
}
if (vectorDrawable != null) {
for (Place explorePlace : placeList) {
final NearbyBaseMarker nearbyBaseMarker = new NearbyBaseMarker();
final BaseMarker baseMarker = new BaseMarker();
String distance = formatDistanceBetween(curLatLng, explorePlace.location);
explorePlace.setDistance(distance);

nearbyBaseMarker.title(
baseMarker.setTitle(
explorePlace.name.substring(5, explorePlace.name.lastIndexOf(".")));
nearbyBaseMarker.position(
new com.mapbox.mapboxsdk.geometry.LatLng(
baseMarker.setPosition(
new fr.free.nrw.commons.location.LatLng(
explorePlace.location.getLatitude(),
explorePlace.location.getLongitude()));
nearbyBaseMarker.place(explorePlace);
explorePlace.location.getLongitude(), 0));
baseMarker.setPlace(explorePlace);

Glide.with(context)
.asBitmap()
Expand All @@ -175,13 +172,13 @@ public static List<NearbyBaseMarker> loadAttractionsFromLocationToBaseMarkerOpti
@Override
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()
baseMarker.setIcon(
ImageUtils.addRedBorder(resource, 6, context));
baseMarkerList.add(baseMarker);
if (baseMarkerList.size()
== placeList.size()) { // if true, we added all markers to list and can trigger thumbs ready callback
callback.onNearbyBaseMarkerThumbsReady(baseMarkerOptions,
explorePlacesInfo, selectedMarker);
callback.onNearbyBaseMarkerThumbsReady(baseMarkerList,
explorePlacesInfo);
}
}

Expand All @@ -193,25 +190,24 @@ 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));
baseMarkerOptions.add(nearbyBaseMarker);
if (baseMarkerOptions.size()
baseMarker.fromResource(context, R.drawable.image_placeholder_96);
baseMarkerList.add(baseMarker);
if (baseMarkerList.size()
== placeList.size()) { // if true, we added all markers to list and can trigger thumbs ready callback
callback.onNearbyBaseMarkerThumbsReady(baseMarkerOptions,
explorePlacesInfo, selectedMarker);
callback.onNearbyBaseMarkerThumbsReady(baseMarkerList,
explorePlacesInfo);
}
}
});
}
}
return baseMarkerOptions;
return baseMarkerList;
}

interface NearbyBaseMarkerThumbCallback {

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