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-helium314-noprofiles' into mnalis-westnordost-pr…
…ofiles-helium314
- Loading branch information
Showing
12 changed files
with
284 additions
and
10 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
80 changes: 80 additions & 0 deletions
80
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,80 @@ | ||
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 | ||
|
||
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", | ||
|
||
// name & wheelchair | ||
"hotel", "guest_house", "motel", "hostel", "alpine_hut", "apartment", "resort", "camp_site", "caravan_site", "chalet" // accommodations | ||
|
||
// and tourism = information, see above | ||
), | ||
"shop" to arrayOf( | ||
// common | ||
"beauty", "massage", "hairdresser","boutique","wool","tattoo","electrical","florist","glaziery", | ||
"locksmith","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", "key_cutter", "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 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) | ||
} | ||
|
||
} |
32 changes: 32 additions & 0 deletions
32
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,32 @@ | ||
package de.westnordost.streetcomplete.quests.contact | ||
|
||
import android.os.Bundle | ||
import android.view.View | ||
|
||
import de.westnordost.streetcomplete.R | ||
import de.westnordost.streetcomplete.quests.AbstractQuestFormAnswerFragment | ||
import de.westnordost.streetcomplete.util.TextChangedWatcher | ||
import kotlinx.android.synthetic.main.quest_phone.* | ||
|
||
|
||
class AddContactPhoneForm : AbstractQuestFormAnswerFragment<String>() { | ||
|
||
override val contentLayoutResId = R.layout.quest_phone | ||
|
||
private val contact get() = nameInput?.text?.toString().orEmpty().trim() | ||
|
||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
|
||
val prefill = "+" // maybe store or do better? | ||
nameInput.setText(prefill) | ||
nameInput.addTextChangedListener(TextChangedWatcher { checkIsFormComplete() }) | ||
} | ||
|
||
override fun onClickOk() { | ||
applyAnswer(contact) | ||
} | ||
|
||
|
||
override fun isFormComplete() = contact.isNotEmpty() | ||
} |
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 | ||
|
||
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", | ||
|
||
// name & wheelchair | ||
"hotel", "guest_house", "motel", "hostel", "alpine_hut", "apartment", "resort", "camp_site", "caravan_site", "chalet" // accommodations | ||
), | ||
"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", "key_cutter", "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 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) | ||
} | ||
|
||
} |
31 changes: 31 additions & 0 deletions
31
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,31 @@ | ||
package de.westnordost.streetcomplete.quests.contact | ||
|
||
import android.os.Bundle | ||
import android.view.View | ||
|
||
import de.westnordost.streetcomplete.R | ||
import de.westnordost.streetcomplete.quests.AbstractQuestFormAnswerFragment | ||
import de.westnordost.streetcomplete.util.TextChangedWatcher | ||
import kotlinx.android.synthetic.main.quest_website.* | ||
|
||
|
||
class AddContactWebsiteForm : AbstractQuestFormAnswerFragment<String>() { | ||
|
||
override val contentLayoutResId = R.layout.quest_website | ||
|
||
private val contact get() = nameInput?.text?.toString().orEmpty().trim() | ||
|
||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
|
||
nameInput.setText("http://") | ||
nameInput.addTextChangedListener(TextChangedWatcher { checkIsFormComplete() }) | ||
} | ||
|
||
override fun onClickOk() { | ||
applyAnswer(contact) | ||
} | ||
|
||
|
||
override fun isFormComplete() = contact.isNotEmpty() | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<EditText | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:id="@+id/nameInput" | ||
android:inputType="phone" | ||
android:textSize="40sp" | ||
tools:text="Bürger König" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content"/> |
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,10 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<EditText | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:id="@+id/nameInput" | ||
android:inputType="textUri" | ||
android:textSize="40sp" | ||
tools:text="Bürger König" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content"/> |
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