diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/QuestModule.java b/app/src/main/java/de/westnordost/streetcomplete/quests/QuestModule.java index 5029f9a19c..8990b36e73 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/QuestModule.java +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/QuestModule.java @@ -12,6 +12,7 @@ import de.westnordost.streetcomplete.data.QuestTypeRegistry; import de.westnordost.streetcomplete.data.osm.download.OverpassMapDataDao; import de.westnordost.streetcomplete.data.osmnotes.OsmNoteQuestType; +import de.westnordost.streetcomplete.quests.address.AddAddressStreet; import de.westnordost.streetcomplete.quests.baby_changing_table.AddBabyChangingTable; import de.westnordost.streetcomplete.quests.bike_parking_capacity.AddBikeParkingCapacity; import de.westnordost.streetcomplete.quests.bike_parking_cover.AddBikeParkingCover; @@ -67,7 +68,7 @@ import de.westnordost.streetcomplete.quests.toilet_availability.AddToiletAvailability; import de.westnordost.streetcomplete.quests.toilets_fee.AddToiletsFee; import de.westnordost.streetcomplete.quests.tracktype.AddTracktype; -import de.westnordost.streetcomplete.quests.housenumber.AddHousenumber; +import de.westnordost.streetcomplete.quests.address.AddHousenumber; import de.westnordost.streetcomplete.quests.max_speed.AddMaxSpeed; import de.westnordost.streetcomplete.quests.opening_hours.AddOpeningHours; import de.westnordost.streetcomplete.quests.localized_name.AddRoadName; @@ -107,6 +108,7 @@ public class QuestModule new AddBusStopName(o), new AddIsBuildingUnderground(o), //to avoid asking AddHousenumber and other for underground buildings new AddHousenumber(o), + new AddAddressStreet(o), new MarkCompletedHighwayConstruction(o), new AddReligionToPlaceOfWorship(o), // icons on maps are different - OSM Carto, mapy.cz, OsmAnd, Sputnik etc new AddParkingAccess(o), //OSM Carto, mapy.cz, OSMand, Sputnik etc diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/address/AddAddressStreet.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/address/AddAddressStreet.kt new file mode 100644 index 0000000000..ec1f3388bf --- /dev/null +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/address/AddAddressStreet.kt @@ -0,0 +1,43 @@ +package de.westnordost.streetcomplete.quests.address + +import de.westnordost.osmapi.map.data.BoundingBox +import de.westnordost.osmapi.map.data.Element +import de.westnordost.streetcomplete.R +import de.westnordost.streetcomplete.data.osm.OsmElementQuestType +import de.westnordost.streetcomplete.data.osm.changes.StringMapChangesBuilder +import de.westnordost.streetcomplete.data.osm.download.MapDataWithGeometryHandler +import de.westnordost.streetcomplete.data.osm.download.OverpassMapDataDao +import de.westnordost.streetcomplete.data.osm.tql.getQuestPrintStatement +import de.westnordost.streetcomplete.data.osm.tql.toGlobalOverpassBBox + +class AddAddressStreet(private val overpassMapDataDao: OverpassMapDataDao) : OsmElementQuestType { + override val commitMessage = "Add address" + override val icon = R.drawable.ic_quest_label + + override fun getTitle(tags: Map) = R.string.quest_address_street_title + + override fun createForm() = AddAddressStreetForm() + + override fun download(bbox: BoundingBox, handler: MapDataWithGeometryHandler): Boolean { + return overpassMapDataDao.getAndHandleQuota(getOverpassQuery(bbox), handler); + } + + override fun isApplicableTo(element: Element): Boolean? = null + + override fun applyAnswerTo(answer: AddressStreetAnswer, changes: StringMapChangesBuilder) { + when(answer){ + is StreetName -> {changes.add("addr:street", answer.name)} + is PlaceName -> {changes.add("addr:place", answer.name)} + } + } + + private fun getOverpassQuery(bbox: BoundingBox) = + bbox.toGlobalOverpassBBox() + """ + relation["type"="associatedStreet"]; + > -> .inStreetRelation; + + nwr["addr:street"!~".*"]["addr:housenumber"]["addr:place"!~".*"] -> .missing_data; + + (.missing_data; - .inStreetRelation;);""" + + getQuestPrintStatement() +} diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/address/AddAddressStreetForm.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/address/AddAddressStreetForm.kt new file mode 100644 index 0000000000..3340a905a3 --- /dev/null +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/address/AddAddressStreetForm.kt @@ -0,0 +1,40 @@ +package de.westnordost.streetcomplete.quests.address + +import android.os.Bundle +import android.view.View +import androidx.appcompat.app.AlertDialog +import de.westnordost.streetcomplete.R +import de.westnordost.streetcomplete.quests.AbstractQuestFormAnswerFragment +import de.westnordost.streetcomplete.quests.OtherAnswer +import de.westnordost.streetcomplete.util.TextChangedWatcher +import kotlinx.android.synthetic.main.quest_placename.* + +class AddAddressStreetForm : AbstractQuestFormAnswerFragment() { + override val contentLayoutResId = R.layout.quest_placename + + override val otherAnswers = listOf( + OtherAnswer(R.string.quest_address_street_no_named_streets) { confirmNoName() } + ) + + private val placeName get() = nameInput?.text?.toString().orEmpty().trim() + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + + nameInput.addTextChangedListener(TextChangedWatcher { checkIsFormComplete() }) + } + + override fun onClickOk() { + applyAnswer(StreetName(placeName)) + } + + private fun confirmNoName() { + AlertDialog.Builder(activity!!) + .setTitle(R.string.quest_name_answer_noName_confirmation_title) + .setPositiveButton(R.string.quest_name_noName_confirmation_positive) { _, _ -> applyAnswer(PlaceName("TODO")) } //TODO! + .setNegativeButton(R.string.quest_generic_confirmation_no, null) + .show() + } + + override fun isFormComplete() = placeName.isNotEmpty() +} diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/housenumber/AddHousenumber.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/address/AddHousenumber.kt similarity index 98% rename from app/src/main/java/de/westnordost/streetcomplete/quests/housenumber/AddHousenumber.kt rename to app/src/main/java/de/westnordost/streetcomplete/quests/address/AddHousenumber.kt index c491e629db..12e7675619 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/housenumber/AddHousenumber.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/address/AddHousenumber.kt @@ -1,4 +1,4 @@ -package de.westnordost.streetcomplete.quests.housenumber +package de.westnordost.streetcomplete.quests.address import android.util.Log @@ -21,7 +21,7 @@ import de.westnordost.streetcomplete.util.SphericalEarthMath class AddHousenumber(private val overpass: OverpassMapDataDao) : OsmElementQuestType { - override val commitMessage = "Add housenumbers" + override val commitMessage = "Add address" override val icon = R.drawable.ic_quest_housenumber // See overview here: https://ent8r.github.io/blacklistr/?streetcomplete=housenumber/AddHousenumber.kt diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/housenumber/AddHousenumberForm.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/address/AddHousenumberForm.kt similarity index 99% rename from app/src/main/java/de/westnordost/streetcomplete/quests/housenumber/AddHousenumberForm.kt rename to app/src/main/java/de/westnordost/streetcomplete/quests/address/AddHousenumberForm.kt index ac9529fed2..774b2250c1 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/housenumber/AddHousenumberForm.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/address/AddHousenumberForm.kt @@ -1,4 +1,4 @@ -package de.westnordost.streetcomplete.quests.housenumber +package de.westnordost.streetcomplete.quests.address import android.os.Bundle import androidx.appcompat.app.AlertDialog diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/address/AddressStreetAnswer.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/address/AddressStreetAnswer.kt new file mode 100644 index 0000000000..3a1c19d663 --- /dev/null +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/address/AddressStreetAnswer.kt @@ -0,0 +1,6 @@ +package de.westnordost.streetcomplete.quests.address + +sealed class AddressStreetAnswer + +data class StreetName(val name:String) : AddressStreetAnswer() +data class PlaceName(val name:String) : AddressStreetAnswer() diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/housenumber/HousenumberAnswer.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/address/HousenumberAnswer.kt similarity index 87% rename from app/src/main/java/de/westnordost/streetcomplete/quests/housenumber/HousenumberAnswer.kt rename to app/src/main/java/de/westnordost/streetcomplete/quests/address/HousenumberAnswer.kt index c41aa32ce8..76b5305b53 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/housenumber/HousenumberAnswer.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/address/HousenumberAnswer.kt @@ -1,4 +1,4 @@ -package de.westnordost.streetcomplete.quests.housenumber +package de.westnordost.streetcomplete.quests.address sealed class HousenumberAnswer diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 9042d43b40..9c85b8affa 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -677,6 +677,8 @@ Otherwise, you can download another keyboard in the app store. Popular keyboards Your answers are directly improving OpenStreetMap. Contributed data is open, everyone can use it. Many great projects are already using it. Currently, the star count is not shared across devices, but answers are added directly to the OpenStreetMap database. Choose one of the markers on the map and answer the question. This way you will improve OpenStreetMap data and get stars. If you see no markers you may need to zoom out the map. + What is the street of this address? + This address has no assigned named street What\'s the surface of the cycleway here? What\'s the surface of the footway here? "Differs along the way…" diff --git a/app/src/test/java/de/westnordost/streetcomplete/quests/add_housenumber/AddHousenumberIntegrationTest.kt b/app/src/test/java/de/westnordost/streetcomplete/quests/add_housenumber/AddHousenumberIntegrationTest.kt index b1fae7bc51..f70d9cc3f5 100644 --- a/app/src/test/java/de/westnordost/streetcomplete/quests/add_housenumber/AddHousenumberIntegrationTest.kt +++ b/app/src/test/java/de/westnordost/streetcomplete/quests/add_housenumber/AddHousenumberIntegrationTest.kt @@ -3,7 +3,7 @@ package de.westnordost.streetcomplete.quests.add_housenumber import de.westnordost.osmapi.map.data.BoundingBox import de.westnordost.streetcomplete.IntegrationTests import de.westnordost.streetcomplete.data.OsmModule -import de.westnordost.streetcomplete.quests.housenumber.AddHousenumber +import de.westnordost.streetcomplete.quests.address.AddHousenumber import de.westnordost.streetcomplete.quests.verifyDownloadYieldsNoQuest import org.junit.Test import org.junit.experimental.categories.Category diff --git a/app/src/test/java/de/westnordost/streetcomplete/quests/add_housenumber/AddHousenumberTest.kt b/app/src/test/java/de/westnordost/streetcomplete/quests/add_housenumber/AddHousenumberTest.kt index 8f83f81dbe..58ff29735c 100644 --- a/app/src/test/java/de/westnordost/streetcomplete/quests/add_housenumber/AddHousenumberTest.kt +++ b/app/src/test/java/de/westnordost/streetcomplete/quests/add_housenumber/AddHousenumberTest.kt @@ -2,7 +2,7 @@ package de.westnordost.streetcomplete.quests.add_housenumber import de.westnordost.streetcomplete.data.osm.changes.StringMapEntryAdd import de.westnordost.streetcomplete.mock -import de.westnordost.streetcomplete.quests.housenumber.* +import de.westnordost.streetcomplete.quests.address.* import de.westnordost.streetcomplete.quests.verifyAnswer import org.junit.Assert.assertFalse import org.junit.Assert.assertTrue