forked from streetcomplete/StreetComplete
-
-
Notifications
You must be signed in to change notification settings - Fork 13
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
Added valves quest #644
Changes from 6 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
fe4b407
Added valves quest
mcliquid 25b2949
Optimized strings
mcliquid 65f4744
Restructured quest files, unified naming, added multi-selection
mcliquid 8d351b6
Added own quest icon (valve icon)
mcliquid 3e7df96
Changed images to copyleft versions (and all from the same author -> …
mcliquid 2cc0870
Update app/src/main/res/authors.txt
mcliquid a5a6866
Fixed license
mcliquid d9c55e5
Image dimensions reduced by approximately 50% and image size reduced …
mcliquid 8515da0
Optimized code after feedback
mcliquid 9799247
reduce image quality
mcliquid eed5386
reduce image quality
mcliquid 1dba914
change not null behavior, values sorted by usage from taginfo
mcliquid File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
38 changes: 38 additions & 0 deletions
38
app/src/main/java/de/westnordost/streetcomplete/quests/valves/AddValves.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,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 } | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
app/src/main/java/de/westnordost/streetcomplete/quests/valves/AddValvesForm.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,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) | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
app/src/main/java/de/westnordost/streetcomplete/quests/valves/Valves.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.valves | ||
|
||
enum class Valves(val osmValue: String) { | ||
SCLAVERAND("sclaverand"), | ||
DUNLOP("dunlop"), | ||
SCHRADER("schrader"), | ||
REGINA("regina"); | ||
} |
26 changes: 26 additions & 0 deletions
26
app/src/main/java/de/westnordost/streetcomplete/quests/valves/ValvesItem.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,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 | ||
} |
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
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.
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.
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.
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,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> |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.