From f0cbc70bbc22387be8bf1d5a3879b815a91ef9a2 Mon Sep 17 00:00:00 2001 From: arrival-spring Date: Fri, 4 Mar 2022 21:20:18 +0000 Subject: [PATCH 1/4] Incorrect tactile paving option for crossings --- .../tactile_paving/AddTactilePavingBusStop.kt | 6 ++--- .../AddTactilePavingCrosswalk.kt | 6 ++--- .../tactile_paving/AddTactilePavingKerb.kt | 6 ++--- .../tactile_paving/TactilePavingAnswer.kt | 7 ++++++ .../tactile_paving/TactilePavingForm.kt | 23 ++++++++++++++++--- app/src/main/res/values/strings.xml | 1 + 6 files changed, 37 insertions(+), 12 deletions(-) create mode 100644 app/src/main/java/de/westnordost/streetcomplete/quests/tactile_paving/TactilePavingAnswer.kt diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/tactile_paving/AddTactilePavingBusStop.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/tactile_paving/AddTactilePavingBusStop.kt index 91194eb5a3..56a4e89292 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/tactile_paving/AddTactilePavingBusStop.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/tactile_paving/AddTactilePavingBusStop.kt @@ -7,7 +7,7 @@ import de.westnordost.streetcomplete.data.osm.osmquests.Tags import de.westnordost.streetcomplete.data.user.achievements.QuestTypeAchievement.BLIND import de.westnordost.streetcomplete.ktx.toYesNo -class AddTactilePavingBusStop : OsmFilterQuestType() { +class AddTactilePavingBusStop : OsmFilterQuestType() { override val elementFilter = """ nodes, ways with @@ -44,7 +44,7 @@ class AddTactilePavingBusStop : OsmFilterQuestType() { override fun createForm() = TactilePavingForm() - override fun applyAnswerTo(answer: Boolean, tags: Tags, timestampEdited: Long) { - tags.updateWithCheckDate("tactile_paving", answer.toYesNo()) + override fun applyAnswerTo(answer: TactilePavingAnswer, tags: Tags, timestampEdited: Long) { + tags.updateWithCheckDate("tactile_paving", answer.osmValue) } } diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/tactile_paving/AddTactilePavingCrosswalk.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/tactile_paving/AddTactilePavingCrosswalk.kt index 905bcf5426..b13bf65127 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/tactile_paving/AddTactilePavingCrosswalk.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/tactile_paving/AddTactilePavingCrosswalk.kt @@ -11,7 +11,7 @@ import de.westnordost.streetcomplete.data.user.achievements.QuestTypeAchievement import de.westnordost.streetcomplete.ktx.toYesNo import de.westnordost.streetcomplete.osm.isCrossing -class AddTactilePavingCrosswalk : OsmElementQuestType { +class AddTactilePavingCrosswalk : OsmElementQuestType { private val crossingFilter by lazy { """ nodes with @@ -61,7 +61,7 @@ class AddTactilePavingCrosswalk : OsmElementQuestType { override fun createForm() = TactilePavingForm() - override fun applyAnswerTo(answer: Boolean, tags: Tags, timestampEdited: Long) { - tags.updateWithCheckDate("tactile_paving", answer.toYesNo()) + override fun applyAnswerTo(answer: TactilePavingAnswer, tags: Tags, timestampEdited: Long) { + tags.updateWithCheckDate("tactile_paving", answer.osmValue) } } diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/tactile_paving/AddTactilePavingKerb.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/tactile_paving/AddTactilePavingKerb.kt index 776815d794..254541e6e5 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/tactile_paving/AddTactilePavingKerb.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/tactile_paving/AddTactilePavingKerb.kt @@ -13,7 +13,7 @@ import de.westnordost.streetcomplete.ktx.toYesNo import de.westnordost.streetcomplete.osm.kerb.couldBeAKerb import de.westnordost.streetcomplete.osm.kerb.findAllKerbNodes -class AddTactilePavingKerb : OsmElementQuestType { +class AddTactilePavingKerb : OsmElementQuestType { private val eligibleKerbsFilter by lazy { """ nodes with @@ -41,8 +41,8 @@ class AddTactilePavingKerb : OsmElementQuestType { if (!eligibleKerbsFilter.matches(element) || element !is Node || !element.couldBeAKerb()) false else null - override fun applyAnswerTo(answer: Boolean, tags: Tags, timestampEdited: Long) { - tags.updateWithCheckDate("tactile_paving", answer.toYesNo()) + override fun applyAnswerTo(answer: TactilePavingAnswer, tags: Tags, timestampEdited: Long) { + tags.updateWithCheckDate("tactile_paving", answer.osmValue) tags["barrier"] = "kerb" } } diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/tactile_paving/TactilePavingAnswer.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/tactile_paving/TactilePavingAnswer.kt new file mode 100644 index 0000000000..130bd262d2 --- /dev/null +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/tactile_paving/TactilePavingAnswer.kt @@ -0,0 +1,7 @@ +package de.westnordost.streetcomplete.quests.tactile_paving + +enum class TactilePavingAnswer(val osmValue: String) { + YES("yes"), + NO("no"), + INCORRECT("incorrect") +} diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/tactile_paving/TactilePavingForm.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/tactile_paving/TactilePavingForm.kt index a60605d013..c7513c527f 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/tactile_paving/TactilePavingForm.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/tactile_paving/TactilePavingForm.kt @@ -1,15 +1,32 @@ package de.westnordost.streetcomplete.quests.tactile_paving import de.westnordost.streetcomplete.R +import de.westnordost.streetcomplete.data.osm.mapdata.Node import de.westnordost.streetcomplete.quests.AbstractQuestAnswerFragment import de.westnordost.streetcomplete.quests.AnswerItem +import de.westnordost.streetcomplete.quests.tactile_paving.TactilePavingAnswer.YES +import de.westnordost.streetcomplete.quests.tactile_paving.TactilePavingAnswer.NO +import de.westnordost.streetcomplete.quests.tactile_paving.TactilePavingAnswer.INCORRECT -class TactilePavingForm : AbstractQuestAnswerFragment() { +class TactilePavingForm : AbstractQuestAnswerFragment() { override val contentLayoutResId = R.layout.quest_tactile_paving + override val otherAnswers get() = listOfNotNull( + createIncorrectAnswerItem() + ) + + private fun createIncorrectAnswerItem(): AnswerItem? { + val node = osmElement as? Node ?: return null + return if (node.tags["highway"] == "crossing" || node.tags["highway"] == "traffic_signals") { + AnswerItem(R.string.quest_tactilePaving_incorrect) { applyAnswer(INCORRECT) } + } else { + null + } + } + override val buttonPanelAnswers = listOf( - AnswerItem(R.string.quest_generic_hasFeature_no) { applyAnswer(false) }, - AnswerItem(R.string.quest_generic_hasFeature_yes) { applyAnswer(true) } + AnswerItem(R.string.quest_generic_hasFeature_no) { applyAnswer(NO) }, + AnswerItem(R.string.quest_generic_hasFeature_yes) { applyAnswer(YES) } ) } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index cf84022228..b75ffb8e84 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -307,6 +307,7 @@ The info you enter is then directly added to the OpenStreetMap in your name, wit "Does this bus stop have tactile paving?" "Does this streetcar stop have tactile paving?" "Does this crosswalk have tactile paving on both sides?" + "Only on one side" Are you sure you checked this on-site? Only information that was found on a survey should be entered. "Does the bus stop %s have tactile paving?" From 9a9f8085644d9dc7edee029407d8b678415cc488 Mon Sep 17 00:00:00 2001 From: arrival-spring Date: Sat, 5 Mar 2022 20:58:25 +0000 Subject: [PATCH 2/4] Add TactilePavingCrosswalkForm --- .../tactile_paving/AddTactilePavingBusStop.kt | 6 ++--- .../AddTactilePavingCrosswalk.kt | 2 +- .../tactile_paving/AddTactilePavingKerb.kt | 6 ++--- .../TactilePavingCrosswalkForm.kt | 26 +++++++++++++++++++ .../tactile_paving/TactilePavingForm.kt | 23 +++------------- 5 files changed, 36 insertions(+), 27 deletions(-) create mode 100644 app/src/main/java/de/westnordost/streetcomplete/quests/tactile_paving/TactilePavingCrosswalkForm.kt diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/tactile_paving/AddTactilePavingBusStop.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/tactile_paving/AddTactilePavingBusStop.kt index 56a4e89292..91194eb5a3 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/tactile_paving/AddTactilePavingBusStop.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/tactile_paving/AddTactilePavingBusStop.kt @@ -7,7 +7,7 @@ import de.westnordost.streetcomplete.data.osm.osmquests.Tags import de.westnordost.streetcomplete.data.user.achievements.QuestTypeAchievement.BLIND import de.westnordost.streetcomplete.ktx.toYesNo -class AddTactilePavingBusStop : OsmFilterQuestType() { +class AddTactilePavingBusStop : OsmFilterQuestType() { override val elementFilter = """ nodes, ways with @@ -44,7 +44,7 @@ class AddTactilePavingBusStop : OsmFilterQuestType() { override fun createForm() = TactilePavingForm() - override fun applyAnswerTo(answer: TactilePavingAnswer, tags: Tags, timestampEdited: Long) { - tags.updateWithCheckDate("tactile_paving", answer.osmValue) + override fun applyAnswerTo(answer: Boolean, tags: Tags, timestampEdited: Long) { + tags.updateWithCheckDate("tactile_paving", answer.toYesNo()) } } diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/tactile_paving/AddTactilePavingCrosswalk.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/tactile_paving/AddTactilePavingCrosswalk.kt index b13bf65127..a49d5a805b 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/tactile_paving/AddTactilePavingCrosswalk.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/tactile_paving/AddTactilePavingCrosswalk.kt @@ -59,7 +59,7 @@ class AddTactilePavingCrosswalk : OsmElementQuestType { override fun isApplicableTo(element: Element): Boolean? = if (!crossingFilter.matches(element)) false else null - override fun createForm() = TactilePavingForm() + override fun createForm() = TactilePavingCrosswalkForm() override fun applyAnswerTo(answer: TactilePavingAnswer, tags: Tags, timestampEdited: Long) { tags.updateWithCheckDate("tactile_paving", answer.osmValue) diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/tactile_paving/AddTactilePavingKerb.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/tactile_paving/AddTactilePavingKerb.kt index 254541e6e5..776815d794 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/tactile_paving/AddTactilePavingKerb.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/tactile_paving/AddTactilePavingKerb.kt @@ -13,7 +13,7 @@ import de.westnordost.streetcomplete.ktx.toYesNo import de.westnordost.streetcomplete.osm.kerb.couldBeAKerb import de.westnordost.streetcomplete.osm.kerb.findAllKerbNodes -class AddTactilePavingKerb : OsmElementQuestType { +class AddTactilePavingKerb : OsmElementQuestType { private val eligibleKerbsFilter by lazy { """ nodes with @@ -41,8 +41,8 @@ class AddTactilePavingKerb : OsmElementQuestType { if (!eligibleKerbsFilter.matches(element) || element !is Node || !element.couldBeAKerb()) false else null - override fun applyAnswerTo(answer: TactilePavingAnswer, tags: Tags, timestampEdited: Long) { - tags.updateWithCheckDate("tactile_paving", answer.osmValue) + override fun applyAnswerTo(answer: Boolean, tags: Tags, timestampEdited: Long) { + tags.updateWithCheckDate("tactile_paving", answer.toYesNo()) tags["barrier"] = "kerb" } } diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/tactile_paving/TactilePavingCrosswalkForm.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/tactile_paving/TactilePavingCrosswalkForm.kt new file mode 100644 index 0000000000..b81074aeae --- /dev/null +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/tactile_paving/TactilePavingCrosswalkForm.kt @@ -0,0 +1,26 @@ +package de.westnordost.streetcomplete.quests.tactile_paving + +import de.westnordost.streetcomplete.R +import de.westnordost.streetcomplete.quests.AbstractQuestAnswerFragment +import de.westnordost.streetcomplete.quests.AnswerItem +import de.westnordost.streetcomplete.quests.tactile_paving.TactilePavingAnswer.YES +import de.westnordost.streetcomplete.quests.tactile_paving.TactilePavingAnswer.NO +import de.westnordost.streetcomplete.quests.tactile_paving.TactilePavingAnswer.INCORRECT + +class TactilePavingCrosswalkForm : AbstractQuestAnswerFragment() { + + override val contentLayoutResId = R.layout.quest_tactile_paving + + override val otherAnswers get() = listOfNotNull( + createIncorrectAnswerItem() + ) + + private fun createIncorrectAnswerItem(): AnswerItem { + return AnswerItem(R.string.quest_tactilePaving_incorrect) { applyAnswer(INCORRECT) } + } + + override val buttonPanelAnswers = listOf( + AnswerItem(R.string.quest_generic_hasFeature_no) { applyAnswer(NO) }, + AnswerItem(R.string.quest_generic_hasFeature_yes) { applyAnswer(YES) } + ) +} diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/tactile_paving/TactilePavingForm.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/tactile_paving/TactilePavingForm.kt index c7513c527f..a60605d013 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/tactile_paving/TactilePavingForm.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/tactile_paving/TactilePavingForm.kt @@ -1,32 +1,15 @@ package de.westnordost.streetcomplete.quests.tactile_paving import de.westnordost.streetcomplete.R -import de.westnordost.streetcomplete.data.osm.mapdata.Node import de.westnordost.streetcomplete.quests.AbstractQuestAnswerFragment import de.westnordost.streetcomplete.quests.AnswerItem -import de.westnordost.streetcomplete.quests.tactile_paving.TactilePavingAnswer.YES -import de.westnordost.streetcomplete.quests.tactile_paving.TactilePavingAnswer.NO -import de.westnordost.streetcomplete.quests.tactile_paving.TactilePavingAnswer.INCORRECT -class TactilePavingForm : AbstractQuestAnswerFragment() { +class TactilePavingForm : AbstractQuestAnswerFragment() { override val contentLayoutResId = R.layout.quest_tactile_paving - override val otherAnswers get() = listOfNotNull( - createIncorrectAnswerItem() - ) - - private fun createIncorrectAnswerItem(): AnswerItem? { - val node = osmElement as? Node ?: return null - return if (node.tags["highway"] == "crossing" || node.tags["highway"] == "traffic_signals") { - AnswerItem(R.string.quest_tactilePaving_incorrect) { applyAnswer(INCORRECT) } - } else { - null - } - } - override val buttonPanelAnswers = listOf( - AnswerItem(R.string.quest_generic_hasFeature_no) { applyAnswer(NO) }, - AnswerItem(R.string.quest_generic_hasFeature_yes) { applyAnswer(YES) } + AnswerItem(R.string.quest_generic_hasFeature_no) { applyAnswer(false) }, + AnswerItem(R.string.quest_generic_hasFeature_yes) { applyAnswer(true) } ) } From 4c11c8cac27364467f33bbff81b855ca807dcb83 Mon Sep 17 00:00:00 2001 From: Tobias Zwick Date: Sat, 5 Mar 2022 22:34:50 +0100 Subject: [PATCH 3/4] shorten other answers function --- .../quests/tactile_paving/TactilePavingCrosswalkForm.kt | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/tactile_paving/TactilePavingCrosswalkForm.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/tactile_paving/TactilePavingCrosswalkForm.kt index b81074aeae..ebd0ae0af6 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/tactile_paving/TactilePavingCrosswalkForm.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/tactile_paving/TactilePavingCrosswalkForm.kt @@ -11,14 +11,10 @@ class TactilePavingCrosswalkForm : AbstractQuestAnswerFragment Date: Sat, 5 Mar 2022 21:49:41 +0000 Subject: [PATCH 4/4] Rename to TactilePavingCrosswalkAnswer --- .../quests/tactile_paving/AddTactilePavingCrosswalk.kt | 5 ++--- ...ilePavingAnswer.kt => TactilePavingCrosswalkAnswer.kt} | 2 +- .../quests/tactile_paving/TactilePavingCrosswalkForm.kt | 8 ++++---- 3 files changed, 7 insertions(+), 8 deletions(-) rename app/src/main/java/de/westnordost/streetcomplete/quests/tactile_paving/{TactilePavingAnswer.kt => TactilePavingCrosswalkAnswer.kt} (65%) diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/tactile_paving/AddTactilePavingCrosswalk.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/tactile_paving/AddTactilePavingCrosswalk.kt index a49d5a805b..e32caf2aa8 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/tactile_paving/AddTactilePavingCrosswalk.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/tactile_paving/AddTactilePavingCrosswalk.kt @@ -8,10 +8,9 @@ import de.westnordost.streetcomplete.data.osm.mapdata.MapDataWithGeometry import de.westnordost.streetcomplete.data.osm.osmquests.OsmElementQuestType import de.westnordost.streetcomplete.data.osm.osmquests.Tags import de.westnordost.streetcomplete.data.user.achievements.QuestTypeAchievement.BLIND -import de.westnordost.streetcomplete.ktx.toYesNo import de.westnordost.streetcomplete.osm.isCrossing -class AddTactilePavingCrosswalk : OsmElementQuestType { +class AddTactilePavingCrosswalk : OsmElementQuestType { private val crossingFilter by lazy { """ nodes with @@ -61,7 +60,7 @@ class AddTactilePavingCrosswalk : OsmElementQuestType { override fun createForm() = TactilePavingCrosswalkForm() - override fun applyAnswerTo(answer: TactilePavingAnswer, tags: Tags, timestampEdited: Long) { + override fun applyAnswerTo(answer: TactilePavingCrosswalkAnswer, tags: Tags, timestampEdited: Long) { tags.updateWithCheckDate("tactile_paving", answer.osmValue) } } diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/tactile_paving/TactilePavingAnswer.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/tactile_paving/TactilePavingCrosswalkAnswer.kt similarity index 65% rename from app/src/main/java/de/westnordost/streetcomplete/quests/tactile_paving/TactilePavingAnswer.kt rename to app/src/main/java/de/westnordost/streetcomplete/quests/tactile_paving/TactilePavingCrosswalkAnswer.kt index 130bd262d2..6b04ebf37c 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/tactile_paving/TactilePavingAnswer.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/tactile_paving/TactilePavingCrosswalkAnswer.kt @@ -1,6 +1,6 @@ package de.westnordost.streetcomplete.quests.tactile_paving -enum class TactilePavingAnswer(val osmValue: String) { +enum class TactilePavingCrosswalkAnswer(val osmValue: String) { YES("yes"), NO("no"), INCORRECT("incorrect") diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/tactile_paving/TactilePavingCrosswalkForm.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/tactile_paving/TactilePavingCrosswalkForm.kt index ebd0ae0af6..554db6aefb 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/tactile_paving/TactilePavingCrosswalkForm.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/tactile_paving/TactilePavingCrosswalkForm.kt @@ -3,11 +3,11 @@ package de.westnordost.streetcomplete.quests.tactile_paving import de.westnordost.streetcomplete.R import de.westnordost.streetcomplete.quests.AbstractQuestAnswerFragment import de.westnordost.streetcomplete.quests.AnswerItem -import de.westnordost.streetcomplete.quests.tactile_paving.TactilePavingAnswer.YES -import de.westnordost.streetcomplete.quests.tactile_paving.TactilePavingAnswer.NO -import de.westnordost.streetcomplete.quests.tactile_paving.TactilePavingAnswer.INCORRECT +import de.westnordost.streetcomplete.quests.tactile_paving.TactilePavingCrosswalkAnswer.YES +import de.westnordost.streetcomplete.quests.tactile_paving.TactilePavingCrosswalkAnswer.NO +import de.westnordost.streetcomplete.quests.tactile_paving.TactilePavingCrosswalkAnswer.INCORRECT -class TactilePavingCrosswalkForm : AbstractQuestAnswerFragment() { +class TactilePavingCrosswalkForm : AbstractQuestAnswerFragment() { override val contentLayoutResId = R.layout.quest_tactile_paving