-
-
Notifications
You must be signed in to change notification settings - Fork 363
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2078 from matkoniecz/resurface
Merge surface quest and detail surface quest, attempt to make interface less confusing [accepted, waiting for merge]
- Loading branch information
Showing
41 changed files
with
209 additions
and
266 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
71 changes: 25 additions & 46 deletions
71
app/src/main/java/de/westnordost/streetcomplete/quests/surface/AddPathSurfaceForm.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 |
---|---|---|
@@ -1,56 +1,35 @@ | ||
package de.westnordost.streetcomplete.quests.surface | ||
|
||
import androidx.appcompat.app.AlertDialog | ||
import de.westnordost.streetcomplete.R | ||
import de.westnordost.streetcomplete.quests.AGroupedImageListQuestAnswerFragment | ||
import de.westnordost.streetcomplete.quests.AImageListQuestAnswerFragment | ||
import de.westnordost.streetcomplete.view.image_select.Item | ||
import de.westnordost.streetcomplete.quests.surface.Surface.* | ||
|
||
class AddPathSurfaceForm : AGroupedImageListQuestAnswerFragment<String, String>() { | ||
class AddPathSurfaceForm : AImageListQuestAnswerFragment<String, SurfaceAnswer>() { | ||
override val items: List<Item<String>> get() = | ||
(PAVED_SURFACES + UNPAVED_SURFACES + GROUND_SURFACES).toItems() + | ||
Item("paved", R.drawable.path_surface_paved, R.string.quest_surface_value_paved, null, listOf()) + | ||
Item("unpaved", R.drawable.path_surface_unpaved, R.string.quest_surface_value_unpaved, null, listOf()) + | ||
Item("ground", R.drawable.surface_ground, R.string.quest_surface_value_ground, null, listOf()) | ||
|
||
override val topItems get() = | ||
when (val pathType = determinePathType(osmElement!!.tags)) { | ||
"bridleway" -> listOf( | ||
DIRT, GRASS, SAND, | ||
PEBBLES, FINE_GRAVEL, COMPACTED | ||
) | ||
"path" -> listOf( | ||
DIRT, PEBBLES, COMPACTED, | ||
ASPHALT, FINE_GRAVEL, PAVING_STONES | ||
) | ||
"footway" -> listOf( | ||
PAVING_STONES, ASPHALT, CONCRETE, | ||
COMPACTED, FINE_GRAVEL, DIRT | ||
) | ||
"cycleway" -> listOf( | ||
PAVING_STONES, ASPHALT, CONCRETE, | ||
COMPACTED, WOOD, METAL | ||
) | ||
"steps" -> listOf( | ||
PAVING_STONES, ASPHALT, CONCRETE, | ||
WOOD, SETT, UNHEWN_COBBLESTONE | ||
) | ||
else -> throw IllegalStateException("Unexpected path type $pathType") | ||
}.toItems() | ||
override val itemsPerRow = 3 | ||
|
||
override val allItems = listOf( | ||
// except for different panorama images, should be the same as for the road quest, to avoid confusion | ||
Item("paved", R.drawable.panorama_path_surface_paved, R.string.quest_surface_value_paved, null, PAVED_SURFACES.toItems()), | ||
Item("unpaved", R.drawable.panorama_path_surface_unpaved, R.string.quest_surface_value_unpaved, null, UNPAVED_SURFACES.toItems()), | ||
Item("ground", R.drawable.panorama_surface_ground, R.string.quest_surface_value_ground, null, GROUND_SURFACES.toItems()) | ||
) | ||
|
||
private fun determinePathType(tags: Map<String, String>): String? { | ||
val pathType = tags["highway"] | ||
// interpret paths with foot/bicycle/horse=designated as... | ||
if ("path" == pathType) { | ||
if ("designated" == tags["bicycle"]) return "cycleway" | ||
if ("designated" == tags["horse"]) return "bridleway" | ||
if ("designated" == tags["foot"]) return "footway" | ||
override fun onClickOk(selectedItems: List<String>) { | ||
val value = selectedItems.single() | ||
if(value == "paved" || value == "unpaved") { | ||
AlertDialog.Builder(requireContext()) | ||
.setMessage(R.string.quest_surface_detailed_answer_impossible_confirmation) | ||
.setPositiveButton(R.string.quest_generic_confirmation_yes) { | ||
_, _ -> run { | ||
DescribeGenericSurfaceDialog(requireContext()) { description -> | ||
applyAnswer(GenericSurfaceAnswer(value, description)) | ||
}.show() | ||
} | ||
} | ||
.setNegativeButton(android.R.string.cancel, null) | ||
.show() | ||
return | ||
} | ||
return pathType | ||
} | ||
|
||
override fun onClickOk(value: String) { | ||
applyAnswer(value) | ||
applyAnswer(SpecificSurfaceAnswer(value)) | ||
} | ||
} |
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
43 changes: 26 additions & 17 deletions
43
app/src/main/java/de/westnordost/streetcomplete/quests/surface/AddRoadSurfaceForm.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 |
---|---|---|
@@ -1,26 +1,35 @@ | ||
package de.westnordost.streetcomplete.quests.surface | ||
|
||
import androidx.appcompat.app.AlertDialog | ||
import de.westnordost.streetcomplete.R | ||
import de.westnordost.streetcomplete.quests.AGroupedImageListQuestAnswerFragment | ||
import de.westnordost.streetcomplete.quests.AImageListQuestAnswerFragment | ||
import de.westnordost.streetcomplete.view.image_select.Item | ||
import de.westnordost.streetcomplete.quests.surface.Surface.* | ||
|
||
class AddRoadSurfaceForm : AGroupedImageListQuestAnswerFragment<String,String>() { | ||
class AddRoadSurfaceForm : AImageListQuestAnswerFragment<String, SurfaceAnswer>() { | ||
override val items: List<Item<String>> get() = | ||
(PAVED_SURFACES + UNPAVED_SURFACES + GROUND_SURFACES).toItems() + | ||
Item("paved", R.drawable.surface_paved, R.string.quest_surface_value_paved, null, listOf()) + | ||
Item("unpaved", R.drawable.surface_unpaved, R.string.quest_surface_value_unpaved, null, listOf()) + | ||
Item("ground", R.drawable.surface_ground, R.string.quest_surface_value_ground, null, listOf()) | ||
|
||
override val topItems get() = | ||
// tracks often have different surfaces than other roads | ||
if (osmElement!!.tags["highway"] == "track") | ||
listOf(DIRT, GRASS, PEBBLES, FINE_GRAVEL, COMPACTED, ASPHALT).toItems() | ||
else | ||
listOf(ASPHALT, CONCRETE, SETT, PAVING_STONES, COMPACTED, DIRT).toItems() | ||
override val itemsPerRow = 3 | ||
|
||
override val allItems = listOf( | ||
Item("paved", R.drawable.panorama_surface_paved, R.string.quest_surface_value_paved, null, PAVED_SURFACES.toItems()), | ||
Item("unpaved", R.drawable.panorama_surface_unpaved, R.string.quest_surface_value_unpaved, null, UNPAVED_SURFACES.toItems()), | ||
Item("ground", R.drawable.panorama_surface_ground, R.string.quest_surface_value_ground, null, GROUND_SURFACES.toItems()) | ||
) | ||
|
||
override fun onClickOk(value: String) { | ||
applyAnswer(value) | ||
override fun onClickOk(selectedItems: List<String>) { | ||
val value = selectedItems.single() | ||
if(value == "paved" || value == "unpaved") { | ||
AlertDialog.Builder(requireContext()) | ||
.setMessage(R.string.quest_surface_detailed_answer_impossible_confirmation) | ||
.setPositiveButton(R.string.quest_generic_confirmation_yes) { | ||
_, _ -> run { | ||
DescribeGenericSurfaceDialog(requireContext()) { description -> | ||
applyAnswer(GenericSurfaceAnswer(value, description)) | ||
}.show() | ||
} | ||
} | ||
.setNegativeButton(android.R.string.cancel, null) | ||
.show() | ||
return | ||
} | ||
applyAnswer(SpecificSurfaceAnswer(value)) | ||
} | ||
} |
Oops, something went wrong.