Skip to content

Commit

Permalink
Show in the quest form if an element is to be found underground (#1326)
Browse files Browse the repository at this point in the history
  • Loading branch information
westnordost committed Feb 3, 2019
1 parent bc88762 commit b6d286a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,10 @@ abstract class AbstractQuestAnswerFragment<T> : AbstractBottomSheetFragment() {

titleLabel.text = resources.getHtmlQuestTitle(questType, osmElement)

/* prefer addr:floor etc. over level as level is rather an index than how the floor is
denominated in the building and thus may (sometimes) not coincide with it. E.g.
addr:floor may be "M" while level is "2" */
val level = osmElement?.tags?.let { it["addr:floor"] ?: it["level:ref"] ?: it["level"] }
if (level != null) {
val levelLabelText = getLevelLabelText()
if (levelLabelText != null) {
levelLabel.visibility = View.VISIBLE
levelLabel.text = resources.getString(R.string.on_level, level)
levelLabel.text = levelLabelText
} else {
levelLabel.visibility = View.GONE
}
Expand Down Expand Up @@ -162,6 +159,21 @@ abstract class AbstractQuestAnswerFragment<T> : AbstractBottomSheetFragment() {
}
}

private fun getLevelLabelText(): String? {
val tags = osmElement?.tags ?: return null
/* prefer addr:floor etc. over level as level is rather an index than how the floor is
denominated in the building and thus may (sometimes) not coincide with it. E.g.
addr:floor may be "M" while level is "2" */
val level = tags["addr:floor"] ?: tags["level:ref"] ?: tags["level"]
if (level != null) {
return resources.getString(R.string.on_level, level)
}
val tunnel = tags["tunnel"]
if(tunnel != null && tunnel != "no" || tags["location"] == "underground") {
return resources.getString(R.string.underground)
}
return null
}

override fun onStart() {
super.onStart()
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -639,4 +639,5 @@ Otherwise, you can download another keyboard in the app store. Popular keyboards
that does not carry an implicit meaning of where it is located in respect to the ground floor.
The context is usually shopping centres, train stations or airport terminals -->
<string name="on_level">on level %s:</string>
<string name="underground">underground:</string>
</resources>

0 comments on commit b6d286a

Please sign in to comment.