Skip to content

Commit

Permalink
Grill fuel quest -- add OtherAnswer that this is just a firering, not…
Browse files Browse the repository at this point in the history
… a Grill (#5371)

* add a "not a BBQ" other answer

* try to fix compile issues

* cleanups

* try to fix compile error

* try NOT_BBQ as an enum

* enum kludge

* include

* try to get it to compile

* try to import variables

* try to get rid of "sealed interface class" in order to get it to compile

* add confirmNotBbq()

* add missing import

* indicate magic value

* try to get "sealed interface BbqFuelAnswer" to work

* try buttonPanelAnswers from dier_type

* try building_entrance items override

* whitespace cleanups

* Update app/src/main/java/de/westnordost/streetcomplete/quests/bbq_fuel/AddBbqFuelForm.kt

* rename NOT_BBQ => IsFirePitAnswer

* indicate what it is instead of what it is not, try different words for clarification and shortening

* rephrase other answer, use different message format

* try to fix compilation error
Failed to flatten XML for resource 'quest_bbq_fuel_not_a_bbq' with error: Invalid unicode escape sequence in string

* cleanup texts

* Update app/src/main/res/values/strings.xml

Co-authored-by: Flo Edelmann <[email protected]>

---------

Co-authored-by: Tobias Zwick <[email protected]>
Co-authored-by: Flo Edelmann <[email protected]>
  • Loading branch information
3 people authored Nov 26, 2023
1 parent 9de3369 commit 723078c
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import de.westnordost.streetcomplete.data.osm.osmquests.OsmFilterQuestType
import de.westnordost.streetcomplete.data.user.achievements.EditTypeAchievement.OUTDOORS
import de.westnordost.streetcomplete.osm.Tags

class AddBbqFuel : OsmFilterQuestType<BbqFuel>() {
class AddBbqFuel : OsmFilterQuestType<BbqFuelAnswer>() {

override val elementFilter = """
nodes, ways with
Expand All @@ -30,7 +30,13 @@ class AddBbqFuel : OsmFilterQuestType<BbqFuel>() {

override fun createForm() = AddBbqFuelForm()

override fun applyAnswerTo(answer: BbqFuel, tags: Tags, geometry: ElementGeometry, timestampEdited: Long) {
tags["fuel"] = answer.osmValue
override fun applyAnswerTo(answer: BbqFuelAnswer, tags: Tags, geometry: ElementGeometry, timestampEdited: Long) {
when (answer) {
is BbqFuel -> tags["fuel"] = answer.osmValue
IsFirePitAnswer -> {
tags.remove("amenity")
tags["leisure"] = "firepit"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,32 @@
package de.westnordost.streetcomplete.quests.bbq_fuel

import androidx.appcompat.app.AlertDialog

Check failure on line 3 in app/src/main/java/de/westnordost/streetcomplete/quests/bbq_fuel/AddBbqFuelForm.kt

View workflow job for this annotation

GitHub Actions / Kotlin

Imports must be ordered in lexicographic order without any empty lines in-between with "java", "javax", "kotlin" and aliases in the end
import de.westnordost.streetcomplete.R
import de.westnordost.streetcomplete.quests.AListQuestForm
import de.westnordost.streetcomplete.quests.AnswerItem
import de.westnordost.streetcomplete.quests.TextItem
import de.westnordost.streetcomplete.quests.bbq_fuel.BbqFuel.WOOD
import de.westnordost.streetcomplete.quests.bbq_fuel.BbqFuel.ELECTRIC
import de.westnordost.streetcomplete.quests.bbq_fuel.BbqFuel.CHARCOAL

class AddBbqFuelForm : AListQuestForm<BbqFuel>() {
class AddBbqFuelForm : AListQuestForm<BbqFuelAnswer>() {
override val items: List<TextItem<BbqFuelAnswer>> = listOf(
TextItem(WOOD, R.string.quest_bbq_fuel_wood),
TextItem(ELECTRIC, R.string.quest_bbq_fuel_electric),
TextItem(CHARCOAL, R.string.quest_bbq_fuel_charcoal),
)

override val items = listOf(
TextItem(BbqFuel.WOOD, R.string.quest_bbq_fuel_wood),
TextItem(BbqFuel.ELECTRIC, R.string.quest_bbq_fuel_electric),
TextItem(BbqFuel.CHARCOAL, R.string.quest_bbq_fuel_charcoal),
override val otherAnswers = listOf(
AnswerItem(R.string.quest_bbq_fuel_not_a_bbq) { confirmNotBbq() },
)

private fun confirmNotBbq() {
val ctx = context ?: return
AlertDialog.Builder(ctx)
.setTitle(R.string.quest_generic_confirmation_title)
.setMessage(R.string.quest_bbq_fuel_not_a_bbq_confirmation)
.setPositiveButton(R.string.quest_generic_confirmation_yes) { _, _ -> applyAnswer(IsFirePitAnswer) }
.setNegativeButton(R.string.quest_generic_confirmation_no, null)
.show()
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package de.westnordost.streetcomplete.quests.bbq_fuel

sealed interface BbqFuelAnswer

enum class BbqFuel(val osmValue: String) : BbqFuelAnswer {
WOOD("wood"),
ELECTRIC("electric"),
CHARCOAL("charcoal")
}

object IsFirePitAnswer : BbqFuelAnswer
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1301,6 +1301,8 @@ If there are no signs along the whole street which apply for the highlighted sec
<string name="quest_bbq_fuel_wood">Wood</string>
<string name="quest_bbq_fuel_electric">Electric</string>
<string name="quest_bbq_fuel_charcoal">Charcoal</string>
<string name="quest_bbq_fuel_not_a_bbq">It’s a fire enclosure</string>
<string name="quest_bbq_fuel_not_a_bbq_confirmation">Fire enclosures don’t have a cooking surface (e.g. grate/plate), as opposed to grills.</string>

<string name="quest_railway_crossing_barrier_title2">What barriers are used at this railway crossing?</string>
<string name="quest_railway_crossing_barrier_none2">No barriers</string>
Expand Down

0 comments on commit 723078c

Please sign in to comment.