Skip to content

Commit

Permalink
feat: add directly POI from long press gesture on the map
Browse files Browse the repository at this point in the history
  • Loading branch information
sgrimault committed Jun 20, 2022
1 parent 71594da commit 3f0b6e0
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 7 deletions.
2 changes: 1 addition & 1 deletion maps/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
id 'kotlin-android'
}

version = "0.6.5"
version = "0.6.6"

android {
compileSdkVersion 31
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,13 @@ class EditFeatureButton(

private val mapEventReceiver = object : MapEventsReceiver {
override fun longPressHelper(p: GeoPoint?): Boolean {
// nothing to do...
return false
if (showSnackbarAboutAddingPoiAndInsufficientZoomLevel(p)) {
return false
}

addPoi(p)

return true
}

override fun singleTapConfirmedHelper(p: GeoPoint?): Boolean {
Expand Down Expand Up @@ -124,7 +129,7 @@ class EditFeatureButton(
if (!selectedPoi.isNullOrBlank()) return true
if (pois.isNotEmpty() && listener?.getEditMode() == EditMode.SINGLE) return true

if (listener?.getMinZoomEditing() ?: 0.0 <= event?.zoomLevel ?: 0.0) {
if ((listener?.getMinZoomEditing() ?: 0.0) <= (event?.zoomLevel ?: 0.0)) {
show()
} else {
hide()
Expand Down Expand Up @@ -305,7 +310,9 @@ class EditFeatureButton(
private fun centerMapToMarker(marker: Marker) {
val mapView = listener?.getMapView() ?: return
val editZoom =
if (listener?.getMinZoomEditing() ?: mapView.zoomLevelDouble <= mapView.zoomLevelDouble) mapView.zoomLevelDouble
if ((listener?.getMinZoomEditing()
?: mapView.zoomLevelDouble) <= mapView.zoomLevelDouble
) mapView.zoomLevelDouble
else listener?.getMinZoomEditing() ?: mapView.zoomLevelDouble

animateTo(
Expand All @@ -315,6 +322,25 @@ class EditFeatureButton(
)
}

private fun showSnackbarAboutAddingPoiAndInsufficientZoomLevel(geoPoint: GeoPoint?): Boolean {
val mapView = listener?.getMapView() ?: return false
if (geoPoint == null) return false

if ((listener?.getMinZoomEditing()
?: mapView.zoomLevelDouble) <= mapView.zoomLevelDouble
) {
return false
}

listener?.makeSnackbar(
R.string.snackbar_add_poi_zoom_min,
Snackbar.LENGTH_SHORT
)
?.show()

return true
}

private fun showSnackbarAboutDeletedPoi(geoPoint: GeoPoint?) {
if (geoPoint == null) return

Expand Down
1 change: 1 addition & 0 deletions maps/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<string name="snackbar_permissions_rationale">L\'application requiert des permissions</string>
<string name="snackbar_layers_undefined">Aucun fond de défini</string>
<string name="snackbar_base_path_undefined">Impossible de charger les couches depuis \'%1$s\'</string>
<string name="snackbar_add_poi_zoom_min">Le niveau de zoom est insuffisant pour ajouter un marqueur</string>

<string name="toast_location_outside_map_boundaries">Votre position est en dehors des limites de la carte</string>

Expand Down
1 change: 1 addition & 0 deletions maps/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<string name="snackbar_permissions_rationale">Some permissions are needed</string>
<string name="snackbar_layers_undefined">No layers defined</string>
<string name="snackbar_base_path_undefined">Unable to load layers from path \'%1$s\'</string>
<string name="snackbar_add_poi_zoom_min">The zoom level is insufficient to add a POI</string>

<string name="toast_location_outside_map_boundaries">Your position is outside map boundaries</string>

Expand Down
4 changes: 2 additions & 2 deletions maps/version.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#Mon May 23 12:59:52 CEST 2022
VERSION_CODE=1700
#Mon Jun 20 22:38:06 CEST 2022
VERSION_CODE=1715

0 comments on commit 3f0b6e0

Please sign in to comment.