-
-
Notifications
You must be signed in to change notification settings - Fork 361
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4010 from FloEdelmann/bicycle-rental-type
Add bicycle rental type quest
- Loading branch information
Showing
23 changed files
with
131 additions
and
1 deletion.
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
48 changes: 48 additions & 0 deletions
48
app/src/main/java/de/westnordost/streetcomplete/quests/bike_rental_type/AddBikeRentalType.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,48 @@ | ||
package de.westnordost.streetcomplete.quests.bike_rental_type | ||
|
||
import de.westnordost.streetcomplete.R | ||
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.osm.osmquests.Tags | ||
import de.westnordost.streetcomplete.data.user.achievements.QuestTypeAchievement.BICYCLIST | ||
|
||
class AddBikeRentalType : OsmFilterQuestType<BikeRentalTypeAnswer>() { | ||
|
||
override val elementFilter = """ | ||
nodes, ways with | ||
amenity = bicycle_rental | ||
and access !~ private|no | ||
and (!bicycle_rental or bicycle_rental = yes) | ||
and !shop | ||
""" | ||
override val changesetComment = "Add bicycle rental type" | ||
override val wikiLink = "Key:bicycle_rental" | ||
override val icon = R.drawable.ic_quest_bicycle_rental | ||
override val isDeleteElementEnabled = true | ||
override val questTypeAchievements = listOf(BICYCLIST) | ||
|
||
override fun getTitle(tags: Map<String, String>) = R.string.quest_bicycle_rental_type_title | ||
|
||
override fun getHighlightedElements(element: Element, getMapData: () -> MapDataWithGeometry) = | ||
getMapData().filter("nodes, ways with amenity = bicycle_rental") | ||
|
||
override fun createForm() = AddBikeRentalTypeForm() | ||
|
||
override fun applyAnswerTo(answer: BikeRentalTypeAnswer, tags: Tags, timestampEdited: Long) { | ||
when (answer) { | ||
is BikeRentalType -> { | ||
tags["bicycle_rental"] = answer.osmValue | ||
if (answer == BikeRentalType.HUMAN) { | ||
tags["shop"] = "rental" | ||
} | ||
} | ||
is BikeShopWithRental -> { | ||
tags.remove("amenity") | ||
tags["shop"] = "bicycle" | ||
tags["service:bicycle:rental"] = "yes" | ||
} | ||
} | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
.../main/java/de/westnordost/streetcomplete/quests/bike_rental_type/AddBikeRentalTypeForm.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,25 @@ | ||
package de.westnordost.streetcomplete.quests.bike_rental_type | ||
|
||
import de.westnordost.streetcomplete.R | ||
import de.westnordost.streetcomplete.quests.AImageListQuestAnswerFragment | ||
import de.westnordost.streetcomplete.quests.bike_rental_type.BikeRentalType.DOCKING_STATION | ||
import de.westnordost.streetcomplete.quests.bike_rental_type.BikeRentalType.DROPOFF_POINT | ||
import de.westnordost.streetcomplete.quests.bike_rental_type.BikeRentalType.HUMAN | ||
import de.westnordost.streetcomplete.view.image_select.Item | ||
|
||
class AddBikeRentalTypeForm : AImageListQuestAnswerFragment<BikeRentalTypeAnswer, BikeRentalTypeAnswer>() { | ||
|
||
override val items: List<Item<BikeRentalTypeAnswer>> = listOf( | ||
Item(DOCKING_STATION, R.drawable.bicycle_rental_docking_station, R.string.quest_bicycle_rental_type_docking_station), | ||
Item(DROPOFF_POINT, R.drawable.bicycle_rental_dropoff_point, R.string.quest_bicycle_rental_type_dropoff_point), | ||
Item(HUMAN, R.drawable.bicycle_rental_human, R.string.quest_bicycle_rental_type_human), | ||
Item(BikeShopWithRental, R.drawable.bicycle_rental_shop_with_rental, R.string.quest_bicycle_rental_type_shop_with_rental), | ||
) | ||
|
||
override val itemsPerRow = 2 | ||
override val moveFavoritesToFront = false | ||
|
||
override fun onClickOk(selectedItems: List<BikeRentalTypeAnswer>) { | ||
applyAnswer(selectedItems.single()) | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
app/src/main/java/de/westnordost/streetcomplete/quests/bike_rental_type/BikeRentalType.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,11 @@ | ||
package de.westnordost.streetcomplete.quests.bike_rental_type | ||
|
||
sealed interface BikeRentalTypeAnswer | ||
|
||
enum class BikeRentalType(val osmValue: String) : BikeRentalTypeAnswer { | ||
DOCKING_STATION("docking_station"), | ||
DROPOFF_POINT("dropoff_point"), | ||
HUMAN("shop"), | ||
} | ||
|
||
object BikeShopWithRental : BikeRentalTypeAnswer |
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,33 @@ | ||
<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,64s-64,-28.654 -64,-64 28.654,-64 64,-64 64,28.654 64,64" | ||
android:strokeWidth=".2" | ||
android:fillColor="#ca72e2"/> | ||
<path | ||
android:pathData="m36.222,24h55.056c4.694,0 8.472,3.779 8.472,8.472v63.056c0,4.694 -3.779,8.472 -8.472,8.472h-55.056c-4.694,0 -8.472,-3.779 -8.472,-8.472v-63.056c0,-4.694 3.779,-8.472 8.472,-8.472z" | ||
android:strokeAlpha="0.2" | ||
android:strokeWidth="8" | ||
android:fillColor="#00000000" | ||
android:strokeColor="#000"/> | ||
<path | ||
android:pathData="m36.347,20.111h55.056c4.694,0 8.472,3.779 8.472,8.472v63.056c0,4.694 -3.779,8.472 -8.472,8.472h-55.056c-4.694,0 -8.472,-3.779 -8.472,-8.472v-63.056c0,-4.694 3.779,-8.472 8.472,-8.472z" | ||
android:strokeAlpha="0.98995" | ||
android:strokeWidth="8" | ||
android:fillColor="#495aad" | ||
android:strokeColor="#fff"/> | ||
<path | ||
android:pathData="m57.93,80.679a10.075,10.075 0,0 1,-10.075 10.075,10.075 10.075,0 0,1 -10.075,-10.075 10.075,10.075 0,0 1,10.075 -10.075,10.075 10.075,0 0,1 10.075,10.075m32.832,-0.002a10.075,10.075 0,0 1,-10.075 10.075,10.075 10.075,0 0,1 -10.075,-10.075 10.075,10.075 0,0 1,10.075 -10.075,10.075 10.075,0 0,1 10.075,10.075m-37.305,-15.517 l12.733,15.461h14.553l-10.005,-15.461h-17.281m17.281,-3.638 l4.433,-0.009m-8.98,19.108 l4.548,-19.1m-22.738,19.1 l7.581,-22.569h7.276" | ||
android:strokeLineJoin="round" | ||
android:strokeWidth="3.5012" | ||
android:fillColor="#00000000" | ||
android:strokeColor="#fff" | ||
android:strokeLineCap="round"/> | ||
<path | ||
android:pathData="m87.877,34.554c-2.299,-2.295 -5.474,-3.701 -8.979,-3.675 -5.797,0 -10.82,3.914 -12.454,9.121h-27.405l-3.162,3.156v2.104l5.27,5.26h3.162l3.162,-3.156h1.054l3.162,3.156h6.324l3.162,-3.156h5.27c1.528,5.312 6.552,8.971 12.296,8.918 7.115,0.053 12.859,-5.68 12.859,-12.728 0,-3.524 -1.423,-6.706 -3.722,-9.001zM85.408,40.846c0.698,0.697 1.133,1.657 1.133,2.709 0.053,2.156 -1.687,3.892 -3.9,3.892 -2.108,0 -3.848,-1.736 -3.848,-3.84 0,-2.104 1.739,-3.84 3.9,-3.892 1.054,0 2.016,0.434 2.714,1.131z" | ||
android:strokeWidth=".74457" | ||
android:fillColor="#fff"/> | ||
</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