Skip to content
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

add AddAcceptsCards quest #3953

Merged
merged 9 commits into from
Apr 18, 2022
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import de.westnordost.streetcomplete.data.meta.CountryInfos
import de.westnordost.streetcomplete.data.osmnotes.notequests.OsmNoteQuestType
import de.westnordost.streetcomplete.data.quest.QuestType
import de.westnordost.streetcomplete.data.quest.QuestTypeRegistry
import de.westnordost.streetcomplete.quests.accepts_cards.AddAcceptsCards
import de.westnordost.streetcomplete.quests.accepts_cash.AddAcceptsCash
import de.westnordost.streetcomplete.quests.address.AddAddressStreet
import de.westnordost.streetcomplete.quests.address.AddHousenumber
Expand Down Expand Up @@ -391,6 +392,7 @@ whether the postbox is still there in countries in which it is enabled */
AddWheelchairAccessToilets(), // used by wheelmap, OsmAnd, Organic Maps

// shop
AddAcceptsCards(),
AddAcceptsCash(),
AddVegetarian(),
AddVegan(),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package de.westnordost.streetcomplete.quests.accepts_cards

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.CITIZEN
import de.westnordost.streetcomplete.osm.IS_SHOP_OR_DISUSED_SHOP_EXPRESSION
import de.westnordost.streetcomplete.util.ktx.toYesNo

class AddAcceptsCards : OsmFilterQuestType<CardAcceptance>() {

override val elementFilter = """
nodes with (
amenity=restaurant
or amenity=fast_food
or amenity=cafe
or amenity=ice_cream
westnordost marked this conversation as resolved.
Show resolved Hide resolved
or (shop and shop !~ no|vacant|mall)
)
and !payment:credit_cards and !payment:debit_cards
and !brand and !wikipedia:brand and !wikidata:brand
and (!seasonal or seasonal = no)
"""
override val changesetComment = "Add whether cards are accepted"
override val defaultDisabledMessage = R.string.default_disabled_msg_go_inside
override val wikiLink = "Key:payment"
override val icon = R.drawable.ic_quest_card
override val isDeleteElementEnabled = true
westnordost marked this conversation as resolved.
Show resolved Hide resolved
override val questTypeAchievements = listOf(CITIZEN)

override fun getTitle(tags: Map<String, String>) = R.string.quest_accepts_cards

override fun getHighlightedElements(element: Element, getMapData: () -> MapDataWithGeometry) =
getMapData().filter(IS_SHOP_OR_DISUSED_SHOP_EXPRESSION)

override fun createForm() = AddAcceptsCardsForm()

override fun applyAnswerTo(answer: CardAcceptance, tags: Tags, timestampEdited: Long) {
tags["payment:debit_cards"] = answer.debit.toYesNo()
tags["payment:credit_cards"] = answer.credit.toYesNo()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package de.westnordost.streetcomplete.quests.accepts_cards

import de.westnordost.streetcomplete.R
import de.westnordost.streetcomplete.quests.AListQuestAnswerFragment
import de.westnordost.streetcomplete.quests.TextItem
import de.westnordost.streetcomplete.quests.accepts_cards.CardAcceptance.DEBIT_AND_CREDIT
import de.westnordost.streetcomplete.quests.accepts_cards.CardAcceptance.CREDIT_CARDS_ONLY
import de.westnordost.streetcomplete.quests.accepts_cards.CardAcceptance.DEBIT_CARDS_ONLY
import de.westnordost.streetcomplete.quests.accepts_cards.CardAcceptance.NEITHER_DEBIT_NOR_CREDIT

class AddAcceptsCardsForm : AListQuestAnswerFragment<CardAcceptance>() {

override val items = listOf(
TextItem(DEBIT_AND_CREDIT, R.string.quest_accepts_cards_debit_and_credit),
TextItem(CREDIT_CARDS_ONLY, R.string.quest_accepts_cards_credit_only),
TextItem(DEBIT_CARDS_ONLY, R.string.quest_accepts_cards_dedit_only),
TextItem(NEITHER_DEBIT_NOR_CREDIT, R.string.quest_accepts_cards_unavailable),
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package de.westnordost.streetcomplete.quests.accepts_cards

enum class CardAcceptance(val debit: Boolean, val credit: Boolean) {
DEBIT_AND_CREDIT(true, true),
CREDIT_CARDS_ONLY(false, true),
DEBIT_CARDS_ONLY(true, false),
NEITHER_DEBIT_NOR_CREDIT(false, false),
}
36 changes: 36 additions & 0 deletions app/src/main/res/drawable/ic_quest_card.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<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="#e9a76f"/>
<path
android:fillColor="#FF000000"
android:pathData="M20.364,36L107.636,36A4.364,4.286 0,0 1,112 40.286L112,95.714A4.364,4.286 0,0 1,107.636 100L20.364,100A4.364,4.286 0,0 1,16 95.714L16,40.286A4.364,4.286 0,0 1,20.364 36z"
android:fillAlpha="0.2"/>
<path
android:pathData="M20.364,32L107.636,32A4.364,4.286 0,0 1,112 36.286L112,91.714A4.364,4.286 0,0 1,107.636 96L20.364,96A4.364,4.286 0,0 1,16 91.714L16,36.286A4.364,4.286 0,0 1,20.364 32z"
android:fillColor="#fff"/>
<path
android:pathData="M91,63L103,63A2,2 0,0 1,105 65L105,75A2,2 0,0 1,103 77L91,77A2,2 0,0 1,89 75L89,65A2,2 0,0 1,91 63z"
android:strokeWidth="2"
android:fillColor="#efd27b"
android:strokeColor="#e4b31d"/>
<path
android:pathData="M16,40h96v16h-96z"
android:fillColor="#444"/>
<path
android:pathData="M23.826,64L60.174,64A3.826,3.826 0,0 1,64 67.826L64,68.174A3.826,3.826 0,0 1,60.174 72L23.826,72A3.826,3.826 0,0 1,20 68.174L20,67.826A3.826,3.826 0,0 1,23.826 64z"
android:fillColor="#ccc"/>
<path
android:pathData="M24,80L60,80A4,4 0,0 1,64 84L64,84A4,4 0,0 1,60 88L24,88A4,4 0,0 1,20 84L20,84A4,4 0,0 1,24 80z"
android:fillColor="#ccc"/>
<path
android:pathData="m101,70h4m-12,0h-4m8,-4 l-4,4 4,4 4,-4z"
android:strokeLineJoin="bevel"
android:strokeWidth="2"
android:fillColor="#00000000"
android:strokeColor="#e4b31d"/>
</vector>
6 changes: 6 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,12 @@ However, before uploading your changes, the app checks with a &lt;a href=\"https
<!-- Quests -->
<!-- sorted alphabetically by title -->

<string name="quest_accepts_cards">Are credit or debit cards accepted here?</string>
<string name="quest_accepts_cards_debit_and_credit">Both</string>
<string name="quest_accepts_cards_credit_only">Only credit cards</string>
<string name="quest_accepts_cards_dedit_only">Only debit cards</string>
<string name="quest_accepts_cards_unavailable">Neither debit nor credit cards</string>

<string name="quest_accepts_cash_title2">"Is cash payment accepted here?"</string>

<string name="quest_accessible_for_pedestrians_title_prohibited">Are pedestrians forbidden to walk on this road here?</string>
Expand Down