-
-
Notifications
You must be signed in to change notification settings - Fork 362
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implements AddBoardName quest (#5882)
- Loading branch information
Showing
6 changed files
with
123 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
42 changes: 42 additions & 0 deletions
42
app/src/main/java/de/westnordost/streetcomplete/quests/board_name/AddBoardName.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,42 @@ | ||
package de.westnordost.streetcomplete.quests.board_name | ||
|
||
import de.westnordost.streetcomplete.R | ||
import de.westnordost.streetcomplete.data.osm.geometry.ElementGeometry | ||
import de.westnordost.streetcomplete.data.osm.osmquests.OsmFilterQuestType | ||
import de.westnordost.streetcomplete.data.quest.AllCountriesExcept | ||
import de.westnordost.streetcomplete.data.user.achievements.EditTypeAchievement.OUTDOORS | ||
import de.westnordost.streetcomplete.osm.Tags | ||
import de.westnordost.streetcomplete.osm.applyTo | ||
|
||
class AddBoardName : OsmFilterQuestType<BoardNameAnswer>() { | ||
|
||
override val elementFilter = """ | ||
nodes, ways, relations with | ||
( | ||
tourism=information and information=board | ||
and board_type != notice | ||
and !board:title | ||
) | ||
and !name and noname != yes and name:signed != no | ||
""" | ||
|
||
override val changesetComment = "Determine information board names" | ||
override val wikiLink = "Tag:information=board" | ||
override val icon = R.drawable.ic_quest_board_name | ||
override val achievements = listOf(OUTDOORS) | ||
|
||
override fun getTitle(tags: Map<String, String>) = R.string.quest_board_name_title | ||
|
||
override fun createForm() = AddBoardNameForm() | ||
|
||
override fun applyAnswerTo(answer: BoardNameAnswer, tags: Tags, geometry: ElementGeometry, timestampEdited: Long) { | ||
when (answer) { | ||
is NoBoardName -> { | ||
tags["noname"] = "yes" | ||
} | ||
is BoardName -> { | ||
answer.localizedNames.applyTo(tags) | ||
} | ||
} | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
app/src/main/java/de/westnordost/streetcomplete/quests/board_name/AddBoardNameForm.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.board_name | ||
|
||
import androidx.appcompat.app.AlertDialog | ||
import de.westnordost.streetcomplete.R | ||
import de.westnordost.streetcomplete.databinding.QuestLocalizednameBinding | ||
import de.westnordost.streetcomplete.osm.LocalizedName | ||
import de.westnordost.streetcomplete.quests.AAddLocalizedNameForm | ||
import de.westnordost.streetcomplete.quests.AnswerItem | ||
|
||
class AddBoardNameForm : AAddLocalizedNameForm<BoardNameAnswer>() { | ||
|
||
override val contentLayoutResId = R.layout.quest_localizedname | ||
private val binding by contentViewBinding(QuestLocalizednameBinding::bind) | ||
|
||
override val addLanguageButton get() = binding.addLanguageButton | ||
override val namesList get() = binding.namesList | ||
|
||
override val otherAnswers = listOf( | ||
AnswerItem(R.string.quest_placeName_no_name_answer) { confirmNoName() }, | ||
AnswerItem(R.string.quest_streetName_answer_cantType) { showKeyboardInfo() } | ||
) | ||
|
||
override fun onClickOk(names: List<LocalizedName>) { | ||
applyAnswer(BoardName(names)) | ||
} | ||
|
||
private fun confirmNoName() { | ||
AlertDialog.Builder(requireContext()) | ||
.setTitle(R.string.quest_name_answer_noName_confirmation_title) | ||
.setPositiveButton(R.string.quest_name_noName_confirmation_positive) { _, _ -> applyAnswer(NoBoardName) } | ||
.setNegativeButton(R.string.quest_generic_confirmation_no, null) | ||
.show() | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
app/src/main/java/de/westnordost/streetcomplete/quests/board_name/BoardNameAnswer.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.board_name | ||
|
||
import de.westnordost.streetcomplete.osm.LocalizedName | ||
|
||
sealed interface BoardNameAnswer | ||
|
||
data object NoBoardName : BoardNameAnswer | ||
data class BoardName(val localizedNames: List<LocalizedName>) : BoardNameAnswer |
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,35 @@ | ||
<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,64 -35.346,0 -64,-28.654 -64,-64 0,-35.346 28.654,-64 64,-64 35.346,0 64,28.654 64,64" | ||
android:fillColor="#e9a76f"/> | ||
<path | ||
android:pathData="m90.34,44c-7.028,-3.778 -0.34,-20 7.66,-34" | ||
android:strokeAlpha="0.2" | ||
android:strokeWidth="8" | ||
android:strokeColor="#000"/> | ||
<path | ||
android:pathData="M90.34,40C83.312,36.222 88,23 96,9" | ||
android:strokeWidth="8" | ||
android:strokeColor="#7077ce" | ||
android:fillAlpha="0.2"/> | ||
<path | ||
android:pathData="m63.986,28 l-46,46v4l36,36h4l46,-46V30l-2,-2z" | ||
android:fillColor="#000" | ||
android:fillAlpha="0.2"/> | ||
<path | ||
android:pathData="m64,24 l-46,46v4l36,36h4l46,-46L104,26l-2,-2zM90,32a6,6 0,0 1,6 6,6 6,0 0,1 -6,6 6,6 0,0 1,-6 -6,6 6,0 0,1 6,-6z" | ||
android:fillColor="#fff"/> | ||
<path | ||
android:pathData="m122,37.549c-11.141,6.167 -22.034,7.418 -32,2.451" | ||
android:strokeAlpha="0.2" | ||
android:strokeWidth="8" | ||
android:strokeColor="#000"/> | ||
<path | ||
android:pathData="M120.606,34.299C109.465,40.466 99.994,44.745 90.027,39.778" | ||
android:strokeWidth="8" | ||
android:strokeColor="#7077ce"/> | ||
</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