mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-29 22:03:55 +01:00
Nearby: Add ability to navigate to Explore fragment on 'Show in Explore' click
This commit is contained in:
parent
e5c5ca87d7
commit
3eda5dc169
1 changed files with 45 additions and 28 deletions
|
|
@ -247,27 +247,28 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
||||||
|
|
||||||
private final ActivityResultLauncher<Intent> galleryPickLauncherForResult =
|
private final ActivityResultLauncher<Intent> galleryPickLauncherForResult =
|
||||||
registerForActivityResult(new StartActivityForResult(),
|
registerForActivityResult(new StartActivityForResult(),
|
||||||
result -> {
|
result -> {
|
||||||
controller.handleActivityResultWithCallback(requireActivity(), callbacks -> {
|
controller.handleActivityResultWithCallback(requireActivity(), callbacks -> {
|
||||||
controller.onPictureReturnedFromGallery(result, requireActivity(), callbacks);
|
controller.onPictureReturnedFromGallery(result, requireActivity(), callbacks);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
private final ActivityResultLauncher<Intent> customSelectorLauncherForResult =
|
private final ActivityResultLauncher<Intent> customSelectorLauncherForResult =
|
||||||
registerForActivityResult(new StartActivityForResult(),
|
registerForActivityResult(new StartActivityForResult(),
|
||||||
result -> {
|
result -> {
|
||||||
controller.handleActivityResultWithCallback(requireActivity(), callbacks -> {
|
controller.handleActivityResultWithCallback(requireActivity(), callbacks -> {
|
||||||
controller.onPictureReturnedFromCustomSelector(result, requireActivity(), callbacks);
|
controller.onPictureReturnedFromCustomSelector(result, requireActivity(),
|
||||||
|
callbacks);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
private final ActivityResultLauncher<Intent> cameraPickLauncherForResult =
|
private final ActivityResultLauncher<Intent> cameraPickLauncherForResult =
|
||||||
registerForActivityResult(new StartActivityForResult(),
|
registerForActivityResult(new StartActivityForResult(),
|
||||||
result -> {
|
result -> {
|
||||||
controller.handleActivityResultWithCallback(requireActivity(), callbacks -> {
|
controller.handleActivityResultWithCallback(requireActivity(), callbacks -> {
|
||||||
controller.onPictureReturnedFromCamera(result, requireActivity(), callbacks);
|
controller.onPictureReturnedFromCamera(result, requireActivity(), callbacks);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
private ActivityResultLauncher<String[]> inAppCameraLocationPermissionLauncher = registerForActivityResult(
|
private ActivityResultLauncher<String[]> inAppCameraLocationPermissionLauncher = registerForActivityResult(
|
||||||
new RequestMultiplePermissions(),
|
new RequestMultiplePermissions(),
|
||||||
|
|
@ -342,7 +343,8 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
||||||
|
|
||||||
initNetworkBroadCastReceiver();
|
initNetworkBroadCastReceiver();
|
||||||
scope = LifecycleOwnerKt.getLifecycleScope(getViewLifecycleOwner());
|
scope = LifecycleOwnerKt.getLifecycleScope(getViewLifecycleOwner());
|
||||||
presenter = new NearbyParentFragmentPresenter(bookmarkLocationDao, placesRepository, nearbyController);
|
presenter = new NearbyParentFragmentPresenter(bookmarkLocationDao, placesRepository,
|
||||||
|
nearbyController);
|
||||||
progressDialog = new ProgressDialog(getActivity());
|
progressDialog = new ProgressDialog(getActivity());
|
||||||
progressDialog.setCancelable(false);
|
progressDialog.setCancelable(false);
|
||||||
progressDialog.setMessage("Saving in progress...");
|
progressDialog.setMessage("Saving in progress...");
|
||||||
|
|
@ -359,6 +361,7 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
||||||
inflater.inflate(R.menu.nearby_fragment_menu, menu);
|
inflater.inflate(R.menu.nearby_fragment_menu, menu);
|
||||||
MenuItem refreshButton = menu.findItem(R.id.item_refresh);
|
MenuItem refreshButton = menu.findItem(R.id.item_refresh);
|
||||||
MenuItem listMenu = menu.findItem(R.id.list_sheet);
|
MenuItem listMenu = menu.findItem(R.id.list_sheet);
|
||||||
|
MenuItem showInExploreButton = menu.findItem(R.id.list_item_show_in_explore);
|
||||||
MenuItem saveAsGPXButton = menu.findItem(R.id.list_item_gpx);
|
MenuItem saveAsGPXButton = menu.findItem(R.id.list_item_gpx);
|
||||||
MenuItem saveAsKMLButton = menu.findItem(R.id.list_item_kml);
|
MenuItem saveAsKMLButton = menu.findItem(R.id.list_item_kml);
|
||||||
refreshButton.setOnMenuItemClickListener(new OnMenuItemClickListener() {
|
refreshButton.setOnMenuItemClickListener(new OnMenuItemClickListener() {
|
||||||
|
|
@ -379,6 +382,17 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
showInExploreButton.setOnMenuItemClickListener(new OnMenuItemClickListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onMenuItemClick(@NonNull MenuItem item) {
|
||||||
|
((MainActivity) getContext()).loadExploreMapFromNearby(
|
||||||
|
binding.map.getZoomLevelDouble(),
|
||||||
|
binding.map.getMapCenter().getLatitude(),
|
||||||
|
binding.map.getMapCenter().getLongitude()
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
saveAsGPXButton.setOnMenuItemClickListener(new OnMenuItemClickListener() {
|
saveAsGPXButton.setOnMenuItemClickListener(new OnMenuItemClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -493,7 +507,8 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
||||||
initRvNearbyList();
|
initRvNearbyList();
|
||||||
onResume();
|
onResume();
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||||
binding.tvAttribution.setText(Html.fromHtml(getString(R.string.map_attribution), Html.FROM_HTML_MODE_LEGACY));
|
binding.tvAttribution.setText(
|
||||||
|
Html.fromHtml(getString(R.string.map_attribution), Html.FROM_HTML_MODE_LEGACY));
|
||||||
} else {
|
} else {
|
||||||
//noinspection deprecation
|
//noinspection deprecation
|
||||||
binding.tvAttribution.setText(Html.fromHtml(getString(R.string.map_attribution)));
|
binding.tvAttribution.setText(Html.fromHtml(getString(R.string.map_attribution)));
|
||||||
|
|
@ -739,8 +754,8 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines the number of spans (columns) in the RecyclerView based on device orientation
|
* Determines the number of spans (columns) in the RecyclerView based on device orientation and
|
||||||
* and adapter item count.
|
* adapter item count.
|
||||||
*
|
*
|
||||||
* @return The number of spans to be used in the RecyclerView.
|
* @return The number of spans to be used in the RecyclerView.
|
||||||
*/
|
*/
|
||||||
|
|
@ -1175,7 +1190,6 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clears the Nearby local cache and then calls for pin details to be fetched afresh.
|
* Clears the Nearby local cache and then calls for pin details to be fetched afresh.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
private void emptyCache() {
|
private void emptyCache() {
|
||||||
// reload the map once the cache is cleared
|
// reload the map once the cache is cleared
|
||||||
|
|
@ -1338,7 +1352,8 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches and updates the data for a specific place, then updates the corresponding marker on the map.
|
* Fetches and updates the data for a specific place, then updates the corresponding marker on
|
||||||
|
* the map.
|
||||||
*
|
*
|
||||||
* @param entity The entity ID of the place.
|
* @param entity The entity ID of the place.
|
||||||
* @param place The Place object containing the initial place data.
|
* @param place The Place object containing the initial place data.
|
||||||
|
|
@ -1469,9 +1484,8 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stops any ongoing queries and clears all disposables.
|
* Stops any ongoing queries and clears all disposables. This method sets the stopQuery flag to
|
||||||
* This method sets the stopQuery flag to true and clears the compositeDisposable
|
* true and clears the compositeDisposable to prevent any further processing.
|
||||||
* to prevent any further processing.
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void stopQuery() {
|
public void stopQuery() {
|
||||||
|
|
@ -1624,7 +1638,8 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
||||||
new Builder(getContext())
|
new Builder(getContext())
|
||||||
.setMessage(R.string.login_alert_message)
|
.setMessage(R.string.login_alert_message)
|
||||||
.setCancelable(false)
|
.setCancelable(false)
|
||||||
.setNegativeButton(R.string.cancel, (dialog, which) -> {})
|
.setNegativeButton(R.string.cancel, (dialog, which) -> {
|
||||||
|
})
|
||||||
.setPositiveButton(R.string.login, (dialog, which) -> {
|
.setPositiveButton(R.string.login, (dialog, which) -> {
|
||||||
// logout of the app
|
// logout of the app
|
||||||
BaseLogoutListener logoutListener = new BaseLogoutListener(getActivity());
|
BaseLogoutListener logoutListener = new BaseLogoutListener(getActivity());
|
||||||
|
|
@ -1743,7 +1758,7 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
||||||
final boolean filterForPlaceState,
|
final boolean filterForPlaceState,
|
||||||
final boolean filterForAllNoneType) {
|
final boolean filterForAllNoneType) {
|
||||||
final boolean displayExists = false;
|
final boolean displayExists = false;
|
||||||
final boolean displayNeedsPhoto= false;
|
final boolean displayNeedsPhoto = false;
|
||||||
final boolean displayWlm = false;
|
final boolean displayWlm = false;
|
||||||
if (selectedLabels == null || selectedLabels.size() == 0) {
|
if (selectedLabels == null || selectedLabels.size() == 0) {
|
||||||
replaceMarkerOverlays(NearbyController.markerLabelList);
|
replaceMarkerOverlays(NearbyController.markerLabelList);
|
||||||
|
|
@ -1903,8 +1918,8 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
||||||
/**
|
/**
|
||||||
* Adds multiple markers representing places to the map and handles item gestures.
|
* Adds multiple markers representing places to the map and handles item gestures.
|
||||||
*
|
*
|
||||||
* @param markerPlaceGroups The list of marker place groups containing the places and
|
* @param markerPlaceGroups The list of marker place groups containing the places and their
|
||||||
* their bookmarked status
|
* bookmarked status
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void replaceMarkerOverlays(final List<MarkerPlaceGroup> markerPlaceGroups) {
|
public void replaceMarkerOverlays(final List<MarkerPlaceGroup> markerPlaceGroups) {
|
||||||
|
|
@ -1913,7 +1928,7 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
||||||
for (int i = markerPlaceGroups.size() - 1; i >= 0; i--) {
|
for (int i = markerPlaceGroups.size() - 1; i >= 0; i--) {
|
||||||
newMarkers.add(
|
newMarkers.add(
|
||||||
convertToMarker(markerPlaceGroups.get(i).getPlace(),
|
convertToMarker(markerPlaceGroups.get(i).getPlace(),
|
||||||
markerPlaceGroups.get(i).getIsBookmarked())
|
markerPlaceGroups.get(i).getIsBookmarked())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
clearAllMarkers();
|
clearAllMarkers();
|
||||||
|
|
@ -2103,7 +2118,8 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
||||||
if (binding.fabCamera.isShown()) {
|
if (binding.fabCamera.isShown()) {
|
||||||
Timber.d("Camera button tapped. Place: %s", selectedPlace.toString());
|
Timber.d("Camera button tapped. Place: %s", selectedPlace.toString());
|
||||||
storeSharedPrefs(selectedPlace);
|
storeSharedPrefs(selectedPlace);
|
||||||
controller.initiateCameraPick(getActivity(), inAppCameraLocationPermissionLauncher, cameraPickLauncherForResult);
|
controller.initiateCameraPick(getActivity(), inAppCameraLocationPermissionLauncher,
|
||||||
|
cameraPickLauncherForResult);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -2121,7 +2137,8 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
||||||
if (binding.fabCustomGallery.isShown()) {
|
if (binding.fabCustomGallery.isShown()) {
|
||||||
Timber.d("Gallery button tapped. Place: %s", selectedPlace.toString());
|
Timber.d("Gallery button tapped. Place: %s", selectedPlace.toString());
|
||||||
storeSharedPrefs(selectedPlace);
|
storeSharedPrefs(selectedPlace);
|
||||||
controller.initiateCustomGalleryPickWithPermission(getActivity(), customSelectorLauncherForResult);
|
controller.initiateCustomGalleryPickWithPermission(getActivity(),
|
||||||
|
customSelectorLauncherForResult);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue