From 55d619f676a362e8530fba91a730d0360873bc08 Mon Sep 17 00:00:00 2001 From: Nick-Tallguy Date: Tue, 25 Jun 2024 14:45:38 +0100 Subject: [PATCH 01/21] 1st attempt at gates displaying only --- .../streetcomplete/quests/barrier_opening/WidthAnswer.kt | 5 +++++ build.gradle.kts | 2 +- gradle/wrapper/gradle-wrapper.properties | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/WidthAnswer.kt diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/WidthAnswer.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/WidthAnswer.kt new file mode 100644 index 0000000000..93d0b68695 --- /dev/null +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/WidthAnswer.kt @@ -0,0 +1,5 @@ +package de.westnordost.streetcomplete.quests.barrier_opening + +import de.westnordost.streetcomplete.osm.Length + +data class WidthAnswer(val width: Length, val isARMeasurement: Boolean) diff --git a/build.gradle.kts b/build.gradle.kts index ac51a90f51..b77d3ae65a 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -5,7 +5,7 @@ buildscript { } dependencies { val kotlinVersion = "2.0.0" - classpath("com.android.tools.build:gradle:8.4.1") + classpath("com.android.tools.build:gradle:8.5.0") classpath(kotlin("gradle-plugin", version = kotlinVersion)) } } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index cbf1b3ea9f..f2b939b60b 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip zipStoreBase=GRADLE_USER_HOME From 65c5fbc425b64f065f75a80d912bf2b49884ce73 Mon Sep 17 00:00:00 2001 From: Nick-Tallguy Date: Sat, 29 Jun 2024 13:57:38 +0100 Subject: [PATCH 02/21] Quest files created and mainly updated - still need to; * Check values in Form, * General check of files - although it builds, it will not run, * New icon needed at some point, * Need to filter out the gates etc which are on private roads etc - waiting until after the more general files are working first .. issue https://github.com/streetcomplete/StreetComplete/issues/5678 refers --- .../streetcomplete/quests/QuestsModule.kt | 2 + .../barrier_opening/AddBarrierOpening.kt | 65 +++++++++++++ .../barrier_opening/AddGateWidthForm.kt | 96 +++++++++++++++++++ app/src/main/res/values/strings.xml | 2 + 4 files changed, 165 insertions(+) create mode 100644 app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/AddBarrierOpening.kt create mode 100644 app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/AddGateWidthForm.kt 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 0fe6701e7d..1829347171 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/QuestsModule.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/QuestsModule.kt @@ -25,6 +25,7 @@ import de.westnordost.streetcomplete.quests.atm_operator.AddAtmOperator import de.westnordost.streetcomplete.quests.baby_changing_table.AddBabyChangingTable import de.westnordost.streetcomplete.quests.barrier_bicycle_barrier_installation.AddBicycleBarrierInstallation import de.westnordost.streetcomplete.quests.barrier_bicycle_barrier_type.AddBicycleBarrierType +import de.westnordost.streetcomplete.quests.barrier_opening.AddBarrierOpening import de.westnordost.streetcomplete.quests.barrier_type.AddBarrierOnPath import de.westnordost.streetcomplete.quests.barrier_type.AddBarrierOnRoad import de.westnordost.streetcomplete.quests.barrier_type.AddBarrierType @@ -510,6 +511,7 @@ fun questTypeRegistry( 140 to AddRoadWidth(arSupportChecker), 141 to AddRoadSmoothness(), 142 to AddPathSmoothness(), + 163 to AddBarrierOpening(arSupportChecker), // footways 143 to AddPathSurface(), // used by OSM Carto, BRouter, OsmAnd, OSRM, graphhopper... diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/AddBarrierOpening.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/AddBarrierOpening.kt new file mode 100644 index 0000000000..365466e7db --- /dev/null +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/AddBarrierOpening.kt @@ -0,0 +1,65 @@ +package de.westnordost.streetcomplete.quests.barrier_opening + +import de.westnordost.streetcomplete.R +import de.westnordost.streetcomplete.data.elementfilter.toElementFilterExpression +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.osmquests.OsmElementQuestType +import de.westnordost.streetcomplete.data.user.achievements.EditTypeAchievement.BICYCLIST +import de.westnordost.streetcomplete.data.user.achievements.EditTypeAchievement.CAR +import de.westnordost.streetcomplete.data.user.achievements.EditTypeAchievement.PEDESTRIAN +import de.westnordost.streetcomplete.data.user.achievements.EditTypeAchievement.WHEELCHAIR +import de.westnordost.streetcomplete.osm.Tags +import de.westnordost.streetcomplete.quests.width.WidthAnswer +import de.westnordost.streetcomplete.screens.measure.ArSupportChecker + +class AddBarrierOpening( + private val checkArSupport: ArSupportChecker + ) : OsmElementQuestType { + + private val nodeFilter by lazy { """ + nodes with + barrier ~ ${GATEWAYS.joinToString( "|")} + and (!maxwidth:physical or !source:maxwidth:physical ~ ".*estimat.*") + and (!width or source:width ~ ".*estimat.*") + and (!maxwidth or source:maxwidth ~ ".*estimat.*") + """.toElementFilterExpression() } + + override val changesetComment = "Specify width of opening" + override val wikiLink = "Key:barrier" + // icon needed + override val icon = R.drawable.ic_quest_bicycleway_width + override val achievements = listOf(BICYCLIST, CAR, PEDESTRIAN, WHEELCHAIR) + override val defaultDisabledMessage: Int + get() = if (!checkArSupport()) R.string.default_disabled_msg_no_ar else 0 + + override fun getTitle(tags: Map) = R.string.quest_barrier_opening_width_gate + + override fun getApplicableElements(mapData: MapDataWithGeometry) = + mapData.nodes.filter { nodeFilter.matches(it) } + + override fun isApplicableTo(element: Element) = + nodeFilter.matches(element) + + override fun createForm() = AddGateWidthForm() + + override fun applyAnswerTo(answer: WidthAnswer, tags: Tags, geometry: ElementGeometry, timestampEdited: Long) { + val key = if (tags["barrier"] in GATEWAYS) "maxwidth:physical" else "width" + + tags[key] = answer.width.toOsmValue() + + if (answer.isARMeasurement) { + tags["source:$key"] = "ARCore" + } else { + tags.remove("source:$key") + } + + // update width:barrier if it is set + if (key == "width" && tags.containsKey("maxwidth")) { + tags["maxwidth:physical"] = answer.width.toOsmValue() + } + } +} + +val GATEWAYS = setOf("gate", "entrance", "sliding_gate", "swing_gate", "wicket_gate", "bollard", "block") diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/AddGateWidthForm.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/AddGateWidthForm.kt new file mode 100644 index 0000000000..2c40816269 --- /dev/null +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/AddGateWidthForm.kt @@ -0,0 +1,96 @@ +package de.westnordost.streetcomplete.quests.barrier_opening + +import android.os.Bundle +import android.view.View +import androidx.appcompat.app.AlertDialog +import androidx.core.view.isGone +import de.westnordost.streetcomplete.R +import de.westnordost.streetcomplete.databinding.QuestLengthBinding +import de.westnordost.streetcomplete.osm.Length +import de.westnordost.streetcomplete.osm.hasDubiousRoadWidth +import de.westnordost.streetcomplete.quests.AbstractArMeasureQuestForm +import de.westnordost.streetcomplete.quests.width.WidthAnswer +import de.westnordost.streetcomplete.screens.measure.ArSupportChecker +import de.westnordost.streetcomplete.view.controller.LengthInputViewController +import org.koin.android.ext.android.inject + +class AddGateWidthForm : AbstractArMeasureQuestForm() { + + override val contentLayoutResId = R.layout.quest_length + private val binding by contentViewBinding(QuestLengthBinding::bind) + private val checkArSupport: ArSupportChecker by inject() + private var isARMeasurement: Boolean = false + private lateinit var lengthInput: LengthInputViewController + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + savedInstanceState?.let { isARMeasurement = it.getBoolean(AR) } + } + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + + val isBarrier = element.tags["barrier"] in GATEWAYS + val explanation = if (isBarrier) getString(R.string.quest_barrier_opening_width_explanation) else null + binding.widthExplanationTextView.isGone = explanation == null + binding.widthExplanationTextView.text = explanation + + lengthInput = binding.lengthInput.let { + LengthInputViewController(it.unitSelect, it.metersContainer, it.metersInput, it.feetInchesContainer, it.feetInput, it.inchesInput) + } + lengthInput.unitSelectItemResId = R.layout.spinner_item_centered_large + lengthInput.isCompactMode = true + lengthInput.maxFeetDigits = if (isBarrier) 3 else 2 + lengthInput.maxMeterDigits = Pair(if (isBarrier) 2 else 1, 2) + lengthInput.selectableUnits = countryInfo.lengthUnits + lengthInput.onInputChanged = { + isARMeasurement = false + checkIsFormComplete() + } + binding.measureButton.isGone = !checkArSupport() + binding.measureButton.setOnClickListener { takeMeasurement() } + } + + private fun takeMeasurement() { + val lengthUnit = lengthInput.unit ?: return + takeMeasurement(lengthUnit, false) + } + + override fun onMeasured(length: Length) { + lengthInput.length = length + isARMeasurement = true + } + + override fun onClickOk() { + val length = lengthInput.length!! + val newTags = element.tags + ("width" to length.toMeters().toString()) + if (hasDubiousRoadWidth(newTags) != true) { + applyAnswer(WidthAnswer(length, isARMeasurement)) + } else { + confirmDubiousRoadWidth { + applyAnswer(WidthAnswer(length, isARMeasurement)) + } + } + } + + private fun confirmDubiousRoadWidth(onConfirmed: () -> Unit) { + activity?.let { AlertDialog.Builder(it) + .setTitle(R.string.quest_generic_confirmation_title) + .setMessage(R.string.quest_road_width_unusualInput_confirmation_description) + .setPositiveButton(R.string.quest_generic_confirmation_yes) { _, _ -> onConfirmed() } + .setNegativeButton(R.string.quest_generic_confirmation_no, null) + .show() + } + } + + override fun isFormComplete(): Boolean = lengthInput.length != null + + override fun onSaveInstanceState(outState: Bundle) { + super.onSaveInstanceState(outState) + outState.putBoolean(AR, isARMeasurement) + } + + companion object { + private const val AR = "ar" + } +} diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 5685b14f34..7e80c4cae0 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1772,5 +1772,7 @@ Alternatively, you can leave a note (with a photo)." Message contains Filter messages Not inside, but covered + What is the width of the opening here + What is the maximum usable opening width here From d1ac50124a5f2c304545603330b472d325c7552f Mon Sep 17 00:00:00 2001 From: Nick-Tallguy Date: Sat, 29 Jun 2024 14:45:01 +0100 Subject: [PATCH 03/21] update number applied to quest - had previously accidentally duplicated a number --- .../java/de/westnordost/streetcomplete/quests/QuestsModule.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 1829347171..276e378b48 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/QuestsModule.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/QuestsModule.kt @@ -511,7 +511,7 @@ fun questTypeRegistry( 140 to AddRoadWidth(arSupportChecker), 141 to AddRoadSmoothness(), 142 to AddPathSmoothness(), - 163 to AddBarrierOpening(arSupportChecker), + 170 to AddBarrierOpening(arSupportChecker), // footways 143 to AddPathSurface(), // used by OSM Carto, BRouter, OsmAnd, OSRM, graphhopper... From d9642f143ea150d7443305ac4616aa3c43e238e8 Mon Sep 17 00:00:00 2001 From: Nick-Tallguy Date: Sat, 29 Jun 2024 16:54:06 +0100 Subject: [PATCH 04/21] remove own copy of WidthAnswer.kt - not needed --- .../streetcomplete/quests/barrier_opening/WidthAnswer.kt | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/WidthAnswer.kt diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/WidthAnswer.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/WidthAnswer.kt deleted file mode 100644 index 93d0b68695..0000000000 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/WidthAnswer.kt +++ /dev/null @@ -1,5 +0,0 @@ -package de.westnordost.streetcomplete.quests.barrier_opening - -import de.westnordost.streetcomplete.osm.Length - -data class WidthAnswer(val width: Length, val isARMeasurement: Boolean) From d867ab4aed26bafca1244cdec342c3d37014e7c0 Mon Sep 17 00:00:00 2001 From: Nick-Tallguy Date: Sun, 30 Jun 2024 15:01:26 +0100 Subject: [PATCH 05/21] Barriers are now displaying - need to sort the filters. Emulator shows it is possible to update data - needs more checking. --- .../quests/barrier_opening/AddBarrierOpening.kt | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/AddBarrierOpening.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/AddBarrierOpening.kt index 365466e7db..37106bfd57 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/AddBarrierOpening.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/AddBarrierOpening.kt @@ -20,12 +20,25 @@ class AddBarrierOpening( private val nodeFilter by lazy { """ nodes with - barrier ~ ${GATEWAYS.joinToString( "|")} - and (!maxwidth:physical or !source:maxwidth:physical ~ ".*estimat.*") + barrier ~ ${GATEWAYS.joinToString("|")} + and (!maxwidth:physical or source:maxwidth_physical ~ ".*estimat.*") and (!width or source:width ~ ".*estimat.*") and (!maxwidth or source:maxwidth ~ ".*estimat.*") """.toElementFilterExpression() } + + // private val wayFilter by lazy { """ + // ways with ( + // ( + // barrier ~ ${GATEWAYS.joinToString( "|")} +// +// and area != yes +// and (!width or source:width ~ ".*estimat.*") +// and (access !~ private|no or (foot and foot !~ private|no)) +// and foot != no +// and placement != transition +// """.toElementFilterExpression() } + override val changesetComment = "Specify width of opening" override val wikiLink = "Key:barrier" // icon needed From 7498974041f8ec37d1300bedf26355a7d4cebc22 Mon Sep 17 00:00:00 2001 From: Nick-Tallguy Date: Sun, 30 Jun 2024 17:01:17 +0100 Subject: [PATCH 06/21] Flters seem to be working okay on emulator - need to produce apk and test on phone (emulator does not have streetmeasure, and won't seem to load it. https://github.com/streetcomplete/StreetComplete/issues/5678 refers Also still needs an icon. --- .../barrier_opening/AddBarrierOpening.kt | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/AddBarrierOpening.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/AddBarrierOpening.kt index 37106bfd57..cf91b540e1 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/AddBarrierOpening.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/AddBarrierOpening.kt @@ -24,20 +24,13 @@ class AddBarrierOpening( and (!maxwidth:physical or source:maxwidth_physical ~ ".*estimat.*") and (!width or source:width ~ ".*estimat.*") and (!maxwidth or source:maxwidth ~ ".*estimat.*") + and access !~ private|no|customers|agricultural """.toElementFilterExpression() } - - // private val wayFilter by lazy { """ - // ways with ( - // ( - // barrier ~ ${GATEWAYS.joinToString( "|")} -// -// and area != yes -// and (!width or source:width ~ ".*estimat.*") -// and (access !~ private|no or (foot and foot !~ private|no)) -// and foot != no -// and placement != transition -// """.toElementFilterExpression() } + private val excludedWaysFilter by lazy { """ + ways with + highway and access ~ private|no + """.toElementFilterExpression() } override val changesetComment = "Specify width of opening" override val wikiLink = "Key:barrier" @@ -49,8 +42,16 @@ class AddBarrierOpening( override fun getTitle(tags: Map) = R.string.quest_barrier_opening_width_gate - override fun getApplicableElements(mapData: MapDataWithGeometry) = + override fun getApplicableElements(mapData: MapDataWithGeometry): Iterable { mapData.nodes.filter { nodeFilter.matches(it) } + val excludedWayNodeIds = mapData.ways + .filter { excludedWaysFilter.matches(it) } + .flatMapTo(HashSet()) { it.nodeIds } + + return mapData.nodes + .filter { nodeFilter.matches(it) && it.id !in excludedWayNodeIds } + } + override fun isApplicableTo(element: Element) = nodeFilter.matches(element) From 71120157167524ae7d73b112783c6cbc83a5dbc8 Mon Sep 17 00:00:00 2001 From: Nick-Tallguy Date: Sat, 6 Jul 2024 00:11:21 +0100 Subject: [PATCH 07/21] Amendments to pull request; * strings.xml - line 1775 question mark added, and line 1776 deleted. * AddBarrierOpening.kt - * bollard and block removed, ** lines 59 - 62 - not changed yet (needs research by me), * lines 66 - 70 - indentation added, ** lines 72 - 75 - not changed yet (needs research by me), * line 39 CAR & PEDESTRIAN removed. Will continue to research for items with ** & then resubmit. --- .../quests/barrier_opening/AddBarrierOpening.kt | 16 +++++++--------- app/src/main/res/values/strings.xml | 3 +-- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/AddBarrierOpening.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/AddBarrierOpening.kt index cf91b540e1..411c19dc86 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/AddBarrierOpening.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/AddBarrierOpening.kt @@ -7,8 +7,6 @@ import de.westnordost.streetcomplete.data.osm.mapdata.Element import de.westnordost.streetcomplete.data.osm.mapdata.MapDataWithGeometry import de.westnordost.streetcomplete.data.osm.osmquests.OsmElementQuestType import de.westnordost.streetcomplete.data.user.achievements.EditTypeAchievement.BICYCLIST -import de.westnordost.streetcomplete.data.user.achievements.EditTypeAchievement.CAR -import de.westnordost.streetcomplete.data.user.achievements.EditTypeAchievement.PEDESTRIAN import de.westnordost.streetcomplete.data.user.achievements.EditTypeAchievement.WHEELCHAIR import de.westnordost.streetcomplete.osm.Tags import de.westnordost.streetcomplete.quests.width.WidthAnswer @@ -36,7 +34,7 @@ class AddBarrierOpening( override val wikiLink = "Key:barrier" // icon needed override val icon = R.drawable.ic_quest_bicycleway_width - override val achievements = listOf(BICYCLIST, CAR, PEDESTRIAN, WHEELCHAIR) + override val achievements = listOf(BICYCLIST, WHEELCHAIR) override val defaultDisabledMessage: Int get() = if (!checkArSupport()) R.string.default_disabled_msg_no_ar else 0 @@ -63,11 +61,11 @@ class AddBarrierOpening( tags[key] = answer.width.toOsmValue() - if (answer.isARMeasurement) { - tags["source:$key"] = "ARCore" - } else { - tags.remove("source:$key") - } + if (answer.isARMeasurement) { + tags["source:$key"] = "ARCore" + } else { + tags.remove("source:$key") + } // update width:barrier if it is set if (key == "width" && tags.containsKey("maxwidth")) { @@ -76,4 +74,4 @@ class AddBarrierOpening( } } -val GATEWAYS = setOf("gate", "entrance", "sliding_gate", "swing_gate", "wicket_gate", "bollard", "block") +val GATEWAYS = setOf("gate", "entrance", "sliding_gate", "swing_gate", "wicket_gate") diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 060aea085a..e6dde3465d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1772,7 +1772,6 @@ Alternatively, you can leave a note (with a photo)." Message contains Filter messages Not inside, but covered - What is the width of the opening here - What is the maximum usable opening width here + What is the width of the opening here? From 1f7deeae1ef7377d4615ae90b78021c159d5e966 Mon Sep 17 00:00:00 2001 From: Nick-Tallguy Date: Sat, 6 Jul 2024 00:33:13 +0100 Subject: [PATCH 08/21] amend indentation to remove warning on Android Studio - Lint issue --- .../streetcomplete/quests/barrier_opening/AddBarrierOpening.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/AddBarrierOpening.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/AddBarrierOpening.kt index 411c19dc86..9080ad7411 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/AddBarrierOpening.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/AddBarrierOpening.kt @@ -59,7 +59,7 @@ class AddBarrierOpening( override fun applyAnswerTo(answer: WidthAnswer, tags: Tags, geometry: ElementGeometry, timestampEdited: Long) { val key = if (tags["barrier"] in GATEWAYS) "maxwidth:physical" else "width" - tags[key] = answer.width.toOsmValue() + tags[key] = answer.width.toOsmValue() if (answer.isARMeasurement) { tags["source:$key"] = "ARCore" From 01fd90bf776dfe1f78af9aff9ad744b964991b98 Mon Sep 17 00:00:00 2001 From: Nick-Tallguy Date: Sat, 6 Jul 2024 23:38:35 +0100 Subject: [PATCH 09/21] remove reference to removed string in Form --- .../streetcomplete/quests/barrier_opening/AddGateWidthForm.kt | 3 --- 1 file changed, 3 deletions(-) diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/AddGateWidthForm.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/AddGateWidthForm.kt index 2c40816269..ee88200c94 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/AddGateWidthForm.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/AddGateWidthForm.kt @@ -31,9 +31,6 @@ class AddGateWidthForm : AbstractArMeasureQuestForm() { super.onViewCreated(view, savedInstanceState) val isBarrier = element.tags["barrier"] in GATEWAYS - val explanation = if (isBarrier) getString(R.string.quest_barrier_opening_width_explanation) else null - binding.widthExplanationTextView.isGone = explanation == null - binding.widthExplanationTextView.text = explanation lengthInput = binding.lengthInput.let { LengthInputViewController(it.unitSelect, it.metersContainer, it.metersInput, it.feetInchesContainer, it.feetInput, it.inchesInput) From 36b6331898ea9f8f52e17de9e15a53845d523d5a Mon Sep 17 00:00:00 2001 From: Nick-Tallguy Date: Mon, 8 Jul 2024 11:11:35 +0100 Subject: [PATCH 10/21] remove reference to removed string in Form --- .../quests/barrier_opening/AddBarrierOpening.kt | 10 +++++++--- .../quests/barrier_opening/AddGateWidthForm.kt | 3 ++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/AddBarrierOpening.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/AddBarrierOpening.kt index 9080ad7411..b1084101cf 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/AddBarrierOpening.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/AddBarrierOpening.kt @@ -27,7 +27,7 @@ class AddBarrierOpening( private val excludedWaysFilter by lazy { """ ways with - highway and access ~ private|no + highway and access ~ private|no|customers|agricultural """.toElementFilterExpression() } override val changesetComment = "Specify width of opening" @@ -57,9 +57,13 @@ class AddBarrierOpening( override fun createForm() = AddGateWidthForm() override fun applyAnswerTo(answer: WidthAnswer, tags: Tags, geometry: ElementGeometry, timestampEdited: Long) { - val key = if (tags["barrier"] in GATEWAYS) "maxwidth:physical" else "width" + val key = if (tags["barrier"] in GATEWAYS) "maxwidth:physical" else 0 + // val key = if (tags["barrier"] in GATEWAYS) "maxwidth:physical" else "width" + // val key = tags["barrier"] in GATEWAYS + // "maxwidth:physical" - tags[key] = answer.width.toOsmValue() + // tags[key] = answer.width.toOsmValue() + tags[key.toString()] = answer.width.toOsmValue() if (answer.isARMeasurement) { tags["source:$key"] = "ARCore" diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/AddGateWidthForm.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/AddGateWidthForm.kt index ee88200c94..e1d3fee9ce 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/AddGateWidthForm.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/AddGateWidthForm.kt @@ -60,7 +60,8 @@ class AddGateWidthForm : AbstractArMeasureQuestForm() { override fun onClickOk() { val length = lengthInput.length!! - val newTags = element.tags + ("width" to length.toMeters().toString()) + // val newTags = element.tags + ("width" to length.toMeters().toString()) + val newTags = element.tags + ("maxwidth:physical" to length.toMeters().toString()) if (hasDubiousRoadWidth(newTags) != true) { applyAnswer(WidthAnswer(length, isARMeasurement)) } else { From 94dfa3dfbc9853a250d9c113eb94dcce38d69ce6 Mon Sep 17 00:00:00 2001 From: Nick-Tallguy Date: Mon, 8 Jul 2024 16:54:31 +0100 Subject: [PATCH 11/21] remove unnecessary code & amend if / else statement --- .../quests/barrier_opening/AddBarrierOpening.kt | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/AddBarrierOpening.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/AddBarrierOpening.kt index b1084101cf..bf6fb740c5 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/AddBarrierOpening.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/AddBarrierOpening.kt @@ -57,12 +57,8 @@ class AddBarrierOpening( override fun createForm() = AddGateWidthForm() override fun applyAnswerTo(answer: WidthAnswer, tags: Tags, geometry: ElementGeometry, timestampEdited: Long) { - val key = if (tags["barrier"] in GATEWAYS) "maxwidth:physical" else 0 - // val key = if (tags["barrier"] in GATEWAYS) "maxwidth:physical" else "width" - // val key = tags["barrier"] in GATEWAYS - // "maxwidth:physical" - // tags[key] = answer.width.toOsmValue() + val key = if (tags["barrier"] in GATEWAYS) "maxwidth:physical" else 0 tags[key.toString()] = answer.width.toOsmValue() if (answer.isARMeasurement) { @@ -71,10 +67,6 @@ class AddBarrierOpening( tags.remove("source:$key") } - // update width:barrier if it is set - if (key == "width" && tags.containsKey("maxwidth")) { - tags["maxwidth:physical"] = answer.width.toOsmValue() - } } } From b6205fdb920308e3f5755ea44750f537f9d06306 Mon Sep 17 00:00:00 2001 From: Nick-Tallguy Date: Fri, 12 Jul 2024 09:58:58 +0100 Subject: [PATCH 12/21] remove duplicate strings brought in from merge. --- app/src/main/res/values/strings.xml | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 96ea24ab48..3846fee584 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1775,17 +1775,6 @@ Alternatively, you can leave a note (with a photo)." Chicane Curb extension + traffic island No narrowed lane here - Logs (%1$d) - for use in error reports - Filter - Share logs - Show logs - Log level - From - To - Message contains - Filter messages - Not inside, but covered What is the width of the opening here? From 7dcdcf99265d0060321b02dff405c140e69dd4fc Mon Sep 17 00:00:00 2001 From: Nick-Tallguy Date: Fri, 12 Jul 2024 10:52:08 +0100 Subject: [PATCH 13/21] add wheelchair width icon --- res/graphics/quest/wheelchair_width.svg | 135 ++++++++++++++++++++++++ 1 file changed, 135 insertions(+) create mode 100644 res/graphics/quest/wheelchair_width.svg diff --git a/res/graphics/quest/wheelchair_width.svg b/res/graphics/quest/wheelchair_width.svg new file mode 100644 index 0000000000..d248e72e59 --- /dev/null +++ b/res/graphics/quest/wheelchair_width.svg @@ -0,0 +1,135 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + From 061028dd6cdf48bcae5e2fcac40d4f5c2fcdd21a Mon Sep 17 00:00:00 2001 From: Nick-Tallguy Date: Fri, 12 Jul 2024 11:21:59 +0100 Subject: [PATCH 14/21] add icon based on wheelchair icon, and amend files to include. --- .../barrier_opening/AddBarrierOpening.kt | 3 +- .../res/drawable/ic_quest_barrier_opening.xml | 88 ++++++++++ res/graphics/quest/wheelchair_width.svg | 160 +++--------------- 3 files changed, 117 insertions(+), 134 deletions(-) create mode 100644 app/src/main/res/drawable/ic_quest_barrier_opening.xml diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/AddBarrierOpening.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/AddBarrierOpening.kt index bf6fb740c5..09234b7202 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/AddBarrierOpening.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/AddBarrierOpening.kt @@ -32,8 +32,7 @@ class AddBarrierOpening( override val changesetComment = "Specify width of opening" override val wikiLink = "Key:barrier" - // icon needed - override val icon = R.drawable.ic_quest_bicycleway_width + override val icon = R.drawable.ic_quest_barrier_opening override val achievements = listOf(BICYCLIST, WHEELCHAIR) override val defaultDisabledMessage: Int get() = if (!checkArSupport()) R.string.default_disabled_msg_no_ar else 0 diff --git a/app/src/main/res/drawable/ic_quest_barrier_opening.xml b/app/src/main/res/drawable/ic_quest_barrier_opening.xml new file mode 100644 index 0000000000..26c13e0a4d --- /dev/null +++ b/app/src/main/res/drawable/ic_quest_barrier_opening.xml @@ -0,0 +1,88 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/res/graphics/quest/wheelchair_width.svg b/res/graphics/quest/wheelchair_width.svg index d248e72e59..215e6c09f2 100644 --- a/res/graphics/quest/wheelchair_width.svg +++ b/res/graphics/quest/wheelchair_width.svg @@ -1,135 +1,31 @@ - - - - - - - - - - + + + + + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + From 8c8032c3d3524d9c24688c46c51be5d1c4af004d Mon Sep 17 00:00:00 2001 From: "Nick Allen (OSM = Tallguy)" Date: Fri, 12 Jul 2024 17:09:21 +0100 Subject: [PATCH 15/21] Update app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/AddBarrierOpening.kt Co-authored-by: Tobias Zwick --- .../streetcomplete/quests/barrier_opening/AddBarrierOpening.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/AddBarrierOpening.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/AddBarrierOpening.kt index 09234b7202..71e0706741 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/AddBarrierOpening.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/AddBarrierOpening.kt @@ -51,7 +51,7 @@ class AddBarrierOpening( override fun isApplicableTo(element: Element) = - nodeFilter.matches(element) + if (nodeFilter.matches(element)) null else false override fun createForm() = AddGateWidthForm() From bf7ef42b5b195a60d270398155e17282db19ae8a Mon Sep 17 00:00:00 2001 From: "Nick Allen (OSM = Tallguy)" Date: Fri, 12 Jul 2024 17:15:01 +0100 Subject: [PATCH 16/21] Update app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/AddBarrierOpening.kt Co-authored-by: Tobias Zwick --- .../streetcomplete/quests/barrier_opening/AddBarrierOpening.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/AddBarrierOpening.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/AddBarrierOpening.kt index 71e0706741..1565f7183c 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/AddBarrierOpening.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/AddBarrierOpening.kt @@ -40,7 +40,6 @@ class AddBarrierOpening( override fun getTitle(tags: Map) = R.string.quest_barrier_opening_width_gate override fun getApplicableElements(mapData: MapDataWithGeometry): Iterable { - mapData.nodes.filter { nodeFilter.matches(it) } val excludedWayNodeIds = mapData.ways .filter { excludedWaysFilter.matches(it) } .flatMapTo(HashSet()) { it.nodeIds } From 981929d2f82f167f0ec7cb835d5851c34c25b9f3 Mon Sep 17 00:00:00 2001 From: Nick-Tallguy Date: Tue, 23 Jul 2024 18:30:05 +0100 Subject: [PATCH 17/21] remove if/else choice, update line 59 with maxwidth:physical as tag to use. Amend indent. --- .../quests/barrier_opening/AddBarrierOpening.kt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/AddBarrierOpening.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/AddBarrierOpening.kt index 09234b7202..2e8b4f0ae4 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/AddBarrierOpening.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/AddBarrierOpening.kt @@ -49,7 +49,6 @@ class AddBarrierOpening( .filter { nodeFilter.matches(it) && it.id !in excludedWayNodeIds } } - override fun isApplicableTo(element: Element) = nodeFilter.matches(element) @@ -57,14 +56,15 @@ class AddBarrierOpening( override fun applyAnswerTo(answer: WidthAnswer, tags: Tags, geometry: ElementGeometry, timestampEdited: Long) { - val key = if (tags["barrier"] in GATEWAYS) "maxwidth:physical" else 0 - tags[key.toString()] = answer.width.toOsmValue() + val key = "maxwidth:physical" + + tags[key] = answer.width.toOsmValue() - if (answer.isARMeasurement) { - tags["source:$key"] = "ARCore" - } else { - tags.remove("source:$key") - } + if (answer.isARMeasurement) { + tags["source:$key"] = "ARCore" + } else { + tags.remove("source:$key") + } } } From 5ccb88ba3daa5a683d188ee30c56106bede2a34f Mon Sep 17 00:00:00 2001 From: Nick-Tallguy Date: Tue, 23 Jul 2024 21:07:15 +0100 Subject: [PATCH 18/21] remove AddGateWidthForm.kt, amend AddWidthForm.kt and update AddBarrierOpening.kt to use changes --- .../barrier_opening/AddBarrierOpening.kt | 5 +- .../barrier_opening/AddGateWidthForm.kt | 94 ------------------- .../quests/width/AddWidthForm.kt | 4 + 3 files changed, 7 insertions(+), 96 deletions(-) delete mode 100644 app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/AddGateWidthForm.kt diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/AddBarrierOpening.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/AddBarrierOpening.kt index d981da1b80..8ee44bd8c8 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/AddBarrierOpening.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/AddBarrierOpening.kt @@ -9,6 +9,7 @@ import de.westnordost.streetcomplete.data.osm.osmquests.OsmElementQuestType import de.westnordost.streetcomplete.data.user.achievements.EditTypeAchievement.BICYCLIST import de.westnordost.streetcomplete.data.user.achievements.EditTypeAchievement.WHEELCHAIR import de.westnordost.streetcomplete.osm.Tags +import de.westnordost.streetcomplete.quests.width.AddWidthForm import de.westnordost.streetcomplete.quests.width.WidthAnswer import de.westnordost.streetcomplete.screens.measure.ArSupportChecker @@ -50,8 +51,8 @@ class AddBarrierOpening( override fun isApplicableTo(element: Element) = if (nodeFilter.matches(element)) null else false - - override fun createForm() = AddGateWidthForm() + + override fun createForm() = AddWidthForm() override fun applyAnswerTo(answer: WidthAnswer, tags: Tags, geometry: ElementGeometry, timestampEdited: Long) { diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/AddGateWidthForm.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/AddGateWidthForm.kt deleted file mode 100644 index e1d3fee9ce..0000000000 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/AddGateWidthForm.kt +++ /dev/null @@ -1,94 +0,0 @@ -package de.westnordost.streetcomplete.quests.barrier_opening - -import android.os.Bundle -import android.view.View -import androidx.appcompat.app.AlertDialog -import androidx.core.view.isGone -import de.westnordost.streetcomplete.R -import de.westnordost.streetcomplete.databinding.QuestLengthBinding -import de.westnordost.streetcomplete.osm.Length -import de.westnordost.streetcomplete.osm.hasDubiousRoadWidth -import de.westnordost.streetcomplete.quests.AbstractArMeasureQuestForm -import de.westnordost.streetcomplete.quests.width.WidthAnswer -import de.westnordost.streetcomplete.screens.measure.ArSupportChecker -import de.westnordost.streetcomplete.view.controller.LengthInputViewController -import org.koin.android.ext.android.inject - -class AddGateWidthForm : AbstractArMeasureQuestForm() { - - override val contentLayoutResId = R.layout.quest_length - private val binding by contentViewBinding(QuestLengthBinding::bind) - private val checkArSupport: ArSupportChecker by inject() - private var isARMeasurement: Boolean = false - private lateinit var lengthInput: LengthInputViewController - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - savedInstanceState?.let { isARMeasurement = it.getBoolean(AR) } - } - - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - super.onViewCreated(view, savedInstanceState) - - val isBarrier = element.tags["barrier"] in GATEWAYS - - lengthInput = binding.lengthInput.let { - LengthInputViewController(it.unitSelect, it.metersContainer, it.metersInput, it.feetInchesContainer, it.feetInput, it.inchesInput) - } - lengthInput.unitSelectItemResId = R.layout.spinner_item_centered_large - lengthInput.isCompactMode = true - lengthInput.maxFeetDigits = if (isBarrier) 3 else 2 - lengthInput.maxMeterDigits = Pair(if (isBarrier) 2 else 1, 2) - lengthInput.selectableUnits = countryInfo.lengthUnits - lengthInput.onInputChanged = { - isARMeasurement = false - checkIsFormComplete() - } - binding.measureButton.isGone = !checkArSupport() - binding.measureButton.setOnClickListener { takeMeasurement() } - } - - private fun takeMeasurement() { - val lengthUnit = lengthInput.unit ?: return - takeMeasurement(lengthUnit, false) - } - - override fun onMeasured(length: Length) { - lengthInput.length = length - isARMeasurement = true - } - - override fun onClickOk() { - val length = lengthInput.length!! - // val newTags = element.tags + ("width" to length.toMeters().toString()) - val newTags = element.tags + ("maxwidth:physical" to length.toMeters().toString()) - if (hasDubiousRoadWidth(newTags) != true) { - applyAnswer(WidthAnswer(length, isARMeasurement)) - } else { - confirmDubiousRoadWidth { - applyAnswer(WidthAnswer(length, isARMeasurement)) - } - } - } - - private fun confirmDubiousRoadWidth(onConfirmed: () -> Unit) { - activity?.let { AlertDialog.Builder(it) - .setTitle(R.string.quest_generic_confirmation_title) - .setMessage(R.string.quest_road_width_unusualInput_confirmation_description) - .setPositiveButton(R.string.quest_generic_confirmation_yes) { _, _ -> onConfirmed() } - .setNegativeButton(R.string.quest_generic_confirmation_no, null) - .show() - } - } - - override fun isFormComplete(): Boolean = lengthInput.length != null - - override fun onSaveInstanceState(outState: Bundle) { - super.onSaveInstanceState(outState) - outState.putBoolean(AR, isARMeasurement) - } - - companion object { - private const val AR = "ar" - } -} diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/width/AddWidthForm.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/width/AddWidthForm.kt index f9e6d0da11..5e8395ff6a 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/width/AddWidthForm.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/width/AddWidthForm.kt @@ -10,6 +10,7 @@ import de.westnordost.streetcomplete.osm.ALL_ROADS import de.westnordost.streetcomplete.osm.Length import de.westnordost.streetcomplete.osm.hasDubiousRoadWidth import de.westnordost.streetcomplete.quests.AbstractArMeasureQuestForm +import de.westnordost.streetcomplete.quests.barrier_opening.GATEWAYS import de.westnordost.streetcomplete.screens.measure.ArSupportChecker import de.westnordost.streetcomplete.view.controller.LengthInputViewController import org.koin.android.ext.android.inject @@ -32,6 +33,7 @@ class AddWidthForm : AbstractArMeasureQuestForm() { val isRoad = element.tags["highway"] in ALL_ROADS val explanation = if (isRoad) getString(R.string.quest_road_width_explanation) else null + val isBarrier = element.tags["barrier"] in GATEWAYS binding.widthExplanationTextView.isGone = explanation == null binding.widthExplanationTextView.text = explanation @@ -42,6 +44,8 @@ class AddWidthForm : AbstractArMeasureQuestForm() { lengthInput.isCompactMode = true lengthInput.maxFeetDigits = if (isRoad) 3 else 2 lengthInput.maxMeterDigits = Pair(if (isRoad) 2 else 1, 2) + lengthInput.maxFeetDigits = if (isBarrier) 3 else 2 + lengthInput.maxMeterDigits = Pair(if (isBarrier) 2 else 1, 2) lengthInput.selectableUnits = countryInfo.lengthUnits lengthInput.onInputChanged = { isARMeasurement = false From 03862246f996ccb04577b40855d66a84acdfc063 Mon Sep 17 00:00:00 2001 From: Nick-Tallguy Date: Tue, 23 Jul 2024 21:18:49 +0100 Subject: [PATCH 19/21] amend indentation --- .../quests/barrier_opening/AddBarrierOpening.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/AddBarrierOpening.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/AddBarrierOpening.kt index 8ee44bd8c8..ea447f590c 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/AddBarrierOpening.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/AddBarrierOpening.kt @@ -51,12 +51,12 @@ class AddBarrierOpening( override fun isApplicableTo(element: Element) = if (nodeFilter.matches(element)) null else false - + override fun createForm() = AddWidthForm() override fun applyAnswerTo(answer: WidthAnswer, tags: Tags, geometry: ElementGeometry, timestampEdited: Long) { - val key = "maxwidth:physical" + val key = "maxwidth:physical" tags[key] = answer.width.toOsmValue() From 10cdf8683f1b8cbf694ed889db1975641ae98dd1 Mon Sep 17 00:00:00 2001 From: Nick-Tallguy Date: Wed, 24 Jul 2024 00:39:31 +0100 Subject: [PATCH 20/21] remove last changes to AddWidthForm & remove 'GATEWAYS' - replace with list. correct indentation errors. --- .../barrier_opening/AddBarrierOpening.kt | 22 +++++++++---------- .../quests/width/AddWidthForm.kt | 4 ---- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/AddBarrierOpening.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/AddBarrierOpening.kt index ea447f590c..f0ae0364b1 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/AddBarrierOpening.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/AddBarrierOpening.kt @@ -18,17 +18,17 @@ class AddBarrierOpening( ) : OsmElementQuestType { private val nodeFilter by lazy { """ - nodes with - barrier ~ ${GATEWAYS.joinToString("|")} - and (!maxwidth:physical or source:maxwidth_physical ~ ".*estimat.*") - and (!width or source:width ~ ".*estimat.*") - and (!maxwidth or source:maxwidth ~ ".*estimat.*") - and access !~ private|no|customers|agricultural - """.toElementFilterExpression() } + nodes with + barrier ~ gate|entrance|sliding_gate|swing_gate|wicket_gate + and (!maxwidth:physical or source:maxwidth_physical ~ ".*estimat.*") + and (!width or source:width ~ ".*estimat.*") + and (!maxwidth or source:maxwidth ~ ".*estimat.*") + and access !~ private|no|customers|agricultural + """.toElementFilterExpression() } private val excludedWaysFilter by lazy { """ ways with - highway and access ~ private|no|customers|agricultural + highway and access ~ private|no|customers|agricultural """.toElementFilterExpression() } override val changesetComment = "Specify width of opening" @@ -61,12 +61,10 @@ class AddBarrierOpening( tags[key] = answer.width.toOsmValue() if (answer.isARMeasurement) { - tags["source:$key"] = "ARCore" + tags["source:$key"] = "ARCore" } else { - tags.remove("source:$key") + tags.remove("source:$key") } } } - -val GATEWAYS = setOf("gate", "entrance", "sliding_gate", "swing_gate", "wicket_gate") diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/width/AddWidthForm.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/width/AddWidthForm.kt index 5e8395ff6a..f9e6d0da11 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/width/AddWidthForm.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/width/AddWidthForm.kt @@ -10,7 +10,6 @@ import de.westnordost.streetcomplete.osm.ALL_ROADS import de.westnordost.streetcomplete.osm.Length import de.westnordost.streetcomplete.osm.hasDubiousRoadWidth import de.westnordost.streetcomplete.quests.AbstractArMeasureQuestForm -import de.westnordost.streetcomplete.quests.barrier_opening.GATEWAYS import de.westnordost.streetcomplete.screens.measure.ArSupportChecker import de.westnordost.streetcomplete.view.controller.LengthInputViewController import org.koin.android.ext.android.inject @@ -33,7 +32,6 @@ class AddWidthForm : AbstractArMeasureQuestForm() { val isRoad = element.tags["highway"] in ALL_ROADS val explanation = if (isRoad) getString(R.string.quest_road_width_explanation) else null - val isBarrier = element.tags["barrier"] in GATEWAYS binding.widthExplanationTextView.isGone = explanation == null binding.widthExplanationTextView.text = explanation @@ -44,8 +42,6 @@ class AddWidthForm : AbstractArMeasureQuestForm() { lengthInput.isCompactMode = true lengthInput.maxFeetDigits = if (isRoad) 3 else 2 lengthInput.maxMeterDigits = Pair(if (isRoad) 2 else 1, 2) - lengthInput.maxFeetDigits = if (isBarrier) 3 else 2 - lengthInput.maxMeterDigits = Pair(if (isBarrier) 2 else 1, 2) lengthInput.selectableUnits = countryInfo.lengthUnits lengthInput.onInputChanged = { isARMeasurement = false From db00d200af2f84a92c33a1d70588a1fb8f26d298 Mon Sep 17 00:00:00 2001 From: Tobias Zwick Date: Wed, 24 Jul 2024 23:23:03 +0200 Subject: [PATCH 21/21] fix indentation --- .../quests/barrier_opening/AddBarrierOpening.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/AddBarrierOpening.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/AddBarrierOpening.kt index f0ae0364b1..353f8de9df 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/AddBarrierOpening.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/barrier_opening/AddBarrierOpening.kt @@ -14,8 +14,8 @@ import de.westnordost.streetcomplete.quests.width.WidthAnswer import de.westnordost.streetcomplete.screens.measure.ArSupportChecker class AddBarrierOpening( - private val checkArSupport: ArSupportChecker - ) : OsmElementQuestType { + private val checkArSupport: ArSupportChecker +) : OsmElementQuestType { private val nodeFilter by lazy { """ nodes with