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

Add aerial imagery, fixes #56 #2755

Merged
merged 16 commits into from Apr 19, 2021
Merged
3 changes: 3 additions & 0 deletions app/src/main/assets/map_theme/jawg/scene-satellite.yaml
@@ -0,0 +1,3 @@
import:
- streetcomplete.yaml
- streetcomplete-satellite-style.yaml
2 changes: 2 additions & 0 deletions app/src/main/java/de/westnordost/streetcomplete/Prefs.kt
Expand Up @@ -13,6 +13,8 @@ object Prefs {
const val KEEP_SCREEN_ON = "display.keepScreenOn"
const val UNGLUE_HINT_TIMES_SHOWN = "unglueHint.shown"
const val THEME_SELECT = "theme.select"
const val THEME_BACKGROUND = "theme.background_type"

const val RESURVEY_INTERVALS = "quests.resurveyIntervals"

const val OSM_USER_ID = "osm.userid"
Expand Down
Expand Up @@ -2,6 +2,7 @@ package de.westnordost.streetcomplete.map

import android.app.Activity
import android.content.Intent
import android.content.SharedPreferences
import android.content.res.Configuration
import android.graphics.PointF
import android.graphics.RectF
Expand All @@ -27,6 +28,7 @@ import de.westnordost.osmapi.map.data.LatLon
import de.westnordost.osmapi.map.data.OsmLatLon
import de.westnordost.streetcomplete.ApplicationConstants
import de.westnordost.streetcomplete.Injector
import de.westnordost.streetcomplete.Prefs
import de.westnordost.streetcomplete.R
import de.westnordost.streetcomplete.data.maptiles.MapTilesDownloadCacheConfig
import de.westnordost.streetcomplete.ktx.awaitLayout
Expand Down Expand Up @@ -66,6 +68,7 @@ open class MapFragment : Fragment(),

@Inject internal lateinit var vectorTileProvider: VectorTileProvider
@Inject internal lateinit var cacheConfig: MapTilesDownloadCacheConfig
@Inject internal lateinit var prefsShared: SharedPreferences

interface Listener {
/** Called when the map has been completely initialized */
Expand Down Expand Up @@ -218,7 +221,14 @@ open class MapFragment : Fragment(),
protected open fun getSceneFilePath(): String {
val currentNightMode = resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK
val isNightMode = currentNightMode == Configuration.UI_MODE_NIGHT_YES
val scene = if (isNightMode) "scene-dark.yaml" else "scene-light.yaml"
val isAerialView = prefsShared.getString(Prefs.THEME_BACKGROUND, "MAP") == "AERIAL"

val scene = when {
isAerialView -> "scene-satellite.yaml"
isNightMode -> "scene-dark.yaml"
else -> "scene-light.yaml"
}

return "${vectorTileProvider.sceneFilePath}/$scene"
}

Expand Down
9 changes: 9 additions & 0 deletions app/src/main/res/values/arrays.xml
Expand Up @@ -36,4 +36,13 @@
<item>DARK</item>
</string-array>

<string-array name="pref_entries_background_type_select" translatable="false">
<item>@string/background_type_map</item>
<item>@string/background_type_aerial_esri</item>
</string-array>

<string-array name="pref_entryvalues_background_type_select" translatable="false">
<item>MAP</item>
<item>AERIAL</item>
</string-array>
</resources>
4 changes: 4 additions & 0 deletions app/src/main/res/values/strings.xml
Expand Up @@ -991,4 +991,8 @@ Otherwise, you can download another keyboard in the app store. Popular keyboards
<string name="quest_drinking_water_potable_unsigned">Safe to drink (unsigned)</string>
<string name="quest_drinking_water_not_potable_signed">Not safe to drink (signed)</string>
<string name="quest_drinking_water_not_potable_unsigned">Not safe to drink (unsigned)</string>

<string name="pref_background_type_select">Select background type</string>
<string name="background_type_map">Map</string>
<string name="background_type_aerial_esri">Aerial (by Esri)</string>
</resources>
10 changes: 10 additions & 0 deletions app/src/main/res/xml/preferences.xml
Expand Up @@ -61,6 +61,16 @@
android:entryValues="@array/pref_entryvalues_theme_select"
android:persistent="true"
/>
matkoniecz marked this conversation as resolved.
Show resolved Hide resolved

<ListPreference
android:key="theme.background_type"
android:title="@string/pref_background_type_select"
android:summary="%s"
android:defaultValue="MAP"
android:entries="@array/pref_entries_background_type_select"
android:entryValues="@array/pref_entryvalues_background_type_select"
android:persistent="true"
/>
</PreferenceCategory>

<PreferenceCategory
Expand Down