-
-
Notifications
You must be signed in to change notification settings - Fork 364
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
5 changed files
with
92 additions
and
0 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
36 changes: 36 additions & 0 deletions
36
.../main/java/de/westnordost/streetcomplete/quests/defibrillator/AddDefibrillatorLocation.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.defibrillator | ||
|
||
import de.westnordost.streetcomplete.R | ||
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.mapdata.filter | ||
import de.westnordost.streetcomplete.data.osm.osmquests.OsmFilterQuestType | ||
import de.westnordost.streetcomplete.data.user.achievements.EditTypeAchievement.LIFESAVER | ||
import de.westnordost.streetcomplete.osm.Tags | ||
|
||
class AddDefibrillatorLocation : OsmFilterQuestType<String>() { | ||
|
||
override val elementFilter = """ | ||
nodes with | ||
emergency = defibrillator | ||
and !location and !defibrillator:location | ||
and access !~ private|no" | ||
""" | ||
override val changesetComment = "Specify defibrillator location" | ||
override val wikiLink = "Tag:emergency=defibrillator" | ||
override val icon = R.drawable.ic_quest_defibrillator | ||
override val isDeleteElementEnabled = false | ||
override val achievements = listOf(LIFESAVER) | ||
|
||
override fun getTitle(tags: Map<String, String>) = R.string.quest_defibrillator_location | ||
|
||
override fun getHighlightedElements(element: Element, getMapData: () -> MapDataWithGeometry) = | ||
getMapData().filter("nodes with emergency = defibrillator") | ||
|
||
override fun createForm() = AddDefibrillatorLocationForm() | ||
|
||
override fun applyAnswerTo(answer: String, tags: Tags, geometry: ElementGeometry, timestampEdited: Long) { | ||
tags["defibrillator:location"] = answer | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...n/java/de/westnordost/streetcomplete/quests/defibrillator/AddDefibrillatorLocationForm.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,28 @@ | ||
package de.westnordost.streetcomplete.quests.defibrillator | ||
|
||
import android.os.Bundle | ||
import android.view.View | ||
import androidx.core.widget.doAfterTextChanged | ||
import de.westnordost.streetcomplete.R | ||
import de.westnordost.streetcomplete.databinding.QuestLocationBinding | ||
import de.westnordost.streetcomplete.quests.AbstractOsmQuestForm | ||
import de.westnordost.streetcomplete.util.ktx.nonBlankTextOrNull | ||
|
||
class AddDefibrillatorLocationForm : AbstractOsmQuestForm<String>() { | ||
|
||
override val contentLayoutResId = R.layout.quest_location | ||
private val binding by contentViewBinding(QuestLocationBinding::bind) | ||
|
||
private val location get() = binding.locationInput.nonBlankTextOrNull | ||
|
||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
binding.locationInput.doAfterTextChanged { checkIsFormComplete() } | ||
} | ||
|
||
override fun onClickOk() { | ||
applyAnswer(location!!) | ||
} | ||
|
||
override fun isFormComplete() = location != null | ||
} |
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,24 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:orientation="vertical" | ||
android:paddingStart="24dp" | ||
android:paddingEnd="24dp"> | ||
<TextView | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="@string/quest_defibrillator_location_description" | ||
android:labelFor="@+id/commentInput"/> | ||
|
||
<EditText xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:id="@+id/locationInput" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:inputType="textMultiLine|textCapSentences" | ||
android:minLines="3" | ||
android:maxLength="253" | ||
android:background="@drawable/background_edittext_outline" | ||
/> | ||
</LinearLayout> |
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