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

Added valves quest #644

Merged
merged 12 commits into from
Sep 12, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ import de.westnordost.streetcomplete.quests.traffic_signals_vibrate.AddTrafficSi
import de.westnordost.streetcomplete.quests.trail_visibility.AddTrailVisibility
import de.westnordost.streetcomplete.quests.tree.AddTreeGenus
import de.westnordost.streetcomplete.quests.sac_scale.AddSacScale
import de.westnordost.streetcomplete.quests.valves.AddValves
import de.westnordost.streetcomplete.quests.via_ferrata_scale.AddViaFerrataScale
import de.westnordost.streetcomplete.quests.way_lit.AddWayLit
import de.westnordost.streetcomplete.quests.wheelchair_access.AddWheelchairAccessBusiness
Expand Down Expand Up @@ -603,6 +604,7 @@ fun getQuestTypeList(
EE_QUEST_OFFSET + 7 to AddServiceBuildingOperator(),
EE_QUEST_OFFSET + 29 to AddStreetCabinetType(),
EE_QUEST_OFFSET + 8 to AddOutdoorSeatingType(),
EE_QUEST_OFFSET + 51 to AddValves(),
EE_QUEST_OFFSET + 25 to AddDestination(),
EE_QUEST_OFFSET + 22 to AddArtworkType(),
EE_QUEST_OFFSET + 23 to AddRailwayPlatformRef(),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package de.westnordost.streetcomplete.quests.valves

import de.westnordost.streetcomplete.R
import de.westnordost.streetcomplete.data.osm.geometry.ElementGeometry
import de.westnordost.streetcomplete.data.osm.mapdata.Element
import de.westnordost.streetcomplete.data.osm.mapdata.MapDataWithGeometry
import de.westnordost.streetcomplete.data.osm.mapdata.filter
import de.westnordost.streetcomplete.data.osm.osmquests.OsmFilterQuestType
import de.westnordost.streetcomplete.data.user.achievements.EditTypeAchievement.BICYCLIST
import de.westnordost.streetcomplete.osm.Tags

class AddValves : OsmFilterQuestType<List<Valves>>() {

override val elementFilter = """
nodes, ways with
(compressed_air = yes
or service:bicycle:pump = yes
or amenity = compressed_air)
and access !~ private|no
and !valves
"""
override val changesetComment = "Specify valves types for air pumps or compressed air"
override val wikiLink = "Key:valves"
override val icon = R.drawable.ic_quest_valve
override val isDeleteElementEnabled = true
override val achievements = listOf(BICYCLIST)

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

override fun createForm() = AddValvesForm()

override fun getHighlightedElements(element: Element, getMapData: () -> MapDataWithGeometry) =
getMapData().filter("nodes, ways with amenity = compressed_air or service:bicycle:pump = yes or compressed_air = yes")

override fun applyAnswerTo(answer: List<Valves>, tags: Tags, geometry: ElementGeometry, timestampEdited: Long) {
tags["valves"] = answer.joinToString(";") { it.osmValue }
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think sorting the values could be useful?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question, there are already all possible combinations in taginfo. I guess a consuming app will have to extract the values anyway. As far as I can see there are only the Orchard Produce and the Sports Quest with multi-value answers, and neither does sort the values. Would it be easy to implement?
image

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I too see no benefit to sorting...

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be easy to implement?

should be answer.sortedBy { it.osmValue }.joinToString(";") { it.osmValue }

There is no benefit for consumers checking for specific valves, but e.g. if SCEE ends up being the most used editor for this tag (and thus values being mostly sorted), it could make reading a list as posted by @mnalis a little easier.

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package de.westnordost.streetcomplete.quests.valves

import android.os.Bundle
import de.westnordost.streetcomplete.R
import de.westnordost.streetcomplete.quests.AImageListQuestForm

class AddValvesForm : AImageListQuestForm<Valves, List<Valves>>() {

override val items get() = Valves.entries
.mapNotNull { it.asItem() }
.sortedBy { (it.value!!.osmValue) }
mcliquid marked this conversation as resolved.
Show resolved Hide resolved
override val itemsPerRow = 2
override val maxSelectableItems = -1

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
imageSelector.cellLayoutId = R.layout.cell_icon_select_with_label_below
}

override fun onClickOk(selectedItems: List<Valves>) {
applyAnswer(selectedItems)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package de.westnordost.streetcomplete.quests.valves

enum class Valves(val osmValue: String) {
SCLAVERAND("sclaverand"),
DUNLOP("dunlop"),
SCHRADER("schrader"),
REGINA("regina");
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package de.westnordost.streetcomplete.quests.valves

import de.westnordost.streetcomplete.R
import de.westnordost.streetcomplete.quests.valves.Valves.*
import de.westnordost.streetcomplete.view.image_select.DisplayItem
import de.westnordost.streetcomplete.view.image_select.Item

fun Valves.asItem(): DisplayItem<Valves>? {
val iconResId = iconResId ?: return null
val titleResId = titleResId ?: return null
return Item(this, iconResId, titleResId)
}
mcliquid marked this conversation as resolved.
Show resolved Hide resolved

val Valves.titleResId: Int get() = when (this) {
mcliquid marked this conversation as resolved.
Show resolved Hide resolved
SCLAVERAND -> R.string.quest_valves_sclaverand
DUNLOP -> R.string.quest_valves_dunlop
SCHRADER -> R.string.quest_valves_schrader
REGINA -> R.string.quest_valves_regina
}

val Valves.iconResId: Int get() = when (this) {
SCLAVERAND -> R.drawable.valves_presta
DUNLOP -> R.drawable.valves_dunlop
SCHRADER -> R.drawable.valves_schrader
REGINA -> R.drawable.valves_regina
}
6 changes: 6 additions & 0 deletions app/src/main/res/authors.txt
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,12 @@ tourism_information_map.jpg CC0 https://commons.wikimedia.org/w
tourism_information_office.jpg CC-BY-SA 4.0 https://commons.wikimedia.org/wiki/File:Tourist_information_shop,_Delft_(2018).jpg (Donald Trung)
tourism_information_termina... CC-BY 4.0 https://wiki.openstreetmap.org/wiki/File:Uh%C5%99%C3%ADn%C4%9Bves,_Nov%C3%A9_n%C3%A1m%C4%9Bst%C3%AD,_informa%C4%8Dn%C3%AD_stojan.jpg (ŠJů)

valves_schrader.jpg Copyleft BohwaZ https://commons.wikimedia.org/wiki/File:Valve_Schrader.jpg
valves_sclaverand.jpg Copyleft BohwaZ https://commons.wikimedia.org/wiki/File:Valve_Presta.JPG
valves_dunlop.jpg Copyleft BohwaZ https://commons.wikimedia.org/wiki/File:Valve_Dunlop.JPG
valves_regina.jpg Copyleft BohwaZ https://commons.wikimedia.org/wiki/File:Valve_Regina_avec_son_bouchon.jpg
mcliquid marked this conversation as resolved.
Show resolved Hide resolved


via_ferrata_scale_0.jpg CC-BY-SA-2.0 https://wiki.openstreetmap.org/wiki/File:Super_easy_ferrata.jpg
via_ferrata_scale_1.jpg CC-BY-SA-3.0 https://wiki.openstreetmap.org/wiki/File:Alpspitz-ferrata-a.jpg
via_ferrata_scale_2.jpg CC-BY-SA-2.0 https://wiki.openstreetmap.org/wiki/File:Alpspitz-ferrata-b.jpg
Expand Down
Binary file added app/src/main/res/drawable-hdpi/valves_dunlop.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-hdpi/valves_presta.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-hdpi/valves_regina.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-mdpi/valves_dunlop.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-mdpi/valves_presta.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-mdpi/valves_regina.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-xhdpi/valves_dunlop.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-xhdpi/valves_presta.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-xhdpi/valves_regina.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
57 changes: 57 additions & 0 deletions app/src/main/res/drawable/ic_quest_valve.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<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.3 -28.7,64 -64,64S0,99.3 0,64 28.7,0 64,0s64,28.7 64,64"
android:fillColor="#ca72e2"/>
<path
android:pathData="M49.8,104.1h28.5V27.9h-28.5v76.2Z"
android:fillColor="#8ea0ad"/>
<path
android:pathData="M45,58.9h38v-14.3h-38v14.3Z"
android:fillColor="#444"/>
<path
android:pathData="M59.3,27.9h9.5v-14.3h-9.3l-0.2,14.3Z"
android:fillColor="#666"/>
<path
android:pathData="M45,113.6h38v-9.5h-38v9.5Z"
android:fillColor="#c4ced4"/>
<path
android:pathData="M49.8,32.9h28.5v-2.4h-28.5v2.4Z"
android:fillColor="#c4ced4"/>
<path
android:pathData="M49.8,37.4h28.5v-2.4h-28.5v2.4Z"
android:fillColor="#c4ced4"/>
<path
android:pathData="M49.8,42.2h28.5v-2.4h-28.5v2.4Z"
android:fillColor="#c4ced4"/>
<path
android:pathData="M49.8,63.8h28.5v-2.4h-28.5v2.4Z"
android:fillColor="#c4ced4"/>
<path
android:pathData="M49.8,68.3h28.5v-2.4h-28.5v2.4Z"
android:fillColor="#c4ced4"/>
<path
android:pathData="M49.8,73.1h28.5v-2.4h-28.5v2.4Z"
android:fillColor="#c4ced4"/>
<path
android:pathData="M49.8,78h28.5v-2.4h-28.5v2.4Z"
android:fillColor="#c4ced4"/>
<path
android:pathData="M49.8,82.5h28.5v-2.4h-28.5v2.4Z"
android:fillColor="#c4ced4"/>
<path
android:pathData="M49.8,87.3h28.5v-2.4h-28.5v2.4Z"
android:fillColor="#c4ced4"/>
<path
android:pathData="M49.8,92.2h28.5v-2.4h-28.5v2.4Z"
android:fillColor="#c4ced4"/>
<path
android:pathData="M49.8,96.7h28.5v-2.4h-28.5v2.4Z"
android:fillColor="#c4ced4"/>
<path
android:pathData="M49.8,101.5h28.5v-2.4h-28.5v2.4Z"
android:fillColor="#c4ced4"/>
</vector>
8 changes: 8 additions & 0 deletions app/src/main/res/values/strings_ee.xml
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,14 @@
<string name="quest_shelter_type_field_shelter">Field shelter</string>
<string name="quest_shelter_type_rock_shelter">Rock shelter</string>

<!-- valves (air compressor or bicycle pump) -->
<string name="quest_valves_title">What types of valves are available here?</string>
<string name="quest_valves_disabled_msg">This quest is disabled by default because it requires a very close inspection of the available valves.</string>
<string name="quest_valves_sclaverand">SV: Sclaverand / Presta / French valve</string>
<string name="quest_valves_dunlop">DV/NV: Dunlop / Woods</string>
<string name="quest_valves_schrader">AV: Schrader / Car valve</string>
<string name="quest_valves_regina">RV: Regina / Italian</string>

<!-- artwork type -->
<string name="quest_artwork_title">What kind of artwork is this?</string>
<string name="quest_artwork_sculpture">Sculpture</string>
Expand Down
50 changes: 50 additions & 0 deletions res/graphics/quest/valve.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.