Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#506 Add background type Custom #564

Open
wants to merge 2 commits into
base: modified
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -223,13 +223,24 @@ class InsertNodeFragment :
}

private fun toggleBackground() {
prefs.putString(Prefs.THEME_BACKGROUND, if (prefs.getString(Prefs.THEME_BACKGROUND, "MAP") == "MAP") "AERIAL" else "MAP")
val newBackgroundType = when(prefs.getString(Prefs.THEME_BACKGROUND, "MAP")){
"MAP" -> "AERIAL"
"AERIAL" -> "CUSTOM"
"CUSTOM" -> "MAP"
else -> "MAP"
}

prefs.putString(Prefs.THEME_BACKGROUND, newBackgroundType)
updateMapButtonText()
}

private fun updateMapButtonText() {
val isMap = prefs.getString(Prefs.THEME_BACKGROUND, "MAP") == "MAP"
val textId = if (isMap) R.string.background_type_aerial_esri else R.string.background_type_map
val textId = when(prefs.getString(Prefs.THEME_BACKGROUND, "MAP")){
"MAP" -> R.string.background_type_map
"AERIAL" -> R.string.background_type_aerial_esri
"CUSTOM" -> R.string.background_type_custom
else -> R.string.background_type_map
}
binding.mapButton.setText(textId)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,24 @@ class MoveNodeFragment :
}

private fun toggleBackground() {
prefs.putString(Prefs.THEME_BACKGROUND, if (prefs.getString(Prefs.THEME_BACKGROUND, "MAP") == "MAP") "AERIAL" else "MAP")
val newBackgroundType = when(prefs.getString(Prefs.THEME_BACKGROUND, "MAP")){
"MAP" -> "AERIAL"
"AERIAL" -> "CUSTOM"
"CUSTOM" -> "MAP"
else -> "MAP"
}

prefs.putString(Prefs.THEME_BACKGROUND, newBackgroundType)
updateMapButtonText()
}

private fun updateMapButtonText() {
val isMap = prefs.getString(Prefs.THEME_BACKGROUND, "MAP") == "MAP"
val textId = if (isMap) R.string.background_type_aerial_esri else R.string.background_type_map
val textId = when(prefs.getString(Prefs.THEME_BACKGROUND, "MAP")){
"MAP" -> R.string.background_type_map
"AERIAL" -> R.string.background_type_aerial_esri
"CUSTOM" -> R.string.background_type_custom
else -> R.string.background_type_map
}
binding.mapButton.setText(textId)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,13 +193,24 @@ class SplitWayFragment :
}

private fun toggleBackground() {
prefs.putString(Prefs.THEME_BACKGROUND, if (prefs.getString(Prefs.THEME_BACKGROUND, "MAP") == "MAP") "AERIAL" else "MAP")
val newBackgroundType = when(prefs.getString(Prefs.THEME_BACKGROUND, "MAP")){
"MAP" -> "AERIAL"
"AERIAL" -> "CUSTOM"
"CUSTOM" -> "MAP"
else -> "MAP"
}

prefs.putString(Prefs.THEME_BACKGROUND, newBackgroundType)
updateMapButtonText()
}

private fun updateMapButtonText() {
val isMap = prefs.getString(Prefs.THEME_BACKGROUND, "MAP") == "MAP"
val textId = if (isMap) R.string.background_type_aerial_esri else R.string.background_type_map
val textId = when(prefs.getString(Prefs.THEME_BACKGROUND, "MAP")){
"MAP" -> R.string.background_type_map
"AERIAL" -> R.string.background_type_aerial_esri
"CUSTOM" -> R.string.background_type_custom
else -> R.string.background_type_map
}
binding.mapButton.setText(textId)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ open class MapFragment :

private val onBackgroundChangedListener = prefs.addStringListener(Prefs.THEME_BACKGROUND, "MAP") {
sceneMapComponent?.isAerialView =
(prefs.getStringOrNull(Prefs.THEME_BACKGROUND) ?: "MAP") == "AERIAL"
prefs.getString(Prefs.THEME_BACKGROUND,"MAP") != "MAP"
viewLifecycleScope.launch { sceneMapComponent?.loadScene() }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class SceneMapComponent(
private var loadedSceneFilePath: String? = null
private var loadedSceneUpdates: List<String>? = null

var isAerialView: Boolean = false
var isAerialView: Boolean = prefs.getString(Prefs.THEME_BACKGROUND,"MAP") != "MAP"
set(value) {
field = value
aerialViewChanged = true
Expand Down Expand Up @@ -75,11 +75,24 @@ class SceneMapComponent(
if (isAerialView && it.first.startsWith("layers.buildings")) null
else SceneUpdate(it.first, it.second)
} + listOfNotNull(
if (isAerialView)
SceneUpdate("sources.raster.url", prefs.getString(Prefs.RASTER_TILE_URL, "https://server.arcgisonline.com/arcgis/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}"))
else null
)
when (prefs.getString(Prefs.THEME_BACKGROUND, "MAP")) {
"MAP" -> null
"AERIAL" -> SceneUpdate(
"sources.raster.url",
"https://server.arcgisonline.com/arcgis/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}"
)

"CUSTOM" -> SceneUpdate(
"sources.raster.url",
prefs.getString(
Prefs.RASTER_TILE_URL,
"https://server.arcgisonline.com/arcgis/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}"
)
)

else -> null
}
)

private fun getBaseSceneUpdates(): List<SceneUpdate> = listOf(
SceneUpdate("global.language", Locale.getDefault().language),
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/arrays.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,13 @@
<string-array name="pref_entries_background_type_select" translatable="false">
<item>@string/background_type_map</item>
<item>@string/background_type_aerial_esri</item>
<item>@string/background_type_custom</item>
</string-array>

<string-array name="pref_entryvalues_background_type_select" translatable="false">
<item>MAP</item>
<item>AERIAL</item>
<item>CUSTOM</item>
</string-array>

<string-array name="pref_quest_settings_level_quest" translatable="false">
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings_ee.xml
Original file line number Diff line number Diff line change
Expand Up @@ -671,4 +671,5 @@ Out of the box SCEE is configured to behave very similar to StreetComplete.</str
<!-- actually there are still SC translations available, as only the main string has been removed from SC. -->
<string name="close">Close</string>

<string name="background_type_custom">Custom</string>
</resources>