Skip to content

Commit

Permalink
intial board_name copied from bus_stop_name
Browse files Browse the repository at this point in the history
  • Loading branch information
mnalis committed Sep 8, 2024
1 parent 962c7b2 commit b0b35e0
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package de.westnordost.streetcomplete.quests.board_name

import de.westnordost.streetcomplete.R
import de.westnordost.streetcomplete.data.osm.geometry.ElementGeometry
import de.westnordost.streetcomplete.data.osm.osmquests.OsmFilterQuestType
import de.westnordost.streetcomplete.data.quest.AllCountriesExcept
import de.westnordost.streetcomplete.data.user.achievements.EditTypeAchievement.OUTDOORS
import de.westnordost.streetcomplete.osm.Tags
import de.westnordost.streetcomplete.osm.applyTo

class AddBoardName : OsmFilterQuestType<BoardNameAnswer>() {

override val elementFilter = """
nodes, ways, relations with
(
tourism=information and information=board
and board_type != notice
and !board:title
)
and !name and noname != yes and name:signed != no
"""

override val changesetComment = "Determine information board names"
override val wikiLink = "Tag:information=board"
override val icon = R.drawable.ic_quest_board_name
override val achievements = listOf(OUTDOORS)

override fun getTitle(tags: Map<String, String>) = R.string.quest_board_name_title

override fun createForm() = AddBoardNameForm()

override fun applyAnswerTo(answer: BoardNameAnswer, tags: Tags, geometry: ElementGeometry, timestampEdited: Long) {
when (answer) {
is NoBoardName -> {
tags["name:signed"] = "no"
}
is BoardName -> {
answer.localizedNames.applyTo(tags)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package de.westnordost.streetcomplete.quests.board_name

import androidx.appcompat.app.AlertDialog
import de.westnordost.streetcomplete.R
import de.westnordost.streetcomplete.databinding.QuestLocalizednameBinding
import de.westnordost.streetcomplete.osm.LocalizedName
import de.westnordost.streetcomplete.quests.AAddLocalizedNameForm
import de.westnordost.streetcomplete.quests.AnswerItem

class AddBoardNameForm : AAddLocalizedNameForm<BoardNameAnswer>() {

override val contentLayoutResId = R.layout.quest_localizedname
private val binding by contentViewBinding(QuestLocalizednameBinding::bind)

override val addLanguageButton get() = binding.addLanguageButton
override val namesList get() = binding.namesList

override val otherAnswers = listOf(
AnswerItem(R.string.quest_placeName_no_name_answer) { confirmNoName() },
AnswerItem(R.string.quest_streetName_answer_cantType) { showKeyboardInfo() }
)

override fun onClickOk(names: List<LocalizedName>) {
applyAnswer(BoardName(names))
}

private fun confirmNoName() {
AlertDialog.Builder(requireContext())
.setTitle(R.string.quest_name_answer_noName_confirmation_title)
.setPositiveButton(R.string.quest_name_noName_confirmation_positive) { _, _ -> applyAnswer(NoBoardName) }
.setNegativeButton(R.string.quest_generic_confirmation_no, null)
.show()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package de.westnordost.streetcomplete.quests.board_name

import de.westnordost.streetcomplete.osm.LocalizedName

sealed interface BoardNameAnswer

data object NoBoardName : BoardNameAnswer
data class BoardName(val localizedNames: List<LocalizedName>) : BoardNameAnswer

0 comments on commit b0b35e0

Please sign in to comment.