Skip to content

Commit

Permalink
Display object note in hint - v1
Browse files Browse the repository at this point in the history
If it exists, the `note` tag for an object is shown in the QuestHint.
  • Loading branch information
kmpoppe committed Sep 10, 2024
1 parent 3eb3e0f commit bacbfdb
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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<Unit>() {

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) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ class AddOpeningHoursForm : AbstractOsmQuestForm<OpeningHoursAnswer>() {

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()
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -18,7 +20,17 @@ class AddPlaceNameForm : AAddLocalizedNameForm<PlaceNameAnswer>() {
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<LocalizedName>) {
applyAnswer(PlaceName(names))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ class AddPostboxCollectionTimesForm : AbstractOsmQuestForm<CollectionTimesAnswer

private fun initStateFromTags() {
val ct = element.tags["collection_times"]
val objectNote = element.tags["note"]
if (objectNote != null) {
this.setHint(getString(R.string.note_for_object) + " " + objectNote)
}
val rows = ct?.toOpeningHoursOrNull(lenient = true)?.toCollectionTimesRows()
if (rows != null) {
collectionTimesAdapter.collectionTimesRows = rows.toMutableList()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,21 @@ class AddPostboxRefForm : AbstractOsmQuestForm<PostboxRefAnswer>() {

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
initStateFromTags()
binding.refInput.doAfterTextChanged { checkIsFormComplete() }
}

override fun onClickOk() {
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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ class ShopTypeForm : AbstractOsmQuestForm<ShopTypeAnswer>() {
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 {
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ The info you enter is directly added to OpenStreetMap in your name, without the
<string name="osm_element_gone_description">"Are you sure that it does not exist, not even at a slightly different location? If you’re not sure, leave a note instead.</string>
<string name="osm_element_gone_confirmation">It does not exist</string>
<string name="leave_note">Leave note</string>
<string name="note_for_object">Note for this object:</string>

<string name="quest_generic_answer_differs_along_the_way">"Differs along the way…"</string>
<string name="quest_split_way_description">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?</string>
Expand Down

0 comments on commit bacbfdb

Please sign in to comment.