From bacbfdbec8e62e2a3696ba9650234f5d3425dc58 Mon Sep 17 00:00:00 2001 From: Kai Michael Poppe Date: Tue, 10 Sep 2024 10:43:20 +0200 Subject: [PATCH 01/11] Display object note in hint - v1 If it exists, the `note` tag for an object is shown in the QuestHint. --- .../quests/existence/CheckExistenceForm.kt | 13 +++++++++++++ .../quests/opening_hours/AddOpeningHoursForm.kt | 4 ++++ .../quests/place_name/AddPlaceNameForm.kt | 12 ++++++++++++ .../AddPostboxCollectionTimesForm.kt | 4 ++++ .../quests/postbox_ref/AddPostboxRefForm.kt | 8 ++++++++ .../streetcomplete/quests/shop_type/ShopTypeForm.kt | 8 ++++++++ app/src/main/res/values/strings.xml | 1 + 7 files changed, 50 insertions(+) diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/existence/CheckExistenceForm.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/existence/CheckExistenceForm.kt index a7340bea64..aaacbaaf81 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/existence/CheckExistenceForm.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/existence/CheckExistenceForm.kt @@ -1,11 +1,24 @@ package de.westnordost.streetcomplete.quests.existence +import android.os.Bundle +import android.view.View import de.westnordost.streetcomplete.R import de.westnordost.streetcomplete.quests.AbstractOsmQuestForm import de.westnordost.streetcomplete.quests.AnswerItem class CheckExistenceForm : AbstractOsmQuestForm() { + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + initStateFromTags() + } + + private fun initStateFromTags() { + val objectNote = element.tags["note"] + if (objectNote != null) { + this.setHint(getString(R.string.note_for_object) + " " + objectNote) + } + } override val buttonPanelAnswers = listOf( AnswerItem(R.string.quest_generic_hasFeature_no) { deletePoiNode() }, AnswerItem(R.string.quest_generic_hasFeature_yes) { applyAnswer(Unit) } diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/opening_hours/AddOpeningHoursForm.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/opening_hours/AddOpeningHoursForm.kt index 658196cde2..60e3d9930a 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/opening_hours/AddOpeningHoursForm.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/opening_hours/AddOpeningHoursForm.kt @@ -114,6 +114,10 @@ class AddOpeningHoursForm : AbstractOsmQuestForm() { private fun initStateFromTags() { val oh = element.tags["opening_hours"] + val objectNote = element.tags["note"] + if (objectNote != null) { + this.setHint(getString(R.string.note_for_object) + " " + objectNote) + } val rows = oh?.toOpeningHoursOrNull(lenient = true)?.toOpeningHoursRows() if (rows != null) { openingHoursAdapter.rows = rows.toMutableList() diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/place_name/AddPlaceNameForm.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/place_name/AddPlaceNameForm.kt index c787e38a7a..0533a6f1cd 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/place_name/AddPlaceNameForm.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/place_name/AddPlaceNameForm.kt @@ -1,5 +1,7 @@ package de.westnordost.streetcomplete.quests.place_name +import android.os.Bundle +import android.view.View import androidx.appcompat.app.AlertDialog import de.westnordost.streetcomplete.R import de.westnordost.streetcomplete.databinding.QuestLocalizednameBinding @@ -18,7 +20,17 @@ class AddPlaceNameForm : AAddLocalizedNameForm() { override val otherAnswers = listOf( AnswerItem(R.string.quest_placeName_no_name_answer) { confirmNoName() } ) + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + initStateFromTags() + } + private fun initStateFromTags() { + val objectNote = element.tags["note"] + if (objectNote != null) { + this.setHint(getString(R.string.note_for_object) + " " + objectNote) + } + } override fun onClickOk(names: List) { applyAnswer(PlaceName(names)) } diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/postbox_collection_times/AddPostboxCollectionTimesForm.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/postbox_collection_times/AddPostboxCollectionTimesForm.kt index d4d97b656a..17e56813ac 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/postbox_collection_times/AddPostboxCollectionTimesForm.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/postbox_collection_times/AddPostboxCollectionTimesForm.kt @@ -95,6 +95,10 @@ class AddPostboxCollectionTimesForm : AbstractOsmQuestForm() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) + initStateFromTags() binding.refInput.doAfterTextChanged { checkIsFormComplete() } } @@ -30,6 +31,13 @@ class AddPostboxRefForm : AbstractOsmQuestForm() { applyAnswer(PostboxRef(ref!!)) } + private fun initStateFromTags() { + val objectNote = element.tags["note"] + if (objectNote != null) { + this.setHint(getString(R.string.note_for_object) + " " + objectNote) + } + } + private fun confirmNoRef() { val ctx = context ?: return AlertDialog.Builder(ctx) diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/shop_type/ShopTypeForm.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/shop_type/ShopTypeForm.kt index 34de4351e5..84afcc7794 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/shop_type/ShopTypeForm.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/shop_type/ShopTypeForm.kt @@ -50,6 +50,14 @@ class ShopTypeForm : AbstractOsmQuestForm() { POPULAR_PLACE_FEATURE_IDS, ).show() } + initStateFromTags() + } + + private fun initStateFromTags() { + val objectNote = element.tags["note"] + if (objectNote != null) { + this.setHint(getString(R.string.note_for_object) + " " + objectNote) + } } private fun filterOnlyShops(feature: Feature): Boolean { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 8e056c9f99..cd37644857 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -153,6 +153,7 @@ The info you enter is directly added to OpenStreetMap in your name, without the "Are you sure that it does not exist, not even at a slightly different location? If you’re not sure, leave a note instead. It does not exist Leave note + Note for this object: "Differs along the way…" If it differs along the way, the first step is to split up the way. After that, the quest can be answered for each part separately.\nSplit it now? From c6ee10d1aa84b6e22d04a2e1e9230f6426516d72 Mon Sep 17 00:00:00 2001 From: Kai Michael Poppe Date: Tue, 10 Sep 2024 13:20:29 +0200 Subject: [PATCH 02/11] Display object note for BusStopName Adding Bus Stop Name in the mix also. --- .../quests/bus_stop_name/AddBusStopNameForm.kt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/bus_stop_name/AddBusStopNameForm.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/bus_stop_name/AddBusStopNameForm.kt index a871c96315..9bf48dd853 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/bus_stop_name/AddBusStopNameForm.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/bus_stop_name/AddBusStopNameForm.kt @@ -1,6 +1,9 @@ package de.westnordost.streetcomplete.quests.bus_stop_name +import android.os.Bundle +import android.view.View import androidx.appcompat.app.AlertDialog +import androidx.core.widget.doAfterTextChanged import de.westnordost.streetcomplete.R import de.westnordost.streetcomplete.databinding.QuestLocalizednameBinding import de.westnordost.streetcomplete.osm.LocalizedName @@ -15,6 +18,17 @@ class AddBusStopNameForm : AAddLocalizedNameForm() { override val addLanguageButton get() = binding.addLanguageButton override val namesList get() = binding.namesList + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + initStateFromTags() + } + + private fun initStateFromTags() { + val objectNote = element.tags["note"] + if (objectNote != null) { + this.setHint(getString(R.string.note_for_object) + " " + objectNote) + } + } override val otherAnswers = listOf( AnswerItem(R.string.quest_placeName_no_name_answer) { confirmNoName() }, AnswerItem(R.string.quest_streetName_answer_cantType) { showKeyboardInfo() } From 99a7fe503f2772224da3342388c772f774d91d7f Mon Sep 17 00:00:00 2001 From: Kai Michael Poppe Date: Tue, 10 Sep 2024 20:06:22 +0200 Subject: [PATCH 03/11] Revert "Display object note for BusStopName" This reverts commit c6ee10d1aa84b6e22d04a2e1e9230f6426516d72. --- .../quests/bus_stop_name/AddBusStopNameForm.kt | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/bus_stop_name/AddBusStopNameForm.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/bus_stop_name/AddBusStopNameForm.kt index 9bf48dd853..a871c96315 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/bus_stop_name/AddBusStopNameForm.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/bus_stop_name/AddBusStopNameForm.kt @@ -1,9 +1,6 @@ package de.westnordost.streetcomplete.quests.bus_stop_name -import android.os.Bundle -import android.view.View import androidx.appcompat.app.AlertDialog -import androidx.core.widget.doAfterTextChanged import de.westnordost.streetcomplete.R import de.westnordost.streetcomplete.databinding.QuestLocalizednameBinding import de.westnordost.streetcomplete.osm.LocalizedName @@ -18,17 +15,6 @@ class AddBusStopNameForm : AAddLocalizedNameForm() { override val addLanguageButton get() = binding.addLanguageButton override val namesList get() = binding.namesList - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - super.onViewCreated(view, savedInstanceState) - initStateFromTags() - } - - private fun initStateFromTags() { - val objectNote = element.tags["note"] - if (objectNote != null) { - this.setHint(getString(R.string.note_for_object) + " " + objectNote) - } - } override val otherAnswers = listOf( AnswerItem(R.string.quest_placeName_no_name_answer) { confirmNoName() }, AnswerItem(R.string.quest_streetName_answer_cantType) { showKeyboardInfo() } From d6e48e93376c79eab7dc3e2ac255159369b3e17d Mon Sep 17 00:00:00 2001 From: Kai Michael Poppe Date: Tue, 10 Sep 2024 20:06:27 +0200 Subject: [PATCH 04/11] Revert "Display object note in hint - v1" This reverts commit bacbfdbec8e62e2a3696ba9650234f5d3425dc58. --- .../quests/existence/CheckExistenceForm.kt | 13 ------------- .../quests/opening_hours/AddOpeningHoursForm.kt | 4 ---- .../quests/place_name/AddPlaceNameForm.kt | 12 ------------ .../AddPostboxCollectionTimesForm.kt | 4 ---- .../quests/postbox_ref/AddPostboxRefForm.kt | 8 -------- .../streetcomplete/quests/shop_type/ShopTypeForm.kt | 8 -------- app/src/main/res/values/strings.xml | 1 - 7 files changed, 50 deletions(-) diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/existence/CheckExistenceForm.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/existence/CheckExistenceForm.kt index aaacbaaf81..a7340bea64 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/existence/CheckExistenceForm.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/existence/CheckExistenceForm.kt @@ -1,24 +1,11 @@ package de.westnordost.streetcomplete.quests.existence -import android.os.Bundle -import android.view.View import de.westnordost.streetcomplete.R import de.westnordost.streetcomplete.quests.AbstractOsmQuestForm import de.westnordost.streetcomplete.quests.AnswerItem class CheckExistenceForm : AbstractOsmQuestForm() { - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - super.onViewCreated(view, savedInstanceState) - initStateFromTags() - } - - private fun initStateFromTags() { - val objectNote = element.tags["note"] - if (objectNote != null) { - this.setHint(getString(R.string.note_for_object) + " " + objectNote) - } - } override val buttonPanelAnswers = listOf( AnswerItem(R.string.quest_generic_hasFeature_no) { deletePoiNode() }, AnswerItem(R.string.quest_generic_hasFeature_yes) { applyAnswer(Unit) } diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/opening_hours/AddOpeningHoursForm.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/opening_hours/AddOpeningHoursForm.kt index 60e3d9930a..658196cde2 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/opening_hours/AddOpeningHoursForm.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/opening_hours/AddOpeningHoursForm.kt @@ -114,10 +114,6 @@ class AddOpeningHoursForm : AbstractOsmQuestForm() { private fun initStateFromTags() { val oh = element.tags["opening_hours"] - val objectNote = element.tags["note"] - if (objectNote != null) { - this.setHint(getString(R.string.note_for_object) + " " + objectNote) - } val rows = oh?.toOpeningHoursOrNull(lenient = true)?.toOpeningHoursRows() if (rows != null) { openingHoursAdapter.rows = rows.toMutableList() diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/place_name/AddPlaceNameForm.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/place_name/AddPlaceNameForm.kt index 0533a6f1cd..c787e38a7a 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/place_name/AddPlaceNameForm.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/place_name/AddPlaceNameForm.kt @@ -1,7 +1,5 @@ package de.westnordost.streetcomplete.quests.place_name -import android.os.Bundle -import android.view.View import androidx.appcompat.app.AlertDialog import de.westnordost.streetcomplete.R import de.westnordost.streetcomplete.databinding.QuestLocalizednameBinding @@ -20,17 +18,7 @@ class AddPlaceNameForm : AAddLocalizedNameForm() { override val otherAnswers = listOf( AnswerItem(R.string.quest_placeName_no_name_answer) { confirmNoName() } ) - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - super.onViewCreated(view, savedInstanceState) - initStateFromTags() - } - private fun initStateFromTags() { - val objectNote = element.tags["note"] - if (objectNote != null) { - this.setHint(getString(R.string.note_for_object) + " " + objectNote) - } - } override fun onClickOk(names: List) { applyAnswer(PlaceName(names)) } diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/postbox_collection_times/AddPostboxCollectionTimesForm.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/postbox_collection_times/AddPostboxCollectionTimesForm.kt index 17e56813ac..d4d97b656a 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/postbox_collection_times/AddPostboxCollectionTimesForm.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/postbox_collection_times/AddPostboxCollectionTimesForm.kt @@ -95,10 +95,6 @@ class AddPostboxCollectionTimesForm : AbstractOsmQuestForm() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - initStateFromTags() binding.refInput.doAfterTextChanged { checkIsFormComplete() } } @@ -31,13 +30,6 @@ class AddPostboxRefForm : AbstractOsmQuestForm() { applyAnswer(PostboxRef(ref!!)) } - private fun initStateFromTags() { - val objectNote = element.tags["note"] - if (objectNote != null) { - this.setHint(getString(R.string.note_for_object) + " " + objectNote) - } - } - private fun confirmNoRef() { val ctx = context ?: return AlertDialog.Builder(ctx) diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/shop_type/ShopTypeForm.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/shop_type/ShopTypeForm.kt index 84afcc7794..34de4351e5 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/shop_type/ShopTypeForm.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/shop_type/ShopTypeForm.kt @@ -50,14 +50,6 @@ class ShopTypeForm : AbstractOsmQuestForm() { POPULAR_PLACE_FEATURE_IDS, ).show() } - initStateFromTags() - } - - private fun initStateFromTags() { - val objectNote = element.tags["note"] - if (objectNote != null) { - this.setHint(getString(R.string.note_for_object) + " " + objectNote) - } } private fun filterOnlyShops(feature: Feature): Boolean { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index cd37644857..8e056c9f99 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -153,7 +153,6 @@ The info you enter is directly added to OpenStreetMap in your name, without the "Are you sure that it does not exist, not even at a slightly different location? If you’re not sure, leave a note instead. It does not exist Leave note - Note for this object: "Differs along the way…" If it differs along the way, the first step is to split up the way. After that, the quest can be answered for each part separately.\nSplit it now? From 0ad6953561a5665cbcb51ba2e7afb04d77f7f172 Mon Sep 17 00:00:00 2001 From: Kai Michael Poppe Date: Tue, 10 Sep 2024 21:15:47 +0200 Subject: [PATCH 05/11] Refactor - v2 Added labels to fragment_quest_answer and made it display a note whenever a quest will be answered. --- .../streetcomplete/quests/AbstractOsmQuestForm.kt | 4 ++++ .../streetcomplete/quests/AbstractQuestForm.kt | 12 ++++++++++++ app/src/main/res/layout/fragment_quest_answer.xml | 13 +++++++++++++ app/src/main/res/values/strings.xml | 1 + app/src/main/res/values/textStyles.xml | 12 ++++++++++++ 5 files changed, 42 insertions(+) diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/AbstractOsmQuestForm.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/AbstractOsmQuestForm.kt index 5138f0592b..da62d3266e 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/AbstractOsmQuestForm.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/AbstractOsmQuestForm.kt @@ -119,6 +119,10 @@ abstract class AbstractOsmQuestForm : AbstractQuestForm(), IsShowingQuestDeta setTitle(getString(osmElementQuestType.getTitle(element.tags))) setTitleHintLabel(getNameAndLocationSpanned(element, resources, featureDictionary)) + val objNote = element.tags["note"] + if (objNote != null) { + setObjNote(objNote) + } } override fun onStart() { diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/AbstractQuestForm.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/AbstractQuestForm.kt index ff6e95b808..0b6efdc0b3 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/AbstractQuestForm.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/AbstractQuestForm.kt @@ -169,6 +169,13 @@ abstract class AbstractQuestForm : updateInfoButtonVisibility() } + protected fun setObjNote(text: CharSequence?) { + binding.titleNoteLabel.isGone = text == null + binding.titleNoteLabel.text = getString(R.string.note_for_object) + binding.noteLabel.isGone = text == null + binding.noteLabel.text = text + decideObjNoteVisible() + } protected fun setHintImages(images: List) { binding.infoPictures.isGone = images.isEmpty() binding.infoPictures.removeAllViews() @@ -181,6 +188,11 @@ abstract class AbstractQuestForm : updateInfoButtonVisibility() } + private fun decideObjNoteVisible() { + binding.titleNoteLabel.isGone = binding.titleNoteLabel.text == null + binding.noteLabel.isGone = binding.noteLabel.text == null + } + private fun toggleInfoArea() { infoIsExpanded = !infoIsExpanded binding.infoButton.setImageResource( diff --git a/app/src/main/res/layout/fragment_quest_answer.xml b/app/src/main/res/layout/fragment_quest_answer.xml index 48ad6b9855..caa8710747 100644 --- a/app/src/main/res/layout/fragment_quest_answer.xml +++ b/app/src/main/res/layout/fragment_quest_answer.xml @@ -72,6 +72,19 @@ android:textAppearance="@style/TextAppearance.TitleLarge.Hint" android:visibility="gone"/> + + + "Are you sure that it does not exist, not even at a slightly different location? If you’re not sure, leave a note instead. It does not exist Leave note + \nAnother mapper wrote: "Differs along the way…" If it differs along the way, the first step is to split up the way. After that, the quest can be answered for each part separately.\nSplit it now? diff --git a/app/src/main/res/values/textStyles.xml b/app/src/main/res/values/textStyles.xml index 814873ba96..c74bd21d39 100644 --- a/app/src/main/res/values/textStyles.xml +++ b/app/src/main/res/values/textStyles.xml @@ -19,6 +19,18 @@ normal + + + + - - - -