diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/QuestsModule.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/QuestsModule.kt index 94b8a96a77..f9c0ecf28d 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/QuestsModule.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/QuestsModule.kt @@ -31,6 +31,7 @@ import de.westnordost.streetcomplete.quests.barrier_type.AddBarrierType import de.westnordost.streetcomplete.quests.barrier_type.AddStileType import de.westnordost.streetcomplete.quests.bbq_fuel.AddBbqFuel import de.westnordost.streetcomplete.quests.bench_backrest.AddBenchBackrest +import de.westnordost.streetcomplete.quests.bench_armrest.AddBenchArmrest import de.westnordost.streetcomplete.quests.bike_parking_capacity.AddBikeParkingCapacity import de.westnordost.streetcomplete.quests.bike_parking_cover.AddBikeParkingCover import de.westnordost.streetcomplete.quests.bike_parking_type.AddBikeParkingType @@ -266,6 +267,7 @@ fun questTypeRegistry( 9 to AddCarWashType(), 10 to AddBenchBackrest(), + 170 to AddBenchArmrest(), 11 to AddAmenityCover(getFeature), 12 to AddBridgeStructure(), diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/bench_armrest/AddBenchArmrest.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/bench_armrest/AddBenchArmrest.kt new file mode 100644 index 0000000000..5e851cd04e --- /dev/null +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/bench_armrest/AddBenchArmrest.kt @@ -0,0 +1,52 @@ +package de.westnordost.streetcomplete.quests.bench_armrest + +import de.westnordost.streetcomplete.R +import de.westnordost.streetcomplete.data.osm.geometry.ElementGeometry +import de.westnordost.streetcomplete.data.osm.mapdata.Element +import de.westnordost.streetcomplete.data.osm.mapdata.MapDataWithGeometry +import de.westnordost.streetcomplete.data.osm.mapdata.filter +import de.westnordost.streetcomplete.data.osm.osmquests.OsmFilterQuestType +import de.westnordost.streetcomplete.data.user.achievements.EditTypeAchievement.OUTDOORS +import de.westnordost.streetcomplete.data.user.achievements.EditTypeAchievement.PEDESTRIAN +import de.westnordost.streetcomplete.osm.Tags +import de.westnordost.streetcomplete.quests.bench_armrest.BenchArmrestAnswer.NO +import de.westnordost.streetcomplete.quests.bench_armrest.BenchArmrestAnswer.PICNIC_TABLE +import de.westnordost.streetcomplete.quests.bench_armrest.BenchArmrestAnswer.YES + +class AddBenchArmrest : OsmFilterQuestType() { + + override val elementFilter = """ + nodes, ways with + amenity = bench + and (!area or area = no) + and !armrest + and !bench:type + and (!seasonal or seasonal = no) + and access !~ private|no + """ + override val changesetComment = "Survey whether benches have armrests" + override val wikiLink = "Key:armrest" + override val icon = R.drawable.ic_quest_bench_poi + override val isDeleteElementEnabled = true + override val achievements = listOf(PEDESTRIAN, OUTDOORS) + + override val hint = R.string.quest_bench_armrest_description + + override fun getTitle(tags: Map) = R.string.quest_bench_armrest_title + + override fun getHighlightedElements(element: Element, getMapData: () -> MapDataWithGeometry) = + getMapData().filter("nodes, ways with amenity = bench or leisure = picnic_table") + + override fun createForm() = AddBenchArmrestForm() + + override fun applyAnswerTo(answer: BenchArmrestAnswer, tags: Tags, geometry: ElementGeometry, timestampEdited: Long) { + when (answer) { + PICNIC_TABLE -> { + tags["leisure"] = "picnic_table" + tags.remove("amenity") + } + YES -> tags["armrest"] = "yes" + NO -> tags["armrest"] = "no" + } + } +} diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/bench_armrest/AddBenchArmrestForm.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/bench_armrest/AddBenchArmrestForm.kt new file mode 100644 index 0000000000..510ac04f56 --- /dev/null +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/bench_armrest/AddBenchArmrestForm.kt @@ -0,0 +1,20 @@ +package de.westnordost.streetcomplete.quests.bench_armrest + +import de.westnordost.streetcomplete.R +import de.westnordost.streetcomplete.quests.AbstractOsmQuestForm +import de.westnordost.streetcomplete.quests.AnswerItem +import de.westnordost.streetcomplete.quests.bench_armrest.BenchArmrestAnswer.NO +import de.westnordost.streetcomplete.quests.bench_armrest.BenchArmrestAnswer.PICNIC_TABLE +import de.westnordost.streetcomplete.quests.bench_armrest.BenchArmrestAnswer.YES + +class AddBenchArmrestForm : AbstractOsmQuestForm() { + + override val buttonPanelAnswers = listOf( + AnswerItem(R.string.quest_generic_hasFeature_no) { applyAnswer(NO) }, + AnswerItem(R.string.quest_generic_hasFeature_yes) { applyAnswer(YES) } + ) + + override val otherAnswers = listOf( + AnswerItem(R.string.quest_bench_answer_picnic_table) { applyAnswer(PICNIC_TABLE) } + ) +} diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/bench_armrest/BenchArmrestAnswer.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/bench_armrest/BenchArmrestAnswer.kt new file mode 100644 index 0000000000..f4458cb548 --- /dev/null +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/bench_armrest/BenchArmrestAnswer.kt @@ -0,0 +1,3 @@ +package de.westnordost.streetcomplete.quests.bench_armrest + +enum class BenchArmrestAnswer { YES, NO, PICNIC_TABLE } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 41da1bca8a..9ca26b2350 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -715,6 +715,9 @@ Before uploading your changes, the app checks with a <a href=\"https://www.we Converted into a passage in a wall/fence/etc. Converted into a gate + Does this bench have any armrests? + It does not matter how many armrests the bench has or where they are on the bench. + Does this bench have a backrest? It’s a picnic table