mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
Fixes Issue 6308: Explore map shows image at my location rather than at shown location (#6315)
Some checks failed
Android CI / Run tests and generate APK (push) Has been cancelled
Some checks failed
Android CI / Run tests and generate APK (push) Has been cancelled
* ExploreMapFragment.java: add helper methods and fields to enable proper Explore map behavior Before this commit, there was no way to tell if the user had arrived from the Nearby and before the Nearby map center location had been searched for markers. This commit adds a boolean flag to indicate this situation. Access, modification, and initialization methods were added for this boolean value. Additionally, a helper method to retrieve the Nearby map center LatLng was added as a convienience. * ExploreMapPresenter.java: fix map update code to search for Nearby LatLng when appropriate Before this commit, when the user selected "Show in explore" in Nearby when no pins were on the map, Explore would only search for markers at the user's current GPS location, rather than those at the Nearby map center. After this commit, code was added to check if the user recently came from the Nearby map. If so, the stored coordinates of the Nearby map is searched rather than the user's current GPS coordinates. Additionally, the boolean that indicates that the user recently came from the Nearby map is set to false. This ensures that the stored Nearby map center coordinates are not used when the user taps the icon to focus the map on their current location. --------- Co-authored-by: Nicolas Raoul <nicolas.raoul@gmail.com>
This commit is contained in:
parent
b3c1474b31
commit
eb617ae8ca
2 changed files with 42 additions and 1 deletions
|
|
@ -120,6 +120,7 @@ public class ExploreMapFragment extends CommonsDaggerSupportFragment
|
|||
private double prevZoom;
|
||||
private double prevLatitude;
|
||||
private double prevLongitude;
|
||||
private boolean recentlyCameFromNearbyMap;
|
||||
|
||||
private ExploreMapPresenter presenter;
|
||||
|
||||
|
|
@ -371,6 +372,16 @@ public class ExploreMapFragment extends CommonsDaggerSupportFragment
|
|||
prevLatitude = getArguments().getDouble("prev_latitude");
|
||||
prevLongitude = getArguments().getDouble("prev_longitude");
|
||||
}
|
||||
|
||||
setRecentlyCameFromNearbyMap(isCameFromNearbyMap());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The LatLng from the previous Fragment's map center or (0,0,0) coordinates
|
||||
* if that information is not available/applicable.
|
||||
*/
|
||||
public LatLng getPreviousLatLng() {
|
||||
return new LatLng(prevLatitude, prevLongitude, (float)prevZoom);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -383,6 +394,23 @@ public class ExploreMapFragment extends CommonsDaggerSupportFragment
|
|||
return prevZoom != 0.0 || prevLatitude != 0.0 || prevLongitude != 0.0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value that indicates if the user navigated from "Show in Explore" in Nearby and
|
||||
* that the LatLng from Nearby has yet to be searched for map markers.
|
||||
*/
|
||||
public boolean recentlyCameFromNearbyMap() {
|
||||
return recentlyCameFromNearbyMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value that indicates if the user navigated from "Show in Explore" in Nearby and
|
||||
* that the LatLng from Nearby has yet to be searched for map markers.
|
||||
* @param newValue The value to set.
|
||||
*/
|
||||
public void setRecentlyCameFromNearbyMap(boolean newValue) {
|
||||
recentlyCameFromNearbyMap = newValue;
|
||||
}
|
||||
|
||||
public void loadNearbyMapFromExplore() {
|
||||
((MainActivity) getContext()).loadNearbyMapFromExplore(
|
||||
binding.mapView.getZoomLevelDouble(),
|
||||
|
|
|
|||
|
|
@ -74,9 +74,22 @@ public class ExploreMapPresenter
|
|||
*/
|
||||
if (locationChangeType.equals(LOCATION_SIGNIFICANTLY_CHANGED)) {
|
||||
Timber.d("LOCATION_SIGNIFICANTLY_CHANGED");
|
||||
LatLng populateLatLng = exploreMapFragmentView.getMapCenter();
|
||||
|
||||
//If "Show in Explore" was selected in Nearby, use the previous LatLng
|
||||
if (exploreMapFragmentView instanceof ExploreMapFragment) {
|
||||
ExploreMapFragment exploreMapFragment = (ExploreMapFragment)exploreMapFragmentView;
|
||||
if (exploreMapFragment.recentlyCameFromNearbyMap()) {
|
||||
//Ensure this LatLng will not be used again if user searches their GPS location
|
||||
exploreMapFragment.setRecentlyCameFromNearbyMap(false);
|
||||
|
||||
populateLatLng = exploreMapFragment.getPreviousLatLng();
|
||||
}
|
||||
}
|
||||
|
||||
lockUnlockNearby(true);
|
||||
exploreMapFragmentView.setProgressBarVisibility(true);
|
||||
exploreMapFragmentView.populatePlaces(exploreMapFragmentView.getMapCenter());
|
||||
exploreMapFragmentView.populatePlaces(populateLatLng);
|
||||
} else if (locationChangeType.equals(SEARCH_CUSTOM_AREA)) {
|
||||
Timber.d("SEARCH_CUSTOM_AREA");
|
||||
lockUnlockNearby(true);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue