forked from streetcomplete/StreetComplete
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
intial board_name copied from bus_stop_name
- Loading branch information
Showing
3 changed files
with
84 additions
and
0 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
app/src/main/java/de/westnordost/streetcomplete/quests/board_name/AddBoardName.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
app/src/main/java/de/westnordost/streetcomplete/quests/board_name/AddBoardNameForm.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
app/src/main/java/de/westnordost/streetcomplete/quests/board_name/BoardNameAnswer.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |