forked from streetcomplete/StreetComplete
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'mnalis-v38b1-smoothness-helium314' into mnalis-v38-smoo…
…thness-helium314
- Loading branch information
Showing
15 changed files
with
286 additions
and
30 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
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
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
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
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
78 changes: 78 additions & 0 deletions
78
app/src/main/java/de/westnordost/streetcomplete/quests/contact/AddContactPhone.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,78 @@ | ||
package de.westnordost.streetcomplete.quests.contact | ||
|
||
import de.westnordost.streetcomplete.R | ||
import de.westnordost.streetcomplete.data.osm.edits.update_tags.StringMapChangesBuilder | ||
import de.westnordost.streetcomplete.data.osm.osmquests.OsmFilterQuestType | ||
import de.westnordost.streetcomplete.data.user.achievements.QuestTypeAchievement.CITIZEN | ||
|
||
class AddContactPhone : OsmFilterQuestType<String>() { | ||
|
||
override val elementFilter = """ | ||
nodes, ways, relations with | ||
( | ||
tourism = information and information = office | ||
or """.trimIndent() + | ||
|
||
// 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 "wheelchair only" tab. | ||
|
||
mapOf( | ||
"amenity" to arrayOf( | ||
// common | ||
"restaurant", "cafe", "nightclub","internet_cafe", | ||
"cinema", "townhall", "courthouse", "embassy", "community_centre", "youth_centre", "library", | ||
"dentist", "doctors", "clinic", "veterinary","animal_shelter", | ||
|
||
// name & wheelchair only | ||
"arts_centre","ferry_terminal" | ||
), | ||
"tourism" to arrayOf( | ||
// common | ||
"zoo", "aquarium", "gallery", "museum", | ||
), | ||
"shop" to arrayOf( | ||
// common | ||
"beauty", "massage", "hairdresser","boutique","wool","tattoo","electrical","florist","glaziery", | ||
"computer","electronics","hifi","bicycle","outdoor","sports","clothing","art","craft","model", | ||
"musical_instrument","camera","books","travel_agency","cheese","chocolate","coffee","health_food" | ||
), | ||
"leisure" to arrayOf( | ||
// common | ||
"fitness_centre", "bowling_alley","sports_centre" | ||
), | ||
"office" to arrayOf( | ||
// common | ||
"insurance", "government", "travel_agent", "tax_advisor", "religion", "employment_agency", | ||
|
||
// name & wheelchair | ||
"lawyer", "estate_agent", "therapist" | ||
), | ||
"craft" to arrayOf( | ||
// common | ||
"carpenter", "shoemaker", "tailor", "photographer", "dressmaker", | ||
"electronics_repair", "stonemason","winery" | ||
) | ||
).map { it.key + " ~ " + it.value.joinToString("|") }.joinToString("\n or ") + | ||
"\n) and !phone and !contact:phone and !contact:mobile and !brand and name" | ||
|
||
override val commitMessage = "Add phone number" | ||
override val wikiLink = "Key:phone" | ||
override val icon = R.drawable.ic_quest_blind_traffic_lights_sound | ||
|
||
override val questTypeAchievements = listOf(CITIZEN) | ||
|
||
override fun getTitle(tags: Map<String, String>) = R.string.quest_contact_phone | ||
|
||
override fun getTitleArgs(tags: Map<String, String>, featureName: Lazy<String?>): Array<String> { | ||
val name = tags["name"] | ||
return if (name != null) arrayOf(name) else arrayOf() | ||
} | ||
|
||
override fun createForm() = AddContactPhoneForm() | ||
|
||
override fun applyAnswerTo(answer: String, changes: StringMapChangesBuilder) { | ||
changes.add("phone", answer) | ||
} | ||
|
||
} |
36 changes: 36 additions & 0 deletions
36
app/src/main/java/de/westnordost/streetcomplete/quests/contact/AddContactPhoneForm.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,36 @@ | ||
package de.westnordost.streetcomplete.quests.contact | ||
|
||
import android.os.Bundle | ||
import android.text.InputType | ||
import android.view.View | ||
|
||
import de.westnordost.streetcomplete.R | ||
import de.westnordost.streetcomplete.quests.AbstractQuestFormAnswerFragment | ||
import de.westnordost.streetcomplete.util.TextChangedWatcher | ||
import de.westnordost.streetcomplete.databinding.QuestContactBinding | ||
|
||
|
||
class AddContactPhoneForm : AbstractQuestFormAnswerFragment<String>() { | ||
|
||
override val contentLayoutResId = R.layout.quest_contact | ||
private val binding by contentViewBinding(QuestContactBinding::bind) | ||
|
||
private val contact get() = binding.nameInput?.text?.toString().orEmpty().trim() | ||
|
||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
binding.nameInput.inputType = InputType.TYPE_CLASS_PHONE | ||
|
||
binding.nameInput.setText(PREFILL) | ||
binding.nameInput.addTextChangedListener(TextChangedWatcher { checkIsFormComplete() }) | ||
} | ||
|
||
override fun onClickOk() { | ||
applyAnswer(contact) | ||
} | ||
|
||
|
||
override fun isFormComplete() = contact.isNotEmpty() && contact != PREFILL | ||
} | ||
|
||
private const val PREFILL = "+" |
81 changes: 81 additions & 0 deletions
81
app/src/main/java/de/westnordost/streetcomplete/quests/contact/AddContactWebsite.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,81 @@ | ||
package de.westnordost.streetcomplete.quests.contact | ||
|
||
import de.westnordost.streetcomplete.R | ||
import de.westnordost.streetcomplete.data.osm.edits.update_tags.StringMapChangesBuilder | ||
import de.westnordost.streetcomplete.data.osm.osmquests.OsmFilterQuestType | ||
import de.westnordost.streetcomplete.data.user.achievements.QuestTypeAchievement.CITIZEN | ||
|
||
class AddContactWebsite : OsmFilterQuestType<String>() { | ||
|
||
override val elementFilter = """ | ||
nodes, ways, relations with | ||
( | ||
tourism = information and information = office | ||
or """.trimIndent() + | ||
|
||
// 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 "wheelchair only" tab. | ||
|
||
mapOf( | ||
"amenity" to arrayOf( | ||
// common | ||
"restaurant", "cafe", "nightclub", // eat & drink | ||
"cinema", "townhall", "courthouse", "embassy", "community_centre", "youth_centre", "library", // civic | ||
"internet_cafe", // commercial | ||
"dentist", "doctors", "clinic", "veterinary", // health | ||
"animal_shelter", | ||
|
||
// name & wheelchair only | ||
"arts_centre","ferry_terminal" | ||
), | ||
"tourism" to arrayOf( | ||
// common | ||
"zoo", "aquarium", "gallery", "museum", | ||
), | ||
"shop" to arrayOf( | ||
// common | ||
"beauty", "massage", "hairdresser","boutique","wool","tattoo","electrical","florist","glaziery", | ||
"computer","electronics","hifi","mobile_phone","bicycle","outdoor","sports","clothing","art","craft","model", | ||
"musical_instrument","camera","books","travel_agency","cheese","chocolate","coffee","health_food" | ||
|
||
), | ||
"leisure" to arrayOf( | ||
// common | ||
"fitness_centre", "bowling_alley","sports_centre" | ||
), | ||
"office" to arrayOf( | ||
// common | ||
"insurance", "government", "travel_agent", "tax_advisor", "religion", "employment_agency", | ||
|
||
// name & wheelchair | ||
"lawyer", "estate_agent", "therapist" | ||
), | ||
"craft" to arrayOf( | ||
// common | ||
"carpenter", "shoemaker", "tailor", "photographer", "dressmaker", | ||
"electronics_repair", "stonemason","winery" | ||
) | ||
).map { it.key + " ~ " + it.value.joinToString("|") }.joinToString("\n or ") + | ||
"\n) and !website and !contact:website and !contact:facebook and !contact:instagram and !brand and name" | ||
|
||
override val commitMessage = "Add website" | ||
override val wikiLink = "Key:website" | ||
override val icon = R.drawable.ic_quest_wifi | ||
|
||
override val questTypeAchievements = listOf(CITIZEN) | ||
|
||
override fun getTitle(tags: Map<String, String>) = R.string.quest_contact_website | ||
|
||
override fun getTitleArgs(tags: Map<String, String>, featureName: Lazy<String?>): Array<String> { | ||
val name = tags["name"] | ||
return if (name != null) arrayOf(name) else arrayOf() | ||
} | ||
|
||
override fun createForm() = AddContactWebsiteForm() | ||
|
||
override fun applyAnswerTo(answer: String, changes: StringMapChangesBuilder) { | ||
changes.add("website", answer) | ||
} | ||
|
||
} |
36 changes: 36 additions & 0 deletions
36
app/src/main/java/de/westnordost/streetcomplete/quests/contact/AddContactWebsiteForm.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,36 @@ | ||
package de.westnordost.streetcomplete.quests.contact | ||
|
||
import android.os.Bundle | ||
import android.text.InputType | ||
import android.view.View | ||
|
||
import de.westnordost.streetcomplete.R | ||
import de.westnordost.streetcomplete.quests.AbstractQuestFormAnswerFragment | ||
import de.westnordost.streetcomplete.util.TextChangedWatcher | ||
import de.westnordost.streetcomplete.databinding.QuestContactBinding | ||
|
||
|
||
class AddContactWebsiteForm : AbstractQuestFormAnswerFragment<String>() { | ||
|
||
override val contentLayoutResId = R.layout.quest_contact | ||
private val binding by contentViewBinding(QuestContactBinding::bind) | ||
|
||
private val contact 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 or InputType.TYPE_TEXT_VARIATION_URI | ||
|
||
binding.nameInput.setText(PREFILL) | ||
binding.nameInput.addTextChangedListener(TextChangedWatcher { checkIsFormComplete() }) | ||
} | ||
|
||
override fun onClickOk() { | ||
applyAnswer(contact) | ||
} | ||
|
||
|
||
override fun isFormComplete() = contact.isNotEmpty() && contact != PREFILL | ||
} | ||
|
||
private const val PREFILL = "http://" |
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
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
Oops, something went wrong.