-
-
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.
add steps incline quest (fixes #1817)
- Loading branch information
1 parent
2dfb419
commit 4578c2c
Showing
10 changed files
with
187 additions
and
0 deletions.
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
34 changes: 34 additions & 0 deletions
34
app/src/main/java/de/westnordost/streetcomplete/quests/steps_incline/AddStepsIncline.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,34 @@ | ||
package de.westnordost.streetcomplete.quests.steps_incline | ||
|
||
import de.westnordost.streetcomplete.R | ||
import de.westnordost.streetcomplete.data.osm.changes.StringMapChangesBuilder | ||
import de.westnordost.streetcomplete.data.osm.mapdata.OverpassMapDataAndGeometryApi | ||
import de.westnordost.streetcomplete.data.osm.osmquest.SimpleOverpassQuestType | ||
import de.westnordost.streetcomplete.quests.steps_incline.StepsIncline.* | ||
|
||
class AddStepsIncline(o: OverpassMapDataAndGeometryApi) : SimpleOverpassQuestType<StepsIncline>(o) { | ||
|
||
override val tagFilters = """ | ||
ways with highway = steps | ||
and (!indoor or indoor = no) | ||
and area != yes | ||
and access !~ private|no | ||
and !incline | ||
""" | ||
|
||
override val commitMessage = "Add which way leads up for these steps" | ||
override val wikiLink = "Key:incline" | ||
override val icon = R.drawable.ic_quest_steps | ||
override val isSplitWayEnabled = true | ||
|
||
override fun getTitle(tags: Map<String, String>) = R.string.quest_steps_incline_title | ||
|
||
override fun createForm() = AddStepsInclineForm() | ||
|
||
override fun applyAnswerTo(answer: StepsIncline, changes: StringMapChangesBuilder) { | ||
changes.add("incline", when(answer) { | ||
UP -> "up" | ||
UP_REVERSED -> "down" | ||
}) | ||
} | ||
} |
86 changes: 86 additions & 0 deletions
86
app/src/main/java/de/westnordost/streetcomplete/quests/steps_incline/AddStepsInclineForm.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,86 @@ | ||
package de.westnordost.streetcomplete.quests.steps_incline | ||
|
||
import android.os.Bundle | ||
import androidx.annotation.AnyThread | ||
import android.view.View | ||
|
||
import de.westnordost.streetcomplete.R | ||
import de.westnordost.streetcomplete.data.osm.elementgeometry.ElementPolylinesGeometry | ||
import de.westnordost.streetcomplete.quests.AbstractQuestFormAnswerFragment | ||
import de.westnordost.streetcomplete.quests.StreetSideRotater | ||
import de.westnordost.streetcomplete.quests.steps_incline.StepsIncline.* | ||
import de.westnordost.streetcomplete.view.Item | ||
import de.westnordost.streetcomplete.view.dialogs.ImageListPickerDialog | ||
import kotlinx.android.synthetic.main.quest_street_side_puzzle.* | ||
import kotlinx.android.synthetic.main.view_little_compass.* | ||
|
||
class AddStepsInclineForm : AbstractQuestFormAnswerFragment<StepsIncline>() { | ||
|
||
override val contentLayoutResId = R.layout.quest_oneway | ||
override val contentPadding = false | ||
|
||
private var streetSideRotater: StreetSideRotater? = null | ||
|
||
private var selection: StepsIncline? = null | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
|
||
savedInstanceState?.getString(SELECTION)?.let { selection = valueOf(it) } | ||
} | ||
|
||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
|
||
puzzleView.showOnlyRightSide() | ||
puzzleView.listener = { showDirectionSelectionDialog() } | ||
|
||
val defaultResId = R.drawable.ic_steps_incline_unknown | ||
val defaultTitleId = R.string.quest_street_side_puzzle_select | ||
|
||
puzzleView.setRightSideImageResource(selection?.iconResId ?: defaultResId) | ||
puzzleView.setRightSideText(resources.getString( selection?.titleResId ?: defaultTitleId )) | ||
|
||
streetSideRotater = StreetSideRotater(puzzleView, compassNeedleView, elementGeometry as ElementPolylinesGeometry) | ||
} | ||
|
||
override fun onSaveInstanceState(outState: Bundle) { | ||
super.onSaveInstanceState(outState) | ||
selection?.let { outState.putString(SELECTION, it.name) } | ||
} | ||
|
||
override fun isFormComplete() = selection != null | ||
|
||
override fun onClickOk() { | ||
applyAnswer(selection!!) | ||
} | ||
|
||
@AnyThread override fun onMapOrientation(rotation: Float, tilt: Float) { | ||
streetSideRotater?.onMapOrientation(rotation, tilt) | ||
} | ||
|
||
private fun showDirectionSelectionDialog() { | ||
val ctx = context ?: return | ||
val items = StepsIncline.values().map { it.toItem() } | ||
ImageListPickerDialog(ctx, items, R.layout.labeled_icon_button_cell, 2) { selected -> | ||
val dir = selected.value!! | ||
puzzleView.replaceRightSideImageResource(dir.iconResId) | ||
puzzleView.setRightSideText(resources.getString(dir.titleResId)) | ||
selection = dir | ||
checkIsFormComplete() | ||
}.show() | ||
} | ||
|
||
companion object { | ||
private const val SELECTION = "selection" | ||
} | ||
} | ||
|
||
private fun StepsIncline.toItem(): Item<StepsIncline> = Item(this, iconResId, titleResId) | ||
|
||
private val StepsIncline.titleResId: Int get() = R.string.quest_steps_incline_up | ||
|
||
private val StepsIncline.iconResId: Int get() = when(this) { | ||
UP -> R.drawable.ic_steps_incline_up | ||
UP_REVERSED -> R.drawable.ic_steps_incline_up_reversed | ||
} |
5 changes: 5 additions & 0 deletions
5
app/src/main/java/de/westnordost/streetcomplete/quests/steps_incline/StepsIncline.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,5 @@ | ||
package de.westnordost.streetcomplete.quests.steps_incline | ||
|
||
enum class StepsIncline { | ||
UP, UP_REVERSED | ||
} |
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,5 @@ | ||
<vector android:height="256dp" android:viewportHeight="64" | ||
android:viewportWidth="64" android:width="256dp" xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<path android:fillColor="#e6e6e6" android:pathData="m34,19h-4c-0.5922,-3.2596 3.9754,-3.6312 3.935,-6.0951 -0.0734,-0.9014 -0.6641,-1.1186 -1.3673,-1.2108 -1.3053,0.1077 -1.7281,1.1897 -1.8474,2.2023l-4.0498,-0.501c0.3481,-3.4373 2.3296,-5.3954 5.3296,-5.3954 4,0 6,2 6,5s-3.9818,3.1536 -4,6zM30,21h4v3h-4z"/> | ||
<path android:fillColor="#e6e6e6" android:pathData="m34,51h-4c-0.5922,-3.2596 3.9754,-3.6312 3.935,-6.0951 -0.0734,-0.9014 -0.6641,-1.1186 -1.3673,-1.2108 -1.3053,0.1077 -1.7281,1.1897 -1.8474,2.2023l-4.0498,-0.501c0.3481,-3.4373 2.3296,-5.3954 5.3296,-5.3954 4,0 6,2 6,5 0,3 -3.9818,3.1536 -4,6zM30,53h4v3h-4z"/> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<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:fillColor="#529add"/> | ||
<path | ||
android:pathData="m39.99,120v-16h24v-16h24v-16h24" | ||
android:strokeAlpha="0.2" | ||
android:strokeWidth="8" | ||
android:strokeColor="#000"/> | ||
<path | ||
android:pathData="m43.272,55.529c-0.068,-7.573 5.492,-11.485 13.801,-14.828 5.956,5.09 11.023,15.172 18.915,3.301m-25.983,44c6.495,-12.989 2.996,-20.279 7.068,-29.883 10.305,7.791 17.174,-0.718 14.915,17.882m-14.915,-35.3c-1.427,5.412 -0.352,12.663 0.657,18.075" | ||
android:strokeAlpha="0.2" | ||
android:strokeLineJoin="round" | ||
android:strokeWidth="8" | ||
android:strokeColor="#000" | ||
android:strokeLineCap="round"/> | ||
<path | ||
android:fillColor="#000" | ||
android:pathData="m68.699,25.265a8.548,8.548 0,0 1,-8.548 8.548,8.548 8.548,0 0,1 -8.548,-8.548 8.548,8.548 0,0 1,8.548 -8.548,8.548 8.548,0 0,1 8.548,8.548" | ||
android:fillAlpha="0.2"/> | ||
<path | ||
android:pathData="m39.99,116v-16h24v-16h24v-16h24" | ||
android:strokeWidth="8" | ||
android:strokeColor="#fff"/> | ||
<path | ||
android:pathData="m68.699,21.265a8.548,8.548 0,0 1,-8.548 8.548,8.548 8.548,0 0,1 -8.548,-8.548 8.548,8.548 0,0 1,8.548 -8.548,8.548 8.548,0 0,1 8.548,8.548" | ||
android:fillColor="#fff"/> | ||
<path | ||
android:pathData="m43.284,51.527c-0.068,-7.573 5.492,-11.485 13.801,-14.828 5.956,5.09 11.023,15.172 18.915,3.301m-25.983,44c6.495,-12.989 2.996,-20.279 7.068,-29.883 10.305,7.791 17.174,-0.718 14.915,17.882m-14.915,-35.3c-1.427,5.412 -0.352,12.663 0.657,18.075" | ||
android:strokeLineJoin="round" | ||
android:strokeWidth="8" | ||
android:strokeColor="#fff" | ||
android:strokeLineCap="round"/> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<vector android:height="256dp" android:viewportHeight="64" | ||
android:viewportWidth="64" android:width="256dp" xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<path android:fillColor="#666" android:pathData="m34,19h-4c-0.5922,-3.2596 3.9754,-3.6312 3.935,-6.0951 -0.0734,-0.9014 -0.6641,-1.1186 -1.3673,-1.2108 -1.3053,0.1077 -1.7281,1.1897 -1.8474,2.2023l-4.0498,-0.501c0.3481,-3.4373 2.3296,-5.3954 5.3296,-5.3954 4,0 6,2 6,5s-3.9818,3.1536 -4,6zM30,21h4v3h-4z"/> | ||
<path android:fillColor="#666" android:pathData="m34,51h-4c-0.5922,-3.2596 3.9754,-3.6312 3.935,-6.0951 -0.0734,-0.9014 -0.6641,-1.1186 -1.3673,-1.2108 -1.3053,0.1077 -1.7281,1.1897 -1.8474,2.2023l-4.0498,-0.501c0.3481,-3.4373 2.3296,-5.3954 5.3296,-5.3954 4,0 6,2 6,5 0,3 -3.9818,3.1536 -4,6zM30,53h4v3h-4z"/> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<vector android:height="256dp" android:viewportHeight="64" | ||
android:viewportWidth="64" android:width="256dp" xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<path android:fillColor="#808080" android:pathData="m0,0h64v64h-64z"/> | ||
<path android:fillColor="#fff" android:pathData="m32,18 l-14,16h8l2,12h8l2,-12h8z"/> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<vector android:height="256dp" android:viewportHeight="64" | ||
android:viewportWidth="64" android:width="256dp" xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<path android:fillColor="#808080" android:pathData="m0,0h64v64h-64z"/> | ||
<path android:fillColor="#fff" android:pathData="m32,46 l-14,-16h8l2,-12h8l2,12h8z"/> | ||
</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