Skip to content

Commit

Permalink
Implements AddBoardName quest (#5882)
Browse files Browse the repository at this point in the history
  • Loading branch information
mnalis authored Sep 9, 2024
1 parent 8e597cf commit 3b051b8
Show file tree
Hide file tree
Showing 6 changed files with 123 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import de.westnordost.streetcomplete.quests.bike_rental_capacity.AddBikeRentalCa
import de.westnordost.streetcomplete.quests.bike_rental_type.AddBikeRentalType
import de.westnordost.streetcomplete.quests.bike_shop.AddBikeRepairAvailability
import de.westnordost.streetcomplete.quests.bike_shop.AddSecondHandBicycleAvailability
import de.westnordost.streetcomplete.quests.board_name.AddBoardName
import de.westnordost.streetcomplete.quests.board_type.AddBoardType
import de.westnordost.streetcomplete.quests.bollard_type.AddBollardType
import de.westnordost.streetcomplete.quests.bridge_structure.AddBridgeStructure
Expand Down Expand Up @@ -340,6 +341,7 @@ fun questTypeRegistry(
155 to AddGritBinSeasonal(),

50 to AddBoardType(),
171 to AddBoardName(),

51 to AddBarrierType(), // basically any more detailed rendering and routing: OSM Carto, mapy.cz, OSMand for start
52 to AddBarrierOnPath(),
Expand Down
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

Check failure on line 6 in app/src/main/java/de/westnordost/streetcomplete/quests/board_name/AddBoardName.kt

View workflow job for this annotation

GitHub Actions / Kotlin

Unused import
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["noname"] = "yes"
}
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
35 changes: 35 additions & 0 deletions app/src/main/res/drawable/ic_quest_board_name.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="128dp"
android:height="128dp"
android:viewportWidth="128"
android:viewportHeight="128">
<path
android:pathData="m128,64c0,35.346 -28.654,64 -64,64 -35.346,0 -64,-28.654 -64,-64 0,-35.346 28.654,-64 64,-64 35.346,0 64,28.654 64,64"
android:fillColor="#e9a76f"/>
<path
android:pathData="m90.34,44c-7.028,-3.778 -0.34,-20 7.66,-34"
android:strokeAlpha="0.2"
android:strokeWidth="8"
android:strokeColor="#000"/>
<path
android:pathData="M90.34,40C83.312,36.222 88,23 96,9"
android:strokeWidth="8"
android:strokeColor="#7077ce"
android:fillAlpha="0.2"/>
<path
android:pathData="m63.986,28 l-46,46v4l36,36h4l46,-46V30l-2,-2z"
android:fillColor="#000"
android:fillAlpha="0.2"/>
<path
android:pathData="m64,24 l-46,46v4l36,36h4l46,-46L104,26l-2,-2zM90,32a6,6 0,0 1,6 6,6 6,0 0,1 -6,6 6,6 0,0 1,-6 -6,6 6,0 0,1 6,-6z"
android:fillColor="#fff"/>
<path
android:pathData="m122,37.549c-11.141,6.167 -22.034,7.418 -32,2.451"
android:strokeAlpha="0.2"
android:strokeWidth="8"
android:strokeColor="#000"/>
<path
android:pathData="M120.606,34.299C109.465,40.466 99.994,44.745 90.027,39.778"
android:strokeWidth="8"
android:strokeColor="#7077ce"/>
</vector>
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,8 @@ Before uploading your changes, the app checks with a &lt;a href=\"https://www.we
<string name="quest_air_pump_bicycle_repair_station_title">Is there a working bicycle pump here?</string>
<string name="quest_air_pump_compressor_title">Is there an air compressor available here?</string>

<string name="quest_board_name_title">"What’s the title of this information board?"</string>

<string name="quest_board_type_title">What’s the topic of this information board?</string>
<string name="quest_board_type_history">History</string>
<string name="quest_board_type_geology">Geology</string>
Expand Down

0 comments on commit 3b051b8

Please sign in to comment.