From 6b09a97abbda349b12b3a564532f8a2dcb1eb50e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vojt=C4=9Bch=20Fo=C5=A1n=C3=A1r?= Date: Sun, 29 Sep 2024 15:09:28 +0200 Subject: [PATCH 1/5] =?UTF-8?q?implement=20i=C4=8Do=20and=20vatin=20quest?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../streetcomplete/quests/QuestsModule.kt | 10 +- .../quests/place_ico/AddPlaceIco.kt | 152 ++++++++++++++++++ .../quests/place_ico/AddPlaceIcoForm.kt | 50 ++++++ .../quests/place_ico/PlaceIcoAnswer.kt | 6 + .../quests/place_vatin/AddPlaceVatin.kt | 152 ++++++++++++++++++ .../quests/place_vatin/AddPlaceVatinForm.kt | 70 ++++++++ .../quests/place_vatin/PlaceVatinAnswer.kt | 6 + app/src/main/res/values-cs/strings.xml | 8 +- app/src/main/res/values/strings.xml | 6 + 9 files changed, 455 insertions(+), 5 deletions(-) create mode 100644 app/src/main/java/de/westnordost/streetcomplete/quests/place_ico/AddPlaceIco.kt create mode 100644 app/src/main/java/de/westnordost/streetcomplete/quests/place_ico/AddPlaceIcoForm.kt create mode 100644 app/src/main/java/de/westnordost/streetcomplete/quests/place_ico/PlaceIcoAnswer.kt create mode 100644 app/src/main/java/de/westnordost/streetcomplete/quests/place_vatin/AddPlaceVatin.kt create mode 100644 app/src/main/java/de/westnordost/streetcomplete/quests/place_vatin/AddPlaceVatinForm.kt create mode 100644 app/src/main/java/de/westnordost/streetcomplete/quests/place_vatin/PlaceVatinAnswer.kt diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/QuestsModule.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/QuestsModule.kt index a8327c6c60d..c003d869db7 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/QuestsModule.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/QuestsModule.kt @@ -28,8 +28,8 @@ import de.westnordost.streetcomplete.quests.baby_changing_table.AddBabyChangingT import de.westnordost.streetcomplete.quests.barrier_bicycle_barrier_installation.AddBicycleBarrierInstallation import de.westnordost.streetcomplete.quests.barrier_bicycle_barrier_type.AddBicycleBarrierType import de.westnordost.streetcomplete.quests.barrier_height.AddBarrierHeight -import de.westnordost.streetcomplete.quests.barrier_opening.AddBarrierOpening import de.westnordost.streetcomplete.quests.barrier_locked.AddBarrierLocked +import de.westnordost.streetcomplete.quests.barrier_opening.AddBarrierOpening import de.westnordost.streetcomplete.quests.barrier_type.AddBarrierOnPath import de.westnordost.streetcomplete.quests.barrier_type.AddBarrierOnRoad import de.westnordost.streetcomplete.quests.barrier_type.AddBarrierType @@ -148,7 +148,9 @@ import de.westnordost.streetcomplete.quests.piste_difficulty.AddPisteDifficulty import de.westnordost.streetcomplete.quests.piste_lit.AddPisteLit import de.westnordost.streetcomplete.quests.piste_ref.AddPisteRef import de.westnordost.streetcomplete.quests.pitch_lit.AddPitchLit +import de.westnordost.streetcomplete.quests.place_ico.AddPlaceIco import de.westnordost.streetcomplete.quests.place_name.AddPlaceName +import de.westnordost.streetcomplete.quests.place_vatin.AddPlaceVatin import de.westnordost.streetcomplete.quests.playground_access.AddPlaygroundAccess import de.westnordost.streetcomplete.quests.police_type.AddPoliceType import de.westnordost.streetcomplete.quests.postbox_collection_times.AddPostboxCollectionTimes @@ -166,7 +168,9 @@ import de.westnordost.streetcomplete.quests.road_name.AddRoadName import de.westnordost.streetcomplete.quests.road_name.RoadNameSuggestionsSource import de.westnordost.streetcomplete.quests.roof_colour.AddRoofColour import de.westnordost.streetcomplete.quests.roof_shape.AddRoofShape +import de.westnordost.streetcomplete.quests.sac_scale.AddSacScale import de.westnordost.streetcomplete.quests.sanitary_dump_station.AddSanitaryDumpStation +import de.westnordost.streetcomplete.quests.sauna_availability.AddSaunaAvailability import de.westnordost.streetcomplete.quests.seating.AddOutdoorSeatingType import de.westnordost.streetcomplete.quests.seating.AddSeating import de.westnordost.streetcomplete.quests.segregated.AddCyclewaySegregation @@ -218,8 +222,6 @@ import de.westnordost.streetcomplete.quests.traffic_signals_sound.AddTrafficSign import de.westnordost.streetcomplete.quests.traffic_signals_vibrate.AddTrafficSignalsVibration import de.westnordost.streetcomplete.quests.trail_visibility.AddTrailVisibility import de.westnordost.streetcomplete.quests.tree.AddTreeGenus -import de.westnordost.streetcomplete.quests.sac_scale.AddSacScale -import de.westnordost.streetcomplete.quests.sauna_availability.AddSaunaAvailability import de.westnordost.streetcomplete.quests.valves.AddValves import de.westnordost.streetcomplete.quests.via_ferrata_scale.AddViaFerrataScale import de.westnordost.streetcomplete.quests.way_lit.AddWayLit @@ -637,6 +639,8 @@ fun getQuestTypeList( EE_QUEST_OFFSET + 52 to AddSaunaAvailability(), EE_QUEST_OFFSET + 10 to OsmoseQuest(osmoseDao), EE_QUEST_OFFSET + 11 to CustomQuest(customQuestList), + EE_QUEST_OFFSET + 60 to AddPlaceIco(getFeature), + EE_QUEST_OFFSET + 61 to AddPlaceVatin(getFeature), // POI quests EE_QUEST_OFFSET + 12 to ShowBusiness(), EE_QUEST_OFFSET + 13 to ShowBicycleStuff(), diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/place_ico/AddPlaceIco.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/place_ico/AddPlaceIco.kt new file mode 100644 index 00000000000..a06cee4a335 --- /dev/null +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/place_ico/AddPlaceIco.kt @@ -0,0 +1,152 @@ +package de.westnordost.streetcomplete.quests.place_ico + +import android.content.Context +import de.westnordost.osmfeatures.Feature +import de.westnordost.streetcomplete.R +import de.westnordost.streetcomplete.data.elementfilter.toElementFilterExpression +import de.westnordost.streetcomplete.data.osm.geometry.ElementGeometry +import de.westnordost.streetcomplete.data.osm.mapdata.Element +import de.westnordost.streetcomplete.data.osm.mapdata.MapDataWithGeometry +import de.westnordost.streetcomplete.data.osm.osmquests.OsmElementQuestType +import de.westnordost.streetcomplete.data.user.achievements.EditTypeAchievement.CITIZEN +import de.westnordost.streetcomplete.osm.Tags +import de.westnordost.streetcomplete.osm.isPlaceOrDisusedPlace +import de.westnordost.streetcomplete.quests.fullElementSelectionDialog +import de.westnordost.streetcomplete.quests.questPrefix + +class AddPlaceIco( + private val getFeature: (Element) -> Feature? +) : OsmElementQuestType { + + private val filter by lazy { (""" + nodes, ways with + ( + shop and shop !~ no|vacant + or office and office !~ no|vacant + or craft + or amenity = recycling and recycling_type = centre + or tourism = information and information = office + or """ + + + // The common list is shared by the name quest, the opening hours quest and the wheelchair quest. + // So when adding other tags to the common list keep in mind that they need to be appropriate for all those quests. + // Independent tags can by added in the "name only" tab. + + prefs.getString(questPrefix(prefs) + PREF_ELEMENTS, NAME_PLACES)+ "\n" + """ + ) + and !brand and !ref:ico and ref:ico:signed != yes + """).toElementFilterExpression() } + + override val changesetComment = "Determine place IČO" + override val wikiLink = "Key:ref:ico" + override val icon = R.drawable.ic_quest_general_ref + override val isReplacePlaceEnabled = true + override val achievements = listOf(CITIZEN) + + override fun getTitle(tags: Map) = R.string.quest_placeIco_title + + override fun getApplicableElements(mapData: MapDataWithGeometry): Iterable = + mapData.filter { isApplicableTo(it) } + + override fun isApplicableTo(element: Element): Boolean = + filter.matches(element) && getFeature(element) != null + + override fun getHighlightedElements(element: Element, getMapData: () -> MapDataWithGeometry) = + getMapData().asSequence().filter { it.isPlaceOrDisusedPlace() } + + override fun createForm() = AddPlaceIcoForm() + + override fun applyAnswerTo(answer: PlaceIcoAnswer, tags: Tags, geometry: ElementGeometry, timestampEdited: Long) { + when (answer) { + is NoPlaceIcoSign -> { + tags["ref:ico:signed"] = "no" + } + is PlaceIco -> { + tags["ref:ico"] = answer.ico + } + } + } + + override val hasQuestSettings = true + + override fun getQuestSettingsDialog(context: Context) = + fullElementSelectionDialog(context, prefs, questPrefix(prefs) + PREF_ELEMENTS, R.string.quest_settings_element_selection, NAME_PLACES) +} + +private val NAME_PLACES = mapOf( + "amenity" to arrayOf( + // common + "restaurant", "cafe", "ice_cream", "fast_food", "bar", "pub", "biergarten", // eat & drink + "food_court", "nightclub", + "cinema", "planetarium", "casino", // amenities + "townhall", "courthouse", "embassy", "community_centre", "youth_centre", "library", // civic + "driving_school", "music_school", "prep_school", "language_school", "dive_centre", // learning + "dancing_school", "ski_school", "flight_school", "surf_school", "sailing_school", + "cooking_school", + "bank", "bureau_de_change", "money_transfer", "post_office", "marketplace", // commercial + "internet_cafe", "payment_centre", + "car_wash", "car_rental", "fuel", // car stuff + "dentist", "doctors", "clinic", "pharmacy", "veterinary", // health + "animal_boarding", "animal_shelter", "animal_breeding", // animals + "coworking_space", // work + + // name & opening hours + "boat_rental", + + // name & wheelchair + "theatre", // culture + "conference_centre", "arts_centre", // events + "police", "ranger_station", // civic + "ferry_terminal", // transport + "place_of_worship", // religious + "hospital", // health care + "brothel", "gambling", "love_hotel", "stripclub", // bad stuff + + // name only + "studio", // culture + "events_venue", "exhibition_centre", "music_venue", // events + "prison", "fire_station", // civic + "social_facility", "nursing_home", "childcare", "retirement_home", "social_centre", // social + "monastery", // religious + "kindergarten", "school", "college", "university", "research_institute", // education + ), + "tourism" to arrayOf( + // common + "zoo", "aquarium", "theme_park", "gallery", "museum", + + // name & wheelchair + "attraction", + "hotel", "guest_house", "motel", "hostel", "alpine_hut", "apartment", "resort", "camp_site", "caravan_site", "chalet" // accommodations + + // and tourism = information, see above + ), + "leisure" to arrayOf( + // common + "fitness_centre", "golf_course", "water_park", "miniature_golf", "bowling_alley", + "amusement_arcade", "adult_gaming_centre", "tanning_salon", + + // name & wheelchair + "sports_centre", "stadium", + + // name only + "dance", "nature_reserve", "marina", "horse_riding", + ), + "landuse" to arrayOf( + "cemetery", "allotments" + ), + "military" to arrayOf( + "airfield", "barracks", "training_area" + ), + "healthcare" to arrayOf( + // common + "pharmacy", "doctor", "clinic", "dentist", "centre", "physiotherapist", + "laboratory", "alternative", "psychotherapist", "optometrist", "podiatrist", + "nurse", "counselling", "speech_therapist", "blood_donation", "sample_collection", + "occupational_therapist", "dialysis", "vaccination_centre", "audiologist", + "blood_bank", "nutrition_counselling", + + // name & wheelchair + "rehabilitation", "hospice", "midwife", "birthing_centre" + ), +).map { it.key + " ~ " + it.value.joinToString("|") }.joinToString("\n or ") +private const val PREF_ELEMENTS = "qs_AddPlaceName_element_selection" diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/place_ico/AddPlaceIcoForm.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/place_ico/AddPlaceIcoForm.kt new file mode 100644 index 00000000000..892641954bf --- /dev/null +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/place_ico/AddPlaceIcoForm.kt @@ -0,0 +1,50 @@ +package de.westnordost.streetcomplete.quests.place_ico + +import android.os.Bundle +import android.text.InputType +import android.view.View +import androidx.appcompat.app.AlertDialog +import androidx.core.text.isDigitsOnly +import androidx.core.widget.doAfterTextChanged +import de.westnordost.streetcomplete.R +import de.westnordost.streetcomplete.databinding.QuestContactBinding +import de.westnordost.streetcomplete.quests.AbstractOsmQuestForm +import de.westnordost.streetcomplete.quests.AnswerItem + +class AddPlaceIcoForm : AbstractOsmQuestForm() { + + override val contentLayoutResId = R.layout.quest_contact + private val binding by contentViewBinding(QuestContactBinding::bind) + + private val ico get() = binding.nameInput.text?.toString().orEmpty().trim() + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + binding.nameInput.inputType = InputType.TYPE_CLASS_NUMBER + + binding.nameInput.doAfterTextChanged { + checkIsFormComplete() + } + } + + override val otherAnswers get() = listOfNotNull( + AnswerItem(R.string.quest_placeIco_no_ico_answer) { confirmNoSign() } + ) + + override fun onClickOk() { + applyAnswer(PlaceIco(ico)) + } + + override fun isFormComplete() = ico.length == 8 && ico.isDigitsOnly() + + private fun confirmNoSign() { + val ctx = context ?: return + AlertDialog.Builder(ctx) + .setTitle(R.string.quest_generic_confirmation_title) + .setPositiveButton(R.string.quest_generic_confirmation_yes) { _, _ -> applyAnswer( + NoPlaceIcoSign + ) } + .setNegativeButton(R.string.quest_generic_confirmation_no, null) + .show() + } +} diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/place_ico/PlaceIcoAnswer.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/place_ico/PlaceIcoAnswer.kt new file mode 100644 index 00000000000..dead238545a --- /dev/null +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/place_ico/PlaceIcoAnswer.kt @@ -0,0 +1,6 @@ +package de.westnordost.streetcomplete.quests.place_ico + +sealed interface PlaceIcoAnswer + +data class PlaceIco(val ico: String) : PlaceIcoAnswer +data object NoPlaceIcoSign : PlaceIcoAnswer diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/place_vatin/AddPlaceVatin.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/place_vatin/AddPlaceVatin.kt new file mode 100644 index 00000000000..6a096753dc9 --- /dev/null +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/place_vatin/AddPlaceVatin.kt @@ -0,0 +1,152 @@ +package de.westnordost.streetcomplete.quests.place_vatin + +import android.content.Context +import de.westnordost.osmfeatures.Feature +import de.westnordost.streetcomplete.R +import de.westnordost.streetcomplete.data.elementfilter.toElementFilterExpression +import de.westnordost.streetcomplete.data.osm.geometry.ElementGeometry +import de.westnordost.streetcomplete.data.osm.mapdata.Element +import de.westnordost.streetcomplete.data.osm.mapdata.MapDataWithGeometry +import de.westnordost.streetcomplete.data.osm.osmquests.OsmElementQuestType +import de.westnordost.streetcomplete.data.user.achievements.EditTypeAchievement.CITIZEN +import de.westnordost.streetcomplete.osm.Tags +import de.westnordost.streetcomplete.osm.isPlaceOrDisusedPlace +import de.westnordost.streetcomplete.quests.fullElementSelectionDialog +import de.westnordost.streetcomplete.quests.questPrefix + +class AddPlaceVatin( + private val getFeature: (Element) -> Feature? +) : OsmElementQuestType { + + private val filter by lazy { (""" + nodes, ways with + ( + shop and shop !~ no|vacant + or office and office !~ no|vacant + or craft + or amenity = recycling and recycling_type = centre + or tourism = information and information = office + or """ + + + // The common list is shared by the name quest, the opening hours quest and the wheelchair quest. + // So when adding other tags to the common list keep in mind that they need to be appropriate for all those quests. + // Independent tags can by added in the "name only" tab. + + prefs.getString(questPrefix(prefs) + PREF_ELEMENTS, NAME_PLACES)+ "\n" + """ + ) + and !brand and !ref:vatin and ref:vatin:signed != yes + """).toElementFilterExpression() } + + override val changesetComment = "Determine place VATIN" + override val wikiLink = "Key:ref:vatin" + override val icon = R.drawable.ic_quest_general_ref + override val isReplacePlaceEnabled = true + override val achievements = listOf(CITIZEN) + + override fun getTitle(tags: Map) = R.string.quest_placeVatin_title + + override fun getApplicableElements(mapData: MapDataWithGeometry): Iterable = + mapData.filter { isApplicableTo(it) } + + override fun isApplicableTo(element: Element): Boolean = + filter.matches(element) && getFeature(element) != null + + override fun getHighlightedElements(element: Element, getMapData: () -> MapDataWithGeometry) = + getMapData().asSequence().filter { it.isPlaceOrDisusedPlace() } + + override fun createForm() = AddPlaceVatinForm() + + override fun applyAnswerTo(answer: PlaceVatinAnswer, tags: Tags, geometry: ElementGeometry, timestampEdited: Long) { + when (answer) { + is NoPlaceVatinSign -> { + tags["ref:vatin:signed"] = "no" + } + is PlaceVatin -> { + tags["ref:vatin"] = answer.ico + } + } + } + + override val hasQuestSettings = true + + override fun getQuestSettingsDialog(context: Context) = + fullElementSelectionDialog(context, prefs, questPrefix(prefs) + PREF_ELEMENTS, R.string.quest_settings_element_selection, NAME_PLACES) +} + +private val NAME_PLACES = mapOf( + "amenity" to arrayOf( + // common + "restaurant", "cafe", "ice_cream", "fast_food", "bar", "pub", "biergarten", // eat & drink + "food_court", "nightclub", + "cinema", "planetarium", "casino", // amenities + "townhall", "courthouse", "embassy", "community_centre", "youth_centre", "library", // civic + "driving_school", "music_school", "prep_school", "language_school", "dive_centre", // learning + "dancing_school", "ski_school", "flight_school", "surf_school", "sailing_school", + "cooking_school", + "bank", "bureau_de_change", "money_transfer", "post_office", "marketplace", // commercial + "internet_cafe", "payment_centre", + "car_wash", "car_rental", "fuel", // car stuff + "dentist", "doctors", "clinic", "pharmacy", "veterinary", // health + "animal_boarding", "animal_shelter", "animal_breeding", // animals + "coworking_space", // work + + // name & opening hours + "boat_rental", + + // name & wheelchair + "theatre", // culture + "conference_centre", "arts_centre", // events + "police", "ranger_station", // civic + "ferry_terminal", // transport + "place_of_worship", // religious + "hospital", // health care + "brothel", "gambling", "love_hotel", "stripclub", // bad stuff + + // name only + "studio", // culture + "events_venue", "exhibition_centre", "music_venue", // events + "prison", "fire_station", // civic + "social_facility", "nursing_home", "childcare", "retirement_home", "social_centre", // social + "monastery", // religious + "kindergarten", "school", "college", "university", "research_institute", // education + ), + "tourism" to arrayOf( + // common + "zoo", "aquarium", "theme_park", "gallery", "museum", + + // name & wheelchair + "attraction", + "hotel", "guest_house", "motel", "hostel", "alpine_hut", "apartment", "resort", "camp_site", "caravan_site", "chalet" // accommodations + + // and tourism = information, see above + ), + "leisure" to arrayOf( + // common + "fitness_centre", "golf_course", "water_park", "miniature_golf", "bowling_alley", + "amusement_arcade", "adult_gaming_centre", "tanning_salon", + + // name & wheelchair + "sports_centre", "stadium", + + // name only + "dance", "nature_reserve", "marina", "horse_riding", + ), + "landuse" to arrayOf( + "cemetery", "allotments" + ), + "military" to arrayOf( + "airfield", "barracks", "training_area" + ), + "healthcare" to arrayOf( + // common + "pharmacy", "doctor", "clinic", "dentist", "centre", "physiotherapist", + "laboratory", "alternative", "psychotherapist", "optometrist", "podiatrist", + "nurse", "counselling", "speech_therapist", "blood_donation", "sample_collection", + "occupational_therapist", "dialysis", "vaccination_centre", "audiologist", + "blood_bank", "nutrition_counselling", + + // name & wheelchair + "rehabilitation", "hospice", "midwife", "birthing_centre" + ), +).map { it.key + " ~ " + it.value.joinToString("|") }.joinToString("\n or ") +private const val PREF_ELEMENTS = "qs_AddPlaceName_element_selection" diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/place_vatin/AddPlaceVatinForm.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/place_vatin/AddPlaceVatinForm.kt new file mode 100644 index 00000000000..0e680950f2d --- /dev/null +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/place_vatin/AddPlaceVatinForm.kt @@ -0,0 +1,70 @@ +package de.westnordost.streetcomplete.quests.place_vatin + +import android.os.Bundle +import android.text.InputType +import android.view.View +import androidx.appcompat.app.AlertDialog +import androidx.core.widget.doAfterTextChanged +import de.westnordost.streetcomplete.R +import de.westnordost.streetcomplete.databinding.QuestContactBinding +import de.westnordost.streetcomplete.quests.AbstractOsmQuestForm +import de.westnordost.streetcomplete.quests.AnswerItem + +class AddPlaceVatinForm : AbstractOsmQuestForm() { + + override val contentLayoutResId = R.layout.quest_contact + private val binding by contentViewBinding(QuestContactBinding::bind) + + private val vatin get() = binding.nameInput.text?.toString().orEmpty().trim() + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + binding.nameInput.inputType = InputType.TYPE_CLASS_TEXT + + binding.nameInput.doAfterTextChanged { + val text = binding.nameInput.text.toString() + val countryPrefix = text.substring(0, text.length.coerceAtMost(2)) + if (countryPrefix.isNotEmpty() && countryPrefix.any { it.isLowerCase() }) { + val textAfterCountryPrefix = if (text.length > 2) { text.substring(2) } else { "" } + val newText = countryPrefix.uppercase() + textAfterCountryPrefix + val selection = binding.nameInput.selectionStart + binding.nameInput.setText(newText) + binding.nameInput.setSelection(selection) + } + checkIsFormComplete() + } + } + + override val otherAnswers get() = listOfNotNull( + AnswerItem(R.string.quest_placeVatin_no_vatin_answer) { confirmNoSign() } + ) + + override fun onClickOk() { + applyAnswer(PlaceVatin(vatin)) + } + + override fun isFormComplete(): Boolean { + if (vatin.length < 2) + return false + val countryPrefix = vatin.substring(0, 2); + if (countryPrefix.any { !it.isUpperCase() }) + return false + // TODO other countries https://en.wikipedia.org/wiki/VAT_identification_number + return when (countryPrefix) { + "CZ" -> vatin.length in 2 + 8..2 + 10 && vatin.substring(2).all { it.isDigit() } + "SK" -> vatin.length == 2 + 10 && vatin.substring(2).all { it.isDigit() } + else -> vatin.length >= 2 + 2 // Romania + } + } + + private fun confirmNoSign() { + val ctx = context ?: return + AlertDialog.Builder(ctx) + .setTitle(R.string.quest_generic_confirmation_title) + .setPositiveButton(R.string.quest_generic_confirmation_yes) { _, _ -> applyAnswer( + NoPlaceVatinSign + ) } + .setNegativeButton(R.string.quest_generic_confirmation_no, null) + .show() + } +} diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/place_vatin/PlaceVatinAnswer.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/place_vatin/PlaceVatinAnswer.kt new file mode 100644 index 00000000000..8c43c6425eb --- /dev/null +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/place_vatin/PlaceVatinAnswer.kt @@ -0,0 +1,6 @@ +package de.westnordost.streetcomplete.quests.place_vatin + +sealed interface PlaceVatinAnswer + +data class PlaceVatin(val ico: String) : PlaceVatinAnswer +data object NoPlaceVatinSign : PlaceVatinAnswer diff --git a/app/src/main/res/values-cs/strings.xml b/app/src/main/res/values-cs/strings.xml index 1dc5b9f5bf0..f649f50fd3e 100644 --- a/app/src/main/res/values-cs/strings.xml +++ b/app/src/main/res/values-cs/strings.xml @@ -86,7 +86,7 @@ OpenStreetMap nelze upravovat anonymně. Všechny změny, které provádíte (a <h2>Poloha</h2> <p> -Aplikace s nikým nesdílí vaši GPS polohu. Používá se jen pro automatické stahování dat pro vaše okolí a pro vycentrování mapy na základě vaší polohy. +Aplikace s nikým nesdílí vaši GPS polohu. Používá se jen pro automatické stahování dat pro vaše okolí a pro vycentrování mapy na základě vaší polohy. </p> <h2>Použití dat</h2> @@ -1033,6 +1033,8 @@ Také můžete napsat poznámku (s fotografií)" "Fotoaparát je používán jinou aplikací" "Držák na řidítka" "Kdo tu může zaparkovat kolo? Parkování může být zdarma, nebo placené." + Jaké DIČ (VAT IN) má toto místo? + Není zaznačené "Kdo může používat toto hřiště?" "Chybí výběr těchto chodníků" "Vyberte jednu stranu a pak správnou odpověď. @@ -1093,6 +1095,8 @@ Totéž udělejte i pro druhou stranu, pokud je přítomna." "Jaké jsou tu otevírací hodiny?" "Jsou tu uvedeny otevírací hodiny?" "Jsou tyto otevírací hodiny stále platné?" + Jaké IČ(O) má toto místo? + Není zaznačené "Jaký je název tohoto místa?" "Jakého typu je tento obchod?" "Je tu povoleno kouření?" @@ -1403,4 +1407,4 @@ Podlaží se počítají jako střešní, pokud jejich okna jsou ve střeše. Te "Pod jakým názvem se níže uvedený výběr úkolů uloží." "Vyberte vše, co vyhovuje:" "Jaká je tu šířka v otevřeném stavu?" - \ No newline at end of file + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 4441843bcad..dff7b717eab 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1331,9 +1331,15 @@ If there are no signs along the whole street which apply for the highlighted sec Is this covered (protected from rain)? + What’s the IČ(O) of this place? + There is no sign… + "What’s the name of this place?" "There is no name sign…" + "What’s the VAT number of this place?" + "There is no sign…" + Who is allowed to use this playground? Which type of police station is this? From 0a5e973be5ee954f8dcac63686c19cb1375a8a4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vojt=C4=9Bch=20Fo=C5=A1n=C3=A1r?= Date: Sun, 29 Sep 2024 17:49:30 +0200 Subject: [PATCH 2/5] bad check for :signed != no --- .../westnordost/streetcomplete/quests/place_ico/AddPlaceIco.kt | 2 +- .../streetcomplete/quests/place_vatin/AddPlaceVatin.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/place_ico/AddPlaceIco.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/place_ico/AddPlaceIco.kt index a06cee4a335..293cf9ce33d 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/place_ico/AddPlaceIco.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/place_ico/AddPlaceIco.kt @@ -34,7 +34,7 @@ class AddPlaceIco( prefs.getString(questPrefix(prefs) + PREF_ELEMENTS, NAME_PLACES)+ "\n" + """ ) - and !brand and !ref:ico and ref:ico:signed != yes + and !brand and !ref:ico and ref:ico:signed != no """).toElementFilterExpression() } override val changesetComment = "Determine place IČO" diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/place_vatin/AddPlaceVatin.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/place_vatin/AddPlaceVatin.kt index 6a096753dc9..70c5610bf53 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/place_vatin/AddPlaceVatin.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/place_vatin/AddPlaceVatin.kt @@ -34,7 +34,7 @@ class AddPlaceVatin( prefs.getString(questPrefix(prefs) + PREF_ELEMENTS, NAME_PLACES)+ "\n" + """ ) - and !brand and !ref:vatin and ref:vatin:signed != yes + and !brand and !ref:vatin and ref:vatin:signed != no """).toElementFilterExpression() } override val changesetComment = "Determine place VATIN" From 27d4b727f702d2238ac0851fabc653e3a541b34f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vojt=C4=9Bch=20Fo=C5=A1n=C3=A1r?= Date: Sun, 29 Sep 2024 21:21:48 +0200 Subject: [PATCH 3/5] resolve conflict, fix disabled by default --- .../java/de/westnordost/streetcomplete/quests/QuestsModule.kt | 2 -- .../westnordost/streetcomplete/quests/place_ico/AddPlaceIco.kt | 2 ++ .../streetcomplete/quests/place_vatin/AddPlaceVatin.kt | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/QuestsModule.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/QuestsModule.kt index ec73506f7ab..0e7fe0343af 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/QuestsModule.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/QuestsModule.kt @@ -168,9 +168,7 @@ import de.westnordost.streetcomplete.quests.road_name.AddRoadName import de.westnordost.streetcomplete.quests.road_name.RoadNameSuggestionsSource import de.westnordost.streetcomplete.quests.roof_colour.AddRoofColour import de.westnordost.streetcomplete.quests.roof_shape.AddRoofShape -import de.westnordost.streetcomplete.quests.sac_scale.AddSacScale import de.westnordost.streetcomplete.quests.sanitary_dump_station.AddSanitaryDumpStation -import de.westnordost.streetcomplete.quests.sauna_availability.AddSaunaAvailability import de.westnordost.streetcomplete.quests.seating.AddOutdoorSeatingType import de.westnordost.streetcomplete.quests.seating.AddSeating import de.westnordost.streetcomplete.quests.segregated.AddCyclewaySegregation diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/place_ico/AddPlaceIco.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/place_ico/AddPlaceIco.kt index 293cf9ce33d..a470239e970 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/place_ico/AddPlaceIco.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/place_ico/AddPlaceIco.kt @@ -69,6 +69,8 @@ class AddPlaceIco( override val hasQuestSettings = true + override val defaultDisabledMessage = R.string.default_disabled_msg_ee + override fun getQuestSettingsDialog(context: Context) = fullElementSelectionDialog(context, prefs, questPrefix(prefs) + PREF_ELEMENTS, R.string.quest_settings_element_selection, NAME_PLACES) } diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/place_vatin/AddPlaceVatin.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/place_vatin/AddPlaceVatin.kt index 70c5610bf53..ea1e8cec279 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/place_vatin/AddPlaceVatin.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/place_vatin/AddPlaceVatin.kt @@ -67,6 +67,8 @@ class AddPlaceVatin( } } + override val defaultDisabledMessage = R.string.default_disabled_msg_ee + override val hasQuestSettings = true override fun getQuestSettingsDialog(context: Context) = From 74cf102bbb7391308fbc35d49426332034b79e36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vojt=C4=9Bch=20Fo=C5=A1n=C3=A1r?= Date: Sun, 29 Sep 2024 21:45:43 +0200 Subject: [PATCH 4/5] resolve some notes from @mnalis --- .../streetcomplete/quests/place_vatin/AddPlaceVatin.kt | 2 +- .../quests/place_vatin/AddPlaceVatinForm.kt | 1 + .../streetcomplete/quests/place_vatin/PlaceVatinAnswer.kt | 2 +- app/src/main/res/values-cs/strings.xml | 4 ---- app/src/main/res/values/strings.xml | 6 ------ app/src/main/res/values/strings_ee.xml | 8 ++++++++ 6 files changed, 11 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/place_vatin/AddPlaceVatin.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/place_vatin/AddPlaceVatin.kt index ea1e8cec279..c8feb0bc347 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/place_vatin/AddPlaceVatin.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/place_vatin/AddPlaceVatin.kt @@ -62,7 +62,7 @@ class AddPlaceVatin( tags["ref:vatin:signed"] = "no" } is PlaceVatin -> { - tags["ref:vatin"] = answer.ico + tags["ref:vatin"] = answer.vatin } } } diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/place_vatin/AddPlaceVatinForm.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/place_vatin/AddPlaceVatinForm.kt index 0e680950f2d..a7467c7ead9 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/place_vatin/AddPlaceVatinForm.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/place_vatin/AddPlaceVatinForm.kt @@ -52,6 +52,7 @@ class AddPlaceVatinForm : AbstractOsmQuestForm() { // TODO other countries https://en.wikipedia.org/wiki/VAT_identification_number return when (countryPrefix) { "CZ" -> vatin.length in 2 + 8..2 + 10 && vatin.substring(2).all { it.isDigit() } + "HR" -> vatin.length == 2 + 11 && vatin.substring(2).all { it.isDigit() } "SK" -> vatin.length == 2 + 10 && vatin.substring(2).all { it.isDigit() } else -> vatin.length >= 2 + 2 // Romania } diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/place_vatin/PlaceVatinAnswer.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/place_vatin/PlaceVatinAnswer.kt index 8c43c6425eb..0bf8e07c271 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/place_vatin/PlaceVatinAnswer.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/place_vatin/PlaceVatinAnswer.kt @@ -2,5 +2,5 @@ package de.westnordost.streetcomplete.quests.place_vatin sealed interface PlaceVatinAnswer -data class PlaceVatin(val ico: String) : PlaceVatinAnswer +data class PlaceVatin(val vatin: String) : PlaceVatinAnswer data object NoPlaceVatinSign : PlaceVatinAnswer diff --git a/app/src/main/res/values-cs/strings.xml b/app/src/main/res/values-cs/strings.xml index f649f50fd3e..566f800423e 100644 --- a/app/src/main/res/values-cs/strings.xml +++ b/app/src/main/res/values-cs/strings.xml @@ -1033,8 +1033,6 @@ Také můžete napsat poznámku (s fotografií)" "Fotoaparát je používán jinou aplikací" "Držák na řidítka" "Kdo tu může zaparkovat kolo? Parkování může být zdarma, nebo placené." - Jaké DIČ (VAT IN) má toto místo? - Není zaznačené "Kdo může používat toto hřiště?" "Chybí výběr těchto chodníků" "Vyberte jednu stranu a pak správnou odpověď. @@ -1095,8 +1093,6 @@ Totéž udělejte i pro druhou stranu, pokud je přítomna." "Jaké jsou tu otevírací hodiny?" "Jsou tu uvedeny otevírací hodiny?" "Jsou tyto otevírací hodiny stále platné?" - Jaké IČ(O) má toto místo? - Není zaznačené "Jaký je název tohoto místa?" "Jakého typu je tento obchod?" "Je tu povoleno kouření?" diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index dff7b717eab..4441843bcad 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1331,15 +1331,9 @@ If there are no signs along the whole street which apply for the highlighted sec Is this covered (protected from rain)? - What’s the IČ(O) of this place? - There is no sign… - "What’s the name of this place?" "There is no name sign…" - "What’s the VAT number of this place?" - "There is no sign…" - Who is allowed to use this playground? Which type of police station is this? diff --git a/app/src/main/res/values/strings_ee.xml b/app/src/main/res/values/strings_ee.xml index c4dd52b6d46..72a617f5b0d 100644 --- a/app/src/main/res/values/strings_ee.xml +++ b/app/src/main/res/values/strings_ee.xml @@ -518,6 +518,14 @@ "Beach - next to a beach or by the sea." "Supermarket - on the parking lot of a supermarket." + + What’s the IČ(O) of this place? + There is no sign… + + + "What’s the VAT number of this place?" + "There is no sign…" + What is the phone number of this place? What is the website of this place? From 08283a35a15071d299ecddf804f7e0506f625150 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vojt=C4=9Bch=20Fo=C5=A1n=C3=A1r?= Date: Sun, 29 Sep 2024 21:50:24 +0200 Subject: [PATCH 5/5] resolve more notes from @mnalis --- .../westnordost/streetcomplete/quests/QuestsModule.kt | 10 +++++----- .../streetcomplete/quests/place_ico/AddPlaceIco.kt | 2 +- .../streetcomplete/quests/place_vatin/AddPlaceVatin.kt | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/QuestsModule.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/QuestsModule.kt index 0e7fe0343af..c0efb8c55d6 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/QuestsModule.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/QuestsModule.kt @@ -168,7 +168,9 @@ import de.westnordost.streetcomplete.quests.road_name.AddRoadName import de.westnordost.streetcomplete.quests.road_name.RoadNameSuggestionsSource import de.westnordost.streetcomplete.quests.roof_colour.AddRoofColour import de.westnordost.streetcomplete.quests.roof_shape.AddRoofShape +import de.westnordost.streetcomplete.quests.sac_scale.AddSacScale import de.westnordost.streetcomplete.quests.sanitary_dump_station.AddSanitaryDumpStation +import de.westnordost.streetcomplete.quests.sauna_availability.AddSaunaAvailability import de.westnordost.streetcomplete.quests.seating.AddOutdoorSeatingType import de.westnordost.streetcomplete.quests.seating.AddSeating import de.westnordost.streetcomplete.quests.segregated.AddCyclewaySegregation @@ -206,6 +208,7 @@ import de.westnordost.streetcomplete.quests.surface.AddPathSurface import de.westnordost.streetcomplete.quests.surface.AddPitchSurface import de.westnordost.streetcomplete.quests.surface.AddRoadSurface import de.westnordost.streetcomplete.quests.surface.AddSidewalkSurface +import de.westnordost.streetcomplete.quests.swimming_pool_availability.AddSwimmingPoolAvailability import de.westnordost.streetcomplete.quests.tactile_paving.AddTactilePavingBusStop import de.westnordost.streetcomplete.quests.tactile_paving.AddTactilePavingCrosswalk import de.westnordost.streetcomplete.quests.tactile_paving.AddTactilePavingKerb @@ -220,9 +223,6 @@ import de.westnordost.streetcomplete.quests.traffic_signals_sound.AddTrafficSign import de.westnordost.streetcomplete.quests.traffic_signals_vibrate.AddTrafficSignalsVibration import de.westnordost.streetcomplete.quests.trail_visibility.AddTrailVisibility import de.westnordost.streetcomplete.quests.tree.AddTreeGenus -import de.westnordost.streetcomplete.quests.sac_scale.AddSacScale -import de.westnordost.streetcomplete.quests.sauna_availability.AddSaunaAvailability -import de.westnordost.streetcomplete.quests.swimming_pool_availability.AddSwimmingPoolAvailability import de.westnordost.streetcomplete.quests.valves.AddValves import de.westnordost.streetcomplete.quests.via_ferrata_scale.AddViaFerrataScale import de.westnordost.streetcomplete.quests.way_lit.AddWayLit @@ -641,8 +641,8 @@ fun getQuestTypeList( EE_QUEST_OFFSET + 53 to AddSwimmingPoolAvailability(), EE_QUEST_OFFSET + 10 to OsmoseQuest(osmoseDao), EE_QUEST_OFFSET + 11 to CustomQuest(customQuestList), - EE_QUEST_OFFSET + 60 to AddPlaceIco(getFeature), - EE_QUEST_OFFSET + 61 to AddPlaceVatin(getFeature), + EE_QUEST_OFFSET + 54 to AddPlaceIco(getFeature), + EE_QUEST_OFFSET + 55 to AddPlaceVatin(getFeature), // POI quests EE_QUEST_OFFSET + 12 to ShowBusiness(), EE_QUEST_OFFSET + 13 to ShowBicycleStuff(), diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/place_ico/AddPlaceIco.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/place_ico/AddPlaceIco.kt index a470239e970..28faf0a72d2 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/place_ico/AddPlaceIco.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/place_ico/AddPlaceIco.kt @@ -151,4 +151,4 @@ private val NAME_PLACES = mapOf( "rehabilitation", "hospice", "midwife", "birthing_centre" ), ).map { it.key + " ~ " + it.value.joinToString("|") }.joinToString("\n or ") -private const val PREF_ELEMENTS = "qs_AddPlaceName_element_selection" +private const val PREF_ELEMENTS = "qs_AddPlaceIco_element_selection" diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/place_vatin/AddPlaceVatin.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/place_vatin/AddPlaceVatin.kt index c8feb0bc347..d4f4baac7e9 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/place_vatin/AddPlaceVatin.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/place_vatin/AddPlaceVatin.kt @@ -151,4 +151,4 @@ private val NAME_PLACES = mapOf( "rehabilitation", "hospice", "midwife", "birthing_centre" ), ).map { it.key + " ~ " + it.value.joinToString("|") }.joinToString("\n or ") -private const val PREF_ELEMENTS = "qs_AddPlaceName_element_selection" +private const val PREF_ELEMENTS = "qs_AddPlaceVatin_element_selection"