Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Shelter type quest #473

Merged
merged 20 commits into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import de.westnordost.streetcomplete.data.osm.mapdata.filter
import de.westnordost.streetcomplete.data.osm.osmquests.OsmFilterQuestType
import de.westnordost.streetcomplete.data.user.achievements.EditTypeAchievement
import de.westnordost.streetcomplete.osm.Tags
import de.westnordost.streetcomplete.quests.smoothness.applyTo

class AddShelterType : OsmFilterQuestType<ShelterType>() {

Expand All @@ -30,7 +31,10 @@ class AddShelterType : OsmFilterQuestType<ShelterType>() {

override fun createForm() = AddShelterTypeForm()

override fun applyAnswerTo(answer: ShelterType, tags: Tags, geometry: ElementGeometry, timestampEdited: Long) {
tags["shelter_type"] = answer.osmValue
override fun applyAnswerTo(answer: ShelterTypeAnswer, tags: Tags, geometry: ElementGeometry, timestampEdited: Long) {
when (answer) {
is WeatherShelterAnswer -> tags["shelter_type"] = "weather_shelter"
is ShelterTypeAnswer -> tags["shelter_type"] = answer.osmValue
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,24 @@ package de.westnordost.streetcomplete.quests.shelter_type

import de.westnordost.streetcomplete.R
import de.westnordost.streetcomplete.quests.AImageListQuestForm
import de.westnordost.streetcomplete.quests.AnswerItem
import de.westnordost.streetcomplete.quests.shelter_type.ShelterType.PUBLIC_TRANSPORT
import de.westnordost.streetcomplete.quests.shelter_type.ShelterType.PICNIC_SHELTER
import de.westnordost.streetcomplete.quests.shelter_type.ShelterType.GAZEBO
import de.westnordost.streetcomplete.quests.shelter_type.ShelterType.WEATHER_SHELTER
import de.westnordost.streetcomplete.quests.shelter_type.ShelterType.LEAN_TO
import de.westnordost.streetcomplete.quests.shelter_type.ShelterType.PAVILION
import de.westnordost.streetcomplete.quests.shelter_type.ShelterType.BASIC_HUT
import de.westnordost.streetcomplete.quests.shelter_type.ShelterType.SUN_SHELTER
import de.westnordost.streetcomplete.quests.shelter_type.ShelterType.FIELD_SHELTER
import de.westnordost.streetcomplete.quests.shelter_type.ShelterType.ROCK_SHELTER
import de.westnordost.streetcomplete.view.image_select.Item

class AddShelterTypeForm : AImageListQuestForm<ShelterType, ShelterType>() {
class AddShelterTypeForm : AImageListQuestForm<ShelterTypeAnswer, ShelterType>() {

override val items = listOf(
Item(PUBLIC_TRANSPORT, R.drawable.shelter_type_public_transport, R.string.quest_shelter_type_public_transport),
Item(PICNIC_SHELTER, R.drawable.shelter_type_picnic_shelter, R.string.quest_shelter_type_picnic_shelter),
Item(GAZEBO, R.drawable.shelter_type_gazebo, R.string.quest_shelter_type_gazebo),
Item(WEATHER_SHELTER, R.drawable.shelter_type_weather_shelter, R.string.quest_shelter_type_weather_shelter),
Item(LEAN_TO, R.drawable.shelter_type_lean_to, R.string.quest_shelter_type_lean_to),
Item(PAVILION, R.drawable.shelter_type_pavilion, R.string.quest_shelter_type_pavilion) ,
Item(BASIC_HUT, R.drawable.shelter_type_basic_hut, R.string.quest_shelter_type_basic_hut),
Item(SUN_SHELTER, R.drawable.shelter_type_sun_shelter, R.string.quest_shelter_type_sun_shelter),
Item(FIELD_SHELTER, R.drawable.shelter_type_field_shelter, R.string.quest_shelter_type_field_shelter),
Expand All @@ -34,4 +31,8 @@ class AddShelterTypeForm : AImageListQuestForm<ShelterType, ShelterType>() {
override fun onClickOk(selectedItems: List<ShelterType>) {
applyAnswer(selectedItems.single())
}

override val otherAnswers = listOf(
AnswerItem(R.string.quest_shelter_type_is_weather_shelter) { applyAnswer(WeatherShelterAnswer) }
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ enum class ShelterType(val osmValue: String) {
PUBLIC_TRANSPORT("public_transport"),
PICNIC_SHELTER("picnic_shelter"),
GAZEBO("gazebo"),
WEATHER_SHELTER("weather_shelter"),
LEAN_TO("lean_to"),
PAVILION("pavilion"),
BASIC_HUT("basic_hut"),
SUN_SHELTER("sun_shelter"),
FIELD_SHELTER("field_shelter"),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package de.westnordost.streetcomplete.quests.shelter_type

sealed interface ShelterTypeAnswer

data class ShelterTypeAnswer(val value: ShelterType) : ShelterTypeAnswer
mcliquid marked this conversation as resolved.
Show resolved Hide resolved
object WeatherShelterAnswer : ShelterTypeAnswer
3 changes: 1 addition & 2 deletions app/src/main/res/values/strings_ee.xml
Original file line number Diff line number Diff line change
Expand Up @@ -360,12 +360,11 @@
<!-- shelter type -->
<string name="quest_shelter_type_title">What kind of shelter is this?</string>
<string name="quest_shelter_type_disabled_msg">This quest is disabled by default because it’s not easy to answer. The shelter type must be chosen from suggestions, which are taken from most used values and these are often not easy to differentiate.</string>
<string name="quest_shelter_type_is_weather_shelter">This is a generic weather shelter</string>
<string name="quest_shelter_type_public_transport">Public Transport</string>
<string name="quest_shelter_type_picnic_shelter">Picnic Shelter</string>
<string name="quest_shelter_type_gazebo">Gazebo</string>
<string name="quest_shelter_type_weather_shelter">Weather shelter</string>
<string name="quest_shelter_type_lean_to">Lean-to</string>
<string name="quest_shelter_type_pavilion">Pavilion</string>
<string name="quest_shelter_type_basic_hut">Basic hut</string>
<string name="quest_shelter_type_sun_shelter">Sun shelter</string>
<string name="quest_shelter_type_field_shelter">Field shelter</string>
Expand Down