Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d86a8b5a authored by Fynn Godau's avatar Fynn Godau
Browse files

Merge branch '915-custom-colors' into epic67-maps

parents 9973d7d3 86bb4be9
Loading
Loading
Loading
Loading
+13845 −0

File added.

Preview size limit exceeded, changes collapsed.

+4392 −0

File added.

Preview size limit exceeded, changes collapsed.

+3489 −0

File added.

Preview size limit exceeded, changes collapsed.

+0 −8
Original line number Diff line number Diff line
@@ -14,14 +14,6 @@ import org.microg.gms.maps.mapbox.model.DefaultInfoWindowAdapter
import org.microg.gms.maps.mapbox.model.InfoWindow
import org.microg.gms.maps.mapbox.utils.MapContext

fun getStyleUriByMapType(mapType: Int) = when (mapType) {
    MapsConstants.MAP_TYPE_SATELLITE -> "mapbox://styles/microg/cjxgloted25ap1ct4uex7m6hi"
    MapsConstants.MAP_TYPE_TERRAIN -> "mapbox://styles/mapbox/outdoors-v12"
    MapsConstants.MAP_TYPE_HYBRID -> "mapbox://styles/microg/cjxgloted25ap1ct4uex7m6hi"
    //MAP_TYPE_NONE, MAP_TYPE_NORMAL,
    else -> "mapbox://styles/microg/cjui4020201oo1fmca7yuwbor"
}

abstract class AbstractGoogleMap(context: Context) : IGoogleMapDelegate.Stub() {

    internal val mapContext = MapContext(context)
+7 −7
Original line number Diff line number Diff line
@@ -112,6 +112,7 @@ class GoogleMapImpl(context: Context, var options: GoogleMapOptions) : AbstractG
    var tileId = 0L

    var storedMapType: Int = options.mapType
    var mapStyle: MapStyleOptions? = null
    val waitingCameraUpdates = mutableListOf<CameraUpdate>()
    var locationEnabled: Boolean = false

@@ -228,6 +229,7 @@ class GoogleMapImpl(context: Context, var options: GoogleMapOptions) : AbstractG

    override fun setMapStyle(options: MapStyleOptions?): Boolean {
        Log.d(TAG, "setMapStyle options: " + options?.getJson())
        mapStyle = options
        return true
    }

@@ -347,10 +349,10 @@ class GoogleMapImpl(context: Context, var options: GoogleMapOptions) : AbstractG

    override fun setMapType(type: Int) {
        storedMapType = type
        applyMapType()
        applyMapStyle()
    }

    fun applyMapType() {
    fun applyMapStyle() {
        val lines = lineManager?.annotations?.values()
        val fills = fillManager?.annotations?.values()
        val symbols = symbolManager?.annotations?.values()
@@ -360,11 +362,9 @@ class GoogleMapImpl(context: Context, var options: GoogleMapOptions) : AbstractG
            symbols?.let { runCatching { symbolManager?.update(it) } }
        }

        // TODO: Serve map styles locally
        map?.setStyle(
            Style.Builder().fromUri(
                getStyleUriByMapType(storedMapType)
            ), update
            getStyle(mapContext, storedMapType, mapStyle),
            update
        )

        map?.let { BitmapDescriptorFactoryImpl.registerMap(it) }
@@ -566,7 +566,7 @@ class GoogleMapImpl(context: Context, var options: GoogleMapOptions) : AbstractG
            false
        }

        applyMapType()
        applyMapStyle()
        options.minZoomPreference?.let { if (it != 0f) map.setMinZoomPreference(it.toDouble()) }
        options.maxZoomPreference?.let { if (it != 0f) map.setMaxZoomPreference(it.toDouble()) }
        options.latLngBoundsForCameraTarget?.let { map.setLatLngBoundsForCameraTarget(it.toMapbox()) }
Loading